Solved a bug related to the partial exams
This commit is contained in:
@@ -7,7 +7,6 @@ import AudioPlayer from "@/components/Low/AudioPlayer";
|
|||||||
import Button from "@/components/Low/Button";
|
import Button from "@/components/Low/Button";
|
||||||
import BlankQuestionsModal from "@/components/QuestionsModal";
|
import BlankQuestionsModal from "@/components/QuestionsModal";
|
||||||
import useExamStore, { usePersistentExamStore } from "@/stores/examStore";
|
import useExamStore, { usePersistentExamStore } from "@/stores/examStore";
|
||||||
import { countExercises } from "@/utils/moduleUtils";
|
|
||||||
import PartDivider from "./Navigation/SectionDivider";
|
import PartDivider from "./Navigation/SectionDivider";
|
||||||
import { Dialog, Transition } from "@headlessui/react";
|
import { Dialog, Transition } from "@headlessui/react";
|
||||||
import { capitalize } from "lodash";
|
import { capitalize } from "lodash";
|
||||||
@@ -171,6 +170,7 @@ export default function Listening({ exam, showSolutions = false, preview = false
|
|||||||
const previousExercise = (solution?: UserSolution) => { };
|
const previousExercise = (solution?: UserSolution) => { };
|
||||||
|
|
||||||
const nextPart = () => {
|
const nextPart = () => {
|
||||||
|
scrollToTop()
|
||||||
if (partIndex + 1 < exam.parts.length && !hasExamEnded) {
|
if (partIndex + 1 < exam.parts.length && !hasExamEnded) {
|
||||||
setPartIndex(partIndex + 1);
|
setPartIndex(partIndex + 1);
|
||||||
setExerciseIndex(0);
|
setExerciseIndex(0);
|
||||||
@@ -191,23 +191,6 @@ export default function Listening({ exam, showSolutions = false, preview = false
|
|||||||
onFinish(userSolutions);
|
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 renderPartExercises = () => {
|
||||||
const exercises = partIndex > -1 ? exam.parts[partIndex].exercises : []
|
const exercises = partIndex > -1 ? exam.parts[partIndex].exercises : []
|
||||||
const formattedExercises = exercises.map(exercise => ({
|
const formattedExercises = exercises.map(exercise => ({
|
||||||
@@ -365,12 +348,12 @@ export default function Listening({ exam, showSolutions = false, preview = false
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{partIndex === -1 && exam.variant !== "partial" && (
|
{partIndex === -1 && exam.variant !== "partial" && (
|
||||||
<Button color="purple" onClick={() => nextPart()} className="max-w-[200px] self-end w-full justify-self-end">
|
<Button color="purple" onClick={() => setPartIndex(0)} className="max-w-[200px] self-end w-full justify-self-end">
|
||||||
Start now
|
Start now
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{exerciseIndex === -1 && partIndex === 0 && exam.variant === "partial" && (
|
{exerciseIndex === -1 && partIndex === 0 && exam.variant === "partial" && (
|
||||||
<Button color="purple" onClick={() => nextPart()} className="max-w-[200px] self-end w-full justify-self-end">
|
<Button color="purple" onClick={() => setExerciseIndex(0)} className="max-w-[200px] self-end w-full justify-self-end">
|
||||||
Start now
|
Start now
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user