forge
Explore
Log in

Don't you dare go Hollow

✨ implement exam link component and enhance exam-related UI features

Browse files at this commit

3f5a474a8a922bf1da31586337c844a8869a6a13Burak BoduroğluParent: ee0b44d
  • feat
    • ✨ implement exam link component and enhance exam-related UI features
Show full message
feat: ✨ implement exam link component and enhance exam-related UI features
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 - Run `bun run build` before every commit.28 - Run `bun run build` before every commit.
29 - Commit messages must follow repository rules and require explicit user approval.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 ## Remaining Commit Order37 ## Remaining Commit Order
32 38
33 | Commit | Scope | Priority |39 | Commit | Scope | Priority |
34 | --- | --- | --- |40 | --- | --- | --- |
35-| 1 | Live monitor + exam room attempt fields | High |
36-| 2 | Marks grade-band labels | High |
37 | 3 | Settings management page | High |41 | 3 | Settings management page | High |
38 | 4 | Terms API + course term select | Medium |42 | 4 | Terms API + course term select | Medium |
39 | 5 | Course sessions + roll call | Medium |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 - `LiveRosterEntry.status`: includes `absent`.55 - `LiveRosterEntry.status`: includes `absent`.
52 - `LiveRosterEntry.attempt`.56 - `LiveRosterEntry.attempt`.
53 - `LiveRosterEntry.attempts_used`.57 - `LiveRosterEntry.attempts_used`.
58+- `LiveRosterEntry.max_attempts`.
54 - `LiveRosterEntry.left_at`.59 - `LiveRosterEntry.left_at`.
55 - `LiveMonitor.counts.absent`.60 - `LiveMonitor.counts.absent`.
56 - `ExamAttempt.attempt`.61 - `ExamAttempt.attempt`.
src/api/types.tsmodified+4 -0
@@ -149,6 +149,7 @@ export type MarkEntry = {
149 type_weight?: number | null;149 type_weight?: number | null;
150 exam_type_weight?: number | null;150 exam_type_weight?: number | null;
151 mark: number;151 mark: number;
152+ grade?: string | null;
152 graded_by: string;153 graded_by: string;
153 };154 };
154 155
@@ -156,12 +157,14 @@ export type CourseMarks = {
156 course: Course;157 course: Course;
157 results: MarkEntry[];158 results: MarkEntry[];
158 average: number | null;159 average: number | null;
160+ average_grade?: string | null;
159 };161 };
160 162
161 export type MarksReport = {163 export type MarksReport = {
162 user: string;164 user: string;
163 courses: CourseMarks[];165 courses: CourseMarks[];
164 overall_average: number | null;166 overall_average: number | null;
167+ overall_grade?: string | null;
165 };168 };
166 169
167 export type ExamStatistics = {170 export type ExamStatistics = {
@@ -195,6 +198,7 @@ export type LiveRosterEntry = {
195 status: AttemptStatus | "not_started" | "absent";198 status: AttemptStatus | "not_started" | "absent";
196 attempt?: number | null;199 attempt?: number | null;
197 attempts_used?: number | null;200 attempts_used?: number | null;
201+ max_attempts?: number | null;
198 deadline: number | null;202 deadline: number | null;
199 remaining_ms: number | null;203 remaining_ms: number | null;
200 left_at?: number | null;204 left_at?: number | null;
src/components/exams/exam-card.tsxmodified+3 -3
@@ -1,7 +1,7 @@
1 import { Show } from "solid-js";1 import { Show } from "solid-js";
2-import { Link } from "@tanstack/solid-router";
3 import type { Exam } from "@/api/types";2 import type { Exam } from "@/api/types";
4 import { Badge } from "@/components/ui/badge";3 import { Badge } from "@/components/ui/badge";
4+import { ExamLink } from "@/components/exams/exam-link";
5 import { cn } from "@/lib/cn";5 import { cn } from "@/lib/cn";
6 import { examKindLabel } from "@/lib/exam-labels";6 import { examKindLabel } from "@/lib/exam-labels";
7 import { examWeight } from "@/lib/exam-weight";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 return (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 <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">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 <div class="absolute inset-x-0 top-0 h-1 bg-gradient-to-r from-rose-500/70 via-amber-400/50 to-transparent" />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 <div class="flex flex-1 flex-col p-4">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 </dl>111 </dl>
112 </div>112 </div>
113 </article>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 return `${pad(d.getHours())}:${pad(d.getMinutes())}`;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 function scheduleInputToMs(date: string, time: string): number | null {37 function scheduleInputToMs(date: string, time: string): number | null {
33 const dateMatch = date.trim().match(/^(\d{2})\/(\d{2})\/(\d{4})$/);38 const dateMatch = date.trim().match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
34 const timeMatch = time.trim().match(/^(\d{2}):(\d{2})$/);39 const timeMatch = time.trim().match(/^(\d{2}):(\d{2})$/);
@@ -83,6 +88,7 @@ export function ExamForm(props: {
83 const [startsTime, setStartsTime] = createSignal(timeInputFromMs(props.initial?.starts_at));88 const [startsTime, setStartsTime] = createSignal(timeInputFromMs(props.initial?.starts_at));
84 const [endsDate, setEndsDate] = createSignal(dateInputFromMs(props.initial?.ends_at));89 const [endsDate, setEndsDate] = createSignal(dateInputFromMs(props.initial?.ends_at));
85 const [endsTime, setEndsTime] = createSignal(timeInputFromMs(props.initial?.ends_at));90 const [endsTime, setEndsTime] = createSignal(timeInputFromMs(props.initial?.ends_at));
91+ const [durationMinutes, setDurationMinutes] = createSignal(durationMinutesFromMs(props.initial?.duration_ms));
86 const [error, setError] = createSignal("");92 const [error, setError] = createSignal("");
87 const [pending, setPending] = createSignal(false);93 const [pending, setPending] = createSignal(false);
88 const [confirmOpen, setConfirmOpen] = createSignal(false);94 const [confirmOpen, setConfirmOpen] = createSignal(false);
@@ -100,7 +106,7 @@ export function ExamForm(props: {
100 if (names.length > 0 && !names.includes(kind())) setKind(names[0]);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 const value = title().trim();110 const value = title().trim();
105 if (!value) return t("form.titleRequired");111 if (!value) return t("form.titleRequired");
106 if (value.length > 200) return t("form.titleMax");112 if (value.length > 200) return t("form.titleMax");
@@ -110,6 +116,11 @@ export function ExamForm(props: {
110 if (mode() === "sync" || mode() === "async") {116 if (mode() === "sync" || mode() === "async") {
111 if (starts == null || ends == null) return t("exams.scheduleRequired");117 if (starts == null || ends == null) return t("exams.scheduleRequired");
112 if (ends <= starts) return t("form.timeOrder");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 return null;125 return null;
115 };126 };
@@ -130,6 +141,7 @@ export function ExamForm(props: {
130 setStartsTime("");141 setStartsTime("");
131 setEndsDate("");142 setEndsDate("");
132 setEndsTime("");143 setEndsTime("");
144+ setDurationMinutes("");
133 }145 }
134 } catch (err) {146 } catch (err) {
135 setError(formatApiError(err));147 setError(formatApiError(err));
@@ -143,8 +155,9 @@ export function ExamForm(props: {
143 const hasWindow = mode() === "sync" || mode() === "async";155 const hasWindow = mode() === "sync" || mode() === "async";
144 const starts_at = hasWindow ? scheduleInputToMs(startsDate(), startsTime()) : null;156 const starts_at = hasWindow ? scheduleInputToMs(startsDate(), startsTime()) : null;
145 const ends_at = hasWindow ? scheduleInputToMs(endsDate(), endsTime()) : null;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;158+ const durationValue = Number(durationMinutes());
147- const v = validate(starts_at, ends_at);159+ const duration_ms = mode() === "async" && Number.isFinite(durationValue) ? durationValue * 60000 : null;
160+ const v = validate(starts_at, ends_at, duration_ms);
148 if (v) {161 if (v) {
149 setError(v);162 setError(v);
150 return;163 return;
@@ -300,6 +313,22 @@ export function ExamForm(props: {
300 </div>313 </div>
301 </div>314 </div>
302 </Show>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 {error() && <p class="text-sm text-destructive">{error()}</p>}332 {error() && <p class="text-sm text-destructive">{error()}</p>}
304 <div class="flex flex-wrap items-center gap-2">333 <div class="flex flex-wrap items-center gap-2">
305 <Button type="submit" disabled={pending()}>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 if (props.wsState === "connected") return t("ws.connected");358 if (props.wsState === "connected") return t("ws.connected");
359 return t("ws.disconnected");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 return (367 return (
362 <div class="grid auto-rows-fr gap-3 text-sm sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-6">368 <div class="grid auto-rows-fr gap-3 text-sm sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-6">
363 <div class="h-full rounded-lg border bg-background/60 p-3">369 <div class="h-full rounded-lg border bg-background/60 p-3">
364 <p class="text-xs text-muted-foreground">{t("attempt.status")}</p>370 <p class="text-xs text-muted-foreground">{t("attempt.status")}</p>
365 <p class="mt-1 font-medium">{statusLabel()}</p>371 <p class="mt-1 font-medium">{statusLabel()}</p>
366 </div>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 <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"}>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 <p class="text-xs text-muted-foreground">{t("attempt.remaining")}</p>378 <p class="text-xs text-muted-foreground">{t("attempt.remaining")}</p>
369 <p class="mt-1 font-mono text-lg font-semibold tabular-nums">{formatRemaining(props.remainingMs)}</p>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 <p class="mt-1 font-medium">{props.attempt.mark}</p>406 <p class="mt-1 font-medium">{props.attempt.mark}</p>
397 </div>407 </div>
398 </Show>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 </div>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 import { Link } from "@tanstack/solid-router";2 import { Link } from "@tanstack/solid-router";
3 import type { MarksReport } from "@/api/types";3 import type { MarksReport } from "@/api/types";
4 import { Badge } from "@/components/ui/badge";4 import { Badge } from "@/components/ui/badge";
5+import { ExamLink } from "@/components/exams/exam-link";
5 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";6 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
6 import { examKindLabel } from "@/lib/exam-labels";7 import { examKindLabel } from "@/lib/exam-labels";
7 import { examWeight } from "@/lib/exam-weight";8 import { examWeight } from "@/lib/exam-weight";
@@ -9,6 +10,11 @@ import { useT } from "@/stores/preferences-context";
9 10
10 const round = (n: number) => (Math.round(n * 100) / 100).toString();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 export function MarksReportView(props: { report: MarksReport }) {18 export function MarksReportView(props: { report: MarksReport }) {
13 const t = useT();19 const t = useT();
14 return (20 return (
@@ -24,7 +30,7 @@ export function MarksReportView(props: { report: MarksReport }) {
24 <div class="surface-card flex flex-wrap items-center justify-between gap-3 p-5">30 <div class="surface-card flex flex-wrap items-center justify-between gap-3 p-5">
25 <span class="text-sm font-medium text-muted-foreground">{t("marks.overall")}</span>31 <span class="text-sm font-medium text-muted-foreground">{t("marks.overall")}</span>
26 <p class="font-display text-3xl font-semibold tabular-nums">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 <Show when={props.report.overall_average != null}>34 <Show when={props.report.overall_average != null}>
29 <span class="text-base font-medium text-muted-foreground"> / 100</span>35 <span class="text-base font-medium text-muted-foreground"> / 100</span>
30 </Show>36 </Show>
@@ -41,7 +47,7 @@ export function MarksReportView(props: { report: MarksReport }) {
41 </Link>47 </Link>
42 </h3>48 </h3>
43 <Badge variant="secondary" class="rounded-full px-3 py-1" title={t("marks.courseAvg")}>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 </Badge>51 </Badge>
46 </header>52 </header>
47 53
@@ -68,9 +74,9 @@ export function MarksReportView(props: { report: MarksReport }) {
68 {(entry) => (74 {(entry) => (
69 <TableRow>75 <TableRow>
70 <TableCell>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 {entry.title}78 {entry.title}
73- </Link>79+ </ExamLink>
74 </TableCell>80 </TableCell>
75 <TableCell>81 <TableCell>
76 <Badge variant="outline" class="rounded-full capitalize">82 <Badge variant="outline" class="rounded-full capitalize">
@@ -78,7 +84,7 @@ export function MarksReportView(props: { report: MarksReport }) {
78 </Badge>84 </Badge>
79 </TableCell>85 </TableCell>
80 <TableCell class="tabular-nums">{examWeight(entry) ?? "—"}</TableCell>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 </TableRow>88 </TableRow>
83 )}89 )}
84 </For>90 </For>
src/i18n/messages.tsmodified+12 -0
@@ -206,6 +206,8 @@ export type MessageKey =
206 | "attempt.finish"206 | "attempt.finish"
207 | "attempt.status"207 | "attempt.status"
208 | "attempt.remaining"208 | "attempt.remaining"
209+ | "attempt.attempt"
210+ | "attempt.left"
209 | "attempt.progress"211 | "attempt.progress"
210 | "attempt.deadline"212 | "attempt.deadline"
211 | "attempt.notStarted"213 | "attempt.notStarted"
@@ -219,6 +221,7 @@ export type MessageKey =
219 | "attempt.expired"221 | "attempt.expired"
220 | "attempt.closed"222 | "attempt.closed"
221 | "attempt.inProgress"223 | "attempt.inProgress"
224+ | "attempt.absent"
222 | "exams.helpTitle"225 | "exams.helpTitle"
223 | "exams.helpBody"226 | "exams.helpBody"
224 | "admin.title"227 | "admin.title"
@@ -266,6 +269,7 @@ export type MessageKey =
266 | "form.contentMax"269 | "form.contentMax"
267 | "form.descriptionMax"270 | "form.descriptionMax"
268 | "form.timeOrder"271 | "form.timeOrder"
272+ | "form.timePast"
269 | "form.weightRange"273 | "form.weightRange"
270 | "form.markRange"274 | "form.markRange"
271 | "events.markedBy"275 | "events.markedBy"
@@ -568,6 +572,8 @@ const en: Dict = {
568 "attempt.finish": "Finish exam",572 "attempt.finish": "Finish exam",
569 "attempt.status": "Status",573 "attempt.status": "Status",
570 "attempt.remaining": "Remaining",574 "attempt.remaining": "Remaining",
575+ "attempt.attempt": "Attempt",
576+ "attempt.left": "Left",
571 "attempt.progress": "Progress",577 "attempt.progress": "Progress",
572 "attempt.deadline": "Deadline",578 "attempt.deadline": "Deadline",
573 "attempt.notStarted": "Start the scheduled exam to see questions.",579 "attempt.notStarted": "Start the scheduled exam to see questions.",
@@ -581,6 +587,7 @@ const en: Dict = {
581 "attempt.expired": "Expired",587 "attempt.expired": "Expired",
582 "attempt.closed": "This attempt is closed. Answers are read-only.",588 "attempt.closed": "This attempt is closed. Answers are read-only.",
583 "attempt.inProgress": "In progress",589 "attempt.inProgress": "In progress",
590+ "attempt.absent": "No-show",
584 "exams.helpTitle": "About exams",591 "exams.helpTitle": "About exams",
585 "exams.helpBody":592 "exams.helpBody":
586 "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.",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 "form.contentMax": "Content must be at most 10 000 characters",646 "form.contentMax": "Content must be at most 10 000 characters",
640 "form.descriptionMax": "Description must be at most 2 000 characters",647 "form.descriptionMax": "Description must be at most 2 000 characters",
641 "form.timeOrder": "End time must be on or after start time",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 "form.weightRange": "Weight must be an integer from 1 to 100",650 "form.weightRange": "Weight must be an integer from 1 to 100",
643 "form.markRange": "Mark must be an integer from 0 to 100",651 "form.markRange": "Mark must be an integer from 0 to 100",
644 "events.markedBy": "Marked by",652 "events.markedBy": "Marked by",
@@ -940,6 +948,8 @@ const tr: Dict = {
940 "attempt.finish": "Sınavı bitir",948 "attempt.finish": "Sınavı bitir",
941 "attempt.status": "Durum",949 "attempt.status": "Durum",
942 "attempt.remaining": "Kalan süre",950 "attempt.remaining": "Kalan süre",
951+ "attempt.attempt": "Deneme",
952+ "attempt.left": "Çıkış",
943 "attempt.progress": "İlerleme",953 "attempt.progress": "İlerleme",
944 "attempt.deadline": "Bitiş zamanı",954 "attempt.deadline": "Bitiş zamanı",
945 "attempt.notStarted": "Soruları görmek için zamanlı sınavı başlat.",955 "attempt.notStarted": "Soruları görmek için zamanlı sınavı başlat.",
@@ -953,6 +963,7 @@ const tr: Dict = {
953 "attempt.expired": "Süresi doldu",963 "attempt.expired": "Süresi doldu",
954 "attempt.closed": "Bu oturum kapalı. Cevaplar salt okunur.",964 "attempt.closed": "Bu oturum kapalı. Cevaplar salt okunur.",
955 "attempt.inProgress": "Devam ediyor",965 "attempt.inProgress": "Devam ediyor",
966+ "attempt.absent": "Katılmadı",
956 "exams.helpTitle": "Sınavlar hakkında",967 "exams.helpTitle": "Sınavlar hakkında",
957 "exams.helpBody":968 "exams.helpBody":
958 "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.",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 "form.contentMax": "İçerik en fazla 10 000 karakter olmalı",1022 "form.contentMax": "İçerik en fazla 10 000 karakter olmalı",
1012 "form.descriptionMax": "Açıklama en fazla 2 000 karakter olmalı",1023 "form.descriptionMax": "Açıklama en fazla 2 000 karakter olmalı",
1013 "form.timeOrder": "Bitiş, başlangıçtan önce olamaz",1024 "form.timeOrder": "Bitiş, başlangıçtan önce olamaz",
1025+ "form.timePast": "Başlangıç ve bitiş gelecekte olmalı",
1014 "form.weightRange": "Ağırlık 1–100 arası tam sayı olmalı",1026 "form.weightRange": "Ağırlık 1–100 arası tam sayı olmalı",
1015 "form.markRange": "Not 0–100 arası tam sayı olmalı",1027 "form.markRange": "Not 0–100 arası tam sayı olmalı",
1016 "events.markedBy": "İşaretleyen",1028 "events.markedBy": "İşaretleyen",
src/pages/course-detail-page.tsxmodified+4 -4
@@ -10,6 +10,7 @@ import { patchCourseById } from "@/api/patchCourseById";
10 import { postCourseEnrollment } from "@/api/postCourseEnrollment";10 import { postCourseEnrollment } from "@/api/postCourseEnrollment";
11 import { postCourseExam } from "@/api/postCourseExam";11 import { postCourseExam } from "@/api/postCourseExam";
12 import { formatApiError } from "@/api/client";12 import { formatApiError } from "@/api/client";
13+import { ExamLink } from "@/components/exams/exam-link";
13 import { ExamForm } from "@/components/exams/exam-form";14 import { ExamForm } from "@/components/exams/exam-form";
14 import { RouteGuard } from "@/components/layout/route-guard";15 import { RouteGuard } from "@/components/layout/route-guard";
15 import { PageHeader } from "@/components/layout/page-header";16 import { PageHeader } from "@/components/layout/page-header";
@@ -341,9 +342,8 @@ function CourseDetailContent() {
341 <For each={exams() ?? []}>342 <For each={exams() ?? []}>
342 {(exam) => (343 {(exam) => (
343 <li>344 <li>
344- <Link345+ <ExamLink
345- to="/exams/$id"346+ examId={exam.id}
346- params={{ id: exam.id }}
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"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 <div class="min-w-0 space-y-2">349 <div class="min-w-0 space-y-2">
@@ -362,7 +362,7 @@ function CourseDetailContent() {
362 </Badge>362 </Badge>
363 </div>363 </div>
364 </div>364 </div>
365- </Link>365+ </ExamLink>
366 </li>366 </li>
367 )}367 )}
368 </For>368 </For>
src/pages/dashboard-page.tsxmodified+4 -4
@@ -7,6 +7,7 @@ import { getMyMarks } from "@/api/getMyMarks";
7 import { getNotes } from "@/api/getNotes";7 import { getNotes } from "@/api/getNotes";
8 import { formatApiError } from "@/api/client";8 import { formatApiError } from "@/api/client";
9 import type { Event, Exam, Note } from "@/api/types";9 import type { Event, Exam, Note } from "@/api/types";
10+import { ExamLink } from "@/components/exams/exam-link";
10 import { RouteGuard } from "@/components/layout/route-guard";11 import { RouteGuard } from "@/components/layout/route-guard";
11 import { PageHeader } from "@/components/layout/page-header";12 import { PageHeader } from "@/components/layout/page-header";
12 import { Alert } from "@/components/ui/alert";13 import { Alert } from "@/components/ui/alert";
@@ -247,9 +248,8 @@ function DashboardContent() {
247 <For each={previewExams()}>248 <For each={previewExams()}>
248 {(exam: Exam) => (249 {(exam: Exam) => (
249 <li>250 <li>
250- <Link251+ <ExamLink
251- to="/exams/$id"252+ examId={exam.id}
252- params={{ id: exam.id }}
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]"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 <div class="min-w-0">255 <div class="min-w-0">
@@ -261,7 +261,7 @@ function DashboardContent() {
261 <Badge variant="outline" class="shrink-0 capitalize">261 <Badge variant="outline" class="shrink-0 capitalize">
262 {examKindLabel(String(exam.kind), t)}262 {examKindLabel(String(exam.kind), t)}
263 </Badge>263 </Badge>
264- </Link>264+ </ExamLink>
265 </li>265 </li>
266 )}266 )}
267 </For>267 </For>
src/pages/live-monitor-page.tsxmodified+24 -6
@@ -19,7 +19,7 @@ import { createNow } from "@/lib/create-now";
19 import { formatDateTime } from "@/lib/format";19 import { formatDateTime } from "@/lib/format";
20 import { cn } from "@/lib/cn";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 const PAGE_SIZE = 10;24 const PAGE_SIZE = 10;
25 25
@@ -36,6 +36,7 @@ const STATUS_KEY: Record<string, MessageKey> = {
36 in_progress: "attempt.inProgress",36 in_progress: "attempt.inProgress",
37 submitted: "attempt.submitted",37 submitted: "attempt.submitted",
38 expired: "attempt.expired",38 expired: "attempt.expired",
39+ absent: "attempt.absent",
39 };40 };
40 41
41 function labelFromStatus(status: string, t: (key: MessageKey) => string): string {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 function remainingMinutesLabel(entry: LiveRosterEntry): string {76 function remainingMinutesLabel(entry: LiveRosterEntry): string {
76- const remaining = entry.remaining_ms ?? 0;77+ const remaining = entry.remaining_ms;
77 if (entry.status !== "in_progress") return "—";78 if (entry.status !== "in_progress") return "—";
79+ if (remaining == null) return "—";
78 if (remaining > 0) return `${Math.ceil(remaining / 60000)}dk`;80 if (remaining > 0) return `${Math.ceil(remaining / 60000)}dk`;
79 return "<1dk";81 return "<1dk";
80 }82 }
@@ -84,6 +86,13 @@ function isLowRemaining(entry: LiveRosterEntry): boolean {
84 return entry.status === "in_progress" && remaining <= 5 * 60 * 1000;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 function LiveMonitorContent() {96 function LiveMonitorContent() {
88 const params = useParams({ from: "/exams/$id/live" });97 const params = useParams({ from: "/exams/$id/live" });
89 const t = useT();98 const t = useT();
@@ -185,9 +194,10 @@ function LiveMonitorContent() {
185 const k = sortKey();194 const k = sortKey();
186 if (k === "username") return liveRosterName(a, "").localeCompare(liveRosterName(b, ""));195 if (k === "username") return liveRosterName(a, "").localeCompare(liveRosterName(b, ""));
187 if (k === "status") return labelFromStatus(a.status, t).localeCompare(labelFromStatus(b.status, t));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 if (k === "progress") return (a.answered ?? 0) - (b.answered ?? 0);198 if (k === "progress") return (a.answered ?? 0) - (b.answered ?? 0);
189 if (k === "remaining") return (a.remaining_ms ?? 0) - (b.remaining_ms ?? 0);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 if (k === "mark") return (a.mark ?? -1) - (b.mark ?? -1);201 if (k === "mark") return (a.mark ?? -1) - (b.mark ?? -1);
192 return 0;202 return 0;
193 })();203 })();
@@ -237,7 +247,7 @@ function LiveMonitorContent() {
237 247
238 return (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 <div class="surface-card bg-card/80 p-4">251 <div class="surface-card bg-card/80 p-4">
242 <p class="text-xs text-muted-foreground">{t("exams.notStarted")}</p>252 <p class="text-xs text-muted-foreground">{t("exams.notStarted")}</p>
243 <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.not_started}</p>253 <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.not_started}</p>
@@ -254,6 +264,10 @@ function LiveMonitorContent() {
254 <p class="text-xs text-muted-foreground">{t("attempt.expired")}</p>264 <p class="text-xs text-muted-foreground">{t("attempt.expired")}</p>
255 <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.expired}</p>265 <p class="mt-1 font-display text-2xl font-semibold tabular-nums">{counts.expired}</p>
256 </div>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 </section>271 </section>
258 272
259 <section class="surface-card space-y-4 p-5">273 <section class="surface-card space-y-4 p-5">
@@ -280,9 +294,10 @@ function LiveMonitorContent() {
280 <TableRow>294 <TableRow>
281 <SortHead label={t("admin.username")} sortKey="username" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-left" />295 <SortHead label={t("admin.username")} sortKey="username" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-left" />
282 <SortHead label={t("attempt.status")} sortKey="status" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" />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 <SortHead label={t("attempt.progress")} sortKey="progress" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" />298 <SortHead label={t("attempt.progress")} sortKey="progress" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" />
284 <SortHead label={t("attempt.remaining")} sortKey="remaining" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" />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 <SortHead label={t("marks.mark")} sortKey="mark" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" />301 <SortHead label={t("marks.mark")} sortKey="mark" currentKey={sortKey()} currentDir={sortDir()} onSort={toggleSort} class="text-center" />
287 </TableRow>302 </TableRow>
288 </TableHeader>303 </TableHeader>
@@ -305,6 +320,9 @@ function LiveMonitorContent() {
305 {labelFromStatus(entry.status, t)}320 {labelFromStatus(entry.status, t)}
306 </Badge>321 </Badge>
307 </TableCell>322 </TableCell>
323+ <TableCell class="text-center tabular-nums">
324+ {attemptLabel(entry)}
325+ </TableCell>
308 <TableCell class="min-w-32 tabular-nums">326 <TableCell class="min-w-32 tabular-nums">
309 <div class="flex items-center justify-center gap-2">327 <div class="flex items-center justify-center gap-2">
310 <span>{entry.answered}/{m.question_count}</span>328 <span>{entry.answered}/{m.question_count}</span>
@@ -319,7 +337,7 @@ function LiveMonitorContent() {
319 </span>337 </span>
320 </TableCell>338 </TableCell>
321 <TableCell class="text-center text-xs">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 </TableCell>341 </TableCell>
324 <TableCell class="text-center font-semibold tabular-nums">342 <TableCell class="text-center font-semibold tabular-nums">
325 {entry.mark != null ? entry.mark : "—"}343 {entry.mark != null ? entry.mark : "—"}