✨ live monitor overhaul, choice letters, image sizing fix
Browse files at this commitf123ed2129c620ce46fbc74c34cdfa0279cbf6c8Parent: 41ee7b6- feat
- ✨ live monitor overhaul, choice letters, image sizing fix
9 changed files +90 -71
- src/components/exams/answer-sheet-view.tsx +5 -6
- src/components/exams/exam-questions-panel.tsx +2 -2
- src/components/exams/exam-room-ws.tsx +4 -12
- src/components/exams/question-form.tsx +2 -2
- src/components/exams/student-exam-room.tsx +4 -12
- src/i18n/messages.ts +2 -2
- src/lib/exam-status.ts +1 -1
- src/pages/exams-page.tsx +1 -1
- src/pages/live-monitor-page.tsx +69 -33
src/components/exams/answer-sheet-view.tsxmodified+5 -6
| @@ -66,14 +66,13 @@ export function AnswerSheetView(props: { examId: string; userId: string }) { | |||
| 66 | : "border-border" | 66 | : "border-border" |
| 67 | }`} | 67 | }`} |
| 68 | > | 68 | > |
| 69 | - <span class="flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] border text-[11px] font-medium"> | 69 | + <span class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md border bg-background text-[11px] font-semibold text-foreground"> |
| 70 | - {ci() === row.question.correct || ci() === row.answer?.selected | 70 | + {String.fromCharCode(65 + ci())} |
| 71 | - ? ci() === row.question.correct | ||
| 72 | - ? "✓" | ||
| 73 | - : "✗" | ||
| 74 | - : String.fromCharCode(65 + ci())} | ||
| 75 | </span> | 71 | </span> |
| 76 | <span>{choice}</span> | 72 | <span>{choice}</span> |
| 73 | + <Show when={ci() === row.answer?.selected && ci() !== row.question.correct}> | ||
| 74 | + <Badge variant="destructive" class="ml-auto text-[10px]">✗</Badge> | ||
| 75 | + </Show> | ||
| 77 | {ci() === row.question.correct && <Badge variant="outline" class="ml-auto text-[10px]">{t("questions.correct")}</Badge>} | 76 | {ci() === row.question.correct && <Badge variant="outline" class="ml-auto text-[10px]">{t("questions.correct")}</Badge>} |
| 78 | </div> | 77 | </div> |
| 79 | )} | 78 | )} |
src/components/exams/exam-questions-panel.tsxmodified+2 -2
| @@ -199,7 +199,7 @@ export function ExamQuestionsPanel(props: { examId: string; courseId: string; re | |||
| 199 | <img | 199 | <img |
| 200 | src={`/api/exams/${props.examId}/questions/${q.id}/image`} | 200 | src={`/api/exams/${props.examId}/questions/${q.id}/image`} |
| 201 | alt={t("questions.image")} | 201 | alt={t("questions.image")} |
| 202 | - class="max-h-64 rounded-md border object-contain" | 202 | + class="h-64 w-full max-w-2xl rounded-md border bg-muted/20 object-contain" |
| 203 | /> | 203 | /> |
| 204 | </Show> | 204 | </Show> |
| 205 | <Show when={!props.readOnly && q.image}> | 205 | <Show when={!props.readOnly && q.image}> |
| @@ -228,7 +228,7 @@ export function ExamQuestionsPanel(props: { examId: string; courseId: string; re | |||
| 228 | <img | 228 | <img |
| 229 | src={`/api/exams/${props.examId}/questions/${q.id}/choices/${choiceIndex()}/image`} | 229 | src={`/api/exams/${props.examId}/questions/${q.id}/choices/${choiceIndex()}/image`} |
| 230 | alt={t("questions.choiceImage")} | 230 | alt={t("questions.choiceImage")} |
| 231 | - class="max-h-40 rounded-md border object-contain" | 231 | + class="h-36 w-full max-w-md rounded-md border bg-background object-contain" |
| 232 | /> | 232 | /> |
| 233 | </Show> | 233 | </Show> |
| 234 | <Show when={!props.readOnly && q.choice_images?.[choiceIndex()]}> | 234 | <Show when={!props.readOnly && q.choice_images?.[choiceIndex()]}> |
src/components/exams/exam-room-ws.tsxmodified+4 -12
| @@ -584,7 +584,7 @@ function QuestionAnswerCardWS(props: { | |||
| 584 | <img | 584 | <img |
| 585 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/image`} | 585 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/image`} |
| 586 | alt={t("questions.image")} | 586 | alt={t("questions.image")} |
| 587 | - class="mb-4 max-h-64 rounded-md border object-contain" | 587 | + class="mb-4 h-64 w-full max-w-2xl rounded-md border bg-muted/20 object-contain" |
| 588 | /> | 588 | /> |
| 589 | </Show> | 589 | </Show> |
| 590 | <p class="mb-5 whitespace-pre-wrap text-base font-semibold leading-7 sm:text-lg">{props.question.text}</p> | 590 | <p class="mb-5 whitespace-pre-wrap text-base font-semibold leading-7 sm:text-lg">{props.question.text}</p> |
| @@ -616,16 +616,8 @@ function QuestionAnswerCardWS(props: { | |||
| 616 | setValue(String(choiceIndex())); | 616 | setValue(String(choiceIndex())); |
| 617 | }} | 617 | }} |
| 618 | > | 618 | > |
| 619 | - <span | 619 | + <span class={value() === String(choiceIndex()) ? "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-primary bg-primary text-xs font-semibold text-primary-foreground" : "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-input bg-background text-xs font-semibold text-foreground"}> |
| 620 | - class={ | 620 | + {String.fromCharCode(65 + choiceIndex())} |
| 621 | - value() === String(choiceIndex()) | ||
| 622 | - ? "flex h-4 w-4 shrink-0 items-center justify-center rounded-[3px] border border-primary bg-primary" | ||
| 623 | - : "h-4 w-4 shrink-0 rounded-[3px] border border-input bg-background" | ||
| 624 | - } | ||
| 625 | - > | ||
| 626 | - <span | ||
| 627 | - class={value() === String(choiceIndex()) ? "h-2 w-2 rounded-[1px] bg-primary-foreground" : "hidden"} | ||
| 628 | - /> | ||
| 629 | </span> | 621 | </span> |
| 630 | <span class="min-w-0 space-y-2"> | 622 | <span class="min-w-0 space-y-2"> |
| 631 | <span class="block whitespace-pre-wrap">{choice}</span> | 623 | <span class="block whitespace-pre-wrap">{choice}</span> |
| @@ -633,7 +625,7 @@ function QuestionAnswerCardWS(props: { | |||
| 633 | <img | 625 | <img |
| 634 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/choices/${choiceIndex()}/image`} | 626 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/choices/${choiceIndex()}/image`} |
| 635 | alt={t("questions.choiceImage")} | 627 | alt={t("questions.choiceImage")} |
| 636 | - class="max-h-40 rounded-md border object-contain" | 628 | + class="h-36 w-full max-w-md rounded-md border bg-muted/20 object-contain" |
| 637 | /> | 629 | /> |
| 638 | </Show> | 630 | </Show> |
| 639 | </span> | 631 | </span> |
src/components/exams/question-form.tsxmodified+2 -2
| @@ -150,7 +150,7 @@ export function QuestionForm(props: { | |||
| 150 | <img | 150 | <img |
| 151 | src={`/api/exams/${props.initial!.exam}/questions/${props.initial!.id}/image`} | 151 | src={`/api/exams/${props.initial!.exam}/questions/${props.initial!.id}/image`} |
| 152 | alt={t("questions.image")} | 152 | alt={t("questions.image")} |
| 153 | - class="mt-2 max-h-40 rounded-md border object-contain" | 153 | + class="mt-2 h-40 w-full max-w-md rounded-md border bg-muted/20 object-contain" |
| 154 | /> | 154 | /> |
| 155 | </Show> | 155 | </Show> |
| 156 | <input | 156 | <input |
| @@ -268,7 +268,7 @@ export function QuestionForm(props: { | |||
| 268 | <img | 268 | <img |
| 269 | src={`/api/exams/${props.initial!.exam}/questions/${props.initial!.id}/choices/${index}/image`} | 269 | src={`/api/exams/${props.initial!.exam}/questions/${props.initial!.id}/choices/${index}/image`} |
| 270 | alt={t("questions.choiceImage")} | 270 | alt={t("questions.choiceImage")} |
| 271 | - class="mt-2 max-h-32 rounded-md border object-contain" | 271 | + class="mt-2 h-32 w-full max-w-sm rounded-md border bg-muted/20 object-contain" |
| 272 | /> | 272 | /> |
| 273 | </Show> | 273 | </Show> |
| 274 | <div class="mt-2"> | 274 | <div class="mt-2"> |
src/components/exams/student-exam-room.tsxmodified+4 -12
| @@ -295,7 +295,7 @@ function QuestionAnswerCard(props: { | |||
| 295 | <img | 295 | <img |
| 296 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/image`} | 296 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/image`} |
| 297 | alt={t("questions.image")} | 297 | alt={t("questions.image")} |
| 298 | - class="mb-4 max-h-64 rounded-md border object-contain" | 298 | + class="mb-4 h-64 w-full max-w-2xl rounded-md border bg-muted/20 object-contain" |
| 299 | /> | 299 | /> |
| 300 | </Show> | 300 | </Show> |
| 301 | <p class="mb-4 whitespace-pre-wrap text-sm font-medium">{props.question.text}</p> | 301 | <p class="mb-4 whitespace-pre-wrap text-sm font-medium">{props.question.text}</p> |
| @@ -326,16 +326,8 @@ function QuestionAnswerCard(props: { | |||
| 326 | setValue(String(choiceIndex())); | 326 | setValue(String(choiceIndex())); |
| 327 | }} | 327 | }} |
| 328 | > | 328 | > |
| 329 | - <span | 329 | + <span class={value() === String(choiceIndex()) ? "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-primary bg-primary text-xs font-semibold text-primary-foreground" : "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-input bg-background text-xs font-semibold text-foreground"}> |
| 330 | - class={ | 330 | + {String.fromCharCode(65 + choiceIndex())} |
| 331 | - value() === String(choiceIndex()) | ||
| 332 | - ? "flex h-4 w-4 shrink-0 items-center justify-center rounded-[3px] border border-primary bg-primary" | ||
| 333 | - : "h-4 w-4 shrink-0 rounded-[3px] border border-input bg-background" | ||
| 334 | - } | ||
| 335 | - > | ||
| 336 | - <span | ||
| 337 | - class={value() === String(choiceIndex()) ? "h-2 w-2 rounded-[1px] bg-primary-foreground" : "hidden"} | ||
| 338 | - /> | ||
| 339 | </span> | 331 | </span> |
| 340 | <span class="min-w-0 space-y-2"> | 332 | <span class="min-w-0 space-y-2"> |
| 341 | <span class="block whitespace-pre-wrap">{choice}</span> | 333 | <span class="block whitespace-pre-wrap">{choice}</span> |
| @@ -343,7 +335,7 @@ function QuestionAnswerCard(props: { | |||
| 343 | <img | 335 | <img |
| 344 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/choices/${choiceIndex()}/image`} | 336 | src={`/api/exams/${props.question.exam}/questions/${props.question.id}/choices/${choiceIndex()}/image`} |
| 345 | alt={t("questions.choiceImage")} | 337 | alt={t("questions.choiceImage")} |
| 346 | - class="max-h-40 rounded-md border object-contain" | 338 | + class="h-36 w-full max-w-md rounded-md border bg-muted/20 object-contain" |
| 347 | /> | 339 | /> |
| 348 | </Show> | 340 | </Show> |
| 349 | </span> | 341 | </span> |
src/i18n/messages.tsmodified+2 -2
| @@ -984,7 +984,7 @@ const en: Dict = { | |||
| 984 | "attempt.submittedInfo": "You have already submitted this exam. It cannot be reopened.", | 984 | "attempt.submittedInfo": "You have already submitted this exam. It cannot be reopened.", |
| 985 | "attempt.expired": "Expired", | 985 | "attempt.expired": "Expired", |
| 986 | "attempt.expiredInfo": "The time for this exam has expired. It cannot be reopened.", | 986 | "attempt.expiredInfo": "The time for this exam has expired. It cannot be reopened.", |
| 987 | - "attempt.noAttemptsLeft": "No attempts left", | 987 | + "attempt.noAttemptsLeft": "No rights left", |
| 988 | "attempt.closed": "This attempt is closed. Answers are read-only.", | 988 | "attempt.closed": "This attempt is closed. Answers are read-only.", |
| 989 | "attempt.inProgress": "In progress", | 989 | "attempt.inProgress": "In progress", |
| 990 | "attempt.absent": "No-show", | 990 | "attempt.absent": "No-show", |
| @@ -1606,7 +1606,7 @@ const tr: Dict = { | |||
| 1606 | "attempt.submittedInfo": "Bu sınavı zaten teslim ettin. Yeniden açılamaz.", | 1606 | "attempt.submittedInfo": "Bu sınavı zaten teslim ettin. Yeniden açılamaz.", |
| 1607 | "attempt.expired": "Süresi doldu", | 1607 | "attempt.expired": "Süresi doldu", |
| 1608 | "attempt.expiredInfo": "Bu sınavın süresi doldu. Yeniden açılamaz.", | 1608 | "attempt.expiredInfo": "Bu sınavın süresi doldu. Yeniden açılamaz.", |
| 1609 | - "attempt.noAttemptsLeft": "Deneme hakkı bitti", | 1609 | + "attempt.noAttemptsLeft": "Hak bitti", |
| 1610 | "attempt.closed": "Bu oturum kapalı. Cevaplar salt okunur.", | 1610 | "attempt.closed": "Bu oturum kapalı. Cevaplar salt okunur.", |
| 1611 | "attempt.inProgress": "Devam ediyor", | 1611 | "attempt.inProgress": "Devam ediyor", |
| 1612 | "attempt.absent": "Katılmadı", | 1612 | "attempt.absent": "Katılmadı", |
src/lib/exam-status.tsmodified+1 -1
| @@ -14,7 +14,7 @@ export function isSittableExam(exam: Exam): boolean { | |||
| 14 | 14 | ||
| 15 | export function examDisplayStatus(exam: Exam, now: number, attempt?: ExamAttemptSummary | null): ExamDisplayStatus { | 15 | export function examDisplayStatus(exam: Exam, now: number, attempt?: ExamAttemptSummary | null): ExamDisplayStatus { |
| 16 | if (attempt?.status === "submitted" || attempt?.status === "expired") return attempt.status; | 16 | if (attempt?.status === "submitted" || attempt?.status === "expired") return attempt.status; |
| 17 | - if (attempt && attempt.max_attempts > 0 && attempt.attempts_used >= attempt.max_attempts) return "no_attempts_left"; | 17 | + if (attempt && attempt.status !== "in_progress" && attempt.max_attempts > 0 && attempt.attempts_used >= attempt.max_attempts) return "no_attempts_left"; |
| 18 | if (exam.draft) return "draft"; | 18 | if (exam.draft) return "draft"; |
| 19 | if (!isSittableExam(exam)) return "unscheduled"; | 19 | if (!isSittableExam(exam)) return "unscheduled"; |
| 20 | if (exam.mode === "open") return "active"; | 20 | if (exam.mode === "open") return "active"; |
src/pages/exams-page.tsxmodified+1 -1
| @@ -177,7 +177,7 @@ function ExamsContent() { | |||
| 177 | cell: (cell) => { | 177 | cell: (cell) => { |
| 178 | const status = cell.row.original.displayStatus; | 178 | const status = cell.row.original.displayStatus; |
| 179 | return ( | 179 | return ( |
| 180 | - <Badge variant="outline" class={cn("w-28 justify-center rounded-sm", scheduleStatusClass(examStatusTone(status)))}> | 180 | + <Badge variant="outline" class={cn("min-w-28 justify-center whitespace-nowrap rounded-sm", scheduleStatusClass(examStatusTone(status)))}> |
| 181 | <span class={cn("mr-1.5 h-1.5 w-1.5 rounded-full", scheduleStatusDotClass(examStatusTone(status)))} /> | 181 | <span class={cn("mr-1.5 h-1.5 w-1.5 rounded-full", scheduleStatusDotClass(examStatusTone(status)))} /> |
| 182 | {statusLabel(status)} | 182 | {statusLabel(status)} |
| 183 | </Badge> | 183 | </Badge> |
src/pages/live-monitor-page.tsxmodified+69 -33
| @@ -13,12 +13,13 @@ import { Alert } from "@/components/ui/alert"; | |||
| 13 | import { Badge } from "@/components/ui/badge"; | 13 | import { Badge } from "@/components/ui/badge"; |
| 14 | import { Button } from "@/components/ui/button"; | 14 | import { Button } from "@/components/ui/button"; |
| 15 | import { DataTable } from "@/components/ui/data-table"; | 15 | import { DataTable } from "@/components/ui/data-table"; |
| 16 | -import { IconChevronLeft } from "@/components/ui/icons"; | 16 | +import { IconAlert, IconCheck, IconChevronLeft, IconClock, IconExam, IconUsers } from "@/components/ui/icons"; |
| 17 | import { PageSpinner } from "@/components/ui/page-spinner"; | 17 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 18 | import { usePreferences, useT } from "@/stores/preferences-context"; | 18 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 19 | import { createNow } from "@/lib/create-now"; | 19 | import { createNow } from "@/lib/create-now"; |
| 20 | import { cn } from "@/lib/cn"; | 20 | import { cn } from "@/lib/cn"; |
| 21 | import { attemptLabel } from "@/lib/exam-labels"; | 21 | import { attemptLabel } from "@/lib/exam-labels"; |
| 22 | +import { examDisplayStatus, examStatusTone, type ExamDisplayStatus } from "@/lib/exam-status"; | ||
| 22 | import { formatDateTime } from "@/lib/format"; | 23 | import { formatDateTime } from "@/lib/format"; |
| 23 | import { scheduleStatusClass, scheduleStatusDotClass } from "@/lib/schedule-status"; | 24 | import { scheduleStatusClass, scheduleStatusDotClass } from "@/lib/schedule-status"; |
| 24 | 25 | ||
| @@ -38,8 +39,12 @@ const STATUS_KEY: Record<string, MessageKey> = { | |||
| 38 | submitted: "attempt.submitted", | 39 | submitted: "attempt.submitted", |
| 39 | expired: "attempt.expired", | 40 | expired: "attempt.expired", |
| 40 | absent: "attempt.absent", | 41 | absent: "attempt.absent", |
| 42 | + no_attempts_left: "attempt.noAttemptsLeft", | ||
| 41 | }; | 43 | }; |
| 42 | 44 | ||
| 45 | +type LiveDisplayStatus = LiveRosterEntry["status"] | ExamDisplayStatus; | ||
| 46 | +type LiveRosterRow = LiveRosterEntry & { displayStatus: LiveDisplayStatus }; | ||
| 47 | + | ||
| 43 | function labelFromStatus(status: string, t: (key: MessageKey) => string): string { | 48 | function labelFromStatus(status: string, t: (key: MessageKey) => string): string { |
| 44 | const k = STATUS_KEY[status]; | 49 | const k = STATUS_KEY[status]; |
| 45 | return k ? t(k) : status; | 50 | return k ? t(k) : status; |
| @@ -48,10 +53,25 @@ function labelFromStatus(status: string, t: (key: MessageKey) => string): string | |||
| 48 | function statusTone(status: string): string { | 53 | function statusTone(status: string): string { |
| 49 | if (status === "in_progress") return "active"; | 54 | if (status === "in_progress") return "active"; |
| 50 | if (status === "submitted") return "submitted"; | 55 | if (status === "submitted") return "submitted"; |
| 51 | - if (status === "expired" || status === "absent") return "finished"; | 56 | + if (status === "expired" || status === "absent" || status === "no_attempts_left") return "finished"; |
| 52 | return "unscheduled"; | 57 | return "unscheduled"; |
| 53 | } | 58 | } |
| 54 | 59 | ||
| 60 | +function liveTone(status: LiveDisplayStatus): string { | ||
| 61 | + if (status === "in_progress") return "active"; | ||
| 62 | + if (status === "expired") return "finished"; | ||
| 63 | + if (status === "absent" || status === "not_started") return statusTone(status); | ||
| 64 | + return examStatusTone(status); | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +function liveDisplayStatus(entry: LiveRosterEntry, exam: LiveMonitor["exam"], now: number): LiveDisplayStatus { | ||
| 68 | + if (entry.status === "absent") return "absent"; | ||
| 69 | + if (entry.status === "not_started") return "not_started"; | ||
| 70 | + if (entry.status !== "submitted" && entry.status !== "expired" && exam.max_attempts > 0 && entry.attempts_used >= exam.max_attempts) return "no_attempts_left"; | ||
| 71 | + const status = examDisplayStatus(exam, now, { status: entry.status, attempts_used: entry.attempts_used, max_attempts: exam.max_attempts }); | ||
| 72 | + return status === "active" ? "in_progress" : status; | ||
| 73 | +} | ||
| 74 | + | ||
| 55 | function progressPercent(entry: LiveRosterEntry, questionCount: number): number { | 75 | function progressPercent(entry: LiveRosterEntry, questionCount: number): number { |
| 56 | if (questionCount <= 0) return 0; | 76 | if (questionCount <= 0) return 0; |
| 57 | return Math.round(((entry.answered ?? 0) / questionCount) * 100); | 77 | return Math.round(((entry.answered ?? 0) / questionCount) * 100); |
| @@ -81,17 +101,21 @@ function liveRosterName(entry: LiveRosterEntry, fallback: string): string { | |||
| 81 | ); | 101 | ); |
| 82 | } | 102 | } |
| 83 | 103 | ||
| 84 | -function remainingMinutesLabel(entry: LiveRosterEntry): string { | 104 | +function minutesLabel(ms: number): string { |
| 105 | + if (ms <= 0) return "0dk"; | ||
| 106 | + return `${Math.ceil(ms / 60000)}dk`; | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +function remainingMinutesLabel(entry: LiveRosterRow): string { | ||
| 85 | const remaining = entry.remaining_ms; | 110 | const remaining = entry.remaining_ms; |
| 86 | - if (entry.status !== "in_progress") return "—"; | 111 | + if (entry.displayStatus !== "not_started" && entry.displayStatus !== "in_progress") return "—"; |
| 87 | if (remaining == null) return "—"; | 112 | if (remaining == null) return "—"; |
| 88 | - if (remaining > 0) return `${Math.ceil(remaining / 60000)}dk`; | 113 | + return minutesLabel(remaining); |
| 89 | - return "<1dk"; | ||
| 90 | } | 114 | } |
| 91 | 115 | ||
| 92 | -function isLowRemaining(entry: LiveRosterEntry): boolean { | 116 | +function isLowRemaining(entry: LiveRosterRow): boolean { |
| 93 | const remaining = entry.remaining_ms ?? 0; | 117 | const remaining = entry.remaining_ms ?? 0; |
| 94 | - return entry.status === "in_progress" && remaining <= 5 * 60 * 1000; | 118 | + return entry.displayStatus === "in_progress" && remaining <= 5 * 60 * 1000; |
| 95 | } | 119 | } |
| 96 | 120 | ||
| 97 | function LiveMonitorContent() { | 121 | function LiveMonitorContent() { |
| @@ -219,9 +243,20 @@ function LiveMonitorContent() { | |||
| 219 | {(s) => { | 243 | {(s) => { |
| 220 | const m = s(); | 244 | const m = s(); |
| 221 | if (!m) return null; | 245 | if (!m) return null; |
| 222 | - const counts = m.counts ?? { not_started: 0, in_progress: 0, submitted: 0, expired: 0 }; | 246 | + const raw: LiveRosterRow[] = Array.isArray(m.students) ? m.students.map((entry) => ({ ...entry, displayStatus: liveDisplayStatus(entry, m.exam, m.now) })) : []; |
| 223 | - const raw = Array.isArray(m.students) ? m.students : []; | 247 | + const counts = raw.reduce( |
| 224 | - const columns: ColumnDef<LiveRosterEntry>[] = [ | 248 | + (acc, entry) => { |
| 249 | + if (entry.displayStatus === "submitted") acc.submitted += 1; | ||
| 250 | + else if (entry.displayStatus === "expired") acc.expired += 1; | ||
| 251 | + else if (entry.displayStatus === "no_attempts_left") acc.no_attempts_left += 1; | ||
| 252 | + else if (entry.displayStatus === "absent") acc.absent += 1; | ||
| 253 | + else if (entry.displayStatus === "in_progress") acc.in_progress += 1; | ||
| 254 | + else acc.not_started += 1; | ||
| 255 | + return acc; | ||
| 256 | + }, | ||
| 257 | + { not_started: 0, in_progress: 0, submitted: 0, expired: 0, no_attempts_left: 0, absent: 0 }, | ||
| 258 | + ); | ||
| 259 | + const columns: ColumnDef<LiveRosterRow>[] = [ | ||
| 225 | { | 260 | { |
| 226 | id: "username", | 261 | id: "username", |
| 227 | accessorFn: (entry) => liveRosterName(entry, ""), | 262 | accessorFn: (entry) => liveRosterName(entry, ""), |
| @@ -231,16 +266,16 @@ function LiveMonitorContent() { | |||
| 231 | }, | 266 | }, |
| 232 | { | 267 | { |
| 233 | id: "status", | 268 | id: "status", |
| 234 | - accessorFn: (entry) => labelFromStatus(entry.status, t), | 269 | + accessorFn: (entry) => labelFromStatus(entry.displayStatus, t), |
| 235 | header: t("attempt.status"), | 270 | header: t("attempt.status"), |
| 236 | meta: { headerClass: "text-center", cellClass: "text-center" }, | 271 | meta: { headerClass: "text-center", cellClass: "text-center" }, |
| 237 | cell: (cell) => ( | 272 | cell: (cell) => ( |
| 238 | <Badge | 273 | <Badge |
| 239 | variant="outline" | 274 | variant="outline" |
| 240 | - class={cn("rounded-full", scheduleStatusClass(statusTone(cell.row.original.status)))} | 275 | + class={cn("rounded-full", scheduleStatusClass(liveTone(cell.row.original.displayStatus)))} |
| 241 | > | 276 | > |
| 242 | - <span class={cn("mr-1.5 h-1.5 w-1.5 rounded-full", scheduleStatusDotClass(statusTone(cell.row.original.status)))} /> | 277 | + <span class={cn("mr-1.5 h-1.5 w-1.5 rounded-full", scheduleStatusDotClass(liveTone(cell.row.original.displayStatus)))} /> |
| 243 | - {labelFromStatus(cell.row.original.status, t)} | 278 | + {labelFromStatus(cell.row.original.displayStatus, t)} |
| 244 | </Badge> | 279 | </Badge> |
| 245 | ), | 280 | ), |
| 246 | }, | 281 | }, |
| @@ -278,10 +313,13 @@ function LiveMonitorContent() { | |||
| 278 | }, | 313 | }, |
| 279 | { | 314 | { |
| 280 | id: "left", | 315 | id: "left", |
| 281 | - accessorFn: (entry) => entry.left_at ?? 0, | 316 | + accessorFn: (entry) => entry.finished_at ?? entry.left_at ?? 0, |
| 282 | header: t("attempt.left"), | 317 | header: t("attempt.left"), |
| 283 | meta: { headerClass: "text-center", cellClass: "text-center text-xs" }, | 318 | meta: { headerClass: "text-center", cellClass: "text-center text-xs" }, |
| 284 | - cell: (cell) => cell.row.original.left_at ? formatDateTime(cell.row.original.left_at, locale()) : "—", | 319 | + cell: (cell) => { |
| 320 | + const at = cell.row.original.finished_at ?? cell.row.original.left_at; | ||
| 321 | + return at ? formatDateTime(at, locale()) : "—"; | ||
| 322 | + }, | ||
| 285 | }, | 323 | }, |
| 286 | { | 324 | { |
| 287 | id: "mark", | 325 | id: "mark", |
| @@ -294,26 +332,24 @@ function LiveMonitorContent() { | |||
| 294 | 332 | ||
| 295 | return ( | 333 | return ( |
| 296 | <> | 334 | <> |
| 297 | - <section class="grid gap-3 sm:grid-cols-2 lg:grid-cols-5"> | 335 | + <section class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"> |
| 298 | - <div class="surface-card bg-card/80 p-4"> | 336 | + <div class="surface-card bg-card/80 p-3"> |
| 299 | - <p class="text-xs text-muted-foreground">{t("exams.notStarted")}</p> | 337 | + <p class="flex items-center gap-1.5 text-xs text-muted-foreground"><IconClock class="h-3.5 w-3.5" />{t("exams.notStarted")}</p><p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.not_started}</p> |
| 300 | - <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.not_started}</p> | 338 | + </div> |
| 339 | + <div class="surface-card bg-card/80 p-3"> | ||
| 340 | + <p class="flex items-center gap-1.5 text-xs text-muted-foreground"><IconExam class="h-3.5 w-3.5 text-sky-700 dark:text-sky-300" />{t("attempt.inProgress")}</p><p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.in_progress}</p> | ||
| 301 | </div> | 341 | </div> |
| 302 | - <div class="surface-card bg-card/80 p-4"> | 342 | + <div class="surface-card bg-card/80 p-3"> |
| 303 | - <p class="text-xs text-muted-foreground">{t("attempt.inProgress")}</p> | 343 | + <p class="flex items-center gap-1.5 text-xs text-muted-foreground"><IconCheck class="h-3.5 w-3.5 text-emerald-700 dark:text-emerald-300" />{t("attempt.submitted")}</p><p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.submitted}</p> |
| 304 | - <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.in_progress}</p> | ||
| 305 | </div> | 344 | </div> |
| 306 | - <div class="surface-card bg-card/80 p-4"> | 345 | + <div class="surface-card bg-card/80 p-3"> |
| 307 | - <p class="text-xs text-muted-foreground">{t("attempt.submitted")}</p> | 346 | + <p class="flex items-center gap-1.5 text-xs text-muted-foreground"><IconClock class="h-3.5 w-3.5 text-rose-700 dark:text-rose-300" />{t("attempt.expired")}</p><p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.expired}</p> |
| 308 | - <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.submitted}</p> | ||
| 309 | </div> | 347 | </div> |
| 310 | - <div class="surface-card bg-card/80 p-4"> | 348 | + <div class="surface-card bg-card/80 p-3"> |
| 311 | - <p class="text-xs text-muted-foreground">{t("attempt.expired")}</p> | 349 | + <p class="flex items-center gap-1.5 text-xs text-muted-foreground"><IconAlert class="h-3.5 w-3.5 text-rose-700 dark:text-rose-300" />{t("attempt.noAttemptsLeft")}</p><p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.no_attempts_left}</p> |
| 312 | - <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.expired}</p> | ||
| 313 | </div> | 350 | </div> |
| 314 | - <div class="surface-card bg-card/80 p-4"> | 351 | + <div class="surface-card bg-card/80 p-3"> |
| 315 | - <p class="text-xs text-muted-foreground">{t("attempt.absent")}</p> | 352 | + <p class="flex items-center gap-1.5 text-xs text-muted-foreground"><IconUsers class="h-3.5 w-3.5" />{t("attempt.absent")}</p><p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.absent}</p> |
| 316 | - <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.absent ?? 0}</p> | ||
| 317 | </div> | 353 | </div> |
| 318 | </section> | 354 | </section> |
| 319 | 355 | ||