🎨 simplify detail page layouts
Browse files at this commit076d907e989d0190cbc1c46e25309247fbf6eabfParent: e7c8f82- refactor
- 🎨 simplify detail page layouts
2 changed files +284 -274
- src/pages/course-detail-page.tsx +119 -95
- src/pages/exam-detail-page.tsx +165 -179
src/pages/course-detail-page.tsxmodified+119 -95
| @@ -30,7 +30,7 @@ import { Button } from "@/components/ui/button"; | |||
| 30 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 30 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 31 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 31 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 32 | import { EmptyState } from "@/components/ui/empty-state"; | 32 | import { EmptyState } from "@/components/ui/empty-state"; |
| 33 | -import { IconChevronLeft, IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; | 33 | +import { IconBook, IconCalendarDays, IconEdit, IconExam, IconHomework, IconPlus, IconSchool, IconTrash, IconUsers } from "@/components/ui/icons"; |
| 34 | import { createFlash } from "@/lib/flash"; | 34 | import { createFlash } from "@/lib/flash"; |
| 35 | import { cn } from "@/lib/cn"; | 35 | import { cn } from "@/lib/cn"; |
| 36 | import { Input } from "@/components/ui/input"; | 36 | import { Input } from "@/components/ui/input"; |
| @@ -69,7 +69,7 @@ function CourseDetailContent() { | |||
| 69 | return params().id; | 69 | return params().id; |
| 70 | }); | 70 | }); |
| 71 | 71 | ||
| 72 | - const [courseTab, setCourseTab] = createSignal("overview"); | 72 | + const [courseTab, setCourseTab] = createSignal("subjects"); |
| 73 | const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId)); | 73 | const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId)); |
| 74 | const [terms] = createResource(async () => (await getTerms({ limit: 100 })).items); | 74 | const [terms] = createResource(async () => (await getTerms({ limit: 100 })).items); |
| 75 | const [settings] = createResource(() => getSettings()); | 75 | const [settings] = createResource(() => getSettings()); |
| @@ -150,6 +150,11 @@ function CourseDetailContent() { | |||
| 150 | const courseListSearch = (value: CourseKind | undefined) => value ? { kind: value } as never : {} as never; | 150 | const courseListSearch = (value: CourseKind | undefined) => value ? { kind: value } as never : {} as never; |
| 151 | 151 | ||
| 152 | const examCount = createMemo(() => exams()?.length ?? 0); | 152 | const examCount = createMemo(() => exams()?.length ?? 0); |
| 153 | + const nextExam = createMemo(() => | ||
| 154 | + (exams() ?? []) | ||
| 155 | + .filter((exam) => (exam.ends_at ?? exam.starts_at ?? 0) > Date.now()) | ||
| 156 | + .sort((a, b) => (a.starts_at ?? a.ends_at ?? 0) - (b.starts_at ?? b.ends_at ?? 0))[0], | ||
| 157 | + ); | ||
| 153 | const rosterCount = createMemo(() => roster()?.length ?? 0); | 158 | const rosterCount = createMemo(() => roster()?.length ?? 0); |
| 154 | const countDescription = (count: number, item: string) => t("common.countItem", { count, item }); | 159 | const countDescription = (count: number, item: string) => t("common.countItem", { count, item }); |
| 155 | 160 | ||
| @@ -274,50 +279,79 @@ function CourseDetailContent() { | |||
| 274 | {(c) => ( | 279 | {(c) => ( |
| 275 | <Show when={accessReady()} fallback={<PageSpinner />}> | 280 | <Show when={accessReady()} fallback={<PageSpinner />}> |
| 276 | <Show when={canViewCourse()} fallback={<Alert variant="destructive">{t("common.accessDenied")}</Alert>}> | 281 | <Show when={canViewCourse()} fallback={<Alert variant="destructive">{t("common.accessDenied")}</Alert>}> |
| 277 | - <div class="space-y-6"> | 282 | + <div class="mx-auto w-full max-w-[1440px] space-y-6"> |
| 278 | <div class="space-y-2"> | 283 | <div class="space-y-2"> |
| 284 | + <nav class="detail-breadcrumb"> | ||
| 285 | + <Link to="/courses" search={courseListSearch(c().kind)}>{t("courses.kind.course")}</Link> | ||
| 286 | + <span aria-hidden>›</span> | ||
| 287 | + <span class="text-foreground">{c().title}</span> | ||
| 288 | + </nav> | ||
| 279 | <PageHeader | 289 | <PageHeader |
| 280 | accent="violet" | 290 | accent="violet" |
| 281 | - eyebrow={courseKindLabel(c().kind)} | ||
| 282 | title={c().title} | 291 | title={c().title} |
| 283 | description={c().description || "—"} | 292 | description={c().description || "—"} |
| 293 | + class="border-violet-500/30 shadow-sm" | ||
| 284 | actions={ | 294 | actions={ |
| 285 | - <div class="detail-action-group"> | 295 | + <Show when={canManage()}> |
| 286 | - <Link to="/courses" search={courseListSearch(c().kind)}> | 296 | + <TableRowActions |
| 287 | - <Button variant="ghost" size="sm" class="w-full rounded-xl sm:w-auto"> | 297 | + label={t("common.actions")} |
| 288 | - <IconChevronLeft class="h-4 w-4" /> | 298 | + actions={[ |
| 289 | - {t("common.back")} | 299 | + { |
| 290 | - </Button> | 300 | + label: t("common.edit"), |
| 291 | - </Link> | 301 | + icon: <IconEdit class="h-4 w-4" />, |
| 292 | - <Show when={canManage()}> | 302 | + onSelect: startEdit, |
| 293 | - <div class="detail-action-divider"> | 303 | + }, |
| 294 | - <Button type="button" variant="outline" size="sm" class="flex-1 rounded-xl sm:flex-none" onClick={startEdit}> | 304 | + ...(canDeleteCourse() |
| 295 | - <IconEdit class="h-4 w-4" /> | 305 | + ? [{ |
| 296 | - {t("common.edit")} | 306 | + label: t("courses.delete"), |
| 297 | - </Button> | 307 | + icon: <IconTrash class="h-4 w-4" />, |
| 298 | - <Show when={canDeleteCourse()}> | 308 | + destructive: true, |
| 299 | - <Button type="button" variant="destructive" size="sm" class="flex-1 rounded-xl sm:flex-none" onClick={() => setDeleteOpen(true)}> | 309 | + onSelect: () => setDeleteOpen(true), |
| 300 | - <IconTrash class="h-4 w-4" /> | 310 | + }] |
| 301 | - {t("courses.delete")} | 311 | + : []), |
| 302 | - </Button> | 312 | + ]} |
| 303 | - </Show> | 313 | + /> |
| 304 | - </div> | 314 | + </Show> |
| 305 | - </Show> | ||
| 306 | - </div> | ||
| 307 | } | 315 | } |
| 308 | /> | 316 | /> |
| 309 | - <div class="grid gap-3 text-sm sm:grid-cols-3"> | 317 | + <div class="grid gap-2 sm:grid-cols-2 xl:grid-cols-4"> |
| 310 | - <div class="detail-metric-card"> | 318 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-violet-500/30 bg-card p-3.5"> |
| 311 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("courses.kind")}</p> | 319 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> |
| 312 | - <p class="mt-1 font-medium">{courseKindLabel(c().kind)}</p> | 320 | + <IconBook class="h-4 w-4" /> |
| 321 | + </span> | ||
| 322 | + <div class="min-w-0"> | ||
| 323 | + <p class="text-xs font-medium text-muted-foreground">{t("courses.kind")}</p> | ||
| 324 | + <p class="truncate text-sm font-semibold">{courseKindLabel(c().kind)}</p> | ||
| 325 | + </div> | ||
| 326 | + </div> | ||
| 327 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-sky-500/30 bg-card p-3.5"> | ||
| 328 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> | ||
| 329 | + <IconCalendarDays class="h-4 w-4" /> | ||
| 330 | + </span> | ||
| 331 | + <div class="min-w-0"> | ||
| 332 | + <p class="text-xs font-medium text-muted-foreground">{t("terms.term")}</p> | ||
| 333 | + <p class="truncate text-sm font-semibold">{terms()?.find((term) => term.id === c().term)?.name ?? t("terms.unassigned")}</p> | ||
| 334 | + </div> | ||
| 313 | </div> | 335 | </div> |
| 314 | - <div class="detail-metric-card"> | 336 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-emerald-500/30 bg-card p-3.5"> |
| 315 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("terms.term")}</p> | 337 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> |
| 316 | - <p class="mt-1 font-medium">{terms()?.find((term) => term.id === c().term)?.name ?? t("terms.unassigned")}</p> | 338 | + <IconUsers class="h-4 w-4" /> |
| 339 | + </span> | ||
| 340 | + <div class="min-w-0"> | ||
| 341 | + <p class="text-xs font-medium text-muted-foreground">{t("courses.capacity")}</p> | ||
| 342 | + <p class="mono truncate text-sm font-semibold">{c().capacity == null ? "—" : hasCourseManagementRights() ? `${rosterCount()} / ${c().capacity}` : c().capacity}</p> | ||
| 343 | + </div> | ||
| 317 | </div> | 344 | </div> |
| 318 | - <div class="detail-metric-card"> | 345 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-amber-500/30 bg-card p-3.5"> |
| 319 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("courses.capacity")}</p> | 346 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> |
| 320 | - <p class="mono mt-1 font-medium">{c().capacity == null ? "—" : hasCourseManagementRights() ? `${rosterCount()} / ${c().capacity}` : c().capacity}</p> | 347 | + <IconExam class="h-4 w-4" /> |
| 348 | + </span> | ||
| 349 | + <div class="min-w-0"> | ||
| 350 | + <p class="text-xs font-medium text-muted-foreground">{t("courses.nextExam")}</p> | ||
| 351 | + <Show when={nextExam()} fallback={<p class="truncate text-sm font-semibold">{t("courses.noUpcoming")}</p>}> | ||
| 352 | + {(exam) => <ExamLink examId={exam().id} class="block truncate text-sm font-semibold hover:text-primary hover:underline">{exam().title}</ExamLink>} | ||
| 353 | + </Show> | ||
| 354 | + </div> | ||
| 321 | </div> | 355 | </div> |
| 322 | </div> | 356 | </div> |
| 323 | </div> | 357 | </div> |
| @@ -556,58 +590,46 @@ function CourseDetailContent() { | |||
| 556 | )} | 590 | )} |
| 557 | 591 | ||
| 558 | <Tabs value={courseTab()} onChange={setCourseTab} class="space-y-3"> | 592 | <Tabs value={courseTab()} onChange={setCourseTab} class="space-y-3"> |
| 559 | - <TabsList> | 593 | + <TabsList class="border-primary/10 bg-card/80 shadow-sm"> |
| 560 | - <TabsTrigger value="overview">{t("courses.overview")}</TabsTrigger> | 594 | + <TabsTrigger value="subjects"><IconBook class="h-4 w-4" />{t("subjects.title")}</TabsTrigger> |
| 561 | - <TabsTrigger value="work">{t("courses.work")}</TabsTrigger> | 595 | + <TabsTrigger value="exams"><IconExam class="h-4 w-4" />{t("courses.exams")}</TabsTrigger> |
| 562 | - <TabsTrigger value="sessions">{t("sessions.title")}</TabsTrigger> | 596 | + <TabsTrigger value="homework"><IconHomework class="h-4 w-4" />{t("homework.title")}</TabsTrigger> |
| 563 | - <TabsTrigger value="people">{t("courses.people")}</TabsTrigger> | 597 | + <TabsTrigger value="sessions"><IconCalendarDays class="h-4 w-4" />{t("sessions.title")}</TabsTrigger> |
| 598 | + <TabsTrigger value="teachers"><IconSchool class="h-4 w-4" />{t("courses.teachers")}</TabsTrigger> | ||
| 599 | + <Show when={hasCourseManagementRights()}> | ||
| 600 | + <TabsTrigger value="students"><IconUsers class="h-4 w-4" />{t("courses.roster")}</TabsTrigger> | ||
| 601 | + </Show> | ||
| 564 | </TabsList> | 602 | </TabsList> |
| 565 | 603 | ||
| 566 | - <TabsContent value="overview" class="space-y-4"> | 604 | + <TabsContent value="subjects" class="space-y-4 border-border/60 bg-card/80 shadow-sm"> |
| 567 | - <div class="data-shell p-4"> | 605 | + <div class="flex flex-wrap items-center justify-between gap-3"> |
| 568 | - <h2 class="font-display text-base font-semibold">{t("courses.overview")}</h2> | 606 | + <Badge variant="secondary" class="rounded-full">{countDescription(subjectCount(), t("subjects.item"))}</Badge> |
| 569 | - <p class="mt-2 whitespace-pre-wrap text-sm text-muted-foreground">{c().description || "—"}</p> | 607 | + <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg border-primary/30 hover:bg-muted" onClick={() => setShowSubjectForm(true)}><IconPlus class="h-4 w-4" />{t("subjects.add")}</Button></Show> |
| 570 | - </div> | ||
| 571 | - <div class="data-shell p-4"> | ||
| 572 | - <h2 class="font-display text-base font-semibold">{t("courses.upcoming")}</h2> | ||
| 573 | - <Show | ||
| 574 | - when={(exams() ?? []).filter((exam) => (exam.ends_at ?? exam.starts_at ?? 0) > Date.now()).sort((a, b) => (a.starts_at ?? a.ends_at ?? 0) - (b.starts_at ?? b.ends_at ?? 0))[0]} | ||
| 575 | - fallback={<p class="mt-2 text-sm text-muted-foreground">{t("courses.noUpcoming")}</p>} | ||
| 576 | - > | ||
| 577 | - {(exam) => <ExamLink examId={exam().id} class="mt-2 block text-sm font-medium hover:underline">{exam().title}</ExamLink>} | ||
| 578 | - </Show> | ||
| 579 | </div> | 608 | </div> |
| 609 | + <CourseSubjectsPanel courseId={id()} canManage={canManage()} active={courseTab() === "subjects"} createOpen={showSubjectForm()} onCreateOpenChange={setShowSubjectForm} onCountChange={setSubjectCount} /> | ||
| 580 | </TabsContent> | 610 | </TabsContent> |
| 581 | 611 | ||
| 582 | - <TabsContent value="work" class="space-y-5"> | 612 | + <TabsContent value="exams" class="space-y-4 border-border/60 bg-card/80 shadow-sm"> |
| 583 | - <div class="space-y-4"> | 613 | + <div class="flex flex-wrap items-center justify-between gap-3"> |
| 584 | - <div class="tab-panel-header"> | 614 | + <Badge variant="secondary" class="rounded-full">{countDescription(examCount(), t("courses.examItem"))}</Badge> |
| 585 | - <p class="text-sm font-medium">{t("subjects.title")} · {countDescription(subjectCount(), t("subjects.item"))}</p> | 615 | + <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg border-primary/30 hover:bg-muted" onClick={() => setShowExamForm(true)}><IconPlus class="h-4 w-4" />{t("courses.addExam")}</Button></Show> |
| 586 | - <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowSubjectForm(true)}><IconPlus class="h-4 w-4" />{t("subjects.add")}</Button></Show> | ||
| 587 | - </div> | ||
| 588 | - <CourseSubjectsPanel courseId={id()} canManage={canManage()} active={courseTab() === "work"} createOpen={showSubjectForm()} onCreateOpenChange={setShowSubjectForm} onCountChange={setSubjectCount} /> | ||
| 589 | - </div> | ||
| 590 | - <div class="space-y-4 border-t border-border/60 pt-5"> | ||
| 591 | - <div class="tab-panel-header"> | ||
| 592 | - <p class="text-sm font-medium">{t("courses.exams")} · {countDescription(examCount(), t("courses.examItem"))}</p> | ||
| 593 | - <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowExamForm(true)}><IconPlus class="h-4 w-4" />{t("courses.addExam")}</Button></Show> | ||
| 594 | - </div> | ||
| 595 | - <Suspense fallback={<DataTableSkeleton />}><DataTable columns={examColumns()} data={exams() ?? []} filterColumn="title" enablePagination pageSize={10} empty={t("exams.empty")} onRowClick={(exam) => void navigate({ to: "/exams/$id", params: { id: exam.id } })} /></Suspense> | ||
| 596 | </div> | 616 | </div> |
| 597 | - <div class="space-y-4 border-t border-border/60 pt-5"> | 617 | + <Suspense fallback={<DataTableSkeleton />}><DataTable columns={examColumns()} data={exams() ?? []} filterColumn="title" enablePagination pageSize={10} empty={t("exams.empty")} onRowClick={(exam) => void navigate({ to: "/exams/$id", params: { id: exam.id } })} /></Suspense> |
| 598 | - <div class="tab-panel-header"> | 618 | + </TabsContent> |
| 599 | - <p class="text-sm font-medium">{t("homework.title")} · {countDescription(homeworkCount(), t("homework.item"))}</p> | 619 | + |
| 600 | - <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowHomeworkForm(true)}><IconPlus class="h-4 w-4" />{t("homework.add")}</Button></Show> | 620 | + <TabsContent value="homework" class="space-y-4 border-border/60 bg-card/80 shadow-sm"> |
| 601 | - </div> | 621 | + <div class="flex flex-wrap items-center justify-between gap-3"> |
| 602 | - <CourseHomeworkPanel courseId={id()} canManage={canManage()} active={courseTab() === "work"} createOpen={showHomeworkForm()} onCreateOpenChange={setShowHomeworkForm} onCountChange={setHomeworkCount} /> | 622 | + <Badge variant="secondary" class="rounded-full">{countDescription(homeworkCount(), t("homework.item"))}</Badge> |
| 623 | + <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg border-primary/30 hover:bg-muted" onClick={() => setShowHomeworkForm(true)}><IconPlus class="h-4 w-4" />{t("homework.add")}</Button></Show> | ||
| 603 | </div> | 624 | </div> |
| 625 | + <CourseHomeworkPanel courseId={id()} canManage={canManage()} active={courseTab() === "homework"} createOpen={showHomeworkForm()} onCreateOpenChange={setShowHomeworkForm} onCountChange={setHomeworkCount} /> | ||
| 604 | </TabsContent> | 626 | </TabsContent> |
| 605 | 627 | ||
| 606 | - <TabsContent value="sessions" class="space-y-4"> | 628 | + <TabsContent value="sessions" class="space-y-4 border-border/60 bg-card/80 shadow-sm"> |
| 607 | - <div class="tab-panel-header"> | 629 | + <div class="flex flex-wrap items-center justify-between gap-3"> |
| 608 | - <p class="text-sm text-muted-foreground">{countDescription(sessionCount(), t("sessions.item"))}</p> | 630 | + <Badge variant="secondary" class="rounded-full">{countDescription(sessionCount(), t("sessions.item"))}</Badge> |
| 609 | <Show when={canManage()}> | 631 | <Show when={canManage()}> |
| 610 | - <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowSessionForm(true)}> | 632 | + <Button type="button" variant="outline" size="sm" class="rounded-lg border-primary/30 hover:bg-muted" onClick={() => setShowSessionForm(true)}> |
| 611 | <IconPlus class="h-4 w-4" /> | 633 | <IconPlus class="h-4 w-4" /> |
| 612 | {t("sessions.add")} | 634 | {t("sessions.add")} |
| 613 | </Button> | 635 | </Button> |
| @@ -616,25 +638,27 @@ function CourseDetailContent() { | |||
| 616 | <CourseSessionsPanel courseId={id()} roster={roster() ?? []} canManage={canManage()} active={courseTab() === "sessions"} createOpen={showSessionForm()} onCreateOpenChange={setShowSessionForm} onCountChange={setSessionCount} /> | 638 | <CourseSessionsPanel courseId={id()} roster={roster() ?? []} canManage={canManage()} active={courseTab() === "sessions"} createOpen={showSessionForm()} onCreateOpenChange={setShowSessionForm} onCountChange={setSessionCount} /> |
| 617 | </TabsContent> | 639 | </TabsContent> |
| 618 | 640 | ||
| 619 | - <TabsContent value="people" class="space-y-5"> | 641 | + <TabsContent value="teachers" class="space-y-4 border-border/60 bg-card/80 shadow-sm"> |
| 620 | - <div class="space-y-4"> | 642 | + <div class="flex flex-wrap items-center justify-between gap-3"> |
| 621 | - <div class="tab-panel-header"> | 643 | + <Badge variant="secondary" class="rounded-full">{countDescription((c().teachers ?? []).length + 1, t("courses.teachers"))}</Badge> |
| 622 | - <p class="text-sm font-medium">{t("courses.teachers")} · {countDescription((c().teachers ?? []).length + 1, t("courses.teachers"))}</p> | 644 | + <Show when={canStaffCourse()}><Button type="button" variant="outline" size="sm" class="rounded-lg border-primary/30 hover:bg-muted" onClick={() => setShowTeacherForm(true)}><IconPlus class="h-4 w-4" />{t("courses.assignTeacher")}</Button></Show> |
| 623 | - <Show when={canStaffCourse()}><Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowTeacherForm(true)}><IconPlus class="h-4 w-4" />{t("courses.assignTeacher")}</Button></Show> | ||
| 624 | - </div> | ||
| 625 | - <p class="rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-sm">{t("common.creator")}: {c().creator.display_name || c().creator.username}</p> | ||
| 626 | - <CourseTeachersPanel courseId={id()} teachers={c().teachers ?? []} canStaff={canStaffCourse()} assignOpen={showTeacherForm()} onAssignOpenChange={setShowTeacherForm} onCourseUpdated={refetchCourse} /> | ||
| 627 | </div> | 645 | </div> |
| 628 | - <Show when={hasCourseManagementRights()}> | 646 | + <div class="flex items-center gap-3 rounded-xl border border-violet-500/30 bg-card px-3 py-2.5 text-sm"> |
| 629 | - <div class="space-y-4 border-t border-border/60 pt-5"> | 647 | + <IconSchool class="h-4 w-4 shrink-0 text-muted-foreground" /> |
| 630 | - <div class="tab-panel-header"> | 648 | + <span><span class="text-muted-foreground">{t("common.creator")}:</span> <span class="font-medium">{c().creator.display_name || c().creator.username}</span></span> |
| 631 | - <p class="text-sm font-medium">{t("courses.roster")} · {countDescription(rosterCount(), t("courses.rosterItem"))}</p> | 649 | + </div> |
| 632 | - <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowEnrollPanel(true)}><IconPlus class="h-4 w-4" />{t("courses.enroll")}</Button></Show> | 650 | + <CourseTeachersPanel courseId={id()} teachers={c().teachers ?? []} canStaff={canStaffCourse()} assignOpen={showTeacherForm()} onAssignOpenChange={setShowTeacherForm} onCourseUpdated={refetchCourse} /> |
| 633 | - </div> | ||
| 634 | - <Suspense fallback={<DataTableSkeleton />}><Show when={(roster() ?? []).length > 0} fallback={<EmptyState kind="courses" title={t("exams.emptyRoster")} />}><DataTable columns={rosterColumns()} data={roster() ?? []} filterColumn="username" enablePagination pageSize={10} /></Show></Suspense> | ||
| 635 | - </div> | ||
| 636 | - </Show> | ||
| 637 | </TabsContent> | 651 | </TabsContent> |
| 652 | + | ||
| 653 | + <Show when={hasCourseManagementRights()}> | ||
| 654 | + <TabsContent value="students" class="space-y-4 border-border/60 bg-card/80 shadow-sm"> | ||
| 655 | + <div class="flex flex-wrap items-center justify-between gap-3"> | ||
| 656 | + <Badge variant="secondary" class="rounded-full">{countDescription(rosterCount(), t("courses.rosterItem"))}</Badge> | ||
| 657 | + <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="rounded-lg border-primary/30 hover:bg-muted" onClick={() => setShowEnrollPanel(true)}><IconPlus class="h-4 w-4" />{t("courses.enroll")}</Button></Show> | ||
| 658 | + </div> | ||
| 659 | + <Suspense fallback={<DataTableSkeleton />}><Show when={(roster() ?? []).length > 0} fallback={<EmptyState kind="courses" title={t("exams.emptyRoster")} />}><DataTable columns={rosterColumns()} data={roster() ?? []} filterColumn="username" enablePagination pageSize={10} /></Show></Suspense> | ||
| 660 | + </TabsContent> | ||
| 661 | + </Show> | ||
| 638 | </Tabs> | 662 | </Tabs> |
| 639 | </div> | 663 | </div> |
| 640 | </Show> | 664 | </Show> |
src/pages/exam-detail-page.tsxmodified+165 -179
| @@ -28,7 +28,7 @@ import { Button } from "@/components/ui/button"; | |||
| 28 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 28 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 29 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 29 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 30 | import { EmptyState } from "@/components/ui/empty-state"; | 30 | import { EmptyState } from "@/components/ui/empty-state"; |
| 31 | -import { IconChevronDown, IconChevronLeft, IconEdit, IconExam, IconEye, IconPlus, IconTrash } from "@/components/ui/icons"; | 31 | +import { IconCalendarDays, IconChart, IconChevronDown, IconClipboardCheck, IconClock, IconEdit, IconExam, IconEye, IconPencilQuestion, IconRefresh, IconTrash } from "@/components/ui/icons"; |
| 32 | import { Input } from "@/components/ui/input"; | 32 | import { Input } from "@/components/ui/input"; |
| 33 | import { PaginationControls } from "@/components/ui/pagination-controls"; | 33 | import { PaginationControls } from "@/components/ui/pagination-controls"; |
| 34 | import { PageSpinner } from "@/components/ui/page-spinner"; | 34 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| @@ -43,7 +43,7 @@ import { examDurationMs, formatDateTime, formatDurationMinutes } from "@/lib/for | |||
| 43 | import { personId, personLabel, personLabelWithId } from "@/lib/person"; | 43 | import { personId, personLabel, personLabelWithId } from "@/lib/person"; |
| 44 | import { cn } from "@/lib/cn"; | 44 | import { cn } from "@/lib/cn"; |
| 45 | import { createFlash } from "@/lib/flash"; | 45 | import { createFlash } from "@/lib/flash"; |
| 46 | -import { scheduleStatusClass, scheduleStatusDotClass } from "@/lib/schedule-status"; | 46 | +import { scheduleStatusClass } from "@/lib/schedule-status"; |
| 47 | import { useAuth } from "@/stores/auth-context"; | 47 | import { useAuth } from "@/stores/auth-context"; |
| 48 | import { usePreferences, useT } from "@/stores/preferences-context"; | 48 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 49 | 49 | ||
| @@ -118,8 +118,7 @@ function ExamDetailContent() { | |||
| 118 | const [answerMark, setAnswerMark] = createSignal("0"); | 118 | const [answerMark, setAnswerMark] = createSignal("0"); |
| 119 | const [answerError, setAnswerError] = createSignal(""); | 119 | const [answerError, setAnswerError] = createSignal(""); |
| 120 | const [answerPending, setAnswerPending] = createSignal(false); | 120 | const [answerPending, setAnswerPending] = createSignal(false); |
| 121 | - const [questionCreateOpen, setQuestionCreateOpen] = createSignal(false); | 121 | + const [examTab, setExamTab] = createSignal("questions"); |
| 122 | - const [examTab, setExamTab] = createSignal("schedule"); | ||
| 123 | const isSittable = () => { | 122 | const isSittable = () => { |
| 124 | const e = exam(); | 123 | const e = exam(); |
| 125 | return e ? isSittableExam(e) : false; | 124 | return e ? isSittableExam(e) : false; |
| @@ -203,6 +202,13 @@ function ExamDetailContent() { | |||
| 203 | }; | 202 | }; |
| 204 | const isFinished = () => examStatus().finished; | 203 | const isFinished = () => examStatus().finished; |
| 205 | const isUpcoming = () => examStatus().upcoming; | 204 | const isUpcoming = () => examStatus().upcoming; |
| 205 | + let defaultTabExamId = ""; | ||
| 206 | + createEffect(() => { | ||
| 207 | + const current = exam(); | ||
| 208 | + if (!current || current.id === defaultTabExamId) return; | ||
| 209 | + defaultTabExamId = current.id; | ||
| 210 | + setExamTab(current.ends_at != null && current.ends_at < now() ? "results" : "questions"); | ||
| 211 | + }); | ||
| 206 | const ownAttemptSummary = (): ExamAttemptSummary | null => { | 212 | const ownAttemptSummary = (): ExamAttemptSummary | null => { |
| 207 | const attempt = ownAttempt(); | 213 | const attempt = ownAttempt(); |
| 208 | return attempt ? { status: attempt.status, attempts_used: attempt.attempts_used, max_attempts: attempt.max_attempts } : null; | 214 | return attempt ? { status: attempt.status, attempts_used: attempt.attempts_used, max_attempts: attempt.max_attempts } : null; |
| @@ -377,21 +383,20 @@ function ExamDetailContent() { | |||
| 377 | {(ex) => ( | 383 | {(ex) => ( |
| 378 | <Show when={accessReady()} fallback={<PageSpinner />}> | 384 | <Show when={accessReady()} fallback={<PageSpinner />}> |
| 379 | <Show when={canViewExam()} fallback={<Alert variant="destructive">{t("common.accessDenied")}</Alert>}> | 385 | <Show when={canViewExam()} fallback={<Alert variant="destructive">{t("common.accessDenied")}</Alert>}> |
| 380 | - <div class="space-y-6"> | 386 | + <div class="mx-auto w-full max-w-[1440px] space-y-6"> |
| 381 | - <div class="sticky top-14 z-10 -mx-4 bg-background px-4 pb-1 sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8"> | 387 | + <div class="sticky top-14 z-10 -mx-4 space-y-2 bg-background px-4 pb-1 sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8"> |
| 388 | + <nav class="detail-breadcrumb"> | ||
| 389 | + <Link to="/exams">{t("exams.title")}</Link> | ||
| 390 | + <span aria-hidden>›</span> | ||
| 391 | + <span class="text-foreground">{ex().title}</span> | ||
| 392 | + </nav> | ||
| 382 | <PageHeader | 393 | <PageHeader |
| 383 | accent="rose" | 394 | accent="rose" |
| 384 | - eyebrow={t("exams.title")} | ||
| 385 | title={ex().title} | 395 | title={ex().title} |
| 386 | description={ex().description || "—"} | 396 | description={ex().description || "—"} |
| 397 | + class="border-rose-500/30 shadow-sm" | ||
| 387 | actions={ | 398 | actions={ |
| 388 | - <div class="detail-action-group"> | 399 | + <div class="flex flex-wrap items-center gap-2"> |
| 389 | - <Link to="/exams"> | ||
| 390 | - <Button variant="ghost" size="sm" class="w-full rounded-xl sm:w-auto"> | ||
| 391 | - <IconChevronLeft class="h-4 w-4" /> | ||
| 392 | - {t("common.back")} | ||
| 393 | - </Button> | ||
| 394 | - </Link> | ||
| 395 | <Show when={isStudent() && !isDraft() && isSittable()}> | 400 | <Show when={isStudent() && !isDraft() && isSittable()}> |
| 396 | <Show when={!isUpcoming() && !isFinished()}> | 401 | <Show when={!isUpcoming() && !isFinished()}> |
| 397 | <Show when={noAttemptsLeft()} | 402 | <Show when={noAttemptsLeft()} |
| @@ -412,106 +417,100 @@ function ExamDetailContent() { | |||
| 412 | </Show> | 417 | </Show> |
| 413 | <Show when={hasCourseManagementRights() && !isDraft() && !isUpcoming() && isSittable()}> | 418 | <Show when={hasCourseManagementRights() && !isDraft() && !isUpcoming() && isSittable()}> |
| 414 | <Link to="/exams/$id/live" params={{ id: id() }}> | 419 | <Link to="/exams/$id/live" params={{ id: id() }}> |
| 415 | - <Button variant="outline" size="sm" class="flex-1 rounded-xl sm:flex-none"> | 420 | + <Button size="sm" class="flex-1 rounded-xl sm:flex-none"> |
| 416 | <IconEye class="h-4 w-4" /> | 421 | <IconEye class="h-4 w-4" /> |
| 417 | {isFinished() ? t("exams.finalState") : t("exams.liveMonitor")} | 422 | {isFinished() ? t("exams.finalState") : t("exams.liveMonitor")} |
| 418 | </Button> | 423 | </Button> |
| 419 | </Link> | 424 | </Link> |
| 420 | </Show> | 425 | </Show> |
| 421 | <Show when={canManage()}> | 426 | <Show when={canManage()}> |
| 422 | - <div class="detail-action-divider"> | 427 | + <TableRowActions |
| 423 | - <Button type="button" variant="outline" size="sm" class="flex-1 rounded-xl sm:flex-none" onClick={() => setEditing(true)}> | 428 | + label={t("common.actions")} |
| 424 | - <IconEdit class="h-4 w-4" /> | 429 | + actions={[ |
| 425 | - {t("common.edit")} | 430 | + { |
| 426 | - </Button> | 431 | + label: t("common.edit"), |
| 427 | - <Button type="button" variant="destructive" size="sm" class="flex-1 rounded-xl sm:flex-none" disabled={pending()} onClick={() => setDeleteOpen(true)}> | 432 | + icon: <IconEdit class="h-4 w-4" />, |
| 428 | - <IconTrash class="h-4 w-4" /> | 433 | + onSelect: () => setEditing(true), |
| 429 | - {t("common.delete")} | 434 | + }, |
| 430 | - </Button> | 435 | + { |
| 431 | - </div> | 436 | + label: t("common.delete"), |
| 437 | + icon: <IconTrash class="h-4 w-4" />, | ||
| 438 | + destructive: true, | ||
| 439 | + disabled: pending(), | ||
| 440 | + onSelect: () => setDeleteOpen(true), | ||
| 441 | + }, | ||
| 442 | + ]} | ||
| 443 | + /> | ||
| 432 | </Show> | 444 | </Show> |
| 433 | </div> | 445 | </div> |
| 434 | } | 446 | } |
| 435 | - /> | ||
| 436 | - </div> | ||
| 437 | - <Show when={hasCourseManagementRights() && isFinished()}> | ||
| 438 | - <label | ||
| 439 | - class={cn( | ||
| 440 | - "detail-metric-card flex cursor-pointer items-center gap-4 text-sm transition-colors", | ||
| 441 | - reviewOn() && "border-primary/30 bg-primary/[0.04]", | ||
| 442 | - )} | ||
| 443 | > | 447 | > |
| 444 | - <div class="min-w-0 flex-1"> | 448 | + <div class="mt-3 flex flex-wrap items-center gap-2"> |
| 445 | - <span class="font-medium">{t("exams.allowReview")}</span> | ||
| 446 | - <p class="text-xs font-normal text-muted-foreground">{t("exams.allowReviewHelp")}</p> | ||
| 447 | - </div> | ||
| 448 | - <span class="relative shrink-0"> | ||
| 449 | - <input | ||
| 450 | - type="checkbox" | ||
| 451 | - class="peer sr-only" | ||
| 452 | - checked={reviewOn()} | ||
| 453 | - disabled={reviewSaving()} | ||
| 454 | - onChange={(e) => toggleReview(e.currentTarget.checked)} | ||
| 455 | - /> | ||
| 456 | - <span class="block h-7 w-12 rounded-full bg-input shadow-[inset_0_1px_2px_rgba(0,0,0,0.12)] ring-1 ring-inset ring-black/5 transition-colors duration-200 peer-checked:bg-primary peer-disabled:opacity-60 peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-background dark:ring-white/10" /> | ||
| 457 | - <span class="pointer-events-none absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-md ring-1 ring-black/5 transition-transform duration-200 ease-out peer-checked:translate-x-5" /> | ||
| 458 | - </span> | ||
| 459 | - </label> | ||
| 460 | - </Show> | ||
| 461 | - <div class="grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-4"> | ||
| 462 | - <div class="detail-metric-card"> | ||
| 463 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("work.status")}</p> | ||
| 464 | <Badge | 449 | <Badge |
| 465 | variant="outline" | 450 | variant="outline" |
| 466 | - class={cn( | 451 | + class={cn("w-fit rounded-full capitalize !bg-transparent !text-foreground", scheduleStatusClass(examStatusTone(detailStatus())))} |
| 467 | - "mt-2 w-fit rounded-full capitalize", | ||
| 468 | - scheduleStatusClass(examStatusTone(detailStatus())), | ||
| 469 | - )} | ||
| 470 | > | 452 | > |
| 471 | - <span class={cn("mr-1.5 inline-block h-1.5 w-1.5 rounded-full", scheduleStatusDotClass(examStatusTone(detailStatus())))} /> | 453 | + <span class="mr-1.5 inline-block h-1.5 w-1.5 rounded-full bg-muted-foreground" /> |
| 472 | {detailStatusLabel()} | 454 | {detailStatusLabel()} |
| 473 | </Badge> | 455 | </Badge> |
| 456 | + <Badge variant="outline" class="rounded-full border-rose-500/30"> | ||
| 457 | + {examKindLabel(String(ex().kind), t)} | ||
| 458 | + </Badge> | ||
| 474 | </div> | 459 | </div> |
| 475 | - <div class="detail-metric-card"> | 460 | + </PageHeader> |
| 476 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.kind")}</p> | 461 | + </div> |
| 477 | - <p class="mt-1 font-medium capitalize">{examKindLabel(String(ex().kind), t)}</p> | 462 | + <div class="grid gap-2 sm:grid-cols-2 xl:grid-cols-4"> |
| 478 | - </div> | 463 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-sky-500/30 bg-card p-3.5"> |
| 479 | - <div class="detail-metric-card"> | 464 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> |
| 480 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.mode")}</p> | 465 | + <IconExam class="h-4 w-4" /> |
| 481 | - <p class="mt-1 font-medium">{examModeLabel(ex().mode)}</p> | 466 | + </span> |
| 467 | + <div class="min-w-0"> | ||
| 468 | + <p class="text-xs font-medium text-muted-foreground">{t("exams.mode")}</p> | ||
| 469 | + <p class="truncate text-sm font-semibold">{examModeLabel(ex().mode)}</p> | ||
| 482 | </div> | 470 | </div> |
| 483 | - <div class="detail-metric-card"> | 471 | + </div> |
| 484 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.maxAttempts")}</p> | 472 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-violet-500/30 bg-card p-3.5"> |
| 485 | - <p class="mono mt-1 font-medium tabular-nums"> | 473 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> |
| 474 | + <IconRefresh class="h-4 w-4" /> | ||
| 475 | + </span> | ||
| 476 | + <div class="min-w-0"> | ||
| 477 | + <p class="text-xs font-medium text-muted-foreground">{t("exams.maxAttempts")}</p> | ||
| 478 | + <p class="mono truncate text-sm font-semibold"> | ||
| 486 | <Show when={isStudent()} fallback={ex().max_attempts}> | 479 | <Show when={isStudent()} fallback={ex().max_attempts}> |
| 487 | {ownAttemptSummary() ? `${ownAttemptSummary()!.attempts_used} / ${ex().max_attempts}` : `0 / ${ex().max_attempts}`} | 480 | {ownAttemptSummary() ? `${ownAttemptSummary()!.attempts_used} / ${ex().max_attempts}` : `0 / ${ex().max_attempts}`} |
| 488 | - <span class="ml-1.5 text-xs text-muted-foreground font-sans tracking-normal"> | ||
| 489 | - ({t("exams.attemptsLeft")}: {ex().max_attempts - (ownAttemptSummary()?.attempts_used ?? 0)}) | ||
| 490 | - </span> | ||
| 491 | </Show> | 481 | </Show> |
| 492 | </p> | 482 | </p> |
| 483 | + <Show when={isStudent()}> | ||
| 484 | + <p class="truncate text-xs text-muted-foreground">{t("exams.attemptsLeft")}: {ex().max_attempts - (ownAttemptSummary()?.attempts_used ?? 0)}</p> | ||
| 485 | + </Show> | ||
| 493 | </div> | 486 | </div> |
| 494 | - <Show when={ex().starts_at}> | ||
| 495 | - <div class="detail-metric-card"> | ||
| 496 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.startsAt")}</p> | ||
| 497 | - <p class="mono mt-1 font-medium tabular-nums">{formatDateTime(ex().starts_at, locale())}</p> | ||
| 498 | - </div> | ||
| 499 | - </Show> | ||
| 500 | - <Show when={ex().ends_at}> | ||
| 501 | - <div class="detail-metric-card"> | ||
| 502 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.endsAt")}</p> | ||
| 503 | - <p class="mono mt-1 font-medium tabular-nums">{formatDateTime(ex().ends_at, locale())}</p> | ||
| 504 | - </div> | ||
| 505 | - </Show> | ||
| 506 | - <Show when={examDurationMs(ex().duration_ms, ex().starts_at, ex().ends_at)}> | ||
| 507 | - {(dur) => ( | ||
| 508 | - <div class="detail-metric-card"> | ||
| 509 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.durationMinutes")}</p> | ||
| 510 | - <p class="mono mt-1 font-medium tabular-nums">{formatDurationMinutes(dur(), locale())}</p> | ||
| 511 | - </div> | ||
| 512 | - )} | ||
| 513 | - </Show> | ||
| 514 | </div> | 487 | </div> |
| 488 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-rose-500/30 bg-card p-3.5"> | ||
| 489 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> | ||
| 490 | + <IconCalendarDays class="h-4 w-4" /> | ||
| 491 | + </span> | ||
| 492 | + <div class="min-w-0"> | ||
| 493 | + <p class="text-xs font-medium text-muted-foreground">{t("exams.window")}</p> | ||
| 494 | + <p class="truncate text-xs font-semibold tabular-nums"> | ||
| 495 | + <Show when={ex().starts_at} fallback="—">{formatDateTime(ex().starts_at, locale())}</Show> | ||
| 496 | + </p> | ||
| 497 | + <Show when={ex().ends_at}> | ||
| 498 | + <p class="truncate text-xs text-muted-foreground tabular-nums">{formatDateTime(ex().ends_at, locale())}</p> | ||
| 499 | + </Show> | ||
| 500 | + </div> | ||
| 501 | + </div> | ||
| 502 | + <div class="flex min-w-0 items-center gap-3 rounded-2xl border border-amber-500/30 bg-card p-3.5"> | ||
| 503 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground"> | ||
| 504 | + <IconClock class="h-4 w-4" /> | ||
| 505 | + </span> | ||
| 506 | + <div class="min-w-0"> | ||
| 507 | + <p class="text-xs font-medium text-muted-foreground">{t("exams.durationMinutes")}</p> | ||
| 508 | + <p class="mono truncate text-sm font-semibold"> | ||
| 509 | + {formatDurationMinutes(examDurationMs(ex().duration_ms, ex().starts_at, ex().ends_at), locale())} | ||
| 510 | + </p> | ||
| 511 | + </div> | ||
| 512 | + </div> | ||
| 513 | + </div> | ||
| 515 | 514 | ||
| 516 | <SidePanel | 515 | <SidePanel |
| 517 | open={answerSheetOpen()} | 516 | open={answerSheetOpen()} |
| @@ -618,77 +617,49 @@ function ExamDetailContent() { | |||
| 618 | </Alert> | 617 | </Alert> |
| 619 | </Show> | 618 | </Show> |
| 620 | 619 | ||
| 621 | - <Tabs value={examTab()} onChange={setExamTab} class="space-y-3"> | 620 | + <Show when={isStudent() && ownResult()}> |
| 622 | - <TabsList> | 621 | + {(result) => ( |
| 623 | - <TabsTrigger value="schedule">{t("exams.schedule")}</TabsTrigger> | 622 | + <section class="space-y-4 rounded-2xl border border-emerald-500/30 bg-card p-4" aria-labelledby="own-exam-result"> |
| 624 | - <Show when={isStudent() && ownResult()}> | 623 | + <div class="flex flex-wrap items-center gap-3"> |
| 625 | - <TabsTrigger value="ownResult">{t("exams.yourResult")}</TabsTrigger> | 624 | + <span class="flex h-9 w-9 items-center justify-center rounded-xl bg-muted text-muted-foreground"> |
| 626 | - </Show> | 625 | + <IconClipboardCheck class="h-4 w-4" /> |
| 627 | - <Show when={hasCourseManagementRights()}> | 626 | + </span> |
| 628 | - <TabsTrigger value="statistics">{t("exams.statistics")}</TabsTrigger> | 627 | + <h2 id="own-exam-result" class="font-display text-base font-semibold">{t("exams.yourResult")}</h2> |
| 629 | - <TabsTrigger value="questions">{t("questions.title")}</TabsTrigger> | 628 | + <ExamResultBadge mark={result().mark} /> |
| 630 | - <TabsTrigger value="results">{t("exams.results")}</TabsTrigger> | ||
| 631 | - </Show> | ||
| 632 | - </TabsList> | ||
| 633 | - | ||
| 634 | - <TabsContent value="schedule" forceMount> | ||
| 635 | - <div class="tab-panel-note mb-4">{t("exams.details")}</div> | ||
| 636 | - <div class="grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-4"> | ||
| 637 | - <div class="detail-metric-card"> | ||
| 638 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.mode")}</p> | ||
| 639 | - <p class="mt-1 font-medium">{examModeLabel(ex().mode)}</p> | ||
| 640 | </div> | 629 | </div> |
| 641 | - <div class="detail-metric-card"> | 630 | + <Show when={ex().allow_review}> |
| 642 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("events.starts")}</p> | 631 | + <AnswerSheetView examId={id()} userId={auth.user()?.id ?? ""} mode="self" /> |
| 643 | - <p class="mono mt-1 font-medium">{formatDateTime(ex().starts_at, locale())}</p> | ||
| 644 | - </div> | ||
| 645 | - <div class="detail-metric-card"> | ||
| 646 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("events.ends")}</p> | ||
| 647 | - <p class="mono mt-1 font-medium">{formatDateTime(ex().ends_at, locale())}</p> | ||
| 648 | - </div> | ||
| 649 | - <div class="detail-metric-card"> | ||
| 650 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.durationMinutes")}</p> | ||
| 651 | - <p class="mono mt-1 font-medium">{formatDurationMinutes(examDurationMs(ex().duration_ms, ex().starts_at, ex().ends_at), locale())}</p> | ||
| 652 | - </div> | ||
| 653 | - </div> | ||
| 654 | - </TabsContent> | ||
| 655 | - | ||
| 656 | - <Show when={isStudent() && ownResult()}> | ||
| 657 | - <TabsContent value="ownResult" forceMount> | ||
| 658 | - <div class="tab-panel-note mb-4">{ownResult() ? `${t("form.mark")}: ${ownResult()!.mark}` : t("exams.notGraded")}</div> | ||
| 659 | - <Suspense fallback={<PageSpinner />}> | ||
| 660 | - <Show when={ownResult()} fallback={<ExamResultBadge notGraded />}> | ||
| 661 | - {(r) => <ExamResultBadge mark={r().mark} />} | ||
| 662 | - </Show> | ||
| 663 | - </Suspense> | ||
| 664 | - <Show when={ex().allow_review && ownResult()}> | ||
| 665 | - <div class="mt-6"> | ||
| 666 | - <AnswerSheetView examId={id()} userId={auth.user()?.id ?? ""} mode="self" /> | ||
| 667 | - </div> | ||
| 668 | </Show> | 632 | </Show> |
| 669 | - </TabsContent> | 633 | + </section> |
| 670 | - </Show> | 634 | + )} |
| 635 | + </Show> | ||
| 636 | + | ||
| 637 | + <Show when={hasCourseManagementRights()}> | ||
| 638 | + <Tabs value={examTab()} onChange={setExamTab} class="space-y-3"> | ||
| 639 | + <TabsList class="border-primary/10 bg-card/80 shadow-sm"> | ||
| 640 | + <TabsTrigger value="statistics"><IconChart class="h-4 w-4" />{t("exams.statistics")}</TabsTrigger> | ||
| 641 | + <TabsTrigger value="questions"><IconPencilQuestion class="h-4 w-4" />{t("questions.title")}</TabsTrigger> | ||
| 642 | + <TabsTrigger value="results"><IconClipboardCheck class="h-4 w-4" />{t("exams.results")}</TabsTrigger> | ||
| 643 | + </TabsList> | ||
| 671 | 644 | ||
| 672 | - <Show when={hasCourseManagementRights()}> | 645 | + <TabsContent value="statistics" forceMount class="border-border/60 bg-card/80 shadow-sm"> |
| 673 | - <TabsContent value="statistics" forceMount> | ||
| 674 | - <div class="tab-panel-note mb-4">{t("exams.examStatistics")}</div> | ||
| 675 | <Suspense fallback={<DataTableSkeleton columns={4} />}> | 646 | <Suspense fallback={<DataTableSkeleton columns={4} />}> |
| 676 | <Show when={stats()}> | 647 | <Show when={stats()}> |
| 677 | {(s) => ( | 648 | {(s) => ( |
| 678 | - <div class="grid gap-3 text-sm sm:grid-cols-4"> | 649 | + <div class="grid gap-2 text-sm sm:grid-cols-2 lg:grid-cols-4"> |
| 679 | - <div class="detail-metric-card"> | 650 | + <div class="rounded-xl border border-violet-500/30 bg-card p-4"> |
| 680 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.graded")}</p> | 651 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.graded")}</p> |
| 681 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().graded}</p> | 652 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().graded}</p> |
| 682 | </div> | 653 | </div> |
| 683 | - <div class="detail-metric-card"> | 654 | + <div class="rounded-xl border border-sky-500/30 bg-card p-4"> |
| 684 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.average")}</p> | 655 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.average")}</p> |
| 685 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().average == null ? "—" : s().average}</p> | 656 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().average == null ? "—" : s().average}</p> |
| 686 | </div> | 657 | </div> |
| 687 | - <div class="detail-metric-card"> | 658 | + <div class="rounded-xl border border-amber-500/30 bg-card p-4"> |
| 688 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.min")}</p> | 659 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.min")}</p> |
| 689 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().min == null ? "—" : s().min}</p> | 660 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().min == null ? "—" : s().min}</p> |
| 690 | </div> | 661 | </div> |
| 691 | - <div class="detail-metric-card"> | 662 | + <div class="rounded-xl border border-emerald-500/30 bg-card p-4"> |
| 692 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.max")}</p> | 663 | <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("exams.max")}</p> |
| 693 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().max == null ? "—" : s().max}</p> | 664 | <p class="mono mt-1 text-2xl font-semibold tabular-nums">{s().max == null ? "—" : s().max}</p> |
| 694 | </div> | 665 | </div> |
| @@ -698,18 +669,55 @@ function ExamDetailContent() { | |||
| 698 | </Suspense> | 669 | </Suspense> |
| 699 | </TabsContent> | 670 | </TabsContent> |
| 700 | 671 | ||
| 701 | - <TabsContent value="questions" forceMount class="space-y-4"> | 672 | + <TabsContent value="questions" forceMount class="border-border/60 bg-card/80 shadow-sm"> |
| 702 | - <div class="tab-panel-header"> | 673 | + <ExamQuestionsPanel examId={id()} courseId={ex().course} readOnly={isFinished()} embedded /> |
| 703 | - <p class="text-sm text-muted-foreground">{t("exams.examQuestions")}</p> | 674 | + </TabsContent> |
| 704 | - <Show when={hasCourseManagementRights() && !isFinished()}> | 675 | + |
| 705 | - <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => { setExamTab("questions"); setQuestionCreateOpen(true); }}> | 676 | + <TabsContent value="results" forceMount class="space-y-4 border-border/60 bg-card/80 shadow-sm"> |
| 706 | - <IconPlus class="h-4 w-4" /> | 677 | + <div class="flex flex-wrap items-center justify-between gap-3"> |
| 707 | - {t("questions.add")} | 678 | + <Badge variant="secondary" class="rounded-full">{`${resultTotal()} ${t("exams.studentResults")}`}</Badge> |
| 679 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 680 | + <Show when={isFinished()}> | ||
| 681 | + <label | ||
| 682 | + class={cn( | ||
| 683 | + "inline-flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 text-xs transition-colors hover:bg-muted/50", | ||
| 684 | + reviewOn() && "text-primary", | ||
| 685 | + )} | ||
| 686 | + title={t("exams.allowReviewHelp")} | ||
| 687 | + > | ||
| 688 | + <span class="font-medium">{t("exams.allowReview")}</span> | ||
| 689 | + <span class="relative shrink-0"> | ||
| 690 | + <input | ||
| 691 | + type="checkbox" | ||
| 692 | + class="peer sr-only" | ||
| 693 | + checked={reviewOn()} | ||
| 694 | + disabled={reviewSaving()} | ||
| 695 | + onChange={(event) => toggleReview(event.currentTarget.checked)} | ||
| 696 | + /> | ||
| 697 | + <span class="block h-6 w-10 rounded-full bg-input ring-1 ring-inset ring-black/5 transition-colors peer-checked:bg-primary peer-disabled:opacity-60 peer-focus-visible:ring-2 peer-focus-visible:ring-ring dark:ring-white/10" /> | ||
| 698 | + <span class="pointer-events-none absolute left-1 top-1 h-4 w-4 rounded-full bg-white shadow-sm transition-transform peer-checked:translate-x-4" /> | ||
| 699 | + </span> | ||
| 700 | + </label> | ||
| 701 | + </Show> | ||
| 702 | + <Button type="button" variant="outline" size="sm" class="rounded-lg" disabled={isDraft()} onClick={() => setGradeOpen(true)}> | ||
| 703 | + <IconEdit class="h-4 w-4" /> | ||
| 704 | + {t("exams.gradeStudent")} | ||
| 708 | </Button> | 705 | </Button> |
| 709 | - </Show> | 706 | + </div> |
| 710 | </div> | 707 | </div> |
| 711 | - <ExamQuestionsPanel examId={id()} courseId={ex().course} readOnly={isFinished()} embedded createOpen={questionCreateOpen()} onCreateOpenChange={setQuestionCreateOpen} /> | 708 | + <Suspense fallback={<PageSpinner />}> |
| 709 | + <Show | ||
| 710 | + when={(results()?.items ?? []).length > 0} | ||
| 711 | + fallback={<EmptyState kind="exams" title={t("exams.noResults")} />} | ||
| 712 | + > | ||
| 713 | + <DataTable columns={resultColumns()} data={results()?.items ?? []} filterColumn="user" /> | ||
| 714 | + <Show when={resultTotal() > RESULT_PAGE_SIZE}> | ||
| 715 | + <PaginationControls page={Math.min(resultPage(), resultTotalPages() - 1)} totalPages={resultTotalPages()} onPageChange={setResultPage} /> | ||
| 716 | + </Show> | ||
| 717 | + </Show> | ||
| 718 | + </Suspense> | ||
| 712 | </TabsContent> | 719 | </TabsContent> |
| 720 | + </Tabs> | ||
| 713 | 721 | ||
| 714 | <SidePanel | 722 | <SidePanel |
| 715 | open={gradeOpen()} | 723 | open={gradeOpen()} |
| @@ -730,29 +738,7 @@ function ExamDetailContent() { | |||
| 730 | }} | 738 | }} |
| 731 | /> | 739 | /> |
| 732 | </SidePanel> | 740 | </SidePanel> |
| 733 | - | 741 | + </Show> |
| 734 | - <TabsContent value="results" forceMount class="space-y-4"> | ||
| 735 | - <div class="tab-panel-header"> | ||
| 736 | - <p class="text-sm text-muted-foreground">{`${resultTotal()} ${t("exams.studentResults")}`}</p> | ||
| 737 | - <Button type="button" variant="outline" size="sm" class="rounded-lg" disabled={isDraft()} onClick={() => setGradeOpen(true)}> | ||
| 738 | - <IconEdit class="h-4 w-4" /> | ||
| 739 | - {t("exams.gradeStudent")} | ||
| 740 | - </Button> | ||
| 741 | - </div> | ||
| 742 | - <Suspense fallback={<PageSpinner />}> | ||
| 743 | - <Show | ||
| 744 | - when={(results()?.items ?? []).length > 0} | ||
| 745 | - fallback={<EmptyState kind="exams" title={t("exams.noResults")} />} | ||
| 746 | - > | ||
| 747 | - <DataTable columns={resultColumns()} data={results()?.items ?? []} filterColumn="user" /> | ||
| 748 | - <Show when={resultTotal() > RESULT_PAGE_SIZE}> | ||
| 749 | - <PaginationControls page={Math.min(resultPage(), resultTotalPages() - 1)} totalPages={resultTotalPages()} onPageChange={setResultPage} /> | ||
| 750 | - </Show> | ||
| 751 | - </Show> | ||
| 752 | - </Suspense> | ||
| 753 | - </TabsContent> | ||
| 754 | - </Show> | ||
| 755 | - </Tabs> | ||
| 756 | 742 | ||
| 757 | <Show when={flash()}> | 743 | <Show when={flash()}> |
| 758 | <Alert variant="success">{flash()}</Alert> | 744 | <Alert variant="success">{flash()}</Alert> |