forked from Tadrisino/MathApp_frontend
Quiz: phone Back asks before leaving; unknown hearts are not shown as five full
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import { api, ApiError, type AnswerResult, type Hearts, type Question } from '@/
|
|||||||
import { useAppData } from '@/state/AppData';
|
import { useAppData } from '@/state/AppData';
|
||||||
import { fetchHome } from '@/state/subject';
|
import { fetchHome } from '@/state/subject';
|
||||||
import { findNode, findNodeOfLesson, nextLessonOf, unitColor } from '@/state/curriculum';
|
import { findNode, findNodeOfLesson, nextLessonOf, unitColor } from '@/state/curriculum';
|
||||||
import { useNav } from '@/nav/Navigator';
|
import { useBackStep, useNav } from '@/nav/Navigator';
|
||||||
import { newIdempotencyKey } from '@/api/http';
|
import { newIdempotencyKey } from '@/api/http';
|
||||||
import { SeyarMascot } from '@/mascots/SeyarMascot';
|
import { SeyarMascot } from '@/mascots/SeyarMascot';
|
||||||
import type { SeyarMood } from '@/mascots/seyar';
|
import type { SeyarMood } from '@/mascots/seyar';
|
||||||
@@ -74,6 +74,9 @@ export function QuizScreen({ lessonId, nodeId }: { lessonId?: number; nodeId?: s
|
|||||||
// پشتِ هم درست؛ برای «سه تا پشتِ هم!» (حسِ پیشرفت وسطِ آزمون، نه فقط آخرش).
|
// پشتِ هم درست؛ برای «سه تا پشتِ هم!» (حسِ پیشرفت وسطِ آزمون، نه فقط آخرش).
|
||||||
const [combo, setCombo] = useState(0);
|
const [combo, setCombo] = useState(0);
|
||||||
useGateHold(phase.kind === 'loading');
|
useGateHold(phase.kind === 'loading');
|
||||||
|
// دکمهی برگشتِ گوشی وسطِ تمرین همان «X» است: اول میپرسد، بیصدا بیرون نمیاندازد. برگهی باز خودش قدمِ
|
||||||
|
// برگشتِ جداگانه دارد، پس برگشتِ دوم فقط برگه را میبندد.
|
||||||
|
useBackStep(phase.kind === 'playing' && !confirmExit, () => setConfirmExit(true));
|
||||||
|
|
||||||
// یک کلید برای هر سوال و یکی برای پایانِ درس؛ تکرارِ درخواست دوبار ثبت نمیشود.
|
// یک کلید برای هر سوال و یکی برای پایانِ درس؛ تکرارِ درخواست دوبار ثبت نمیشود.
|
||||||
const answerKeys = useRef(new Map<string, string>());
|
const answerKeys = useRef(new Map<string, string>());
|
||||||
@@ -440,8 +443,10 @@ function HeartsRow({ hearts }: { hearts: Hearts | null }) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const max = hearts?.maxHearts ?? 5;
|
// وضعیتِ قلب نرسید: پنج قلبِ پُرِ ساختگی نشان نمیدهیم؛ سرور با هر جواب عددِ واقعی را برمیگرداند.
|
||||||
const current = hearts?.currentHearts ?? max;
|
if (!hearts) return null;
|
||||||
|
const max = hearts.maxHearts;
|
||||||
|
const current = hearts.currentHearts;
|
||||||
return (
|
return (
|
||||||
<div className="mt-3 flex items-center justify-center gap-2" aria-label={`${toFa(current)} قلب از ${toFa(max)}`}>
|
<div className="mt-3 flex items-center justify-center gap-2" aria-label={`${toFa(current)} قلب از ${toFa(max)}`}>
|
||||||
{Array.from({ length: max }, (_, i) => (
|
{Array.from({ length: max }, (_, i) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user