diff --git a/src/exams/Reading.tsx b/src/exams/Reading.tsx
index 197268fa..16a6d457 100644
--- a/src/exams/Reading.tsx
+++ b/src/exams/Reading.tsx
@@ -90,6 +90,7 @@ export default function Reading({exam, showSolutions = false, onFinish}: Props)
const {hasExamEnded, setHasExamEnded} = useExamStore((state) => state);
const {partIndex, setPartIndex} = useExamStore((state) => state);
const {exerciseIndex, setExerciseIndex} = useExamStore((state) => state);
+ const setStoreQuestionIndex = useExamStore((state) => state.setQuestionIndex);
const scrollToTop = () => Array.from(document.getElementsByTagName("body")).forEach((body) => body.scrollTo(0, 0));
@@ -136,6 +137,7 @@ export default function Reading({exam, showSolutions = false, onFinish}: Props)
setUserSolutions([...userSolutions.filter((x) => x.exercise !== solution.exercise), solution]);
}
setQuestionIndex((prev) => prev + currentQuestionIndex);
+ setStoreQuestionIndex(0);
if (exerciseIndex + 1 < exam.parts[partIndex].exercises.length && !hasExamEnded) {
setExerciseIndex(exerciseIndex + 1);
@@ -176,6 +178,7 @@ export default function Reading({exam, showSolutions = false, onFinish}: Props)
if (solution) {
setUserSolutions([...userSolutions.filter((x) => x.exercise !== solution.exercise), solution]);
}
+ setStoreQuestionIndex(0);
setExerciseIndex(exerciseIndex - 1);
};
@@ -212,14 +215,17 @@ export default function Reading({exam, showSolutions = false, onFinish}: Props)
<>
-
setShowTextModal(false)} />
+ {partIndex > -1 && setShowTextModal(false)} />}
x.exercises)
.findIndex(
- (x) => x.id === exam.parts[partIndex].exercises[exerciseIndex === -1 ? exerciseIndex + 1 : exerciseIndex]?.id,
+ (x) =>
+ x.id ===
+ exam.parts[partIndex > -1 ? partIndex : 0].exercises[exerciseIndex === -1 ? exerciseIndex + 1 : exerciseIndex]
+ ?.id,
) || 0) +
(exerciseIndex === -1 ? 0 : 1) +
questionIndex +
@@ -231,17 +237,21 @@ export default function Reading({exam, showSolutions = false, onFinish}: Props)
label={exerciseIndex === -1 ? undefined : convertCamelCaseToReadable(exam.parts[partIndex].exercises[exerciseIndex].type)}
/>
-1 && "grid grid-cols-2 gap-4")}>
- {renderText()}
+ {partIndex > -1 && renderText()}
+
{exerciseIndex > -1 &&
+ partIndex > -1 &&
exerciseIndex < exam.parts[partIndex].exercises.length &&
!showSolutions &&
renderExercise(getExercise(), nextExercise, previousExercise, setCurrentQuestionIndex)}
+
{exerciseIndex > -1 &&
+ partIndex > -1 &&
exerciseIndex < exam.parts[partIndex].exercises.length &&
showSolutions &&
renderSolution(exam.parts[partIndex].exercises[exerciseIndex], nextExercise, previousExercise, setCurrentQuestionIndex)}
- {exerciseIndex > -1 && exerciseIndex < exam.parts[partIndex].exercises.length && (
+ {exerciseIndex > -1 && partIndex > -1 && exerciseIndex < exam.parts[partIndex].exercises.length && (