diff --git a/src/exams/Listening.tsx b/src/exams/Listening.tsx index 92cd7acb..7288ca8e 100644 --- a/src/exams/Listening.tsx +++ b/src/exams/Listening.tsx @@ -120,7 +120,7 @@ export default function Listening({ exam, showSolutions = false, preview = false }, [partIndex]); useEffect(() => { - if (showSolutions) return setExerciseIndex(-1); + if (showSolutions) return setExerciseIndex(0); }, [setExerciseIndex, showSolutions]); useEffect(() => { @@ -167,7 +167,16 @@ export default function Listening({ exam, showSolutions = false, preview = false ]); }; - const previousExercise = (solution?: UserSolution) => { }; + const previousExercise = (solution?: UserSolution) => { + scrollToTop(); + if (solution) + setUserSolutions([ + ...userSolutions.filter((x) => x.exercise !== solution.exercise), + { ...solution, module: "listening", exam: exam.id } + ]); + + setPartIndex(partIndex - 1) + }; const nextPart = () => { scrollToTop()