- Adapted the exam to store all of its information to Zustand;
- Made it so, every time there is a change or every X seconds, it saves the session;
This commit is contained in:
@@ -50,6 +50,13 @@ export const getExamById = async (module: Module, id: string): Promise<Exam | un
|
||||
}
|
||||
};
|
||||
|
||||
export const defaultExamUserSolutions = (exam: Exam) => {
|
||||
if (exam.module === "reading" || exam.module === "listening")
|
||||
return exam.parts.flatMap((x) => x.exercises).map((x) => defaultUserSolutions(x, exam));
|
||||
|
||||
return exam.exercises.map((x) => defaultUserSolutions(x, exam));
|
||||
};
|
||||
|
||||
export const defaultUserSolutions = (exercise: Exercise, exam: Exam): UserSolution => {
|
||||
const defaultSettings = {
|
||||
exam: exam.id,
|
||||
@@ -73,6 +80,9 @@ export const defaultUserSolutions = (exercise: Exercise, exam: Exam): UserSoluti
|
||||
case "writeBlanks":
|
||||
total = exercise.text.match(/({{\d+}})/g)?.length || 0;
|
||||
return {...defaultSettings, score: {correct: 0, total, missing: total}};
|
||||
case "trueFalse":
|
||||
total = exercise.questions.length;
|
||||
return {...defaultSettings, score: {correct: 0, total, missing: total}};
|
||||
case "writing":
|
||||
total = 1;
|
||||
return {...defaultSettings, score: {correct: 0, total, missing: total}};
|
||||
|
||||
Reference in New Issue
Block a user