Spaces:
Sleeping
Sleeping
deploy v2 study (40-runs baselines) at /v2/: dual-study backend + static/v2 rater UI; v1 study untouched
Browse files840 unmodified lines8418428438448448458468478488498508468478488518528538548558569 unmodified lines8668678688648698708718728 unmodified lines88188288387988488588688737 unmodified lines92592692792392892993093180 unmodified lines10121013101410101015101610171018202 unmodified lines1221122212231219122412251226122712281229123012261231123212331234224 unmodified lines145914601461145714621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484840 unmodified lines return Array.from({length:slotCount},(_,i)=>i);}
/* ----- Ratings ----- *//* ----- Ratings ----- * RATINGS is keyed RATINGS[case_id][model][q_key] — by MODEL NAME, exactly * like desktop index.html, so the shared localStorage blob and the * server-recovered state read identically on both pages. (Older mobile code * keyed by slot index; see migrateSlotKeyedRatings for the one-shot fix-up.) */function getCaseR(cid){ if(!RATINGS[cid]) RATINGS[cid]={}; return RATINGS[cid]; }function getSlotR(cid, s){ const m = getCaseR(cid); if(!m[s]) m[s]={}; return m[s]; }function setRating(cid, sIdx, qk, score){ getSlotR(cid, sIdx)[qk] = score;function getModelR(cid, model){ const m = getCaseR(cid); if(!m[model]) m[model]={}; return m[model]; }function setRating(cid, model, qk, score){ getModelR(cid, model)[qk] = score; saveState(); updateProgress(); if (RATER.submitted_at){9 unmodified lines for (const c of CASES){ const slots = SHUFFLE[c.id] || c.videos.map((_,i)=>i); for (let s=0; s<slots.length; s++){ const r = (RATINGS[c.id]||{})[s] || {}; const r = (RATINGS[c.id]||{})[c.videos[slots[s]].model] || {}; for (const qk of qkeys){ expected++; if (typeof r[qk]==="number" && r[qk]>=1 && r[qk]<=5) done++;8 unmodified lines const expected = slots.length * TOTAL_QUESTIONS; let done=0; for (let s=0;s<slots.length;s++){ const r = (RATINGS[c.id]||{})[s] || {}; const r = (RATINGS[c.id]||{})[c.videos[slots[s]].model] || {}; done += Object.keys(r).filter(k=>typeof r[k]==="number"&&r[k]>=1&&r[k]<=5).length; } return { done, expected };37 unmodified lines slot: String.fromCharCode(65+slotIdx), slot_index: slotIdx, original_index: origIdx, model: c.videos[origIdx].model, path: c.videos[origIdx].path, ratings: (RATINGS[c.id]||{})[slotIdx] || {}, ratings: (RATINGS[c.id]||{})[c.videos[origIdx].model] || {}, })), }; }),80 unmodified lines videos: slots.map((oi,si)=>({ slot:String.fromCharCode(65+si), slot_index:si, original_index:oi, model:c.videos[oi].model, path:c.videos[oi].path, ratings:(RATINGS[c.id]||{})[si]||{}, ratings:(RATINGS[c.id]||{})[c.videos[oi].model]||{}, })), }; }),202 unmodified lines row.appendChild(chip); const group = document.createElement("div"); group.className = "likert"; const cur = getSlotR(c.id, slotIdx)[q.key]; const cur = getModelR(c.id, v.model)[q.key]; for (let s=1; s<=5; s++){ const b = document.createElement("button"); b.dataset.score = String(s); b.textContent = String(s); if (cur===s) b.classList.add("selected"); b.onclick = () => { setRating(c.id, slotIdx, q.key, s); setRating(c.id, v.model, q.key, s); Array.from(group.children).forEach((bb,i)=>bb.classList.toggle("selected", (i+1)===s)); }; group.appendChild(b);224 unmodified lines if (!isAdmin()) anonymize = true; // Admins see all cases; everyone else gets a deterministic 10-case subset. CASES = selectCasesForRater(ALL_CASES); buildShuffle(CASES); saveState(); buildShuffle(CASES); // One-shot migration: older mobile builds keyed RATINGS by slot index // instead of model name. SHUFFLE is deterministic per (rater, case), so a // numeric slot key maps back to the exact model the rater saw and scored. { let moved = 0; for (const c of CASES) { const m = RATINGS[c.id]; if (!m) continue; const slots = SHUFFLE[c.id] || c.videos.map((_,i)=>i); for (const k of Object.keys(m)) { if (!/^\d+$/.test(k)) continue; const model = (c.videos[slots[Number(k)]] || {}).model; if (model && !m[model]) { m[model] = m[k]; moved++; } delete m[k]; } } if (moved) console.info(`[user-study] migrated ${moved} slot-keyed rating group(s) to model keys`); } saveState();
// wire DOM events document.getElementById("drawerBtn").onclick = openDrawer;static/v2/mobile.html+35-11