From 8dda6ac4c76f20b1ac108aaf30227032f96070f2 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 16:07:00 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20exam=20weight=20badge=20fro?= =?UTF-8?q?m=20settings,=20allowRejoin=20toggle,=20beforeLoad=20guards=20c?= =?UTF-8?q?omplete=20-=20exam-weight:=20resolve=20weight=20from=20GET=20/s?= =?UTF-8?q?ettings=20exam=5Fkinds=20by=20kind=20name=20fallback=20-=20exam?= =?UTF-8?q?-card=20+=20exam-detail=20+=20course-detail:=20pass=20settings?= =?UTF-8?q?=20exam=5Fkinds=20to=20examWeight=20-=20marks-report-view:=20re?= =?UTF-8?q?solve=20weight=20from=20settings=20for=20report=20entries=20-?= =?UTF-8?q?=20exam-form:=20allowRejoin=20checkbox=20with=20help=20text=20-?= =?UTF-8?q?=20routers:=20beforeLoad=20guards=20on=20exam-room=20(student),?= =?UTF-8?q?=20live=20(teacher+),=20settings/terms=20(manager+)=20-=20exam-?= =?UTF-8?q?detail:=20exam-room=20CTA=20uses=20isStudent()=20instead=20of?= =?UTF-8?q?=20!isTeacherPlus()=20-=20i18n:=20exams.allowRejoin,=20exams.al?= =?UTF-8?q?lowRejoinHelp=20-=20docs:=20mark=20all=20backlog=20items=20as?= =?UTF-8?q?=20done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/frontend-next-steps.md | 12 +++---- src/components/exams/exam-card.tsx | 6 ++-- src/components/exams/exam-form.tsx | 17 +++++++-- src/components/marks/marks-report-view.tsx | 6 ++-- src/i18n/messages.ts | 6 ++++ src/lib/exam-weight.ts | 20 +++++++++-- src/pages/course-detail-page.tsx | 4 ++- src/pages/exam-detail-page.tsx | 7 ++-- src/routes/router.tsx | 40 ++++++++++++++++++++++ 9 files changed, 100 insertions(+), 18 deletions(-) diff --git a/docs/frontend-next-steps.md b/docs/frontend-next-steps.md index fdf6114..9cb22cc 100644 --- a/docs/frontend-next-steps.md +++ b/docs/frontend-next-steps.md @@ -68,12 +68,12 @@ validation, and list filtering cleanup. ### Incomplete Product Features -| Feature | API | UI | Notes | -|---|---|---|---| -| `allow_rejoin` | Type + body exist | No toggle; form always sends `true` | Deferred | -| Exam weight badge | BE exam DTO has no weight | Badge never shows; needs weight derived from settings kind map | Needs BE or FE-side resolution | -| Router `beforeLoad` | — | Still missing on live monitor, settings, terms | Consistency | -| Exam room CTA | — | Visible to manager/admin on detail page; page itself blocks | Minor | +| Feature | Status | +|---|---| +| `allow_rejoin` toggle | Done — exam form checkbox + help text | +| Exam weight badge | Done — resolved from `GET /settings` exam_kinds by kind name | +| Router `beforeLoad` | Done — live (teacher+), settings/terms (manager+), exam-room (student) | +| Exam room CTA | Done — student-only on exam detail | ### Backend-Dependent Follow-Up diff --git a/src/components/exams/exam-card.tsx b/src/components/exams/exam-card.tsx index 5ecdf7b..71357f0 100644 --- a/src/components/exams/exam-card.tsx +++ b/src/components/exams/exam-card.tsx @@ -1,4 +1,5 @@ -import { Show } from "solid-js"; +import { Show, createResource } from "solid-js"; +import { getSettings } from "@/api/getSettings"; import type { Exam } from "@/api/types"; import { Badge } from "@/components/ui/badge"; import { ExamLink } from "@/components/exams/exam-link"; @@ -11,6 +12,7 @@ import { usePreferences, useT } from "@/stores/preferences-context"; export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number }) { const t = useT(); const { locale } = usePreferences(); + const [settings] = createResource(() => getSettings()); const modeLabel = () => { if (props.exam.mode === "sync") return t("exams.mode.sync"); if (props.exam.mode === "async") return t("exams.mode.async"); @@ -77,7 +79,7 @@ export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number
{examKindLabel(String(props.exam.kind), t)} - + {(weight) => ({t("courses.weight")}: {weight()})} diff --git a/src/components/exams/exam-form.tsx b/src/components/exams/exam-form.tsx index 72ea9f9..b3a89d5 100644 --- a/src/components/exams/exam-form.tsx +++ b/src/components/exams/exam-form.tsx @@ -78,7 +78,7 @@ export function ExamForm(props: { const [mode, setMode] = createSignal(String(props.initial?.mode ?? "")); const [hasRetakes, setHasRetakes] = createSignal((props.initial?.max_attempts ?? 1) !== 1); const [maxAttempts, setMaxAttempts] = createSignal(String(props.initial?.max_attempts ?? 1)); - const allowRejoin = () => props.initial?.allow_rejoin ?? true; + const [allowRejoin, setAllowRejoin] = createSignal(props.initial?.allow_rejoin ?? true); const [startsDate, setStartsDate] = createSignal(dateInputFromMs(props.initial?.starts_at)); const [startsTime, setStartsTime] = createSignal(timeInputFromMs(props.initial?.starts_at)); const [endsDate, setEndsDate] = createSignal(dateInputFromMs(props.initial?.ends_at)); @@ -132,6 +132,7 @@ export function ExamForm(props: { setMode(""); setHasRetakes(false); setMaxAttempts("1"); + setAllowRejoin(true); setStartsDate(""); setStartsTime(""); setEndsDate(""); @@ -165,7 +166,7 @@ export function ExamForm(props: { duration_ms, max_attempts: hasRetakes() ? Number(maxAttempts()) : 1, allow_rejoin: allowRejoin(), - }; + } satisfies ExamFormValues; if (isEdit()) { setPendingValues(values); setConfirmOpen(true); @@ -256,6 +257,18 @@ export function ExamForm(props: {
+
+ +

{t("exams.allowRejoinHelp")}

+
diff --git a/src/components/marks/marks-report-view.tsx b/src/components/marks/marks-report-view.tsx index c688005..9702e53 100644 --- a/src/components/marks/marks-report-view.tsx +++ b/src/components/marks/marks-report-view.tsx @@ -1,5 +1,6 @@ -import { For, Show } from "solid-js"; +import { For, Show, createResource } from "solid-js"; import { Link } from "@tanstack/solid-router"; +import { getSettings } from "@/api/getSettings"; import type { MarksReport } from "@/api/types"; import { Badge } from "@/components/ui/badge"; import { DataTableEmpty, DataTableFrame } from "@/components/ui/data-table"; @@ -18,6 +19,7 @@ function markWithGrade(mark: number | null, grade?: string | null) { export function MarksReportView(props: { report: MarksReport }) { const t = useT(); + const [settings] = createResource(() => getSettings()); return ( 0} @@ -86,7 +88,7 @@ export function MarksReportView(props: { report: MarksReport }) { {examKindLabel(entry.kind, t)} - {examWeight(entry) ?? "—"} + {examWeight(entry, settings()?.exam_kinds) ?? "—"} {markWithGrade(entry.mark, entry.grade)} )} diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index b592065..c0ba99f 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -233,6 +233,8 @@ export type MessageKey = | "exams.maxAttempts" | "exams.maxAttemptsRange" | "exams.retakes" + | "exams.allowRejoin" + | "exams.allowRejoinHelp" | "exams.startTime" | "exams.endTime" | "exams.scheduleRequired" @@ -731,6 +733,8 @@ const en: Dict = { "exams.maxAttempts": "Max attempts", "exams.maxAttemptsRange": "Max attempts must be 1 or higher", "exams.retakes": "Retakes", + "exams.allowRejoin": "Allow rejoin", + "exams.allowRejoinHelp": "If off, a student who leaves the exam room cannot return to answer.", "exams.startTime": "Start time", "exams.endTime": "End time", "exams.scheduleRequired": "Scheduled exams need start and end times", @@ -1239,6 +1243,8 @@ const tr: Dict = { "exams.maxAttempts": "Deneme hakkı", "exams.maxAttemptsRange": "Deneme hakkı 1 veya daha büyük olmalı", "exams.retakes": "Deneme hakkı", + "exams.allowRejoin": "Yeniden girişe izin ver", + "exams.allowRejoinHelp": "Kapalıysa sınav odasından çıkan öğrenci cevap vermek için geri giremez.", "exams.startTime": "Başlangıç saati", "exams.endTime": "Bitiş saati", "exams.scheduleRequired": "Zamanlı sınav için başlangıç ve bitiş gerekli", diff --git a/src/lib/exam-weight.ts b/src/lib/exam-weight.ts index 057e659..3b48c35 100644 --- a/src/lib/exam-weight.ts +++ b/src/lib/exam-weight.ts @@ -1,11 +1,25 @@ type ExamWeightSource = { + kind?: string | null; weight?: number | null; kind_weight?: number | null; type_weight?: number | null; exam_type_weight?: number | null; }; -export function examWeight(source: ExamWeightSource): number | null { - const value = source.kind_weight ?? source.type_weight ?? source.exam_type_weight ?? source.weight ?? null; - return typeof value === "number" && Number.isFinite(value) ? value : null; +type KindWeight = { + name: string; + weight: number; +}; + +export function examWeight( + source: ExamWeightSource, + kinds?: readonly KindWeight[] | null, +): number | null { + const direct = source.kind_weight ?? source.type_weight ?? source.exam_type_weight ?? source.weight ?? null; + if (typeof direct === "number" && Number.isFinite(direct)) return direct; + if (source.kind != null && kinds?.length) { + const match = kinds.find((item) => item.name === String(source.kind)); + if (match && Number.isFinite(match.weight)) return match.weight; + } + return null; } diff --git a/src/pages/course-detail-page.tsx b/src/pages/course-detail-page.tsx index 556e3f1..072327c 100644 --- a/src/pages/course-detail-page.tsx +++ b/src/pages/course-detail-page.tsx @@ -6,6 +6,7 @@ import { getCourseById } from "@/api/getCourseById"; import { getCourseEnrollments } from "@/api/getCourseEnrollments"; import { getCourseExams } from "@/api/getCourseExams"; import { getMyCourses } from "@/api/getMyCourses"; +import { getSettings } from "@/api/getSettings"; import { getTerms } from "@/api/getTerms"; import { patchCourseById } from "@/api/patchCourseById"; import { postCourseEnrollment } from "@/api/postCourseEnrollment"; @@ -66,6 +67,7 @@ function CourseDetailContent() { const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId)); const [terms] = createResource(async () => (await getTerms()).items); + const [settings] = createResource(() => getSettings()); const [exams, { refetch: refetchExams }] = createResource(id, async (courseId) => (await getCourseExams(courseId)).items); const isTeacherPlus = () => hasMinRole(auth.user()?.role, "teacher"); const hasCourseManagementRights = () => { @@ -414,7 +416,7 @@ function CourseDetailContent() {
{examKindLabel(String(exam.kind), t)} - + {(weight) => ({t("courses.weight")}: {weight()})} diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index 2641749..9fa2b90 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -8,6 +8,7 @@ import { getExamResults } from "@/api/getExamResults"; import { getExamStatistics } from "@/api/getExamStatistics"; import { getCourseEnrollments } from "@/api/getCourseEnrollments"; import { getMyCourses } from "@/api/getMyCourses"; +import { getSettings } from "@/api/getSettings"; import { patchExamById } from "@/api/patchExamById"; import { postExamResult } from "@/api/postExamResult"; import { ApiError, formatApiError } from "@/api/client"; @@ -68,7 +69,9 @@ function ExamDetailContent() { }); const [exam, { refetch: refetchExam }] = createResource(id, (examId) => getExamById(examId)); + const [settings] = createResource(() => getSettings()); const isTeacherPlus = createMemo(() => hasMinRole(auth.user()?.role, "teacher")); + const isStudent = createMemo(() => auth.user()?.role === "student"); const hasCourseManagementRights = () => { const e = exam(); @@ -226,7 +229,7 @@ function ExamDetailContent() { {t("common.back")} - +