Updated the problems with the marking - related to the DB not having the correct type

This commit is contained in:
Tiago Ribeiro
2023-09-13 23:46:50 +01:00
parent 3a51185942
commit dc8682e1c3
9 changed files with 50 additions and 28 deletions

View File

@@ -9,9 +9,9 @@ export default function FillBlanksSolutions({id, type, prompt, solutions, text,
const calculateScore = () => {
const total = text.match(/({{\d+}})/g)?.length || 0;
const correct = userSolutions.filter(
(x) => solutions.find((y) => x.id === y.id.toString())?.solution === x.solution.toLowerCase() || false,
(x) => solutions.find((y) => x.id.toString() === y.id.toString())?.solution === 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};
};