diff --git a/src/components/Exercises/WriteBlanks.tsx b/src/components/Exercises/WriteBlanks.tsx
index 189c08ea..18f933f8 100644
--- a/src/components/Exercises/WriteBlanks.tsx
+++ b/src/components/Exercises/WriteBlanks.tsx
@@ -61,7 +61,7 @@ export default function WriteBlanks({id, prompt, type, maxWords, solutions, user
const correct = answers.filter(
(x) =>
solutions
- .find((y) => x.id === y.id)
+ .find((y) => x.id === y.id.toString())
?.solution.map((y) => y.toLowerCase())
.includes(x.solution.toLowerCase()) || false,
).length;
diff --git a/src/components/Solutions/FillBlanks.tsx b/src/components/Solutions/FillBlanks.tsx
index 49494f82..ec7e9815 100644
--- a/src/components/Solutions/FillBlanks.tsx
+++ b/src/components/Solutions/FillBlanks.tsx
@@ -8,8 +8,10 @@ import Button from "../Low/Button";
export default function FillBlanksSolutions({id, type, prompt, solutions, text, userSolutions, onNext, onBack}: FillBlanksExercise & CommonProps) {
const calculateScore = () => {
const total = text.match(/({{\d+}})/g)?.length || 0;
- const correct = userSolutions.filter((x) => solutions.find((y) => x.id === y.id)?.solution === x.solution.toLowerCase() || false).length;
- const missing = total - userSolutions.filter((x) => solutions.find((y) => x.id === y.id)).length;
+ const correct = userSolutions.filter(
+ (x) => solutions.find((y) => x.id === y.id.toString())?.solution === x.solution.toLowerCase() || false,
+ ).length;
+ const missing = total - userSolutions.filter((x) => solutions.find((y) => x.id === y.id.toString())).length;
return {total, correct, missing};
};
diff --git a/src/components/Solutions/MatchSentences.tsx b/src/components/Solutions/MatchSentences.tsx
index f38a858b..20528879 100644
--- a/src/components/Solutions/MatchSentences.tsx
+++ b/src/components/Solutions/MatchSentences.tsx
@@ -21,8 +21,8 @@ export default function MatchSentencesSolutions({
}: MatchSentencesExercise & CommonProps) {
const calculateScore = () => {
const total = sentences.length;
- const correct = userSolutions.filter((x) => sentences.find((y) => y.id === x.question)?.solution === x.option || false).length;
- const missing = total - userSolutions.filter((x) => sentences.find((y) => y.id === x.question)).length;
+ const correct = userSolutions.filter((x) => sentences.find((y) => y.id.toString() === x.question)?.solution === x.option || false).length;
+ const missing = total - userSolutions.filter((x) => sentences.find((y) => y.id.toString() === x.question)).length;
return {total, correct, missing};
};
diff --git a/src/components/Solutions/MultipleChoice.tsx b/src/components/Solutions/MultipleChoice.tsx
index d301ea93..d642af60 100644
--- a/src/components/Solutions/MultipleChoice.tsx
+++ b/src/components/Solutions/MultipleChoice.tsx
@@ -59,8 +59,8 @@ 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 === x.question)?.solution === x.option || false).length;
- const missing = total - userSolutions.filter((x) => questions.find((y) => y.id === x.question)).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;
return {total, correct, missing};
};
diff --git a/src/components/Solutions/TrueFalse.tsx b/src/components/Solutions/TrueFalse.tsx
index f16b5aac..4e65991d 100644
--- a/src/components/Solutions/TrueFalse.tsx
+++ b/src/components/Solutions/TrueFalse.tsx
@@ -10,8 +10,10 @@ type Solution = "true" | "false" | "not_given";
export default function TrueFalseSolution({prompt, type, id, questions, userSolutions, onNext, onBack}: TrueFalseExercise & CommonProps) {
const calculateScore = () => {
const total = questions.length || 0;
- const correct = userSolutions.filter((x) => questions.find((y) => x.id === y.id)?.solution === x.solution.toLowerCase() || false).length;
- const missing = total - userSolutions.filter((x) => questions.find((y) => x.id === y.id)).length;
+ const correct = userSolutions.filter(
+ (x) => questions.find((y) => x.id.toString() === y.id.toString())?.solution === x.solution.toLowerCase() || false,
+ ).length;
+ const missing = total - userSolutions.filter((x) => questions.find((y) => x.id.toString() === y.id.toString())).length;
return {total, correct, missing};
};
@@ -63,10 +65,10 @@ export default function TrueFalseSolution({prompt, type, id, questions, userSolu
You can click a selected option again to deselect it.
{questions.map((question, index) => {
- const userSolution = userSolutions.find((x) => x.id === question.id);
+ const userSolution = userSolutions.find((x) => x.id === question.id.toString());
return (
-
);
}
@@ -83,11 +80,11 @@ export default function WriteBlanksSolutions({
const correct = userSolutions.filter(
(x) =>
solutions
- .find((y) => x.id === y.id)
+ .find((y) => x.id === 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)).length;
+ const missing = total - userSolutions.filter((x) => solutions.find((y) => x.id === y.id.toString())).length;
return {total, correct, missing};
};
@@ -96,9 +93,11 @@ export default function WriteBlanksSolutions({
return (
{reactStringReplace(line, /({{\d+}})/g, (match) => {
- const id = match.replaceAll(/[\{\}]/g, "");
+ const id = match.replaceAll(/[\{\}]/g, "").toString();
const userSolution = userSolutions.find((x) => x.id === id);
- const solution = solutions.find((x) => x.id === id)!;
+ const solution = solutions.find((x) => x.id.toString() === id)!;
+
+ console.log(solution, id, userSolution);
return ;
})}