Redesigned the Record page along with solving some bugs on the FillBlanks
This commit is contained in:
@@ -6,7 +6,7 @@ import {Module} from "@/interfaces";
|
||||
|
||||
import Selection from "@/exams/Selection";
|
||||
import Reading from "@/exams/Reading";
|
||||
import {Exam, ListeningExam, ReadingExam, SpeakingExam, UserSolution, WritingExam, WritingExercise} from "@/interfaces/exam";
|
||||
import {Exam, ListeningExam, ReadingExam, SpeakingExam, UserSolution, WritingEvaluation, WritingExam, WritingExercise} from "@/interfaces/exam";
|
||||
import Listening from "@/exams/Listening";
|
||||
import Writing from "@/exams/Writing";
|
||||
import {ToastContainer, toast} from "react-toastify";
|
||||
@@ -22,6 +22,7 @@ import useExamStore from "@/stores/examStore";
|
||||
import Sidebar from "@/components/Sidebar";
|
||||
import Layout from "@/components/High/Layout";
|
||||
import {sortByModule} from "@/utils/moduleUtils";
|
||||
import {writingReverseMarking} from "@/utils/score";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
const user = req.session.user;
|
||||
@@ -127,7 +128,7 @@ export default function Page() {
|
||||
const writingExam = exams.find((x) => x.id === examId)!;
|
||||
const exercise = writingExam.exercises.find((x) => x.id === exerciseId)! as WritingExercise;
|
||||
|
||||
const response = await axios.post("/api/exam/writing/evaluate", {
|
||||
const response = await axios.post<WritingEvaluation>("/api/exam/writing/evaluate", {
|
||||
question: `${exercise.prompt} ${exercise.attachment ? exercise.attachment.description : ""}`.replaceAll("\n", ""),
|
||||
answer: solution.solutions[0].solution.trim().replaceAll("\n", " "),
|
||||
});
|
||||
@@ -135,7 +136,15 @@ export default function Page() {
|
||||
if (response.status === 200) {
|
||||
setUserSolutions([
|
||||
...userSolutions.filter((x) => x.exercise !== exerciseId),
|
||||
{...solution, solutions: [{id: exerciseId, solution: solution.solutions[0].solution, evaluation: response.data}]},
|
||||
{
|
||||
...solution,
|
||||
score: {
|
||||
correct: writingReverseMarking[response.data.overall],
|
||||
missing: 0,
|
||||
total: 100,
|
||||
},
|
||||
solutions: [{id: exerciseId, solution: solution.solutions[0].solution, evaluation: response.data}],
|
||||
},
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user