diff --git a/src/components/Exercises/TrueFalse.tsx b/src/components/Exercises/TrueFalse.tsx index 4c7ffae9..2dc1998f 100644 --- a/src/components/Exercises/TrueFalse.tsx +++ b/src/components/Exercises/TrueFalse.tsx @@ -17,7 +17,11 @@ export default function TrueFalse({id, type, prompt, questions, userSolutions, o const calculateScore = () => { const total = questions.length || 0; const correct = answers.filter( - (x) => questions.find((y) => x.id.toString() === y.id.toString())?.solution?.toLowerCase() === x.solution.toLowerCase() || false, + (x) => + questions + .find((y) => x.id.toString() === y.id.toString()) + ?.solution?.toString() + .toLowerCase() === x.solution.toLowerCase() || false, ).length; const missing = total - answers.filter((x) => questions.find((y) => x.id.toString() === y.id.toString())).length; diff --git a/src/pages/(exam)/ExamPage.tsx b/src/pages/(exam)/ExamPage.tsx index 0b60a4c1..653869d2 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(-1); + const [moduleIndex, setModuleIndex] = useState(0); const [sessionId, setSessionId] = useState(""); const [exam, setExam] = useState(); const [isEvaluationLoading, setIsEvaluationLoading] = useState(false); @@ -64,6 +64,10 @@ export default function ExamPage({page}: Props) { // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedModules.length]); + useEffect(() => { + if (showSolutions) setModuleIndex(-1); + }, [showSolutions]); + useEffect(() => { (async () => { if (selectedModules.length > 0 && exams.length > 0 && moduleIndex < selectedModules.length) {