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 (
For each of the questions below, select