diff --git a/src/components/exams/answer-sheet-view.tsx b/src/components/exams/answer-sheet-view.tsx
index a5d358c..0ddd85e 100644
--- a/src/components/exams/answer-sheet-view.tsx
+++ b/src/components/exams/answer-sheet-view.tsx
@@ -1,14 +1,15 @@
-import { For, Show, Suspense, createResource, createSignal } from "solid-js";
+import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js";
import { ApiError } from "@/api/client";
import { getExamQuestions } from "@/api/exams";
import { getStudentAnswers, getStudentAnswerImage } from "@/api/exams";
-import { getStudentAttempts, getStudentAttemptAnswers, getStudentAttemptAnswerImage, getStudentMarksHistory } from "@/api/exams";
+import { getStudentAttempts, getStudentAttemptAnswers, getStudentAttemptAnswerImage } from "@/api/exams";
import type { StudentAnswerSheet } from "@/api/client";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { IconCheck, IconDownload, IconX } from "@/components/ui/icons";
import { PageSpinner } from "@/components/ui/page-spinner";
import { ReplayableImage } from "@/components/ui/replayable-image";
+import { DropdownSelect } from "@/components/ui/select";
import { cn } from "@/lib/cn";
import { joinAnswerSheet } from "@/lib/answer-sheet";
import { personLabelWithId } from "@/lib/person";
@@ -33,18 +34,6 @@ export function AnswerSheetView(props: { examId: string; userId: string }) {
}
},
);
- const [marks] = createResource(
- () => [props.examId, props.userId] as const,
- async ([examId, userId]) => {
- try {
- return await getStudentMarksHistory(examId, userId);
- } catch (err) {
- if (err instanceof ApiError && err.status === 404) return [];
- throw err;
- }
- },
- );
-
const latestSeq = () => {
const a = attempts();
return a && a.length ? a[a.length - 1] : null;
@@ -55,7 +44,14 @@ export function AnswerSheetView(props: { examId: string; userId: string }) {
const s = activeSeq();
return s == null || s === latestSeq();
};
- const markForSeq = (seq: number) => marks()?.[seq - 1]?.mark ?? null;
+ // Dropdown options, newest sitting first (a student may have many). Just the
+ // sitting label; the latest is tagged as the current one. Per-sitting stats
+ // live in the sheet header for the selected sitting, not in the dropdown.
+ const attemptOptions = () =>
+ [...(attempts() ?? [])].reverse().map((seq) => ({
+ value: seq,
+ label: `${t("exams.attemptN", { n: seq })}${seq === latestSeq() ? ` (${t("exams.currentAttempt")})` : ""}`,
+ }));
const answerImageUrl = (questionId: string) => {
const seq = activeSeq();
@@ -97,32 +93,45 @@ export function AnswerSheetView(props: { examId: string; userId: string }) {
},
);
+ // Per-sitting answer breakdown for the viewed attempt's header. `is_correct`
+ // is only set for auto-gradable (choice) questions: right = got it, wrong =
+ // missed it, empty = no answer given; answered text questions fall in none
+ // (a human grades those). `pending` surfaces those so the counts stay honest.
+ const sheetStats = createMemo(() => {
+ const rows = data()?.rows ?? [];
+ const answered = (a: (typeof rows)[number]["answer"]) =>
+ !!a && (a.selected != null || !!a.text || !!a.answer_image);
+ let right = 0;
+ let wrong = 0;
+ let empty = 0;
+ let pending = 0;
+ for (const r of rows) {
+ if (!answered(r.answer)) empty++;
+ else if (r.answer?.is_correct === true) right++;
+ else if (r.answer?.is_correct === false) wrong++;
+ else pending++;
+ }
+ return { right, wrong, empty, pending, total: rows.length };
+ });
+
return (
-
{personLabelWithId(d().sheet.user)}