/* ============================================================ INDIC LEAGUE NEWS — Political Spectrum Quiz 10 questions, 4 options, mean → score → label. Per plan §3.10. State NOT persisted mid-quiz (by design). ============================================================ */ function Quiz({ onComplete, onCancel }) { const [idx, setIdx] = React.useState(0); const [answers, setAnswers] = React.useState({}); // { questionIdx: score } const [done, setDone] = React.useState(false); const Q = window.IL_QUIZ; const total = Q.length; const current = Q[idx]; const pick = (score) => { window.IL_Sounds && window.IL_Sounds.pick(); window.IL_Util && window.IL_Util.Haptics.pick(); setAnswers(prev => ({ ...prev, [idx]: score })); if (idx + 1 < total) { setTimeout(() => setIdx(idx + 1), 220); } else { setTimeout(() => { window.IL_Sounds && window.IL_Sounds.success(); window.IL_Util && window.IL_Util.Haptics.success(); setDone(true); }, 220); } }; const goPrev = () => { if (idx === 0) { onCancel && onCancel(); return; } window.IL_Sounds && window.IL_Sounds.tap(); setIdx(idx - 1); }; // RESULT screen if (done) { const scores = Object.values(answers); const raw = scores.reduce((a, b) => a + b, 0) / scores.length; const position = window.IL_Util.clamp(raw, -1, 1); const label = window.IL_LABEL_FROM_SCORE(position); // Marker position on 0–100% based on -1..+1 const markerPct = ((position + 1) / 2) * 100; // Find closest option ID so onboarding can pre-fill const closest = window.IL_POLITICAL_OPTIONS .map(o => ({ id: o.id, dist: Math.abs(o.position - position) })) .sort((a, b) => a.dist - b.dist)[0]; return (
All set
Your political position
{label}
Left Centre Right

This shapes how we balance your feed — not who you are. You can adjust the diversity dial anytime.

); } // QUESTION screen const progress = ((idx) / total) * 100; const picked = answers[idx]; return (
Political Quiz
{idx + 1} / {total}

{current.q}

{current.options.map((opt, i) => ( ))}
{idx > 0 && ( { e.preventDefault(); goPrev(); }} > ← Previous )}
); } Object.assign(window, { Quiz });