From dc8682e1c3594eba3ee0c6de6d006f9f4fcaf0ad Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Wed, 13 Sep 2023 23:46:50 +0100 Subject: [PATCH] Updated the problems with the marking - related to the DB not having the correct type --- src/components/Exercises/FillBlanks.tsx | 10 ++++++---- src/components/Exercises/MatchSentences.tsx | 6 ++++-- src/components/Exercises/MultipleChoice.tsx | 6 ++++-- src/components/Exercises/TrueFalse.tsx | 20 +++++++++++++++----- src/components/Exercises/WriteBlanks.tsx | 2 +- src/components/Solutions/FillBlanks.tsx | 4 ++-- src/components/Solutions/MatchSentences.tsx | 12 +++++++----- src/components/Solutions/MultipleChoice.tsx | 6 ++++-- src/components/Solutions/WriteBlanks.tsx | 12 +++++++----- 9 files changed, 50 insertions(+), 28 deletions(-) diff --git a/src/components/Exercises/FillBlanks.tsx b/src/components/Exercises/FillBlanks.tsx index 5644b959..1f529140 100644 --- a/src/components/Exercises/FillBlanks.tsx +++ b/src/components/Exercises/FillBlanks.tsx @@ -35,10 +35,10 @@ function WordsDrawer({words, isOpen, blankId, previouslySelectedWord, onCancel,
{blankId}
Choose the correct word: -
+
{words.map(({word, isDisabled}) => ( diff --git a/src/components/Solutions/MultipleChoice.tsx b/src/components/Solutions/MultipleChoice.tsx index d642af60..308a4654 100644 --- a/src/components/Solutions/MultipleChoice.tsx +++ b/src/components/Solutions/MultipleChoice.tsx @@ -59,8 +59,10 @@ export default function MultipleChoice({id, type, prompt, questions, userSolutio const calculateScore = () => { const total = questions.length; - const correct = userSolutions.filter((x) => questions.find((y) => y.id.toString() === x.question)?.solution === x.option || false).length; - const missing = total - userSolutions.filter((x) => questions.find((y) => y.id.toString() === x.question)).length; + const correct = userSolutions.filter( + (x) => questions.find((y) => y.id.toString() === x.question.toString())?.solution === x.option || false, + ).length; + const missing = total - userSolutions.filter((x) => questions.find((y) => y.id.toString() === x.question.toString())).length; return {total, correct, missing}; }; diff --git a/src/components/Solutions/WriteBlanks.tsx b/src/components/Solutions/WriteBlanks.tsx index 401df91c..db6e7bd8 100644 --- a/src/components/Solutions/WriteBlanks.tsx +++ b/src/components/Solutions/WriteBlanks.tsx @@ -80,11 +80,11 @@ export default function WriteBlanksSolutions({ const correct = userSolutions.filter( (x) => solutions - .find((y) => x.id === y.id.toString()) + .find((y) => x.id.toString() === y.id.toString()) ?.solution.map((y) => y.toLowerCase()) .includes(x.solution.toLowerCase()) || false, ).length; - const missing = total - userSolutions.filter((x) => solutions.find((y) => x.id === y.id.toString())).length; + const missing = total - userSolutions.filter((x) => solutions.find((y) => x.id.toString() === y.id.toString())).length; return {total, correct, missing}; }; @@ -94,10 +94,12 @@ export default function WriteBlanksSolutions({ {reactStringReplace(line, /({{\d+}})/g, (match) => { const id = match.replaceAll(/[\{\}]/g, "").toString(); - const userSolution = userSolutions.find((x) => x.id === id); - const solution = solutions.find((x) => x.id.toString() === id)!; + const userSolution = userSolutions.find((x) => x.id.toString() === id.toString()); + const solution = solutions.find((x) => x.id.toString() === id.toString())!; - return ; + return ( + + ); })} );