forge
Explore
Log in

Don't you dare go Hollow

✨ exam detail section descriptions, grade panel, and disclosure fix

Browse files at this commit

00278f7cf0e1c8ea016a2039e6f2c0cc1b326cafBurak BoduroğluParent: 0301cb0
  • feat
    • ✨ exam detail section descriptions, grade panel, and disclosure fix
Show full message
feat: ✨ exam detail section descriptions, grade panel, and disclosure fix
- keep SectionDisclosure children mounted (no re-fetch on toggle)
- move Grade form to SidePanel, add Results header button
- disable Grade button before exam ends with hint text
- add i18n keys for exam section descriptions (details, examStatistics, etc.)
- add descriptions to schedule/statistics/questions/results headers
- fix RollCall layout: flex row, centered items, stable button widths
- add hideLabel/hideDetail props to AttendanceStatusPicker for compact use
src/components/events/attendance-status-picker.tsxmodified+12 -6
@@ -1,4 +1,4 @@
1-import { For, createMemo, createResource } from "solid-js";1+import { For, Show, createMemo, createResource } from "solid-js";
2 import { getSettings } from "@/api/getSettings";2 import { getSettings } from "@/api/getSettings";
3 import type { AttendanceStatus } from "@/api/types";3 import type { AttendanceStatus } from "@/api/types";
4 import { Label } from "@/components/ui/label";4 import { Label } from "@/components/ui/label";
@@ -11,6 +11,8 @@ export function AttendanceStatusPicker(props: {
11 value: AttendanceStatus;11 value: AttendanceStatus;
12 onChange: (status: AttendanceStatus) => void;12 onChange: (status: AttendanceStatus) => void;
13 label?: string;13 label?: string;
14+ hideLabel?: boolean;
15+ hideDetail?: boolean;
14 }) {16 }) {
15 const t = useT();17 const t = useT();
16 const [settings] = createResource(() => getSettings());18 const [settings] = createResource(() => getSettings());
@@ -21,10 +23,12 @@ export function AttendanceStatusPicker(props: {
21 const selectedMeta = createMemo(() => getAttendanceStatusMeta(props.value));23 const selectedMeta = createMemo(() => getAttendanceStatusMeta(props.value));
22 return (24 return (
23 <div class="space-y-1.5">25 <div class="space-y-1.5">
24- <Label for={props.id ?? "attendance-status"}>{props.label ?? t("events.status")}</Label>26+ <Show when={!props.hideLabel}>
27+ <Label for={props.id ?? "attendance-status"}>{props.label ?? t("events.status")}</Label>
28+ </Show>
25 <Select29 <Select
26 id={props.id ?? "attendance-status"}30 id={props.id ?? "attendance-status"}
27- class="rounded-lg bg-background/80"31+ class="h-10 rounded-lg bg-background/80"
28 value={props.value}32 value={props.value}
29 onChange={(e) => props.onChange(e.currentTarget.value as AttendanceStatus)}33 onChange={(e) => props.onChange(e.currentTarget.value as AttendanceStatus)}
30 >34 >
@@ -35,9 +39,11 @@ export function AttendanceStatusPicker(props: {
35 }}39 }}
36 </For>40 </For>
37 </Select>41 </Select>
38- <p class="text-xs text-muted-foreground">42+ <Show when={!props.hideDetail}>
39- {selectedMeta() ? `${t(selectedMeta()!.key)}: ${t(selectedMeta()!.detailKey)}` : props.value}43+ <p class="text-xs text-muted-foreground">
40- </p>44+ {selectedMeta() ? `${t(selectedMeta()!.key)}: ${t(selectedMeta()!.detailKey)}` : props.value}
45+ </p>
46+ </Show>
41 </div>47 </div>
42 );48 );
43 }49 }
src/components/sessions/course-sessions-panel.tsxmodified+10 -6
@@ -237,15 +237,19 @@ function RollCall(props: { sessionId: string; roster: Enrollment[] }) {
237 {(row) => {237 {(row) => {
238 const saved = () => rows().get(row.user.id) as SessionAttendance | undefined;238 const saved = () => rows().get(row.user.id) as SessionAttendance | undefined;
239 return (239 return (
240- <div class="grid gap-3 rounded-xl border border-border/80 bg-card p-4 shadow-sm sm:grid-cols-[minmax(0,1fr)_13rem_auto] sm:items-end">240+ <div class="space-y-2 rounded-lg border border-border/50 bg-card px-4 py-3">
241 <div class="min-w-0">241 <div class="min-w-0">
242 <p class="truncate font-medium">{personLabel(row.user)}</p>242 <p class="truncate font-medium">{personLabel(row.user)}</p>
243- <p class="mono mt-1 truncate text-xs text-muted-foreground">{row.user.id}</p>243+ <p class="mono truncate text-xs text-muted-foreground">{row.user.id}</p>
244+ </div>
245+ <div class="flex items-center gap-2">
246+ <div class="min-w-0 flex-1">
247+ <AttendanceStatusPicker hideLabel hideDetail id={`session-${props.sessionId}-${row.user.id}`} value={statusFor(row.user.id)} onChange={(status) => setLocal((current) => ({ ...current, [row.user.id]: status }))} />
248+ </div>
249+ <Button type="button" class="h-10 w-24 shrink-0 rounded-lg" variant={saved() ? "outline" : "default"} onClick={() => void save(row.user.id)}>
250+ {saved() ? t("common.update") : t("common.save")}
251+ </Button>
244 </div>252 </div>
245- <AttendanceStatusPicker id={`session-${props.sessionId}-${row.user.id}`} value={statusFor(row.user.id)} onChange={(status) => setLocal((current) => ({ ...current, [row.user.id]: status }))} />
246- <Button type="button" class="rounded-lg" variant={saved() ? "outline" : "default"} onClick={() => void save(row.user.id)}>
247- {saved() ? t("common.update") : t("common.save")}
248- </Button>
249 </div>253 </div>
250 );254 );
251 }}255 }}
src/components/ui/section-disclosure.tsxmodified+1 -1
@@ -41,7 +41,7 @@ export function SectionDisclosure(props: ParentProps<{
41 >41 >
42 <div class="min-h-0 overflow-hidden">42 <div class="min-h-0 overflow-hidden">
43 <div class={cn("space-y-4 p-4 transition-opacity duration-150 motion-reduce:transition-none", props.open ? "opacity-100" : "opacity-0")}>43 <div class={cn("space-y-4 p-4 transition-opacity duration-150 motion-reduce:transition-none", props.open ? "opacity-100" : "opacity-0")}>
44- {props.open ? props.children : null}44+ {props.children}
45 </div>45 </div>
46 </div>46 </div>
47 </div>47 </div>
src/i18n/messages.tsmodified+15 -0
@@ -206,9 +206,14 @@ export type MessageKey =
206 | "exams.yourResult"206 | "exams.yourResult"
207 | "exams.notGraded"207 | "exams.notGraded"
208 | "exams.gradeStudent"208 | "exams.gradeStudent"
209+ | "exams.gradeAfterExam"
209 | "exams.results"210 | "exams.results"
210 | "exams.noResults"211 | "exams.noResults"
212+ | "exams.details"
211 | "exams.schedule"213 | "exams.schedule"
214+ | "exams.examStatistics"
215+ | "exams.examQuestions"
216+ | "exams.studentResults"
212 | "exams.window"217 | "exams.window"
213 | "exams.unscheduled"218 | "exams.unscheduled"
214 | "exams.mode"219 | "exams.mode"
@@ -681,9 +686,14 @@ const en: Dict = {
681 "exams.yourResult": "Your result",686 "exams.yourResult": "Your result",
682 "exams.notGraded": "Not graded yet",687 "exams.notGraded": "Not graded yet",
683 "exams.gradeStudent": "Grade a student",688 "exams.gradeStudent": "Grade a student",
689+ "exams.gradeAfterExam": "Available after the exam ends",
684 "exams.results": "Results table",690 "exams.results": "Results table",
685 "exams.noResults": "No results yet.",691 "exams.noResults": "No results yet.",
692+ "exams.details": "Exam Details",
686 "exams.schedule": "Schedule",693 "exams.schedule": "Schedule",
694+ "exams.examStatistics": "Exam Statistics",
695+ "exams.examQuestions": "Exam Questions",
696+ "exams.studentResults": "Student Grades",
687 "exams.window": "Window",697 "exams.window": "Window",
688 "exams.unscheduled": "Unscheduled",698 "exams.unscheduled": "Unscheduled",
689 "exams.mode": "Mode",699 "exams.mode": "Mode",
@@ -1166,9 +1176,14 @@ const tr: Dict = {
1166 "exams.yourResult": "Sonucun",1176 "exams.yourResult": "Sonucun",
1167 "exams.notGraded": "Henüz notlanmadı",1177 "exams.notGraded": "Henüz notlanmadı",
1168 "exams.gradeStudent": "Öğrenci notla",1178 "exams.gradeStudent": "Öğrenci notla",
1179+ "exams.gradeAfterExam": "Sınav bitince kullanılabilir",
1169 "exams.results": "Sonuç tablosu",1180 "exams.results": "Sonuç tablosu",
1170 "exams.noResults": "Henüz sonuç yok.",1181 "exams.noResults": "Henüz sonuç yok.",
1182+ "exams.details": "Sınav Detayları",
1171 "exams.schedule": "Zamanlama",1183 "exams.schedule": "Zamanlama",
1184+ "exams.examStatistics": "Sınav İstatistikleri",
1185+ "exams.examQuestions": "Sınav Soruları",
1186+ "exams.studentResults": "Öğrenci Notları",
1172 "exams.window": "Aralık",1187 "exams.window": "Aralık",
1173 "exams.unscheduled": "Zamansız",1188 "exams.unscheduled": "Zamansız",
1174 "exams.mode": "Mod",1189 "exams.mode": "Mod",
src/pages/exam-detail-page.tsxmodified+38 -18
@@ -116,13 +116,13 @@ function ExamDetailContent() {
116 const [deleteOpen, setDeleteOpen] = createSignal(false);116 const [deleteOpen, setDeleteOpen] = createSignal(false);
117 const [removeUserId, setRemoveUserId] = createSignal<string | null>(null);117 const [removeUserId, setRemoveUserId] = createSignal<string | null>(null);
118 const [sheetUserId, setSheetUserId] = createSignal<string | null>(null);118 const [sheetUserId, setSheetUserId] = createSignal<string | null>(null);
119+ const [gradeOpen, setGradeOpen] = createSignal(false);
119 const [openSections, setOpenSections] = createSignal({120 const [openSections, setOpenSections] = createSignal({
120 schedule: true,121 schedule: true,
121 ownResult: false,122 ownResult: false,
122 answerSheet: false,123 answerSheet: false,
123 statistics: false,124 statistics: false,
124 questions: false,125 questions: false,
125- grade: false,
126 results: false,126 results: false,
127 });127 });
128 128
@@ -183,7 +183,7 @@ function ExamDetailContent() {
183 setPending(false);183 setPending(false);
184 }184 }
185 };185 };
186- const toggleSection = (section: "schedule" | "ownResult" | "answerSheet" | "statistics" | "questions" | "grade" | "results") => {186+ const toggleSection = (section: "schedule" | "ownResult" | "answerSheet" | "statistics" | "questions" | "results") => {
187 setOpenSections((current) => ({ ...current, [section]: !current[section] }));187 setOpenSections((current) => ({ ...current, [section]: !current[section] }));
188 };188 };
189 189
@@ -332,7 +332,7 @@ function ExamDetailContent() {
332 open={openSections().schedule}332 open={openSections().schedule}
333 onToggle={() => toggleSection("schedule")}333 onToggle={() => toggleSection("schedule")}
334 title={t("exams.schedule")}334 title={t("exams.schedule")}
335- description={examModeLabel(ex().mode)}335+ description={t("exams.details")}
336 >336 >
337 <div class="grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-4">337 <div class="grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-4">
338 <div class="rounded-lg border bg-muted/25 p-3">338 <div class="rounded-lg border bg-muted/25 p-3">
@@ -355,7 +355,12 @@ function ExamDetailContent() {
355 </SectionDisclosure>355 </SectionDisclosure>
356 356
357 <Show when={!isTeacherPlus() && !isScheduled()}>357 <Show when={!isTeacherPlus() && !isScheduled()}>
358- <SectionDisclosure open={openSections().ownResult} onToggle={() => toggleSection("ownResult")} title={t("exams.yourResult")}>358+ <SectionDisclosure
359+ open={openSections().ownResult}
360+ onToggle={() => toggleSection("ownResult")}
361+ title={t("exams.yourResult")}
362+ description={ownResult() ? `${t("form.mark")}: ${ownResult()!.mark}` : t("exams.notGraded")}
363+ >
359 <Suspense fallback={<PageSpinner />}>364 <Suspense fallback={<PageSpinner />}>
360 <Show when={ownResult()} fallback={<ExamResultBadge notGraded />}>365 <Show when={ownResult()} fallback={<ExamResultBadge notGraded />}>
361 {(r) => <ExamResultBadge mark={r().mark} />}366 {(r) => <ExamResultBadge mark={r().mark} />}
@@ -378,7 +383,7 @@ function ExamDetailContent() {
378 </Show>383 </Show>
379 384
380 <Show when={isTeacherPlus()}>385 <Show when={isTeacherPlus()}>
381- <SectionDisclosure open={openSections().statistics} onToggle={() => toggleSection("statistics")} title={t("exams.statistics")}>386+ <SectionDisclosure open={openSections().statistics} onToggle={() => toggleSection("statistics")} title={t("exams.statistics")} description={t("exams.examStatistics")}>
382 <Suspense fallback={<PageSpinner />}>387 <Suspense fallback={<PageSpinner />}>
383 <Show when={stats()}>388 <Show when={stats()}>
384 {(s) => (389 {(s) => (
@@ -409,28 +414,43 @@ function ExamDetailContent() {
409 open={openSections().questions}414 open={openSections().questions}
410 onToggle={() => toggleSection("questions")}415 onToggle={() => toggleSection("questions")}
411 title={t("questions.title")}416 title={t("questions.title")}
417+ description={t("exams.examQuestions")}
412 >418 >
413 <ExamQuestionsPanel examId={id()} readOnly={isFinished() || isUpcoming()} embedded />419 <ExamQuestionsPanel examId={id()} readOnly={isFinished() || isUpcoming()} embedded />
414 </SectionDisclosure>420 </SectionDisclosure>
415 421
416- <Show when={!isFinished()}>422+ <SidePanel
417- <SectionDisclosure open={openSections().grade} onToggle={() => toggleSection("grade")} title={t("exams.gradeStudent")}>423+ open={gradeOpen()}
418- <GradeForm424+ onOpenChange={setGradeOpen}
419- students={gradeStudents()}425+ title={t("exams.gradeStudent")}
420- onSubmit={async (values) => {426+ >
421- await postExamResult(id(), values);427+ <GradeForm
422- await refetchResults();428+ students={gradeStudents()}
423- }}429+ onSubmit={async (values) => {
424- />430+ await postExamResult(id(), values);
425- </SectionDisclosure>431+ await refetchResults();
426- </Show>432+ }}
433+ />
434+ </SidePanel>
427 435
428 <SectionDisclosure436 <SectionDisclosure
429 open={openSections().results}437 open={openSections().results}
430 onToggle={() => toggleSection("results")}438 onToggle={() => toggleSection("results")}
431 title={t("exams.results")}439 title={t("exams.results")}
432- description={`${(results() ?? []).length}`}440+ description={`${(results() ?? []).length} ${t("exams.studentResults")}`}
433- meta={<Badge variant="secondary" class="mono rounded-sm px-3 py-1">{(results() ?? []).length}</Badge>}441+ actions={
442+ <Show when={isTeacherPlus()}>
443+ <div class="flex items-center gap-2">
444+ <Show when={!isFinished()}>
445+ <span class="text-xs text-muted-foreground">{t("exams.gradeAfterExam")}</span>
446+ </Show>
447+ <Button type="button" variant="outline" size="sm" class="rounded-lg" disabled={!isFinished()} onClick={() => setGradeOpen(true)}>
448+ <IconEdit class="h-4 w-4" />
449+ {t("exams.gradeStudent")}
450+ </Button>
451+ </div>
452+ </Show>
453+ }
434 >454 >
435 <Suspense fallback={<PageSpinner />}>455 <Suspense fallback={<PageSpinner />}>
436 <Show456 <Show