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]);
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()