Updated the problems with the marking - related to the DB not having the correct type
This commit is contained in:
@@ -21,8 +21,10 @@ export default function MatchSentencesSolutions({
|
||||
}: MatchSentencesExercise & CommonProps) {
|
||||
const calculateScore = () => {
|
||||
const total = sentences.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;
|
||||
const correct = userSolutions.filter(
|
||||
(x) => sentences.find((y) => y.id.toString() === x.question.toString())?.solution === x.option || false,
|
||||
).length;
|
||||
const missing = total - userSolutions.filter((x) => sentences.find((y) => y.id.toString() === x.question.toString())).length;
|
||||
|
||||
return {total, correct, missing};
|
||||
};
|
||||
@@ -48,9 +50,9 @@ export default function MatchSentencesSolutions({
|
||||
className={clsx(
|
||||
"w-8 h-8 rounded-full z-10 text-white",
|
||||
"transition duration-300 ease-in-out",
|
||||
!userSolutions.find((x) => x.question === id) && "!bg-mti-red",
|
||||
userSolutions.find((x) => x.question === id)?.option === solution && "bg-mti-purple",
|
||||
userSolutions.find((x) => x.question === id)?.option !== solution && "bg-mti-rose",
|
||||
!userSolutions.find((x) => x.question.toString() === id.toString()) && "!bg-mti-red",
|
||||
userSolutions.find((x) => x.question.toString() === id.toString())?.option === solution && "bg-mti-purple",
|
||||
userSolutions.find((x) => x.question.toString() === id.toString())?.option !== solution && "bg-mti-rose",
|
||||
)}>
|
||||
{id}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user