diff --git a/src/exams/Speaking.tsx b/src/exams/Speaking.tsx index 81a85e21..07c7352f 100644 --- a/src/exams/Speaking.tsx +++ b/src/exams/Speaking.tsx @@ -27,6 +27,12 @@ export default function Speaking({exam, showSolutions = false, onFinish}: Props) const {hasExamEnded, setHasExamEnded} = useExamStore((state) => state); const {exerciseIndex, setExerciseIndex} = useExamStore((state) => state); + useEffect(() => { + if (hasExamEnded && exerciseIndex === -1) { + setExerciseIndex(exerciseIndex + 1); + } + }, [hasExamEnded, exerciseIndex, setExerciseIndex]); + const scrollToTop = () => Array.from(document.getElementsByTagName("body")).forEach((body) => body.scrollTo(0, 0)); const nextExercise = (solution?: UserSolution) => { diff --git a/src/exams/Writing.tsx b/src/exams/Writing.tsx index f103bcab..54547314 100644 --- a/src/exams/Writing.tsx +++ b/src/exams/Writing.tsx @@ -23,6 +23,12 @@ export default function Writing({exam, showSolutions = false, onFinish}: Props) const {hasExamEnded, setHasExamEnded} = useExamStore((state) => state); const {exerciseIndex, setExerciseIndex} = useExamStore((state) => state); + useEffect(() => { + if (hasExamEnded && exerciseIndex === -1) { + setExerciseIndex(exerciseIndex + 1); + } + }, [hasExamEnded, exerciseIndex, setExerciseIndex]); + const scrollToTop = () => Array.from(document.getElementsByTagName("body")).forEach((body) => body.scrollTo(0, 0)); const nextExercise = (solution?: UserSolution) => {