import {FillBlanksExercise, TrueFalseExercise} from "@/interfaces/exam"; import clsx from "clsx"; import reactStringReplace from "react-string-replace"; import {CommonProps} from "."; import {Fragment} from "react"; import Button from "../Low/Button"; import useExamStore from "@/stores/examStore"; type Solution = "true" | "false" | "not_given"; export default function TrueFalseSolution({prompt, type, id, questions, userSolutions, onNext, onBack}: TrueFalseExercise & CommonProps) { const {questionIndex, setQuestionIndex, partIndex, exam} = useExamStore((state) => state); const calculateScore = () => { const total = questions.length || 0; const correct = userSolutions.filter( (x) => questions.find((y) => x.id.toString() === y.id.toString())?.solution === x.solution.toLowerCase() || false, ).length; const missing = total - userSolutions.filter((x) => questions.find((y) => x.id.toString() === y.id.toString())).length; return {total, correct, missing}; }; const getButtonColor = (buttonSolution: Solution, solution: Solution, userSolution: Solution | undefined) => { if (buttonSolution !== userSolution && buttonSolution !== solution) return "purple"; if (userSolution) { if (userSolution === buttonSolution && solution === buttonSolution) { return "purple"; } if (solution === buttonSolution) { return "purple"; } return "rose"; } return "gray"; }; return (
{prompt.split("\\n").map((line, index) => ( {line}
))}

For each of the questions below, select

TRUE FALSE NOT GIVEN if the statement agrees with the information if the statement contradicts with the information if there is no information on this
You can click a selected option again to deselect it.
{userSolutions && questions.map((question, index) => { const userSolution = userSolutions.find((x) => x.id === question.id.toString()); const solution = question.solution.toString().toLowerCase() as Solution; return (
{index + 1}. {question.prompt}
); })}
Correct
Unanswered
Wrong
); }