import {ReadingExam} from "@/interfaces/exam";
import {Fragment, useState} from "react";
import Icon from "@mdi/react";
import {mdiArrowRight, mdiNotebook} from "@mdi/js";
import clsx from "clsx";
import {infoButtonStyle} from "@/constants/buttonStyles";
import {Dialog, Transition} from "@headlessui/react";
import {renderExercise} from "@/components/Exercises";
interface Props {
exam: ReadingExam;
onFinish: () => void;
}
function TextModal({isOpen, title, content, onClose}: {isOpen: boolean; title: string; content: string; onClose: () => void}) {
return (
{title}
{content.split("\n").map((line, index) => (
{line}
))}
Got it, thanks!
);
}
export default function Reading({exam, onFinish}: Props) {
const [exerciseIndex, setExerciseIndex] = useState(-1);
const [showTextModal, setShowTextModal] = useState(false);
const nextExercise = () => {
if (exerciseIndex + 1 < exam.exercises.length) {
setExerciseIndex((prev) => prev + 1);
return;
}
onFinish();
};
const previousExercise = () => {
setExerciseIndex((prev) => prev - 1);
};
const renderText = () => (
<>
Please read the following excerpt attentively, you will then be asked questions about the text you've read.
You will be allowed to read the text while doing the exercises
{exam.text.title}
{exam.text.content.split("\n").map((line, index) => (
{line}
))}
>
);
return (
<>
setShowTextModal(false)} />
{exerciseIndex === -1 && renderText()}
{exerciseIndex > -1 &&
exerciseIndex < exam.exercises.length &&
renderExercise(exam.exercises[exerciseIndex], nextExercise, previousExercise)}
-1 ? "w-full justify-between" : "self-end")}>
{exerciseIndex > -1 && (
setShowTextModal(true)}>
Read Text
)}
{exerciseIndex === -1 && (
Next
)}
>
);
}