From ce353f34c7466e47eb8ff198daf7a354a7543747 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Fri, 1 Nov 2024 10:38:10 +0000 Subject: [PATCH] I think I solved a bit of the time ended --- src/exams/Speaking.tsx | 6 ++++++ src/exams/Writing.tsx | 6 ++++++ 2 files changed, 12 insertions(+) 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) => {