Bug fix on fillblanks calculateScore

This commit is contained in:
Carlos Mesquita
2024-08-27 09:40:20 +01:00
parent 72b498eb85
commit cc5be99b0f
2 changed files with 6 additions and 4 deletions

View File

@@ -55,10 +55,11 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
const solution = solutions.find((y) => x.id.toString() === y.id.toString())?.solution;
if (!solution) return false;
const option = correctWords!.find((w: any) => {
console.log(w);
if (typeof w === "string") {
return w.toLowerCase() === x.solution.toLowerCase();
} else if ('letter' in w) {
return w.word.toLowerCase() === x.solution.toLowerCase();
return w.letter.toLowerCase() === x.solution.toLowerCase();
} else {
return w.id.toString() === x.id.toString();
}
@@ -138,9 +139,10 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
}
useEffect(() => {
if (variant === "mc") {
//if (variant === "mc") {
console.log(answers);
setCurrentSolution({ exercise: id, solutions: answers, score: calculateScore(), type, shuffleMaps: shuffleMaps });
}
//}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [answers])

View File

@@ -34,7 +34,7 @@ export default function FillBlanksSolutions({
if (typeof w === "string") {
return w.toLowerCase() === x.solution.toLowerCase();
} else if ('letter' in w) {
return w.word.toLowerCase() === x.solution.toLowerCase();
return w.letter.toLowerCase() === x.solution.toLowerCase();
} else {
return w.id.toString() === x.id.toString();
}