From 3f5a474a8a922bf1da31586337c844a8869a6a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Wed, 15 Jul 2026 06:55:24 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20implement=20exam=20link=20c?= =?UTF-8?q?omponent=20and=20enhance=20exam-related=20UI=20features?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/backend-ui-alignment-plan.md | 9 ++++-- src/api/types.ts | 4 +++ src/components/exams/exam-card.tsx | 6 ++-- src/components/exams/exam-form.tsx | 35 ++++++++++++++++++++-- src/components/exams/exam-link.tsx | 19 ++++++++++++ src/components/exams/exam-room-ws.tsx | 16 ++++++++++ src/components/marks/marks-report-view.tsx | 16 ++++++---- src/i18n/messages.ts | 12 ++++++++ src/pages/course-detail-page.tsx | 8 ++--- src/pages/dashboard-page.tsx | 8 ++--- src/pages/live-monitor-page.tsx | 30 +++++++++++++++---- 11 files changed, 136 insertions(+), 27 deletions(-) create mode 100644 src/components/exams/exam-link.tsx diff --git a/docs/backend-ui-alignment-plan.md b/docs/backend-ui-alignment-plan.md index f68e8cd..6355180 100644 --- a/docs/backend-ui-alignment-plan.md +++ b/docs/backend-ui-alignment-plan.md @@ -28,12 +28,16 @@ This plan covers the remaining backend features that need simple, low-complexity - Run `bun run build` before every commit. - Commit messages must follow repository rules and require explicit user approval. +## Status + +- 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. +- Commit 2 complete in UI: report card types accept grade-band fields and marks show `mark / grade` when backend sends labels. +- Commits 3-7 remain. + ## Remaining Commit Order | Commit | Scope | Priority | | --- | --- | --- | -| 1 | Live monitor + exam room attempt fields | High | -| 2 | Marks grade-band labels | High | | 3 | Settings management page | High | | 4 | Terms API + course term select | Medium | | 5 | Course sessions + roll call | Medium | @@ -51,6 +55,7 @@ Expose backend attempt, no-show, and room-left fields without making the UI comp - `LiveRosterEntry.status`: includes `absent`. - `LiveRosterEntry.attempt`. - `LiveRosterEntry.attempts_used`. +- `LiveRosterEntry.max_attempts`. - `LiveRosterEntry.left_at`. - `LiveMonitor.counts.absent`. - `ExamAttempt.attempt`. diff --git a/src/api/types.ts b/src/api/types.ts index b3d92f1..5cfb5cc 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -149,6 +149,7 @@ export type MarkEntry = { type_weight?: number | null; exam_type_weight?: number | null; mark: number; + grade?: string | null; graded_by: string; }; @@ -156,12 +157,14 @@ export type CourseMarks = { course: Course; results: MarkEntry[]; average: number | null; + average_grade?: string | null; }; export type MarksReport = { user: string; courses: CourseMarks[]; overall_average: number | null; + overall_grade?: string | null; }; export type ExamStatistics = { @@ -195,6 +198,7 @@ export type LiveRosterEntry = { status: AttemptStatus | "not_started" | "absent"; attempt?: number | null; attempts_used?: number | null; + max_attempts?: number | null; deadline: number | null; remaining_ms: number | null; left_at?: number | null; diff --git a/src/components/exams/exam-card.tsx b/src/components/exams/exam-card.tsx index d5b73f4..5b10bce 100644 --- a/src/components/exams/exam-card.tsx +++ b/src/components/exams/exam-card.tsx @@ -1,7 +1,7 @@ import { Show } from "solid-js"; -import { Link } from "@tanstack/solid-router"; import type { Exam } from "@/api/types"; import { Badge } from "@/components/ui/badge"; +import { ExamLink } from "@/components/exams/exam-link"; import { cn } from "@/lib/cn"; import { examKindLabel } from "@/lib/exam-labels"; import { examWeight } from "@/lib/exam-weight"; @@ -52,7 +52,7 @@ export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number }; return ( - +
@@ -111,6 +111,6 @@ export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number
- +
); } diff --git a/src/components/exams/exam-form.tsx b/src/components/exams/exam-form.tsx index 12429d5..55f71ba 100644 --- a/src/components/exams/exam-form.tsx +++ b/src/components/exams/exam-form.tsx @@ -29,6 +29,11 @@ function timeInputFromMs(ms: number | null | undefined): string { return `${pad(d.getHours())}:${pad(d.getMinutes())}`; } +function durationMinutesFromMs(ms: number | null | undefined): string { + if (ms == null) return ""; + return String(Math.round(ms / 60000)); +} + function scheduleInputToMs(date: string, time: string): number | null { const dateMatch = date.trim().match(/^(\d{2})\/(\d{2})\/(\d{4})$/); const timeMatch = time.trim().match(/^(\d{2}):(\d{2})$/); @@ -83,6 +88,7 @@ export function ExamForm(props: { const [startsTime, setStartsTime] = createSignal(timeInputFromMs(props.initial?.starts_at)); const [endsDate, setEndsDate] = createSignal(dateInputFromMs(props.initial?.ends_at)); const [endsTime, setEndsTime] = createSignal(timeInputFromMs(props.initial?.ends_at)); + const [durationMinutes, setDurationMinutes] = createSignal(durationMinutesFromMs(props.initial?.duration_ms)); const [error, setError] = createSignal(""); const [pending, setPending] = createSignal(false); const [confirmOpen, setConfirmOpen] = createSignal(false); @@ -100,7 +106,7 @@ export function ExamForm(props: { if (names.length > 0 && !names.includes(kind())) setKind(names[0]); }); - const validate = (starts: number | null, ends: number | null): string | null => { + const validate = (starts: number | null, ends: number | null, duration: number | null): string | null => { const value = title().trim(); if (!value) return t("form.titleRequired"); if (value.length > 200) return t("form.titleMax"); @@ -110,6 +116,11 @@ export function ExamForm(props: { if (mode() === "sync" || mode() === "async") { if (starts == null || ends == null) return t("exams.scheduleRequired"); if (ends <= starts) return t("form.timeOrder"); + if (!isEdit() && (starts < Date.now() || ends < Date.now())) return t("form.timePast"); + } + if (mode() === "async") { + if (duration == null) return t("exams.durationRequired"); + if (duration < 60000 || duration > 86400000) return t("exams.durationRange"); } return null; }; @@ -130,6 +141,7 @@ export function ExamForm(props: { setStartsTime(""); setEndsDate(""); setEndsTime(""); + setDurationMinutes(""); } } catch (err) { setError(formatApiError(err)); @@ -143,8 +155,9 @@ export function ExamForm(props: { const hasWindow = mode() === "sync" || mode() === "async"; const starts_at = hasWindow ? scheduleInputToMs(startsDate(), startsTime()) : null; const ends_at = hasWindow ? scheduleInputToMs(endsDate(), endsTime()) : null; - const duration_ms = mode() === "async" && starts_at != null && ends_at != null ? ends_at - starts_at : null; - const v = validate(starts_at, ends_at); + const durationValue = Number(durationMinutes()); + const duration_ms = mode() === "async" && Number.isFinite(durationValue) ? durationValue * 60000 : null; + const v = validate(starts_at, ends_at, duration_ms); if (v) { setError(v); return; @@ -300,6 +313,22 @@ export function ExamForm(props: { + +
+ + setDurationMinutes(e.currentTarget.value)} + /> +
+
{error() &&

{error()}

}