From 49749bfbe91db7b127597164a56912b38c0a2409 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Wed, 13 Nov 2024 09:12:30 +0000 Subject: [PATCH] Solved a bug related to the partial exams --- src/exams/Listening.tsx | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/exams/Listening.tsx b/src/exams/Listening.tsx index 476ab0e9..73a85798 100644 --- a/src/exams/Listening.tsx +++ b/src/exams/Listening.tsx @@ -7,7 +7,6 @@ import AudioPlayer from "@/components/Low/AudioPlayer"; import Button from "@/components/Low/Button"; import BlankQuestionsModal from "@/components/QuestionsModal"; import useExamStore, { usePersistentExamStore } from "@/stores/examStore"; -import { countExercises } from "@/utils/moduleUtils"; import PartDivider from "./Navigation/SectionDivider"; import { Dialog, Transition } from "@headlessui/react"; import { capitalize } from "lodash"; @@ -171,6 +170,7 @@ export default function Listening({ exam, showSolutions = false, preview = false const previousExercise = (solution?: UserSolution) => { }; const nextPart = () => { + scrollToTop() if (partIndex + 1 < exam.parts.length && !hasExamEnded) { setPartIndex(partIndex + 1); setExerciseIndex(0); @@ -191,23 +191,6 @@ export default function Listening({ exam, showSolutions = false, preview = false onFinish(userSolutions); } - const calculateExerciseIndex = () => { - if (partIndex === -1) return 0; - if (partIndex === 0) - return ( - (exerciseIndex === -1 ? 0 : exerciseIndex + 1) + storeQuestionIndex + multipleChoicesDone.reduce((acc, curr) => acc + curr.amount, 0) - ); - - const exercisesPerPart = exam.parts.map((x) => x.exercises.length); - const exercisesDone = exercisesPerPart.filter((_, index) => index < partIndex).reduce((acc, curr) => curr + acc, 0); - return ( - exercisesDone + - (exerciseIndex === -1 ? 0 : exerciseIndex + 1) + - storeQuestionIndex + - multipleChoicesDone.reduce((acc, curr) => acc + curr.amount, 0) - ); - }; - const renderPartExercises = () => { const exercises = partIndex > -1 ? exam.parts[partIndex].exercises : [] const formattedExercises = exercises.map(exercise => ({ @@ -365,12 +348,12 @@ export default function Listening({ exam, showSolutions = false, preview = false )} {partIndex === -1 && exam.variant !== "partial" && ( - )} {exerciseIndex === -1 && partIndex === 0 && exam.variant === "partial" && ( - )}