Skip to content

Commit 0cf189c

Browse files
GumisC4Antoni-Czaplicki
authored andcommitted
feat: added advanced mode per question fix
1 parent af58a39 commit 0cf189c

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/components/quiz/question-form.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/components/quiz/question-form.tsx
21
import { Trash2, TrashIcon } from "lucide-react";
32

43
import { Button } from "@/components/ui/button";
@@ -36,8 +35,6 @@ export function QuestionForm({
3635
};
3736

3837
const handleMultipleChange = (multiple: boolean) => {
39-
// If switching from multiple choice to single choice and there are multiple correct answers,
40-
// keep only the first correct answer
4138
if (
4239
!multiple &&
4340
question.multiple &&
@@ -60,8 +57,6 @@ export function QuestionForm({
6057
};
6158

6259
const updateAnswer = (index: number, updatedAnswer: Answer) => {
63-
// If this is a single-choice question and we're marking an answer as correct,
64-
// unmark all other answers as correct
6560
if (!question.multiple && updatedAnswer.correct) {
6661
const updatedAnswers = question.answers.map((a, index_) => ({
6762
...a,

src/components/quiz/quiz-editor.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/components/quiz/quiz-editor.tsx
21
import { ArrowDownToLineIcon, PlusIcon } from "lucide-react";
32
import { useEffect, useMemo, useState } from "react";
43

@@ -35,7 +34,6 @@ interface QuizEditorProps {
3534
saving?: boolean;
3635
}
3736

38-
// Utility to strip advanced fields when advancedMode is disabled per question
3937
const sanitizeQuestions = (questions: (Question & { advanced?: boolean })[]) =>
4038
questions.map((q) => {
4139
const isAdvanced = Boolean(q.advanced);
@@ -65,7 +63,6 @@ export function QuizEditor({
6563
onSaveAndClose,
6664
saving = false,
6765
}: QuizEditorProps) {
68-
// default advanced for existing quiz: if any question had advanced fields
6966
const initialAdvancedDefault =
7067
initialQuiz?.questions?.some(
7168
(q) =>
@@ -85,7 +82,7 @@ export function QuizEditor({
8582
if (initialQuiz?.questions != null && initialQuiz.questions.length > 0) {
8683
return initialQuiz.questions.map((q) => ({
8784
...q,
88-
// preserve per-question advanced if present, otherwise infer from content or global default
85+
8986
advanced:
9087
Boolean((q as unknown as Q).advanced) ||
9188
Boolean(q.image) ||
@@ -117,7 +114,6 @@ export function QuizEditor({
117114
questions.reduce((max, q) => Math.max(q.id, max), 0),
118115
);
119116

120-
// all questions multiple toggle state (true / false / mixed null)
121117
const allQuestionsMultiple: boolean | null = useMemo(() => {
122118
if (questions.length === 0) {
123119
return null;
@@ -151,7 +147,7 @@ export function QuizEditor({
151147
],
152148
image: "",
153149
explanation: "",
154-
advanced: advancedMode, // use global as default for new question
150+
advanced: advancedMode,
155151
},
156152
]);
157153
setPreviousQuestionId(newId);

0 commit comments

Comments
 (0)