diff --git a/src/components/Solutions/Writing.tsx b/src/components/Solutions/Writing.tsx index 804df4fa..fad9ff5a 100644 --- a/src/components/Solutions/Writing.tsx +++ b/src/components/Solutions/Writing.tsx @@ -1,7 +1,7 @@ /* eslint-disable @next/next/no-img-element */ import {WritingExercise} from "@/interfaces/exam"; import {CommonProps} from "."; -import {Fragment, useState} from "react"; +import {Fragment, useEffect, useState} from "react"; import Button from "../Low/Button"; import {Dialog, Tab, Transition} from "@headlessui/react"; import {writingReverseMarking} from "@/utils/score"; @@ -85,7 +85,7 @@ export default function Writing({id, type, prompt, attachment, userSolutions, on
- {userSolutions && ( + {userSolutions && userSolutions.length > 0 && (
Your answer:
diff --git a/src/pages/(exam)/ExamPage.tsx b/src/pages/(exam)/ExamPage.tsx index 67cc275a..0b60a4c1 100644 --- a/src/pages/(exam)/ExamPage.tsx +++ b/src/pages/(exam)/ExamPage.tsx @@ -30,7 +30,7 @@ interface Props { export default function ExamPage({page}: Props) { const [hasBeenUploaded, setHasBeenUploaded] = useState(false); - const [moduleIndex, setModuleIndex] = useState(0); + const [moduleIndex, setModuleIndex] = useState(-1); const [sessionId, setSessionId] = useState(""); const [exam, setExam] = useState(); const [isEvaluationLoading, setIsEvaluationLoading] = useState(false); @@ -247,14 +247,15 @@ export default function ExamPage({page}: Props) { user={user!} disableSelection={page === "exams"} onStart={(modules, avoid) => { - setSelectedModules(modules); + setModuleIndex(0); setAvoidRepeated(avoid); + setSelectedModules(modules); }} /> ); } - if (moduleIndex >= selectedModules.length) { + if (moduleIndex >= selectedModules.length || moduleIndex === -1) { return ( { const user = req.session.user; @@ -175,7 +175,7 @@ export default function History({user}: {user: User}) { level: calculateBandScore(x.correct, x.total, x.module, user.focus), })); - const { timeSpent, session } = dateStats[0]; + const {timeSpent, session} = dateStats[0]; const selectExam = () => { const examPromises = uniqBy(dateStats, "exam").map((stat) => getExamById(stat.module, stat.exam)); @@ -201,7 +201,7 @@ export default function History({user}: {user: User}) { correct / total >= 0.3 && correct / total < 0.7 && "text-mti-red", correct / total < 0.3 && "text-mti-rose", ); - + const content = ( <>
@@ -215,8 +215,7 @@ export default function History({user}: {user: User}) { )}
- + Level{" "} {(aggregatedLevels.reduce((accumulator, current) => accumulator + current.level, 0) / aggregatedLevels.length).toFixed(1)}