Answer ${MF_COUNT} problems in 4 minutes with 100% accuracy to master a table and unlock the next planet!
${done} of ${MF_TABLES.length} planets mastered β
`; const map = host.querySelector('.mf-map'); MF_TABLES.forEach(n=>{ const open = mfUnlocked(d, n), mastered = !!d.mastered[n], now = n === current; const col = MF_COLORS[n]; const b = el(``); b.onclick = ()=>{ STATE.mfTable = n; render(); }; map.appendChild(b); }); return c; } function mfPlay(host, d, n){ const probs = mfProblems(n); const col = MF_COLORS[n]; host.innerHTML = `Type the answer. It goes in by itself. Every answer must be right!
${mastered ? 'Perfect score in ' + fmt(secs) + '! ' + (next ? 'Planet Γ' + next + ' is unlocked! π' : 'You finished EVERY planet! You are a Math Facts CHAMPION! π') : answered < MF_COUNT ? 'Time ran out after ' + answered + ' problems. You need all ' + MF_COUNT + ' in 4 minutes with no mistakes.' : 'So close! You need all ' + MF_COUNT + ' correct. Practice these and try again:'}
${!mastered && missed.length ? '
Pick your class so you see the right classmates.
Pick your alias below β ${classLabel(STATE.classCode)}.
Enter your 4-digit PIN.
${STATE.loginError}
`)); setTimeout(()=>pinInput.focus(), 0); return c; } function screenSignup(){ const c = el(`Pick a nickname (not your real name) and a 4-digit PIN you'll remember. Your teacher can look up your PIN if you forget it.
What grade are you in?
This helps us write quizzes at the right level for you.
${STATE.loginError}
`)); return c; } async function doSignup(alias, pin){ alias = (alias||'').trim(); if(!alias){ STATE.loginError='Pick an alias first.'; render(); return; } if(!/^\d{4}$/.test(pin||'')){ STATE.loginError='PIN must be exactly 4 digits.'; render(); return; } STATE.loading=true; STATE.loadingMsg='Setting up your shelf...'; render(); const resp = await postJSON('/api/signup', { alias, pin, grade: STATE.signupGrade, classCode: STATE.classCode }); STATE.loading=false; if(resp.error==='alias_taken'){ STATE.loginError='That alias is taken β try another.'; render(); return; } if(resp.error){ STATE.loginError='Something went wrong. Try again.'; render(); return; } STATE.alias = resp.alias; STATE.student = resp; STATE.rosterLoaded = false; STATE.screen = needsRealName(resp) ? 'nameCapture' : 'home'; render(); } async function doLogin(alias, pin){ if(!/^\d{4}$/.test(pin||'')){ STATE.loginError='Enter your 4-digit PIN.'; render(); return; } STATE.loading=true; STATE.loadingMsg='Loading your bookshelf...'; render(); const resp = await postJSON('/api/login', { alias, pin, classCode: STATE.classCode }); STATE.loading=false; if(resp.error==='wrong_pin'){ STATE.loginError='Wrong PIN β try again.'; render(); return; } if(resp.error){ STATE.loginError='Could not find that alias.'; render(); return; } STATE.alias = resp.alias; STATE.student = resp; STATE.screen = needsRealName(resp) ? 'nameCapture' : 'home'; render(); } // Rough check that a first name is plausible: letters only, sensible length, no keyboard // mashing or placeholder words. A student who really has an unusual name can still confirm it. const JUNK_NAMES = ['test','asdf','qwerty','idk','none','no','na','abc','xxx','name','student','hi','hello','lol','poop','bruh','me','user','guest','x','null','undefined']; function looksLikeRealName(n){ const t = String(n||'').trim(); if(t.length < 2 || t.length > 20) return false; if(!/^[A-Za-zΓ-ΓΓ-ΓΆΓΈ-ΓΏ][A-Za-zΓ-ΓΓ-ΓΆΓΈ-ΓΏ'β-]*$/.test(t)) return false; const l = t.toLowerCase(); if(JUNK_NAMES.includes(l)) return false; if(/(.)\1\1/.test(l)) return false; if(l.length >= 4 && !/[aeiouy]/.test(l)) return false; if(/^(asd|sdf|dfg|qwe|wer|zxc|xcv|jkl|hjk|uiop|qaz)/.test(l)) return false; return true; } // Bump NAME_CHECK to ask every student to retype their full first name once at their next login. const NAME_CHECK = '2026-11-16'; function needsRealName(s){ return !s.realName || !looksLikeRealName(s.realName) || s.nameCheck !== NAME_CHECK; } // Prompt shown after login/signup when a student has no realName on file, or one that // doesn't look like a real name. This never touches the AI-facing endpoints or the public // roster - it's merged into the student's own record via the normal save // path and only ever surfaced back out through the teacher-passcode-gated // dashboard, so it stays private even though the student enters it. function screenNameCapture(){ const c = el(`Please type your full first name, spelled the way your teacher knows you (not a nickname or short version). Only your teacher can see this β no one else in the app ever will. First name only, please, no last name.