diff --git a/src/benchmarking/report.py b/src/benchmarking/report.py index 83985e0..92782be 100644 --- a/src/benchmarking/report.py +++ b/src/benchmarking/report.py @@ -7,6 +7,7 @@ Design: Dark mode, amber/teal accents, Inter + JetBrains Mono. from __future__ import annotations +import html import json from typing import Any @@ -34,8 +35,104 @@ FONT_DISPLAY = "'Inter', -apple-system, sans-serif" FONT_DATA = "'JetBrains Mono', 'Fira Code', monospace" +# ── Compare Answers Modal (JS) ──────────────────────────────────── + +_MODAL_JS = """ + // ── Compare Answers Modal ───────────────────────────────── + function escapeHtml(str) { + if (str == null) return ''; + return String(str) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + function scoreChip(label, val) { + val = Number(val) || 0; + const cls = val >= 8 ? 'high' : (val >= 6 ? 'mid' : 'low'); + return '' + label + ' ' + val.toFixed(1) + ''; + } + + function showCompare(idx) { + const q = perQuestion[idx]; + if (!q) return; + + document.getElementById('modalQId').textContent = 'Question ' + (q.question_id || (idx + 1)); + document.getElementById('modalQuestion').textContent = q.question || ''; + + const expected = q.expected_answer || ''; + document.getElementById('modalExpected').innerHTML = expected + ? '
' + escapeHtml(expected) + '