Solved a few bugs on the WriteBlanks module
This commit is contained in:
@@ -16,8 +16,8 @@ export default function TrueFalse({id, type, prompt, questions, userSolutions, o
|
||||
|
||||
const calculateScore = () => {
|
||||
const total = questions.length || 0;
|
||||
const correct = answers.filter((x) => questions.find((y) => x.id === y.id)?.solution === x.solution.toLowerCase() || false).length;
|
||||
const missing = total - answers.filter((x) => questions.find((y) => x.id === y.id)).length;
|
||||
const correct = answers.filter((x) => questions.find((y) => x.id === y.id.toString())?.solution === x.solution.toLowerCase() || false).length;
|
||||
const missing = total - answers.filter((x) => questions.find((y) => x.id === y.id.toString())).length;
|
||||
|
||||
return {total, correct, missing};
|
||||
};
|
||||
@@ -61,26 +61,26 @@ export default function TrueFalse({id, type, prompt, questions, userSolutions, o
|
||||
<span className="text-sm w-full leading-6">You can click a selected option again to deselect it.</span>
|
||||
<div className="bg-mti-gray-smoke rounded-xl px-5 py-6 flex flex-col gap-8">
|
||||
{questions.map((question, index) => (
|
||||
<div key={question.id} className="flex flex-col gap-4">
|
||||
<div key={question.id.toString()} className="flex flex-col gap-4">
|
||||
<span>
|
||||
{index + 1}. {question.prompt}
|
||||
</span>
|
||||
<div className="flex gap-4">
|
||||
<Button
|
||||
variant={answers.find((x) => x.id === question.id)?.solution === "true" ? "solid" : "outline"}
|
||||
onClick={() => toggleAnswer("true", question.id)}
|
||||
variant={answers.find((x) => x.id === question.id.toString())?.solution === "true" ? "solid" : "outline"}
|
||||
onClick={() => toggleAnswer("true", question.id.toString())}
|
||||
className="!py-2">
|
||||
True
|
||||
</Button>
|
||||
<Button
|
||||
variant={answers.find((x) => x.id === question.id)?.solution === "false" ? "solid" : "outline"}
|
||||
onClick={() => toggleAnswer("false", question.id)}
|
||||
variant={answers.find((x) => x.id === question.id.toString())?.solution === "false" ? "solid" : "outline"}
|
||||
onClick={() => toggleAnswer("false", question.id.toString())}
|
||||
className="!py-2">
|
||||
False
|
||||
</Button>
|
||||
<Button
|
||||
variant={answers.find((x) => x.id === question.id)?.solution === "not_given" ? "solid" : "outline"}
|
||||
onClick={() => toggleAnswer("not_given", question.id)}
|
||||
variant={answers.find((x) => x.id === question.id.toString())?.solution === "not_given" ? "solid" : "outline"}
|
||||
onClick={() => toggleAnswer("not_given", question.id.toString())}
|
||||
className="!py-2">
|
||||
Not Given
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user