From bb24fe3c6d0789cfd3c4d0c533188c52d24c55f4 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 18 Nov 2024 15:28:51 +0000 Subject: [PATCH] Quick fix related to the back button of the Listening Exam --- src/exams/Listening.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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()