diff --git a/src/pages/(generation)/LevelGeneration.tsx b/src/pages/(generation)/LevelGeneration.tsx
index 26cdf67b..9a92ec12 100644
--- a/src/pages/(generation)/LevelGeneration.tsx
+++ b/src/pages/(generation)/LevelGeneration.tsx
@@ -1,5 +1,5 @@
import Select from "@/components/Low/Select";
-import {Difficulty, LevelExam, MultipleChoiceExercise} from "@/interfaces/exam";
+import {Difficulty, LevelExam, MultipleChoiceExercise, MultipleChoiceQuestion} from "@/interfaces/exam";
import useExamStore from "@/stores/examStore";
import {getExamById} from "@/utils/exams";
import {playSound} from "@/utils/sound";
@@ -9,12 +9,69 @@ import clsx from "clsx";
import {capitalize, sample} from "lodash";
import {useRouter} from "next/router";
import {useState} from "react";
-import {BsArrowRepeat} from "react-icons/bs";
+import {BsArrowRepeat, BsCheck, BsPencilSquare, BsX} from "react-icons/bs";
import {toast} from "react-toastify";
import {v4} from "uuid";
const DIFFICULTIES: Difficulty[] = ["easy", "medium", "hard"];
+const QuestionDisplay = ({question, onUpdate}: {question: MultipleChoiceQuestion; onUpdate: (question: MultipleChoiceQuestion) => void}) => {
+ const [isEditing, setIsEditing] = useState(false);
+ const [options, setOptions] = useState(question.options);
+
+ return (
+
+
+ {question.id}. {question.prompt}{" "}
+
+
+ {question.options.map((option, index) => (
+
+
+ ({option.id})
+ {" "}
+ {isEditing ? (
+ setOptions((prev) => prev.map((x, idx) => (idx === index ? {...x, text: e.target.value} : x)))}
+ />
+ ) : (
+ {option.text}
+ )}
+
+ ))}
+
+
+ {!isEditing && (
+
+ )}
+ {isEditing && (
+ <>
+
+
+ >
+ )}
+
+
+ );
+};
+
const TaskTab = ({exam, difficulty, setExam}: {exam?: LevelExam; difficulty: Difficulty; setExam: (exam: LevelExam) => void}) => {
const [isLoading, setIsLoading] = useState(false);
@@ -37,6 +94,20 @@ const TaskTab = ({exam, difficulty, setExam}: {exam?: LevelExam; difficulty: Dif
.finally(() => setIsLoading(false));
};
+ const onUpdate = (question: MultipleChoiceQuestion) => {
+ if (!exam) return;
+
+ const updatedExam = {
+ ...exam,
+ exercises: exam.exercises.map((x) => ({
+ ...x,
+ questions: (x as MultipleChoiceExercise).questions.map((q) => (q.id === question.id ? question : q)),
+ })),
+ };
+ console.log(updatedExam);
+ setExam(updatedExam as any);
+ };
+
return (
@@ -80,25 +151,7 @@ const TaskTab = ({exam, difficulty, setExam}: {exam?: LevelExam; difficulty: Dif
{exercise.questions.map((question) => (
-
-
- {question.id}. {question.prompt}
-
-
- {question.options.map((option) => (
-
-
- ({option.id})
- {" "}
- {option.text}
-
- ))}
-
-
+
))}