dehezhang2 commited on
Commit
3c88ed2
·
verified ·
1 Parent(s): 313ee8f

deploy rater (Docker/FastAPI): registration + completeness gate + /api/submit → dataset

Browse files
Files changed (4) hide show
  1. app.py +31 -0
  2. static/admin.html +68 -0
  3. static/index.html +105 -5
  4. static/mobile.html +1 -1
app.py CHANGED
@@ -336,6 +336,37 @@ async def admin_submissions(req: Request):
336
  return JSONResponse({"submissions": out, "total": len(out)})
337
 
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  @app.get("/api/rater_state")
340
  async def get_rater_state(email: str = ""):
341
  """Return the rater's most recent in-progress JSON (if any).
 
336
  return JSONResponse({"submissions": out, "total": len(out)})
337
 
338
 
339
+ @app.delete("/api/admin/submission")
340
+ async def admin_delete_submission(req: Request):
341
+ """Admin-only delete of a submission JSON.
342
+
343
+ Body: {"path": "submissions/...json"} — must start with "submissions/" and
344
+ end with ".json" to prevent the endpoint from deleting unrelated dataset
345
+ files via path traversal.
346
+ """
347
+ _require_admin_password(req)
348
+ if _api is None:
349
+ raise HTTPException(500, "server missing HF_TOKEN secret")
350
+ try:
351
+ payload = await req.json()
352
+ except Exception:
353
+ raise HTTPException(400, "invalid JSON")
354
+ path = (payload.get("path") or "").strip()
355
+ if (not path.startswith("submissions/") or not path.endswith(".json")
356
+ or ".." in path):
357
+ raise HTTPException(400, "path must be a submissions/*.json file")
358
+ try:
359
+ _api.delete_file(
360
+ repo_id=DATASET_REPO, repo_type="dataset",
361
+ path_in_repo=path,
362
+ commit_message=f"admin: delete submission {os.path.basename(path)}",
363
+ )
364
+ except HfHubHTTPError as e:
365
+ status = e.response.status_code if e.response is not None else 500
366
+ raise HTTPException(502, f"delete failed ({status}): {e}")
367
+ return JSONResponse({"ok": True, "deleted": path})
368
+
369
+
370
  @app.get("/api/rater_state")
371
  async def get_rater_state(email: str = ""):
372
  """Return the rater's most recent in-progress JSON (if any).
static/admin.html CHANGED
@@ -292,6 +292,7 @@ function renderTable() {
292
  el("th", {}, "Scores"),
293
  el("th", {}, "Cases"),
294
  el("th", {}, "Received (UTC)"),
 
295
  el("th", { class: "path" }, "Path"),
296
  ));
297
  table.appendChild(thead);
@@ -325,6 +326,23 @@ function renderRow(s) {
325
  tr.appendChild(el("td", {}, String(s.n_cases ?? "—")));
326
  tr.appendChild(el("td", {},
327
  (s.received_at_utc || "—").replace("T"," ").replace("Z","")));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  // Path → link to dataset blob view
329
  const pathLink = el("a", {
330
  href: `https://huggingface.co/datasets/dehezhang2/Frameworker_User_Study/blob/main/${s.path}`,
@@ -353,6 +371,56 @@ function updateVizBtn() {
353
  btn.disabled = SELECTED.size === 0;
354
  }
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  /* ---------- visualization ---------- */
357
  async function visualizeSelected() {
358
  if (SELECTED.size === 0) return;
 
292
  el("th", {}, "Scores"),
293
  el("th", {}, "Cases"),
294
  el("th", {}, "Received (UTC)"),
295
+ el("th", {}, "Action"),
296
  el("th", { class: "path" }, "Path"),
297
  ));
298
  table.appendChild(thead);
 
326
  tr.appendChild(el("td", {}, String(s.n_cases ?? "—")));
327
  tr.appendChild(el("td", {},
328
  (s.received_at_utc || "—").replace("T"," ").replace("Z","")));
329
+ // Row actions: view-as + delete
330
+ const actionCell = el("td", { style: "white-space:nowrap" });
331
+ if (s.rater_email) {
332
+ actionCell.appendChild(el("button", {
333
+ class: "btn",
334
+ style: "padding:3px 8px;margin-right:4px",
335
+ title: "open the main study page with this user's data preloaded",
336
+ onclick: () => viewAs(s),
337
+ }, "👁 View"));
338
+ }
339
+ actionCell.appendChild(el("button", {
340
+ class: "btn danger",
341
+ style: "padding:3px 8px;font-size:11px",
342
+ title: "permanently delete this submission JSON from the dataset",
343
+ onclick: () => deleteSubmission(s),
344
+ }, "🗑"));
345
+ tr.appendChild(actionCell);
346
  // Path → link to dataset blob view
347
  const pathLink = el("a", {
348
  href: `https://huggingface.co/datasets/dehezhang2/Frameworker_User_Study/blob/main/${s.path}`,
 
371
  btn.disabled = SELECTED.size === 0;
372
  }
373
 
374
+ /* ---------- delete a submission ---------- */
375
+ async function deleteSubmission(s) {
376
+ const who = s.rater_name || s.rater_email || "this submission";
377
+ if (!confirm(`Permanently delete ${s.path}?\n\nRater: ${who}\nScores: ${s.n_scores ?? "?"}\n\nThis cannot be undone.`)) return;
378
+ try {
379
+ const r = await fetch("./api/admin/submission", {
380
+ method: "DELETE",
381
+ headers: { "Content-Type": "application/json", "X-Admin-Password": adminPw() },
382
+ body: JSON.stringify({ path: s.path }),
383
+ });
384
+ if (r.status === 401) { clearAdminPw(); renderLogin(); return; }
385
+ if (!r.ok) {
386
+ const text = await r.text().catch(() => "");
387
+ showToast(`Delete failed (HTTP ${r.status}): ${text.slice(0, 80)}`, true);
388
+ return;
389
+ }
390
+ showToast(`Deleted ${who}`);
391
+ // Remove from local list + selection, re-render
392
+ SUBMISSIONS = SUBMISSIONS.filter(x => x.path !== s.path);
393
+ SELECTED.delete(s.path);
394
+ renderTable();
395
+ document.getElementById("summaryMeta").textContent =
396
+ `${SUBMISSIONS.length} submission${SUBMISSIONS.length===1?"":"s"}, ` +
397
+ `${new Set(SUBMISSIONS.map(x=>x.rater_email)).size} unique raters`;
398
+ } catch (e) {
399
+ showToast("Delete failed: " + e.message, true);
400
+ }
401
+ }
402
+
403
+ /* ---------- view-as: open main UI populated with this user's submission ---- */
404
+ async function viewAs(submissionMeta) {
405
+ try {
406
+ const url = `https://huggingface.co/datasets/dehezhang2/Frameworker_User_Study/resolve/main/${submissionMeta.path}`;
407
+ const r = await fetch(url, { cache: "no-cache" });
408
+ if (!r.ok) { showToast(`Fetch failed: HTTP ${r.status}`, true); return; }
409
+ const payload = await r.json();
410
+ // Persist for the main page to pick up — sessionStorage so it doesn't
411
+ // contaminate localStorage long-term, and sits in this tab/window only.
412
+ sessionStorage.setItem("user_study_view_as", JSON.stringify({
413
+ opened_at: new Date().toISOString(),
414
+ meta: submissionMeta,
415
+ payload,
416
+ }));
417
+ window.open("./?view_as=1", "_blank");
418
+ showToast(`Opening main UI as ${submissionMeta.rater_name || submissionMeta.rater_email}`);
419
+ } catch (e) {
420
+ showToast("View-as failed: " + e.message, true);
421
+ }
422
+ }
423
+
424
  /* ---------- visualization ---------- */
425
  async function visualizeSelected() {
426
  if (SELECTED.size === 0) return;
static/index.html CHANGED
@@ -457,6 +457,10 @@ const DIMENSIONS = [
457
  { key: "no_irrelevant_frames",
458
  name: "No irrelevant frames",
459
  desc: "Does the video stay on-prompt? Higher = fewer / no frames or content that weren't asked for by the prompt." },
 
 
 
 
460
  ],
461
  },
462
  {
@@ -927,6 +931,8 @@ const RUBRIC_I18N = {
927
  desc: "内容是否与提示的描述一致(主体、动作、场景、时间、故事走向)?以提示词的文本内容为主要依据。" },
928
  no_irrelevant_frames: { name: "无无关画面",
929
  desc: "视频是否仅呈现提示中要求的内容?分数越高 = 越少出现与提示无关的帧或内容。" },
 
 
930
  realism: { name: "静态真实感",
931
  desc: "单帧的照片级真实感或风格忠实度。若提示词指定了风格,视频应符合该风格。无诡异感或失真伪影。" },
932
  person_stability: { name: "人物稳定性",
@@ -953,6 +959,8 @@ const RUBRIC_I18N = {
953
  desc: "Съответства ли съдържанието на описаното в подканата (обекти, действия, обстановка, време и развитие на историята)? Фокусирайте се основно върху текстовото съдържание на подканата." },
954
  no_irrelevant_frames: { name: "Без неуместни кадри",
955
  desc: "Остава ли видеото в рамките на подканата? По-висок = по-малко / без кадри или съдържание, които не са поискани." },
 
 
956
  realism: { name: "Статичен реализъм",
957
  desc: "Фотореалистичност или стилова достоверност на отделен кадър. Ако подканата задава стил, видеото трябва да следва този стил. Без странни или счупени артефакти." },
958
  person_stability: { name: "Стабилност на хората",
@@ -1002,6 +1010,8 @@ function scaleLabel(score) {
1002
  let CASES = []; // cases visible to this rater (subset of ALL)
1003
  let ALL_CASES = []; // full manifest as fetched from cases.json
1004
  const CASES_PER_RATER = 10; // each rater sees 10 of the full set
 
 
1005
  let SHUFFLE = {}; // case_id -> [orig_idx, ...] (slot -> orig)
1006
  let RATINGS = {}; // case_id -> model_name -> { qkey: 1..5 }
1007
  let RATER = { id: "", name: "", email: "", note: "",
@@ -1046,6 +1056,8 @@ function loadState() {
1046
  }
1047
 
1048
  function saveState() {
 
 
1049
  const blob = {
1050
  rater: RATER,
1051
  anonymize,
@@ -1175,6 +1187,10 @@ function getSlotRatings(caseId, slotIdx) {
1175
  }
1176
 
1177
  function setRating(caseId, slotIdx, qkey, score) {
 
 
 
 
1178
  const model = modelForSlot(caseId, slotIdx);
1179
  if (!model) return;
1180
  getModelRatings(caseId, model)[qkey] = score;
@@ -1228,22 +1244,30 @@ function buildFullSubmissionPayload() {
1228
  }
1229
 
1230
  // Returns { done, expected, missing: [{case_id, slot, q}, ...] } for the entire study.
 
 
 
 
 
 
 
 
1231
  function studyCompleteness() {
1232
- const qkeys = DIMENSIONS.flatMap(d => d.questions.map(q => q.key));
1233
  const missing = [];
1234
  let done = 0, expected = 0;
1235
  for (const c of CASES) {
1236
  const slots = SHUFFLE[c.id] || c.videos.map((_, i) => i);
 
1237
  for (let slotIdx = 0; slotIdx < slots.length; slotIdx++) {
1238
  const origIdx = slots[slotIdx];
1239
  const model = c.videos[origIdx].model;
1240
  const rs = (RATINGS[c.id] || {})[model] || {};
1241
  const slotLetter = String.fromCharCode(65 + slotIdx);
1242
- for (const qk of qkeys) {
1243
  expected++;
1244
- const v = rs[qk];
1245
  if (typeof v === "number" && v >= 1 && v <= 5) done++;
1246
- else missing.push({ case_id: c.id, slot: slotLetter, q: qk, model });
1247
  }
1248
  }
1249
  }
@@ -1251,6 +1275,10 @@ function studyCompleteness() {
1251
  }
1252
 
1253
  async function submitWholeStudy() {
 
 
 
 
1254
  if (!RATER.email || !RATER.name) {
1255
  showToast(t("toast_pls_signin"), true);
1256
  showLoginOverlay(true);
@@ -1344,6 +1372,7 @@ function buildProgressPayload() {
1344
  }
1345
 
1346
  async function saveProgress(opts = {}) {
 
1347
  // opts: { silent: bool, source: "register" | "auto" | "manual" | "unload" }
1348
  const silent = !!opts.silent;
1349
  if (!RATER.email || !RATER.name) return; // no rater yet
@@ -1537,7 +1566,11 @@ function highlightControllability(text, lang, caseId) {
1537
  const merged = [ranges[0].slice()];
1538
  for (let i = 1; i < ranges.length; i++) {
1539
  const top = merged[merged.length - 1];
1540
- if (ranges[i][0] <= top[1]) {
 
 
 
 
1541
  top[1] = Math.max(top[1], ranges[i][1]);
1542
  if (ranges[i][2] === "admin") top[2] = "admin";
1543
  } else merged.push(ranges[i].slice());
@@ -1590,6 +1623,30 @@ function renderShell() {
1590
  setSyncStatus(SYNC_STATUS, SYNC_LAST_DETAIL);
1591
  }
1592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1593
  function renderHeader() {
1594
  // Title + subtitle removed per request — only the progress bar remains in
1595
  // the top strip. The sidebar toggle now lives inside the sidebar header,
@@ -2007,6 +2064,8 @@ function renderRightPane(c) {
2007
  el("span", { class: "dim-hint" }, dimHint(dim)));
2008
  pane.appendChild(dh);
2009
  for (const q of dim.questions) {
 
 
2010
  pane.appendChild(renderQuestionCard(c, q, slots));
2011
  }
2012
  }
@@ -2733,6 +2792,47 @@ function migrateLegacyRatingsV1(legacy, allCases) {
2733
  return;
2734
  }
2735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2736
  // Restore prior state, if any
2737
  const prior = loadState();
2738
  const blankRater = () => ({
 
457
  { key: "no_irrelevant_frames",
458
  name: "No irrelevant frames",
459
  desc: "Does the video stay on-prompt? Higher = fewer / no frames or content that weren't asked for by the prompt." },
460
+ { key: "reference_image_match",
461
+ name: "Reference image match",
462
+ desc: "When the prompt comes with a reference photo (intake_img cases), does the main character / look match it? Only scored for cases that have a reference image — skipped otherwise.",
463
+ only_if_reference_image: true },
464
  ],
465
  },
466
  {
 
931
  desc: "内容是否与提示的描述一致(主体、动作、场景、时间、故事走向)?以提示词的文本内容为主要依据。" },
932
  no_irrelevant_frames: { name: "无无关画面",
933
  desc: "视频是否仅呈现提示中要求的内容?分数越高 = 越少出现与提示无关的帧或内容。" },
934
+ reference_image_match: { name: "参考图一致性",
935
+ desc: "若提示词附带参考图(intake_img 案例),视频中的主角形象是否与参考图一致?仅在存在参考图时打分,无参考图自动跳过。" },
936
  realism: { name: "静态真实感",
937
  desc: "单帧的照片级真实感或风格忠实度。若提示词指定了风格,视频应符合该风格。无诡异感或失真伪影。" },
938
  person_stability: { name: "人物稳定性",
 
959
  desc: "Съответства ли съдържанието на описаното в подканата (обекти, действия, обстановка, време и развитие на историята)? Фокусирайте се основно върху текстовото съдържание на подканата." },
960
  no_irrelevant_frames: { name: "Без неуместни кадри",
961
  desc: "Остава ли видеото в рамките на подканата? По-висок = по-малко / без кадри или съдържание, които не са поискани." },
962
+ reference_image_match: { name: "Съответствие с референтното изображение",
963
+ desc: "Когато подканата включва референтна снимка (случаи intake_img), съответства ли главният герой / външен вид на видеото? Оценява се само при наличие на референтно изображение — иначе се прескача." },
964
  realism: { name: "Статичен реализъм",
965
  desc: "Фотореалистичност или стилова достоверност на отделен кадър. Ако подканата задава стил, видеото трябва да следва този стил. Без странни или счупени артефакти." },
966
  person_stability: { name: "Стабилност на хората",
 
1010
  let CASES = []; // cases visible to this rater (subset of ALL)
1011
  let ALL_CASES = []; // full manifest as fetched from cases.json
1012
  const CASES_PER_RATER = 10; // each rater sees 10 of the full set
1013
+ let VIEW_AS_MODE = false; // admin "view-as" — page is read-only
1014
+ let VIEW_AS_META = null; // { rater_name, rater_email, ... } for the banner
1015
  let SHUFFLE = {}; // case_id -> [orig_idx, ...] (slot -> orig)
1016
  let RATINGS = {}; // case_id -> model_name -> { qkey: 1..5 }
1017
  let RATER = { id: "", name: "", email: "", note: "",
 
1056
  }
1057
 
1058
  function saveState() {
1059
+ // View-as is read-only — never touch localStorage with the impersonated state.
1060
+ if (VIEW_AS_MODE) return;
1061
  const blob = {
1062
  rater: RATER,
1063
  anonymize,
 
1187
  }
1188
 
1189
  function setRating(caseId, slotIdx, qkey, score) {
1190
+ if (VIEW_AS_MODE) {
1191
+ showToast("View-as is read-only — open the regular study to rate.", true);
1192
+ return;
1193
+ }
1194
  const model = modelForSlot(caseId, slotIdx);
1195
  if (!model) return;
1196
  getModelRatings(caseId, model)[qkey] = score;
 
1244
  }
1245
 
1246
  // Returns { done, expected, missing: [{case_id, slot, q}, ...] } for the entire study.
1247
+ // Returns the rubric questions actually applicable to a given case. Skips
1248
+ // `only_if_reference_image: true` questions when the case has no reference
1249
+ // photo.
1250
+ function questionsForCase(c) {
1251
+ const hasRef = !!c.reference_image;
1252
+ return DIMENSIONS.flatMap(d => d.questions.filter(q => !q.only_if_reference_image || hasRef));
1253
+ }
1254
+
1255
  function studyCompleteness() {
 
1256
  const missing = [];
1257
  let done = 0, expected = 0;
1258
  for (const c of CASES) {
1259
  const slots = SHUFFLE[c.id] || c.videos.map((_, i) => i);
1260
+ const qs = questionsForCase(c);
1261
  for (let slotIdx = 0; slotIdx < slots.length; slotIdx++) {
1262
  const origIdx = slots[slotIdx];
1263
  const model = c.videos[origIdx].model;
1264
  const rs = (RATINGS[c.id] || {})[model] || {};
1265
  const slotLetter = String.fromCharCode(65 + slotIdx);
1266
+ for (const q of qs) {
1267
  expected++;
1268
+ const v = rs[q.key];
1269
  if (typeof v === "number" && v >= 1 && v <= 5) done++;
1270
+ else missing.push({ case_id: c.id, slot: slotLetter, q: q.key, model });
1271
  }
1272
  }
1273
  }
 
1275
  }
1276
 
1277
  async function submitWholeStudy() {
1278
+ if (VIEW_AS_MODE) {
1279
+ showToast("View-as is read-only — submit is disabled.", true);
1280
+ return;
1281
+ }
1282
  if (!RATER.email || !RATER.name) {
1283
  showToast(t("toast_pls_signin"), true);
1284
  showLoginOverlay(true);
 
1372
  }
1373
 
1374
  async function saveProgress(opts = {}) {
1375
+ if (VIEW_AS_MODE) return; // never write back when viewing as someone else
1376
  // opts: { silent: bool, source: "register" | "auto" | "manual" | "unload" }
1377
  const silent = !!opts.silent;
1378
  if (!RATER.email || !RATER.name) return; // no rater yet
 
1566
  const merged = [ranges[0].slice()];
1567
  for (let i = 1; i < ranges.length; i++) {
1568
  const top = merged[merged.length - 1];
1569
+ // Strict `<`: only merge ranges that actually overlap. Adjacent ranges
1570
+ // (one ending exactly where the next begins) stay as separate spans,
1571
+ // which keeps Chinese punctuation-flush sentences highlighted as two
1572
+ // distinct red regions matching the en/bg layouts.
1573
+ if (ranges[i][0] < top[1]) {
1574
  top[1] = Math.max(top[1], ranges[i][1]);
1575
  if (ranges[i][2] === "admin") top[2] = "admin";
1576
  } else merged.push(ranges[i].slice());
 
1623
  setSyncStatus(SYNC_STATUS, SYNC_LAST_DETAIL);
1624
  }
1625
 
1626
+ function addViewAsBanner() {
1627
+ const app = document.getElementById("app");
1628
+ if (!app || document.getElementById("viewAsBanner")) return;
1629
+ const who = VIEW_AS_META?.rater_name || VIEW_AS_META?.rater_email || "(unknown)";
1630
+ const bar = el("div", { id: "viewAsBanner",
1631
+ style: "background:#3a2f60;color:#d9b6ff;border-bottom:1px solid #5a4080;"
1632
+ + "padding:8px 16px;display:flex;align-items:center;gap:12px;"
1633
+ + "font-size:13px;font-weight:600;" },
1634
+ el("span", {}, `👁 Viewing as ${who} · read-only`),
1635
+ el("a", { href: "./admin.html", target: "_self",
1636
+ style: "margin-left:auto;color:#d9b6ff;text-decoration:underline;font-size:12px" },
1637
+ "← back to admin"),
1638
+ el("button", {
1639
+ style: "background:#5a4080;border:1px solid #6a4f90;color:#fff;"
1640
+ + "padding:4px 10px;border-radius:4px;cursor:pointer;font-size:12px",
1641
+ onclick: () => {
1642
+ try { sessionStorage.removeItem("user_study_view_as"); } catch (e) {}
1643
+ location.replace("./");
1644
+ },
1645
+ }, "✕ Exit view-as"),
1646
+ );
1647
+ app.insertBefore(bar, app.firstChild);
1648
+ }
1649
+
1650
  function renderHeader() {
1651
  // Title + subtitle removed per request — only the progress bar remains in
1652
  // the top strip. The sidebar toggle now lives inside the sidebar header,
 
2064
  el("span", { class: "dim-hint" }, dimHint(dim)));
2065
  pane.appendChild(dh);
2066
  for (const q of dim.questions) {
2067
+ // Skip "only_if_reference_image" questions for cases without one.
2068
+ if (q.only_if_reference_image && !c.reference_image) continue;
2069
  pane.appendChild(renderQuestionCard(c, q, slots));
2070
  }
2071
  }
 
2792
  return;
2793
  }
2794
 
2795
+ // ===== view-as mode (admin "open the page as this rater") =====
2796
+ // Triggered by admin.html → it puts the target user's submission in
2797
+ // sessionStorage["user_study_view_as"] and opens this page with
2798
+ // ?view_as=1. We treat the page as read-only: no localStorage writes,
2799
+ // no /api/submit, no /api/save_progress.
2800
+ try {
2801
+ const urlVA = new URL(location.href);
2802
+ if (urlVA.searchParams.get("view_as") === "1") {
2803
+ const raw = sessionStorage.getItem("user_study_view_as");
2804
+ if (raw) {
2805
+ const va = JSON.parse(raw);
2806
+ const p = va?.payload;
2807
+ if (p && p.rater) {
2808
+ VIEW_AS_MODE = true;
2809
+ VIEW_AS_META = va.meta || { rater_name: p.rater.name, rater_email: p.rater.email };
2810
+ RATER = Object.assign({
2811
+ id:"", name:"", email:"", note:"",
2812
+ started_at:null, submitted_at:null,
2813
+ }, p.rater);
2814
+ anonymize = p.anonymize_used !== false;
2815
+ // Reconstruct RATINGS from the submission's cases array.
2816
+ RATINGS = {};
2817
+ for (const c of (p.cases || [])) {
2818
+ if (!c || !c.id) continue;
2819
+ RATINGS[c.id] = {};
2820
+ for (const v of (c.videos || [])) {
2821
+ if (!v.model) continue;
2822
+ RATINGS[c.id][v.model] = v.ratings || {};
2823
+ }
2824
+ }
2825
+ SHUFFLE = {};
2826
+ CASES = selectCasesForRater(ALL_CASES);
2827
+ buildShuffle(CASES);
2828
+ renderShell();
2829
+ addViewAsBanner();
2830
+ return;
2831
+ }
2832
+ }
2833
+ }
2834
+ } catch (e) { console.warn("view-as init failed:", e); }
2835
+
2836
  // Restore prior state, if any
2837
  const prior = loadState();
2838
  const blankRater = () => ({
static/mobile.html CHANGED
@@ -675,7 +675,7 @@ function highlightControllability(text, lang, caseId) {
675
  const merged = [ranges[0].slice()];
676
  for (let i=1;i<ranges.length;i++){
677
  const top = merged[merged.length-1];
678
- if (ranges[i][0]<=top[1]) {
679
  top[1] = Math.max(top[1], ranges[i][1]);
680
  if (ranges[i][2] === "admin") top[2] = "admin";
681
  } else merged.push(ranges[i].slice());
 
675
  const merged = [ranges[0].slice()];
676
  for (let i=1;i<ranges.length;i++){
677
  const top = merged[merged.length-1];
678
+ if (ranges[i][0]<top[1]) {
679
  top[1] = Math.max(top[1], ranges[i][1]);
680
  if (ranges[i][2] === "admin") top[2] = "admin";
681
  } else merged.push(ranges[i].slice());