From 6930c83e07b72066c406763517c540a44c54c4fc Mon Sep 17 00:00:00 2001 From: AliReza Date: Thu, 8 Oct 2026 18:04:02 +0330 Subject: [PATCH] =?UTF-8?q?Quiz:=20selecting=20an=20option=20only=20highli?= =?UTF-8?q?ghts=20it=20blue;=20the=20answer=20is=20submitted=20by=20a=20?= =?UTF-8?q?=C2=AB=D8=A8=D8=B1=D8=B1=D8=B3=DB=8C=C2=BB=20button=20and=20gre?= =?UTF-8?q?en/red=20is=20shown=20after,=20then=20=C2=AB=D8=A7=D8=AF=D8=A7?= =?UTF-8?q?=D9=85=D9=87=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/screens/QuizScreen.tsx | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/screens/QuizScreen.tsx b/src/screens/QuizScreen.tsx index 131860e..7a35d6c 100644 --- a/src/screens/QuizScreen.tsx +++ b/src/screens/QuizScreen.tsx @@ -101,9 +101,15 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s }; }, [lessonId, nodeId, nodeMode, reload]); - async function choose(optionId: string) { - if (!question || selected !== null || submitting) return; + /** انتخاب فقط گزینه را آبی می‌کند؛ تا «بررسی» نزده، چیزی ثبت یا رو نمی‌شود و می‌شود عوضش کرد. */ + function choose(optionId: string) { + if (!question || answer || submitting) return; setSelected(optionId); + } + + async function check() { + if (!question || selected === null || answer || submitting) return; + const optionId = selected; setSubmitting(true); let key = answerKeys.current.get(question.id); if (!key) { @@ -121,7 +127,7 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s sounds.wrong(); } } catch (err) { - setSelected(null); + // گزینه انتخاب‌شده می‌ماند تا کاربر دوباره «بررسی» بزند. if (err instanceof ApiError && err.code === 'no_hearts') { setPhase({ kind: 'noHearts', @@ -239,7 +245,7 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s const mood: SeyarMood = !answer ? 'idle' : answer.correct ? 'excited' : outOfHearts ? 'depressed' : 'sad'; const bubble = !answer - ? 'جوابِ درست رو انتخاب کن!' + ? selected === null ? 'جوابِ درست رو انتخاب کن!' : 'مطمئنی؟ «بررسی» رو بزن.' : answer.correct ? 'آفرین! درست بود' : outOfHearts @@ -248,7 +254,7 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s const shortOptions = question.options.every((o) => o.value.length <= 14); const optionClass = (id: string) => { - if (!answer) return selected === id ? 'border-coral bg-[#fff4f2] text-ink' : 'border-line bg-white text-ink'; + if (!answer) return selected === id ? 'border-[#84D8FF] bg-[#DDF4FF] text-[#1581BA]' : 'border-line bg-white text-ink'; if (id === answer.correctOptionId) return 'border-green-400 bg-[#e5fdf0] text-green-700'; if (id === selected) return 'border-red-300 bg-[#fff0f0] text-red-500'; return 'border-line bg-white text-faint'; @@ -312,9 +318,10 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s void choose(option.id)} - disabled={selected !== null && !answer} - whileTap={{ scale: selected === null ? 0.95 : 1 }} + onClick={() => choose(option.id)} + disabled={submitting || answer !== null} + aria-pressed={selected === option.id} + whileTap={{ scale: answer ? 1 : 0.95 }} className={`flex min-h-14 items-center justify-center gap-1.5 rounded-2xl border-2 border-b-4 px-3 py-3 font-black transition-colors ${shortOptions ? 'text-xl' : 'text-base'} ${optionClass(option.id)}`} > @@ -324,17 +331,24 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s ))} - {answer && ( - + + +
+ {answer ? ( + <> {!answer.correct && ( )} void next()}> - {isLast ? 'پایانِ تمرین' : 'سوالِ بعدی'} + {isLast ? 'پایانِ تمرین' : 'ادامه'} - + + ) : ( + void check()}> + بررسی + )}