Quick fix related to the back button of the Listening Exam

This commit is contained in:
Tiago Ribeiro
2024-11-18 15:28:51 +00:00
parent 4f60819dcc
commit bb24fe3c6d

View File

@@ -120,7 +120,7 @@ export default function Listening({ exam, showSolutions = false, preview = false
}, [partIndex]); }, [partIndex]);
useEffect(() => { useEffect(() => {
if (showSolutions) return setExerciseIndex(-1); if (showSolutions) return setExerciseIndex(0);
}, [setExerciseIndex, showSolutions]); }, [setExerciseIndex, showSolutions]);
useEffect(() => { 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 = () => { const nextPart = () => {
scrollToTop() scrollToTop()