Patched a bug where the user would be locked out of continuing if he closed the unawnsered modal

This commit is contained in:
Carlos Mesquita
2024-08-28 13:28:21 +01:00
parent ef32226c6c
commit ea8a3625ef

View File

@@ -129,6 +129,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
if (exerciseIndex + 1 < exam.parts[partIndex].exercises.length && !hasExamEnded) { if (exerciseIndex + 1 < exam.parts[partIndex].exercises.length && !hasExamEnded) {
setExerciseIndex(exerciseIndex + 1); setExerciseIndex(exerciseIndex + 1);
setCurrentSolutionSet(false);
return; return;
} }
@@ -157,6 +158,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
setExerciseIndex(0); setExerciseIndex(0);
setQuestionIndex(0); setQuestionIndex(0);
setMultipleChoicesDone((prev) => [...prev.filter((x) => x.id !== currentExercise!.id), { id: currentExercise!.id, amount: currentExercise?.type == "fillBlanks" ? currentExercise.words.length - 1 : questionIndex }]); setMultipleChoicesDone((prev) => [...prev.filter((x) => x.id !== currentExercise!.id), { id: currentExercise!.id, amount: currentExercise?.type == "fillBlanks" ? currentExercise.words.length - 1 : questionIndex }]);
setCurrentSolutionSet(false);
return; return;
} }
@@ -166,6 +168,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
} }
setHasExamEnded(false); setHasExamEnded(false);
setCurrentSolutionSet(false);
if (typeof showSolutionsSave !== "undefined") { if (typeof showSolutionsSave !== "undefined") {
onFinish(showSolutionsSave); onFinish(showSolutionsSave);
} else { } else {
@@ -177,7 +180,6 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
if (nextExerciseCalled && currentSolutionSet) { if (nextExerciseCalled && currentSolutionSet) {
nextExercise(); nextExercise();
setNextExerciseCalled(false); setNextExerciseCalled(false);
setCurrentSolutionSet(false);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [nextExerciseCalled, currentSolutionSet]) }, [nextExerciseCalled, currentSolutionSet])