From 44c61c2e5d86876500a3f87b42340ac48cb3ded2 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Wed, 14 Feb 2024 11:19:55 +0000 Subject: [PATCH] Fixed a bug with the module evaluation, no idea why it was happening --- src/components/Exercises/Writing.tsx | 6 ++++-- src/pages/(exam)/ExamPage.tsx | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/Exercises/Writing.tsx b/src/components/Exercises/Writing.tsx index 6004a198..c8189421 100644 --- a/src/components/Exercises/Writing.tsx +++ b/src/components/Exercises/Writing.tsx @@ -41,7 +41,7 @@ export default function Writing({ if (inputText.length > 0 && saveTimer % 10 === 0) { setUserSolutions([ ...storeUserSolutions.filter((x) => x.exercise !== id), - {exercise: id, solutions: [{id, solution: inputText}], score: {correct: 1, total: 1, missing: 0}, type}, + {exercise: id, solutions: [{id, solution: inputText}], score: {correct: 1, total: 1, missing: 0}, type, module: "writing"}, ]); } // eslint-disable-next-line react-hooks/exhaustive-deps @@ -64,7 +64,8 @@ export default function Writing({ }, []); useEffect(() => { - if (hasExamEnded) onNext({exercise: id, solutions: [{id, solution: inputText}], score: {correct: 1, total: 1, missing: 0}, type}); + if (hasExamEnded) + onNext({exercise: id, solutions: [{id, solution: inputText}], score: {correct: 1, total: 1, missing: 0}, type, module: "writing"}); // eslint-disable-next-line react-hooks/exhaustive-deps }, [hasExamEnded]); @@ -160,6 +161,7 @@ export default function Writing({ solutions: [{id, solution: inputText.replaceAll(/\s{2,}/g, " ")}], score: {correct: 1, total: 1, missing: 0}, type, + module: "writing", }) } className="max-w-[200px] self-end w-full"> diff --git a/src/pages/(exam)/ExamPage.tsx b/src/pages/(exam)/ExamPage.tsx index 724a58f7..a8bc3435 100644 --- a/src/pages/(exam)/ExamPage.tsx +++ b/src/pages/(exam)/ExamPage.tsx @@ -336,12 +336,13 @@ export default function ExamPage({page}: Props) { }; answers.forEach((x) => { - console.log({x}); + const examModule = + x.module || (x.type === "writing" ? "writing" : x.type === "speaking" || x.type === "interactiveSpeaking" ? "speaking" : undefined); - scores[x.module!] = { - total: scores[x.module!].total + x.score.total, - correct: scores[x.module!].correct + x.score.correct, - missing: scores[x.module!].missing + x.score.missing, + scores[examModule!] = { + total: scores[examModule!].total + x.score.total, + correct: scores[examModule!].correct + x.score.correct, + missing: scores[examModule!].missing + x.score.missing, }; });