/* ================================================================== Assessment → Overview ------------------------------------------------------------------ The online-test platform from the office's point of view: what is live, what has been attempted, how the marks are landing, and a genuine recent-activity column. Reads the backend cockpit assessment summary. The "Live Activity" panel is real attempt rows ordered by time — deliberately NOT a synthetic ticker. A quiet school shows a quiet panel. ================================================================== */ const AssessmentOverviewScreen = ({ setScreen }) => { const CX = window.CX; const state = CX.useCockpitData("/admin/cockpit/assessments", { pollMs: 45000 }); const d = state.data; const statusPill = (s) => s === "live" ? ● Live : s === "grading" ? Grading : s === "published" ? Published : s === "draft" ? Draft : {CX.title(s)}; return (
setScreen("library")}> New test } /> {d && ( <>
setScreen("library")} actionLabel="Open test library" footNote={`${CX.num(d.tests.total)} in library · ${d.tests.draft} draft · ${d.tests.today} scheduled today`} action={Library} /> setScreen("online-tests")} actionLabel="Open online tests" footNote={`${CX.num(d.attempts.submitted)} submitted · ${d.attempts.inProgress} in progress · ${CX.num(d.attempts.distinctStudents)} students`} action={Online} /> = d.scores.avgPct ? "up" : "down") : "flat" } onAction={() => setScreen("doubts")} actionLabel="Open doubts" footNote={ d.scores.graded ? `across ${CX.num(d.scores.graded)} graded attempts · ${d.doubts.open} doubt(s) open` : "no graded attempts yet" } action={Doubts} />
Test Library
{CX.num(d.tests.total)} tests
{d.tests.list.length === 0 ? ( ) : d.tests.list.map((t) => (
{t.display_id}
{t.title}
{[t.subject, t.class_level && `${t.class_level}${t.section || ""}`, t.scheduled_date && CX.date(t.scheduled_date)].filter(Boolean).join(" · ")}
{statusPill(t.status)}
{t.submitted}/{t.enrolled || t.attempts || 0} {t.progressPct}%
))}
{d.tests.published} published · {d.tests.draft} still in draft
Recent Activity
{state.refreshing ? Refreshing… : ● Live}
{d.feed.length === 0 && ( )} {d.feed.map((f, i) => { const done = !!f.submitted_at; const color = done ? "var(--blue-solid)" : "var(--green-solid)"; const score = done && f.max_marks ? ` · ${Math.round((Number(f.auto_score) / Number(f.max_marks)) * 100)}%` : ""; return (
{f.student_name} {done ? "submitted" : "started"}{" "} {f.test_title}
{[f.class_level && `${f.class_level}${f.section || ""}`, f.display_id] .filter(Boolean).join(" · ")}{score}
{CX.relTime(f.submitted_at || f.started_at)}
); })}
)}
); }; window.CockpitAssessment = AssessmentOverviewScreen;