Navigation rework, added prompt edit to components that were missing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import Button from "@/components/Low/Button";
|
||||
import Modal from "@/components/Modal";
|
||||
import { Exam, LevelExam, MultipleChoiceExercise, ShuffleMap } from "@/interfaces/exam";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import useExamStore, { usePersistentExamStore } from "@/stores/exam";
|
||||
import clsx from "clsx";
|
||||
import { useMemo, useState } from "react";
|
||||
import { BsFillGrid3X3GapFill } from "react-icons/bs";
|
||||
@@ -10,16 +10,20 @@ interface Props {
|
||||
exam: LevelExam
|
||||
showSolutions: boolean;
|
||||
runOnClick: ((index: number) => void) | undefined;
|
||||
preview: boolean,
|
||||
}
|
||||
|
||||
const MCQuestionGrid: React.FC<Props> = ({ exam, showSolutions, runOnClick }) => {
|
||||
const MCQuestionGrid: React.FC<Props> = ({ exam, showSolutions, runOnClick, preview }) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const examState = useExamStore((state) => state);
|
||||
const persistentExamState = usePersistentExamStore((state) => state);
|
||||
|
||||
const {
|
||||
userSolutions,
|
||||
partIndex: sectionIndex,
|
||||
exerciseIndex,
|
||||
} = useExamStore((state) => state);
|
||||
} = !preview ? examState : persistentExamState;
|
||||
|
||||
const currentExercise = useMemo(() => (exam as LevelExam).parts[sectionIndex!].exercises[exerciseIndex] as MultipleChoiceExercise, [exam, exerciseIndex, sectionIndex])
|
||||
const userSolution = useMemo(() => userSolutions!.find((x) => x.exercise.toString() == currentExercise.id.toString())!, [currentExercise.id, userSolutions])
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BsBook, BsClipboard, BsHeadphones, BsMegaphone, BsPen } from "react-ico
|
||||
import ProgressBar from "../../Low/ProgressBar";
|
||||
import Timer from "../Timer";
|
||||
import { Exercise, LevelExam } from "@/interfaces/exam";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import useExamStore, { usePersistentExamStore } from "@/stores/exam";
|
||||
import React from "react";
|
||||
import MCQuestionGrid from "./MCQuestionGrid";
|
||||
|
||||
@@ -23,7 +23,8 @@ interface Props {
|
||||
showSolutions?: boolean;
|
||||
currentExercise?: Exercise;
|
||||
runOnClick?: ((questionIndex: number) => void) | undefined;
|
||||
indexLabel?: string
|
||||
indexLabel?: string,
|
||||
preview: boolean,
|
||||
}
|
||||
|
||||
export default function ModuleTitle({
|
||||
@@ -38,9 +39,13 @@ export default function ModuleTitle({
|
||||
showTimer = true,
|
||||
showSolutions = false,
|
||||
runOnClick = undefined,
|
||||
indexLabel = "Question"
|
||||
indexLabel = "Question",
|
||||
preview,
|
||||
}: Props) {
|
||||
const { exam, partIndex, exerciseIndex: examExerciseIndex, userSolutions } = useExamStore((state) => state);
|
||||
const examState = useExamStore((state) => state);
|
||||
const persistentExamState = usePersistentExamStore((state) => state);
|
||||
|
||||
const { exam, partIndex, exerciseIndex: examExerciseIndex, userSolutions } = !preview ? examState : persistentExamState;
|
||||
|
||||
const moduleIcon: { [key in Module]: ReactNode } = {
|
||||
reading: <BsBook className="text-ielts-reading w-6 h-6" />,
|
||||
@@ -52,7 +57,6 @@ export default function ModuleTitle({
|
||||
|
||||
const showGrid = useMemo(() =>
|
||||
exam?.module === "level"
|
||||
&& partIndex > -1
|
||||
&& exam.parts[partIndex].exercises[examExerciseIndex].type === "multipleChoice"
|
||||
&& !!userSolutions,
|
||||
[exam, examExerciseIndex, partIndex, userSolutions]
|
||||
@@ -95,7 +99,7 @@ export default function ModuleTitle({
|
||||
</div>
|
||||
<ProgressBar color={module} label="" percentage={(exerciseIndex * 100) / totalExercises} className="h-2 w-full" />
|
||||
</div>
|
||||
{showGrid && <MCQuestionGrid exam={exam as LevelExam} showSolutions={showSolutions} runOnClick={runOnClick} />}
|
||||
{showGrid && <MCQuestionGrid exam={exam as LevelExam} showSolutions={showSolutions} runOnClick={runOnClick} preview={preview}/>}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user