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

@@ -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({
<span className="text-base leading-5">
{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 <Blank userSolution={userSolution?.solution} maxWords={maxWords} id={id} solutions={solution.solution} disabled />;
return (
<Blank userSolution={userSolution?.solution} maxWords={maxWords} id={id.toString()} solutions={solution.solution} disabled />
);
})}
</span>
);