import {MatchSentencesExercise} from "@/interfaces/exam"; import clsx from "clsx"; import LineTo from "react-lineto"; import {CommonProps} from "."; import {errorButtonStyle, infoButtonStyle} from "@/constants/buttonStyles"; import {mdiArrowLeft, mdiArrowRight} from "@mdi/js"; import Icon from "@mdi/react"; import {Fragment} from "react"; import Button from "../Low/Button"; import Xarrow from "react-xarrows"; export default function MatchSentencesSolutions({ id, type, options, prompt, sentences, userSolutions, onNext, onBack, }: MatchSentencesExercise & CommonProps) { const calculateScore = () => { const total = sentences.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}; }; return ( <>
{prompt.split("\\n").map((line, index) => ( {line}
))}
{sentences.map(({sentence, id, solution}) => (
{sentence}
))}
{options.map(({sentence, id}) => (
{sentence}
))}
{userSolutions && sentences.map((sentence, index) => ( x.question === sentence.id) ? "#CC5454" : userSolutions.find((x) => x.question === sentence.id)?.option === sentence.solution ? "#7872BF" : "#CC5454" } showHead={false} /> ))}
Correct
Unanswered
Wrong
); }