✨ implement exam link component and enhance exam-related UI features
Browse files at this commit3f5a474a8a922bf1da31586337c844a8869a6a13Parent: ee0b44d- feat
- ✨ implement exam link component and enhance exam-related UI features
11 changed files +136 -27
- docs/backend-ui-alignment-plan.md +7 -2
- src/api/types.ts +4 -0
- src/components/exams/exam-card.tsx +3 -3
- src/components/exams/exam-form.tsx +32 -3
- src/components/exams/exam-link.tsx +19 -0
- src/components/exams/exam-room-ws.tsx +16 -0
- src/components/marks/marks-report-view.tsx +11 -5
- src/i18n/messages.ts +12 -0
- src/pages/course-detail-page.tsx +4 -4
- src/pages/dashboard-page.tsx +4 -4
- src/pages/live-monitor-page.tsx +24 -6
docs/backend-ui-alignment-plan.mdmodified+7 -2
| @@ -28,12 +28,16 @@ This plan covers the remaining backend features that need simple, low-complexity | ||
| 28 | 28 | - Run `bun run build` before every commit. |
| 29 | 29 | - Commit messages must follow repository rules and require explicit user approval. |
| 30 | 30 | |
| 31 | +## Status | |
| 32 | + | |
| 33 | +- Commit 1 complete in UI: live monitor shows absent count/status, attempt usage, and left timestamp; exam room summary shows attempt usage and left timestamp. | |
| 34 | +- Commit 2 complete in UI: report card types accept grade-band fields and marks show `mark / grade` when backend sends labels. | |
| 35 | +- Commits 3-7 remain. | |
| 36 | + | |
| 31 | 37 | ## Remaining Commit Order |
| 32 | 38 | |
| 33 | 39 | | Commit | Scope | Priority | |
| 34 | 40 | | --- | --- | --- | |
| 35 | -| 1 | Live monitor + exam room attempt fields | High | | |
| 36 | -| 2 | Marks grade-band labels | High | | |
| 37 | 41 | | 3 | Settings management page | High | |
| 38 | 42 | | 4 | Terms API + course term select | Medium | |
| 39 | 43 | | 5 | Course sessions + roll call | Medium | |
| @@ -51,6 +55,7 @@ Expose backend attempt, no-show, and room-left fields without making the UI comp | ||
| 51 | 55 | - `LiveRosterEntry.status`: includes `absent`. |
| 52 | 56 | - `LiveRosterEntry.attempt`. |
| 53 | 57 | - `LiveRosterEntry.attempts_used`. |
| 58 | +- `LiveRosterEntry.max_attempts`. | |
| 54 | 59 | - `LiveRosterEntry.left_at`. |
| 55 | 60 | - `LiveMonitor.counts.absent`. |
| 56 | 61 | - `ExamAttempt.attempt`. |
src/api/types.tsmodified+4 -0
| @@ -149,6 +149,7 @@ export type MarkEntry = { | ||
| 149 | 149 | type_weight?: number | null; |
| 150 | 150 | exam_type_weight?: number | null; |
| 151 | 151 | mark: number; |
| 152 | + grade?: string | null; | |
| 152 | 153 | graded_by: string; |
| 153 | 154 | }; |
| 154 | 155 | |
| @@ -156,12 +157,14 @@ export type CourseMarks = { | ||
| 156 | 157 | course: Course; |
| 157 | 158 | results: MarkEntry[]; |
| 158 | 159 | average: number | null; |
| 160 | + average_grade?: string | null; | |
| 159 | 161 | }; |
| 160 | 162 | |
| 161 | 163 | export type MarksReport = { |
| 162 | 164 | user: string; |
| 163 | 165 | courses: CourseMarks[]; |
| 164 | 166 | overall_average: number | null; |
| 167 | + overall_grade?: string | null; | |
| 165 | 168 | }; |
| 166 | 169 | |
| 167 | 170 | export type ExamStatistics = { |
| @@ -195,6 +198,7 @@ export type LiveRosterEntry = { | ||
| 195 | 198 | status: AttemptStatus | "not_started" | "absent"; |
| 196 | 199 | attempt?: number | null; |
| 197 | 200 | attempts_used?: number | null; |
| 201 | + max_attempts?: number | null; | |
| 198 | 202 | deadline: number | null; |
| 199 | 203 | remaining_ms: number | null; |
| 200 | 204 | left_at?: number | null; |
src/components/exams/exam-card.tsxmodified+3 -3
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | import { Show } from "solid-js"; |
| 2 | -import { Link } from "@tanstack/solid-router"; | |
| 3 | 2 | import type { Exam } from "@/api/types"; |
| 4 | 3 | import { Badge } from "@/components/ui/badge"; |
| 4 | +import { ExamLink } from "@/components/exams/exam-link"; | |
| 5 | 5 | import { cn } from "@/lib/cn"; |
| 6 | 6 | import { examKindLabel } from "@/lib/exam-labels"; |
| 7 | 7 | import { examWeight } from "@/lib/exam-weight"; |
| @@ -52,7 +52,7 @@ export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number | ||
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | 54 | return ( |
| 55 | - <Link to="/exams/$id" params={{ id: props.exam.id }} class="group block h-full"> | |
| 55 | + <ExamLink examId={props.exam.id} class="group block h-full"> | |
| 56 | 56 | <article class="surface-card relative flex h-full min-h-52 flex-col overflow-hidden transition-all group-hover:-translate-y-0.5 group-hover:border-rose-500/30 group-hover:shadow-sm"> |
| 57 | 57 | <div class="absolute inset-x-0 top-0 h-1 bg-gradient-to-r from-rose-500/70 via-amber-400/50 to-transparent" /> |
| 58 | 58 | <div class="flex flex-1 flex-col p-4"> |
| @@ -111,6 +111,6 @@ export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number | ||
| 111 | 111 | </dl> |
| 112 | 112 | </div> |
| 113 | 113 | </article> |
| 114 | - </Link> | |
| 114 | + </ExamLink> | |
| 115 | 115 | ); |
| 116 | 116 | } |
src/components/exams/exam-form.tsxmodified+32 -3
| @@ -29,6 +29,11 @@ function timeInputFromMs(ms: number | null | undefined): string { | ||
| 29 | 29 | return `${pad(d.getHours())}:${pad(d.getMinutes())}`; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | +function durationMinutesFromMs(ms: number | null | undefined): string { | |
| 33 | + if (ms == null) return ""; | |
| 34 | + return String(Math.round(ms / 60000)); | |
| 35 | +} | |
| 36 | + | |
| 32 | 37 | function scheduleInputToMs(date: string, time: string): number | null { |
| 33 | 38 | const dateMatch = date.trim().match(/^(\d{2})\/(\d{2})\/(\d{4})$/); |
| 34 | 39 | const timeMatch = time.trim().match(/^(\d{2}):(\d{2})$/); |
| @@ -83,6 +88,7 @@ export function ExamForm(props: { | ||
| 83 | 88 | const [startsTime, setStartsTime] = createSignal(timeInputFromMs(props.initial?.starts_at)); |
| 84 | 89 | const [endsDate, setEndsDate] = createSignal(dateInputFromMs(props.initial?.ends_at)); |
| 85 | 90 | const [endsTime, setEndsTime] = createSignal(timeInputFromMs(props.initial?.ends_at)); |
| 91 | + const [durationMinutes, setDurationMinutes] = createSignal(durationMinutesFromMs(props.initial?.duration_ms)); | |
| 86 | 92 | const [error, setError] = createSignal(""); |
| 87 | 93 | const [pending, setPending] = createSignal(false); |
| 88 | 94 | const [confirmOpen, setConfirmOpen] = createSignal(false); |
| @@ -100,7 +106,7 @@ export function ExamForm(props: { | ||
| 100 | 106 | if (names.length > 0 && !names.includes(kind())) setKind(names[0]); |
| 101 | 107 | }); |
| 102 | 108 | |
| 103 | - const validate = (starts: number | null, ends: number | null): string | null => { | |
| 109 | + const validate = (starts: number | null, ends: number | null, duration: number | null): string | null => { | |
| 104 | 110 | const value = title().trim(); |
| 105 | 111 | if (!value) return t("form.titleRequired"); |
| 106 | 112 | if (value.length > 200) return t("form.titleMax"); |
| @@ -110,6 +116,11 @@ export function ExamForm(props: { | ||
| 110 | 116 | if (mode() === "sync" || mode() === "async") { |
| 111 | 117 | if (starts == null || ends == null) return t("exams.scheduleRequired"); |
| 112 | 118 | if (ends <= starts) return t("form.timeOrder"); |
| 119 | + if (!isEdit() && (starts < Date.now() || ends < Date.now())) return t("form.timePast"); | |
| 120 | + } | |
| 121 | + if (mode() === "async") { | |
| 122 | + if (duration == null) return t("exams.durationRequired"); | |
| 123 | + if (duration < 60000 || duration > 86400000) return t("exams.durationRange"); | |
| 113 | 124 | } |
| 114 | 125 | return null; |
| 115 | 126 | }; |
| @@ -130,6 +141,7 @@ export function ExamForm(props: { | ||
| 130 | 141 | setStartsTime(""); |
| 131 | 142 | setEndsDate(""); |
| 132 | 143 | setEndsTime(""); |
| 144 | + setDurationMinutes(""); | |
| 133 | 145 | } |
| 134 | 146 | } catch (err) { |
| 135 | 147 | setError(formatApiError(err)); |
| @@ -143,8 +155,9 @@ export function ExamForm(props: { | ||
| 143 | 155 | const hasWindow = mode() === "sync" || mode() === "async"; |
| 144 | 156 | const starts_at = hasWindow ? scheduleInputToMs(startsDate(), startsTime()) : null; |
| 145 | 157 | const ends_at = hasWindow ? scheduleInputToMs(endsDate(), endsTime()) : null; |
| 146 | - const duration_ms = mode() === "async" && starts_at != null && ends_at != null ? ends_at - starts_at : null; | |
| 147 | - const v = validate(starts_at, ends_at); | |
| 158 | + const durationValue = Number(durationMinutes()); | |
| 159 | + const duration_ms = mode() === "async" && Number.isFinite(durationValue) ? durationValue * 60000 : null; | |
| 160 | + const v = validate(starts_at, ends_at, duration_ms); | |
| 148 | 161 | if (v) { |
| 149 | 162 | setError(v); |
| 150 | 163 | return; |
| @@ -300,6 +313,22 @@ export function ExamForm(props: { | ||
| 300 | 313 | </div> |
| 301 | 314 | </div> |
| 302 | 315 | </Show> |
| 316 | + <Show when={mode() === "async"}> | |
| 317 | + <div class="space-y-1.5"> | |
| 318 | + <Label for="exam-duration-minutes">{t("exams.durationMinutes")}</Label> | |
| 319 | + <Input | |
| 320 | + id="exam-duration-minutes" | |
| 321 | + class="rounded-sm" | |
| 322 | + type="number" | |
| 323 | + min={1} | |
| 324 | + max={1440} | |
| 325 | + step={1} | |
| 326 | + value={durationMinutes()} | |
| 327 | + required | |
| 328 | + onInput={(e) => setDurationMinutes(e.currentTarget.value)} | |
| 329 | + /> | |
| 330 | + </div> | |
| 331 | + </Show> | |
| 303 | 332 | {error() && <p class="text-sm text-destructive">{error()}</p>} |
| 304 | 333 | <div class="flex flex-wrap items-center gap-2"> |
| 305 | 334 | <Button type="submit" disabled={pending()}> |
src/components/exams/exam-link.tsxadded+19 -0
| @@ -0,0 +1,19 @@ | ||
| 1 | +import type { ComponentProps, ParentProps } from "solid-js"; | |
| 2 | +import { splitProps } from "solid-js"; | |
| 3 | + | |
| 4 | +type ExamLinkProps = ParentProps< | |
| 5 | + Omit<ComponentProps<"a">, "href"> & { | |
| 6 | + examId: string; | |
| 7 | + } | |
| 8 | +>; | |
| 9 | + | |
| 10 | +export function ExamLink(props: ExamLinkProps) { | |
| 11 | + const [local, rest] = splitProps(props, ["children", "examId"]); | |
| 12 | + const href = () => `/exams/${encodeURIComponent(local.examId)}`; | |
| 13 | + | |
| 14 | + return ( | |
| 15 | + <a {...rest} href={href()}> | |
| 16 | + {local.children} | |
| 17 | + </a> | |
| 18 | + ); | |
| 19 | +} |
src/components/exams/exam-room-ws.tsxmodified+16 -0
| @@ -358,12 +358,22 @@ function AttemptSummaryWS(props: { attempt: ExamAttempt; remainingMs: number | n | ||
| 358 | 358 | if (props.wsState === "connected") return t("ws.connected"); |
| 359 | 359 | return t("ws.disconnected"); |
| 360 | 360 | }; |
| 361 | + const attemptLabel = () => { | |
| 362 | + if (props.attempt.attempts_used != null && props.attempt.max_attempts != null) return `${props.attempt.attempts_used} / ${props.attempt.max_attempts}`; | |
| 363 | + if (props.attempt.attempt != null) return String(props.attempt.attempt); | |
| 364 | + if (props.attempt.attempts_used != null) return String(props.attempt.attempts_used); | |
| 365 | + return "—"; | |
| 366 | + }; | |
| 361 | 367 | return ( |
| 362 | 368 | <div class="grid auto-rows-fr gap-3 text-sm sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-6"> |
| 363 | 369 | <div class="h-full rounded-lg border bg-background/60 p-3"> |
| 364 | 370 | <p class="text-xs text-muted-foreground">{t("attempt.status")}</p> |
| 365 | 371 | <p class="mt-1 font-medium">{statusLabel()}</p> |
| 366 | 372 | </div> |
| 373 | + <div class="h-full rounded-lg border bg-background/60 p-3"> | |
| 374 | + <p class="text-xs text-muted-foreground">{t("attempt.attempt")}</p> | |
| 375 | + <p class="mt-1 font-medium tabular-nums">{attemptLabel()}</p> | |
| 376 | + </div> | |
| 367 | 377 | <div class={remainingWarn() ? "h-full rounded-lg border border-amber-500/40 bg-amber-500/10 p-3" : "h-full rounded-lg border bg-background/60 p-3"}> |
| 368 | 378 | <p class="text-xs text-muted-foreground">{t("attempt.remaining")}</p> |
| 369 | 379 | <p class="mt-1 font-mono text-lg font-semibold tabular-nums">{formatRemaining(props.remainingMs)}</p> |
| @@ -396,6 +406,12 @@ function AttemptSummaryWS(props: { attempt: ExamAttempt; remainingMs: number | n | ||
| 396 | 406 | <p class="mt-1 font-medium">{props.attempt.mark}</p> |
| 397 | 407 | </div> |
| 398 | 408 | </Show> |
| 409 | + <Show when={props.attempt.left_at != null}> | |
| 410 | + <div class="h-full rounded-lg border border-amber-500/40 bg-amber-500/10 p-3"> | |
| 411 | + <p class="text-xs text-muted-foreground">{t("attempt.left")}</p> | |
| 412 | + <p class="mt-1 font-medium">{formatDateTime(props.attempt.left_at, locale())}</p> | |
| 413 | + </div> | |
| 414 | + </Show> | |
| 399 | 415 | </div> |
| 400 | 416 | ); |
| 401 | 417 | } |
src/components/marks/marks-report-view.tsxmodified+11 -5
| @@ -2,6 +2,7 @@ import { For, Show } from "solid-js"; | ||
| 2 | 2 | import { Link } from "@tanstack/solid-router"; |
| 3 | 3 | import type { MarksReport } from "@/api/types"; |
| 4 | 4 | import { Badge } from "@/components/ui/badge"; |
| 5 | +import { ExamLink } from "@/components/exams/exam-link"; | |
| 5 | 6 | import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; |
| 6 | 7 | import { examKindLabel } from "@/lib/exam-labels"; |
| 7 | 8 | import { examWeight } from "@/lib/exam-weight"; |
| @@ -9,6 +10,11 @@ import { useT } from "@/stores/preferences-context"; | ||
| 9 | 10 | |
| 10 | 11 | const round = (n: number) => (Math.round(n * 100) / 100).toString(); |
| 11 | 12 | |
| 13 | +function markWithGrade(mark: number | null, grade?: string | null) { | |
| 14 | + if (mark == null) return grade ?? "—"; | |
| 15 | + return grade ? `${round(mark)} / ${grade}` : round(mark); | |
| 16 | +} | |
| 17 | + | |
| 12 | 18 | export function MarksReportView(props: { report: MarksReport }) { |
| 13 | 19 | const t = useT(); |
| 14 | 20 | return ( |
| @@ -24,7 +30,7 @@ export function MarksReportView(props: { report: MarksReport }) { | ||
| 24 | 30 | <div class="surface-card flex flex-wrap items-center justify-between gap-3 p-5"> |
| 25 | 31 | <span class="text-sm font-medium text-muted-foreground">{t("marks.overall")}</span> |
| 26 | 32 | <p class="font-display text-3xl font-semibold tabular-nums"> |
| 27 | - {props.report.overall_average == null ? "—" : round(props.report.overall_average)} | |
| 33 | + {markWithGrade(props.report.overall_average, props.report.overall_grade)} | |
| 28 | 34 | <Show when={props.report.overall_average != null}> |
| 29 | 35 | <span class="text-base font-medium text-muted-foreground"> / 100</span> |
| 30 | 36 | </Show> |
| @@ -41,7 +47,7 @@ export function MarksReportView(props: { report: MarksReport }) { | ||
| 41 | 47 | </Link> |
| 42 | 48 | </h3> |
| 43 | 49 | <Badge variant="secondary" class="rounded-full px-3 py-1" title={t("marks.courseAvg")}> |
| 44 | - {block.average == null ? "—" : round(block.average)} | |
| 50 | + {markWithGrade(block.average, block.average_grade)} | |
| 45 | 51 | </Badge> |
| 46 | 52 | </header> |
| 47 | 53 | |
| @@ -68,9 +74,9 @@ export function MarksReportView(props: { report: MarksReport }) { | ||
| 68 | 74 | {(entry) => ( |
| 69 | 75 | <TableRow> |
| 70 | 76 | <TableCell> |
| 71 | - <Link to="/exams/$id" params={{ id: entry.exam }} class="font-medium hover:underline"> | |
| 77 | + <ExamLink examId={entry.exam} class="font-medium hover:underline"> | |
| 72 | 78 | {entry.title} |
| 73 | - </Link> | |
| 79 | + </ExamLink> | |
| 74 | 80 | </TableCell> |
| 75 | 81 | <TableCell> |
| 76 | 82 | <Badge variant="outline" class="rounded-full capitalize"> |
| @@ -78,7 +84,7 @@ export function MarksReportView(props: { report: MarksReport }) { | ||
| 78 | 84 | </Badge> |
| 79 | 85 | </TableCell> |
| 80 | 86 | <TableCell class="tabular-nums">{examWeight(entry) ?? "—"}</TableCell> |
| 81 | - <TableCell class="font-semibold tabular-nums">{entry.mark}</TableCell> | |
| 87 | + <TableCell class="font-semibold tabular-nums">{markWithGrade(entry.mark, entry.grade)}</TableCell> | |
| 82 | 88 | </TableRow> |
| 83 | 89 | )} |
| 84 | 90 | </For> |
src/i18n/messages.tsmodified+12 -0
| @@ -206,6 +206,8 @@ export type MessageKey = | ||
| 206 | 206 | | "attempt.finish" |
| 207 | 207 | | "attempt.status" |
| 208 | 208 | | "attempt.remaining" |
| 209 | + | "attempt.attempt" | |
| 210 | + | "attempt.left" | |
| 209 | 211 | | "attempt.progress" |
| 210 | 212 | | "attempt.deadline" |
| 211 | 213 | | "attempt.notStarted" |
| @@ -219,6 +221,7 @@ export type MessageKey = | ||
| 219 | 221 | | "attempt.expired" |
| 220 | 222 | | "attempt.closed" |
| 221 | 223 | | "attempt.inProgress" |
| 224 | + | "attempt.absent" | |
| 222 | 225 | | "exams.helpTitle" |
| 223 | 226 | | "exams.helpBody" |
| 224 | 227 | | "admin.title" |
| @@ -266,6 +269,7 @@ export type MessageKey = | ||
| 266 | 269 | | "form.contentMax" |
| 267 | 270 | | "form.descriptionMax" |
| 268 | 271 | | "form.timeOrder" |
| 272 | + | "form.timePast" | |
| 269 | 273 | | "form.weightRange" |
| 270 | 274 | | "form.markRange" |
| 271 | 275 | | "events.markedBy" |
| @@ -568,6 +572,8 @@ const en: Dict = { | ||
| 568 | 572 | "attempt.finish": "Finish exam", |
| 569 | 573 | "attempt.status": "Status", |
| 570 | 574 | "attempt.remaining": "Remaining", |
| 575 | + "attempt.attempt": "Attempt", | |
| 576 | + "attempt.left": "Left", | |
| 571 | 577 | "attempt.progress": "Progress", |
| 572 | 578 | "attempt.deadline": "Deadline", |
| 573 | 579 | "attempt.notStarted": "Start the scheduled exam to see questions.", |
| @@ -581,6 +587,7 @@ const en: Dict = { | ||
| 581 | 587 | "attempt.expired": "Expired", |
| 582 | 588 | "attempt.closed": "This attempt is closed. Answers are read-only.", |
| 583 | 589 | "attempt.inProgress": "In progress", |
| 590 | + "attempt.absent": "No-show", | |
| 584 | 591 | "exams.helpTitle": "About exams", |
| 585 | 592 | "exams.helpBody": |
| 586 | 593 | "Exams belong to a course. Teachers add them from the course page with a kind; weighting is defined by the exam kind. Students only see their own mark (or “not graded yet”). Weighted averages appear on the report card.", |
| @@ -639,6 +646,7 @@ const en: Dict = { | ||
| 639 | 646 | "form.contentMax": "Content must be at most 10 000 characters", |
| 640 | 647 | "form.descriptionMax": "Description must be at most 2 000 characters", |
| 641 | 648 | "form.timeOrder": "End time must be on or after start time", |
| 649 | + "form.timePast": "Start and end times must be in the future", | |
| 642 | 650 | "form.weightRange": "Weight must be an integer from 1 to 100", |
| 643 | 651 | "form.markRange": "Mark must be an integer from 0 to 100", |
| 644 | 652 | "events.markedBy": "Marked by", |
| @@ -940,6 +948,8 @@ const tr: Dict = { | ||
| 940 | 948 | "attempt.finish": "Sınavı bitir", |
| 941 | 949 | "attempt.status": "Durum", |
| 942 | 950 | "attempt.remaining": "Kalan süre", |
| 951 | + "attempt.attempt": "Deneme", | |
| 952 | + "attempt.left": "Çıkış", | |
| 943 | 953 | "attempt.progress": "İlerleme", |
| 944 | 954 | "attempt.deadline": "Bitiş zamanı", |
| 945 | 955 | "attempt.notStarted": "Soruları görmek için zamanlı sınavı başlat.", |
| @@ -953,6 +963,7 @@ const tr: Dict = { | ||
| 953 | 963 | "attempt.expired": "Süresi doldu", |
| 954 | 964 | "attempt.closed": "Bu oturum kapalı. Cevaplar salt okunur.", |
| 955 | 965 | "attempt.inProgress": "Devam ediyor", |
| 966 | + "attempt.absent": "Katılmadı", | |
| 956 | 967 | "exams.helpTitle": "Sınavlar hakkında", |
| 957 | 968 | "exams.helpBody": |
| 958 | 969 | "Sınavlar bir derse aittir. Öğretmenler ders sayfasından tür seçerek ekler; ağırlık sınav türünde tanımlıdır. Öğrenciler yalnızca kendi notunu görür. Ağırlıklı ortalamalar Karnem’dedir.", |
| @@ -1011,6 +1022,7 @@ const tr: Dict = { | ||
| 1011 | 1022 | "form.contentMax": "İçerik en fazla 10 000 karakter olmalı", |
| 1012 | 1023 | "form.descriptionMax": "Açıklama en fazla 2 000 karakter olmalı", |
| 1013 | 1024 | "form.timeOrder": "Bitiş, başlangıçtan önce olamaz", |
| 1025 | + "form.timePast": "Başlangıç ve bitiş gelecekte olmalı", | |
| 1014 | 1026 | "form.weightRange": "Ağırlık 1–100 arası tam sayı olmalı", |
| 1015 | 1027 | "form.markRange": "Not 0–100 arası tam sayı olmalı", |
| 1016 | 1028 | "events.markedBy": "İşaretleyen", |
src/pages/course-detail-page.tsxmodified+4 -4
| @@ -10,6 +10,7 @@ import { patchCourseById } from "@/api/patchCourseById"; | ||
| 10 | 10 | import { postCourseEnrollment } from "@/api/postCourseEnrollment"; |
| 11 | 11 | import { postCourseExam } from "@/api/postCourseExam"; |
| 12 | 12 | import { formatApiError } from "@/api/client"; |
| 13 | +import { ExamLink } from "@/components/exams/exam-link"; | |
| 13 | 14 | import { ExamForm } from "@/components/exams/exam-form"; |
| 14 | 15 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 15 | 16 | import { PageHeader } from "@/components/layout/page-header"; |
| @@ -341,9 +342,8 @@ function CourseDetailContent() { | ||
| 341 | 342 | <For each={exams() ?? []}> |
| 342 | 343 | {(exam) => ( |
| 343 | 344 | <li> |
| 344 | - <Link | |
| 345 | - to="/exams/$id" | |
| 346 | - params={{ id: exam.id }} | |
| 345 | + <ExamLink | |
| 346 | + examId={exam.id} | |
| 347 | 347 | class="group flex items-start justify-between gap-3 rounded-lg border border-border/70 bg-background/60 px-4 py-3 transition-all hover:-translate-y-0.5 hover:border-primary/30 hover:bg-accent/35 hover:shadow-sm" |
| 348 | 348 | > |
| 349 | 349 | <div class="min-w-0 space-y-2"> |
| @@ -362,7 +362,7 @@ function CourseDetailContent() { | ||
| 362 | 362 | </Badge> |
| 363 | 363 | </div> |
| 364 | 364 | </div> |
| 365 | - </Link> | |
| 365 | + </ExamLink> | |
| 366 | 366 | </li> |
| 367 | 367 | )} |
| 368 | 368 | </For> |
src/pages/dashboard-page.tsxmodified+4 -4
| @@ -7,6 +7,7 @@ import { getMyMarks } from "@/api/getMyMarks"; | ||
| 7 | 7 | import { getNotes } from "@/api/getNotes"; |
| 8 | 8 | import { formatApiError } from "@/api/client"; |
| 9 | 9 | import type { Event, Exam, Note } from "@/api/types"; |
| 10 | +import { ExamLink } from "@/components/exams/exam-link"; | |
| 10 | 11 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 11 | 12 | import { PageHeader } from "@/components/layout/page-header"; |
| 12 | 13 | import { Alert } from "@/components/ui/alert"; |
| @@ -247,9 +248,8 @@ function DashboardContent() { | ||
| 247 | 248 | <For each={previewExams()}> |
| 248 | 249 | {(exam: Exam) => ( |
| 249 | 250 | <li> |
| 250 | - <Link | |
| 251 | - to="/exams/$id" | |
| 252 | - params={{ id: exam.id }} | |
| 251 | + <ExamLink | |
| 252 | + examId={exam.id} | |
| 253 | 253 | class="flex min-h-[3.5rem] items-center justify-between gap-3 rounded-lg border border-border/70 bg-muted/25 px-3 py-2.5 transition-colors hover:border-primary/35 hover:bg-primary/[0.05]" |
| 254 | 254 | > |
| 255 | 255 | <div class="min-w-0"> |
| @@ -261,7 +261,7 @@ function DashboardContent() { | ||
| 261 | 261 | <Badge variant="outline" class="shrink-0 capitalize"> |
| 262 | 262 | {examKindLabel(String(exam.kind), t)} |
| 263 | 263 | </Badge> |
| 264 | - </Link> | |
| 264 | + </ExamLink> | |
| 265 | 265 | </li> |
| 266 | 266 | )} |
| 267 | 267 | </For> |
src/pages/live-monitor-page.tsxmodified+24 -6
| @@ -19,7 +19,7 @@ import { createNow } from "@/lib/create-now"; | ||
| 19 | 19 | import { formatDateTime } from "@/lib/format"; |
| 20 | 20 | import { cn } from "@/lib/cn"; |
| 21 | 21 | |
| 22 | -type SortKey = "username" | "status" | "progress" | "remaining" | "activity" | "mark"; | |
| 22 | +type SortKey = "username" | "status" | "attempt" | "progress" | "remaining" | "left" | "mark"; | |
| 23 | 23 | |
| 24 | 24 | const PAGE_SIZE = 10; |
| 25 | 25 | |
| @@ -36,6 +36,7 @@ const STATUS_KEY: Record<string, MessageKey> = { | ||
| 36 | 36 | in_progress: "attempt.inProgress", |
| 37 | 37 | submitted: "attempt.submitted", |
| 38 | 38 | expired: "attempt.expired", |
| 39 | + absent: "attempt.absent", | |
| 39 | 40 | }; |
| 40 | 41 | |
| 41 | 42 | function labelFromStatus(status: string, t: (key: MessageKey) => string): string { |
| @@ -73,8 +74,9 @@ function liveRosterName(entry: LiveRosterEntry, fallback: string): string { | ||
| 73 | 74 | } |
| 74 | 75 | |
| 75 | 76 | function remainingMinutesLabel(entry: LiveRosterEntry): string { |
| 76 | - const remaining = entry.remaining_ms ?? 0; | |
| 77 | + const remaining = entry.remaining_ms; | |
| 77 | 78 | if (entry.status !== "in_progress") return "—"; |
| 79 | + if (remaining == null) return "—"; | |
| 78 | 80 | if (remaining > 0) return `${Math.ceil(remaining / 60000)}dk`; |
| 79 | 81 | return "<1dk"; |
| 80 | 82 | } |
| @@ -84,6 +86,13 @@ function isLowRemaining(entry: LiveRosterEntry): boolean { | ||
| 84 | 86 | return entry.status === "in_progress" && remaining <= 5 * 60 * 1000; |
| 85 | 87 | } |
| 86 | 88 | |
| 89 | +function attemptLabel(entry: LiveRosterEntry): string { | |
| 90 | + if (entry.attempts_used != null && entry.max_attempts != null) return `${entry.attempts_used} / ${entry.max_attempts}`; | |
| 91 | + if (entry.attempt != null) return String(entry.attempt); | |
| 92 | + if (entry.attempts_used != null) return String(entry.attempts_used); | |
| 93 | + return "—"; | |
| 94 | +} | |
| 95 | + | |
| 87 | 96 | function LiveMonitorContent() { |
| 88 | 97 | const params = useParams({ from: "/exams/$id/live" }); |
| 89 | 98 | const t = useT(); |
| @@ -185,9 +194,10 @@ function LiveMonitorContent() { | ||
| 185 | 194 | const k = sortKey(); |
| 186 | 195 | if (k === "username") return liveRosterName(a, "").localeCompare(liveRosterName(b, "")); |
| 187 | 196 | if (k === "status") return labelFromStatus(a.status, t).localeCompare(labelFromStatus(b.status, t)); |
| 197 | + if (k === "attempt") return (a.attempts_used ?? a.attempt ?? 0) - (b.attempts_used ?? b.attempt ?? 0); | |
| 188 | 198 | if (k === "progress") return (a.answered ?? 0) - (b.answered ?? 0); |
| 189 | 199 | if (k === "remaining") return (a.remaining_ms ?? 0) - (b.remaining_ms ?? 0); |
| 190 | - if (k === "activity") return (a.last_activity ?? 0) - (b.last_activity ?? 0); | |
| 200 | + if (k === "left") return (a.left_at ?? 0) - (b.left_at ?? 0); | |
| 191 | 201 | if (k === "mark") return (a.mark ?? -1) - (b.mark ?? -1); |
| 192 | 202 | return 0; |
| 193 | 203 | })(); |
| @@ -237,7 +247,7 @@ function LiveMonitorContent() { | ||
| 237 | 247 | |
| 238 | 248 | return ( |
| 239 | 249 | <> |
| 240 | - <section class="grid gap-3 sm:grid-cols-2 lg:grid-cols-4"> | |
| 250 | + <section class="grid gap-3 sm:grid-cols-2 lg:grid-cols-5"> | |
| 241 | 251 | <div class="surface-card bg-card/80 p-4"> |
| 242 | 252 | <p class="text-xs text-muted-foreground">{t("exams.notStarted")}</p> |
| 243 | 253 | <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.not_started}</p> |
| @@ -254,6 +264,10 @@ function LiveMonitorContent() { | ||
| 254 | 264 | <p class="text-xs text-muted-foreground">{t("attempt.expired")}</p> |
| 255 | 265 | <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.expired}</p> |
| 256 | 266 | </div> |
| 267 | + <div class="surface-card bg-card/80 p-4"> | |
| 268 | + <p class="text-xs text-muted-foreground">{t("attempt.absent")}</p> | |
| 269 | + <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.absent ?? 0}</p> | |
| 270 | + </div> | |
| 257 | 271 | </section> |
| 258 | 272 | |
| 259 | 273 | <section class="surface-card space-y-4 p-5"> |
| @@ -280,9 +294,10 @@ function LiveMonitorContent() { | ||
| 280 | 294 | <TableRow> |
| 281 | 295 | <SortHead label={t("admin.username")} sortKey="username" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-left" /> |
| 282 | 296 | <SortHead label={t("attempt.status")} sortKey="status" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" /> |
| 297 | + <SortHead label={t("attempt.attempt")} sortKey="attempt" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" /> | |
| 283 | 298 | <SortHead label={t("attempt.progress")} sortKey="progress" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" /> |
| 284 | 299 | <SortHead label={t("attempt.remaining")} sortKey="remaining" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" /> |
| 285 | - <SortHead label={t("exams.lastActivity")} sortKey="activity" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" /> | |
| 300 | + <SortHead label={t("attempt.left")} sortKey="left" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" /> | |
| 286 | 301 | <SortHead label={t("marks.mark")} sortKey="mark" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" /> |
| 287 | 302 | </TableRow> |
| 288 | 303 | </TableHeader> |
| @@ -305,6 +320,9 @@ function LiveMonitorContent() { | ||
| 305 | 320 | {labelFromStatus(entry.status, t)} |
| 306 | 321 | </Badge> |
| 307 | 322 | </TableCell> |
| 323 | + <TableCell class="text-center tabular-nums"> | |
| 324 | + {attemptLabel(entry)} | |
| 325 | + </TableCell> | |
| 308 | 326 | <TableCell class="min-w-32 tabular-nums"> |
| 309 | 327 | <div class="flex items-center justify-center gap-2"> |
| 310 | 328 | <span>{entry.answered}/{m.question_count}</span> |
| @@ -319,7 +337,7 @@ function LiveMonitorContent() { | ||
| 319 | 337 | </span> |
| 320 | 338 | </TableCell> |
| 321 | 339 | <TableCell class="text-center text-xs"> |
| 322 | - {entry.last_activity ? formatDateTime(entry.last_activity, locale()) : "—"} | |
| 340 | + {entry.left_at ? formatDateTime(entry.left_at, locale()) : "—"} | |
| 323 | 341 | </TableCell> |
| 324 | 342 | <TableCell class="text-center font-semibold tabular-nums"> |
| 325 | 343 | {entry.mark != null ? entry.mark : "—"} |