forge
Explore
Log in

Don't you dare go Hollow

💄 exam question panel and flush table headers

Browse files at this commit

e726e760c27d4e214b16536d8025dc4ee97ff894Burak BoduroğluParent: 1b777d3
  • style
    • 💄 exam question panel and flush table headers
Show full message
style: 💄 exam question panel and flush table headers
- exam "add/edit question" opens in the wide side panel instead of a centred
  dialog whose footer covered the scrolling form
- form footer reaches over the panel's bottom padding, right-aligned actions,
  and a hint that tapping a letter marks the correct answer
- sectioned DataTable frame drops its inner padding, so the header row sits
  flush on the card edge and the sticky header no longer lets rows show above it
- includes the i18n keys for the question generator that follows
src/components/exams/exam-questions-panel.tsxmodified+14 -8
@@ -19,7 +19,6 @@ import { Alert } from "@/components/ui/alert";
19 import { Badge } from "@/components/ui/badge";19 import { Badge } from "@/components/ui/badge";
20 import { Button } from "@/components/ui/button";20 import { Button } from "@/components/ui/button";
21 import { ConfirmDialog } from "@/components/ui/confirm-dialog";21 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
22-import { FormDialog } from "@/components/ui/form-dialog";
23 import { SidePanel } from "@/components/ui/side-panel";22 import { SidePanel } from "@/components/ui/side-panel";
24 import { BankQuestionPicker } from "@/components/exams/bank-question-picker";23 import { BankQuestionPicker } from "@/components/exams/bank-question-picker";
25 import { QuestionForm, type QuestionValues } from "@/components/exams/question-form";24 import { QuestionForm, type QuestionValues } from "@/components/exams/question-form";
@@ -290,16 +289,23 @@ export function ExamQuestionsPanel(props: {
290 />289 />
291 </SidePanel>290 </SidePanel>
292 291
293- <FormDialog292+ {/* A question with choices, pictures and a drawing is long — it gets
293+ the full-height side panel (like the bank picker next to it) instead
294+ of a centred dialog that scrolled under its own footer. */}
295+ <SidePanel
296+ guardUnsaved
297+ size="wide"
294 open={formOpen() || editing() != null}298 open={formOpen() || editing() != null}
295 onOpenChange={(open) => {299 onOpenChange={(open) => {
296 if (!open) {300 if (!open) {
297- setEditing(null);301+ closeAfterGesture(() => {
298- setFormOpen(false);302+ setEditing(null);
303+ setFormOpen(false);
304+ });
299 }305 }
300 }}306 }}
301 title={editing() ? t("questions.edit") : t("questions.add")}307 title={editing() ? t("questions.edit") : t("questions.add")}
302- description={t("questions.title")}308+ description={editing() ? t("questions.editHelp") : t("questions.addHelp")}
303 >309 >
304 <QuestionForm310 <QuestionForm
305 initial={formInitial()}311 initial={formInitial()}
@@ -309,8 +315,8 @@ export function ExamQuestionsPanel(props: {
309 choiceImageSrc={(choiceId) => `/api/exams/${props.examId}/questions/${editing()?.id}/choices/${choiceId}/image`}315 choiceImageSrc={(choiceId) => `/api/exams/${props.examId}/questions/${editing()?.id}/choices/${choiceId}/image`}
310 loadImageBlob={editing() ? () => getExamQuestionImageBlob(props.examId, editing()!.id) : undefined}316 loadImageBlob={editing() ? () => getExamQuestionImageBlob(props.examId, editing()!.id) : undefined}
311 onCancel={() => {317 onCancel={() => {
312- // In-body Cancel bypasses FormDialog's deferred onOpenChange, so318+ // Deferred like the panel's own close — otherwise the same tap
313- // defer here too — otherwise the same tap can reopen the form.319+ // can land on the trigger underneath and reopen the form.
314 closeAfterGesture(() => {320 closeAfterGesture(() => {
315 setEditing(null);321 setEditing(null);
316 setFormOpen(false);322 setFormOpen(false);
@@ -318,7 +324,7 @@ export function ExamQuestionsPanel(props: {
318 }}324 }}
319 onSubmit={submit}325 onSubmit={submit}
320 />326 />
321- </FormDialog>327+ </SidePanel>
322 328
323 {error() && <p class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>}329 {error() && <p class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>}
324 330
src/components/exams/question-form.tsxmodified+18 -10
@@ -58,6 +58,8 @@ export type QuestionFormInitial = {
58 58
59 export function QuestionForm(props: {59 export function QuestionForm(props: {
60 initial?: QuestionFormInitial;60 initial?: QuestionFormInitial;
61+ /** Starting text/kind for a new question (an AI-generated draft); ignored when `initial` is set. */
62+ draft?: { text: string; kind: QuestionKind };
61 subjects: Subject[];63 subjects: Subject[];
62 /** True while `subjects` is still loading, so a missing subject is not misreported. */64 /** True while `subjects` is still loading, so a missing subject is not misreported. */
63 subjectsPending?: boolean;65 subjectsPending?: boolean;
@@ -72,10 +74,10 @@ export function QuestionForm(props: {
72 }) {74 }) {
73 const t = useT();75 const t = useT();
74 let textAreaRef: HTMLTextAreaElement | undefined;76 let textAreaRef: HTMLTextAreaElement | undefined;
75- const [text, setText] = createSignal(props.initial?.text ?? "");77+ const [text, setText] = createSignal(props.initial?.text ?? props.draft?.text ?? "");
76 // No first-subject default: the subject is submitted, so the user picks it.78 // No first-subject default: the subject is submitted, so the user picks it.
77 const [subjectId, setSubjectId] = createSignal(props.initial?.subject ?? "");79 const [subjectId, setSubjectId] = createSignal(props.initial?.subject ?? "");
78- const [kind, setKind] = createSignal<QuestionKind>(props.initial?.kind ?? "choice");80+ const [kind, setKind] = createSignal<QuestionKind>(props.initial?.kind ?? props.draft?.kind ?? "choice");
79 const [points, setPoints] = createSignal(String(props.initial?.points ?? 1));81 const [points, setPoints] = createSignal(String(props.initial?.points ?? 1));
80 const [choiceSet, setChoiceSet] = createSignal<ChoiceSet>(82 const [choiceSet, setChoiceSet] = createSignal<ChoiceSet>(
81 props.initial ? storedChoiceSet(props.initial.choices, props.initial.correct) : blankChoiceSet(),83 props.initial ? storedChoiceSet(props.initial.choices, props.initial.correct) : blankChoiceSet(),
@@ -99,9 +101,9 @@ export function QuestionForm(props: {
99 createEffect(() => {101 createEffect(() => {
100 const initial = props.initial;102 const initial = props.initial;
101 untrack(() => {103 untrack(() => {
102- setText(initial?.text ?? "");104+ setText(initial?.text ?? props.draft?.text ?? "");
103 setSubjectId(initial?.subject ?? "");105 setSubjectId(initial?.subject ?? "");
104- setKind(initial?.kind ?? "choice");106+ setKind(initial?.kind ?? props.draft?.kind ?? "choice");
105 setPoints(String(initial?.points ?? 1));107 setPoints(String(initial?.points ?? 1));
106 setChoiceSet(initial ? storedChoiceSet(initial.choices, initial.correct) : blankChoiceSet());108 setChoiceSet(initial ? storedChoiceSet(initial.choices, initial.correct) : blankChoiceSet());
107 setImage(null);109 setImage(null);
@@ -380,7 +382,10 @@ export function QuestionForm(props: {
380 <Show when={kind() === "choice"}>382 <Show when={kind() === "choice"}>
381 <div class="rounded-lg border bg-card p-3.5 shadow-xs">383 <div class="rounded-lg border bg-card p-3.5 shadow-xs">
382 <div class="mb-3 flex items-center justify-between gap-2 border-b border-border/50 pb-2">384 <div class="mb-3 flex items-center justify-between gap-2 border-b border-border/50 pb-2">
383- <Label class="text-sm font-semibold">{t("questions.choices")}</Label>385+ <div class="min-w-0">
386+ <Label class="text-sm font-semibold">{t("questions.choices")}</Label>
387+ <p class="mt-0.5 text-xs text-muted-foreground">{t("questions.correctHint")}</p>
388+ </div>
384 <Button type="button" variant="outline" size="sm" class="h-7 gap-1 text-xs" disabled={rows().length >= BANK_QUESTION_LIMITS.maxChoices} onClick={addChoice}>389 <Button type="button" variant="outline" size="sm" class="h-7 gap-1 text-xs" disabled={rows().length >= BANK_QUESTION_LIMITS.maxChoices} onClick={addChoice}>
385 <IconPlus class="h-3.5 w-3.5" />390 <IconPlus class="h-3.5 w-3.5" />
386 {t("questions.addChoice")}391 {t("questions.addChoice")}
@@ -464,13 +469,16 @@ export function QuestionForm(props: {
464 469
465 {error() && <p class="rounded-sm bg-destructive/10 px-3 py-1.5 text-sm text-destructive-text">{error()}</p>}470 {error() && <p class="rounded-sm bg-destructive/10 px-3 py-1.5 text-sm text-destructive-text">{error()}</p>}
466 471
467- <div class="sticky bottom-0 -mx-5 flex flex-wrap items-center gap-2 border-t border-border-hairline bg-surface-base px-5 pb-1 pt-4">472+ {/* `-bottom-5 pb-5` reaches over the panel body's own bottom padding —
468- <Button type="submit" class="h-8 text-xs font-semibold" disabled={pending()}>473+ with `bottom-0` the footer stuck above it and the form scrolled
469- {props.submitLabel ?? (props.initial ? t("common.update") : t("common.create"))}474+ visibly underneath. */}
470- </Button>475+ <div class="!mt-auto sticky -bottom-5 z-10 -mx-5 -mb-5 flex flex-wrap items-center justify-end gap-2 border-t border-border-hairline bg-surface-base px-5 pb-5 pt-4">
471- <Button type="button" variant="outline" class="h-8 text-xs font-semibold" onClick={props.onCancel}>476+ <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={props.onCancel}>
472 {t("common.cancel")}477 {t("common.cancel")}
473 </Button>478 </Button>
479+ <Button type="submit" size="sm" class="min-w-[7.5rem] rounded-lg" disabled={pending()}>
480+ {props.submitLabel ?? (props.initial ? t("common.update") : t("common.create"))}
481+ </Button>
474 </div>482 </div>
475 </form>483 </form>
476 );484 );
src/components/ui/data-table.tsxmodified+5 -1
@@ -400,7 +400,11 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
400 </ul>400 </ul>
401 </Show>401 </Show>
402 <Show when={!useCards()}>402 <Show when={!useCards()}>
403- <DataTableFrame class={sectioned() ? "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs sm:p-4" : undefined}>403+ {/* No inner padding: the header row sits flush on the card's top edge.
404+ A padded frame left it floating inside the card, and the sticky
405+ header then pinned below that padding while rows scrolled through
406+ the gap above it. */}
407+ <DataTableFrame class={sectioned() ? "shadow-xs" : undefined}>
404 <Table408 <Table
405 class={cn("data-table table-fixed", props.tableClass)}409 class={cn("data-table table-fixed", props.tableClass)}
406 style={{ width: `max(100%, ${tableWidth()}px)` }}410 style={{ width: `max(100%, ${tableWidth()}px)` }}
src/i18n/locales/en.tsmodified+28 -1
@@ -433,6 +433,31 @@ export const en: Dict = {
433 "nav.studentAnalysis": "Student analysis",433 "nav.studentAnalysis": "Student analysis",
434 "nav.pendingApprovals": "Pending approvals",434 "nav.pendingApprovals": "Pending approvals",
435 "nav.questionGeneration": "Question generation",435 "nav.questionGeneration": "Question generation",
436+ "qgen.subtitle": "Generate practice questions from a page range of your own course notes.",
437+ "qgen.scope": "Course and grade",
438+ "qgen.scopePlaceholder": "Pick a course",
439+ "qgen.noScopes": "You are not assigned to any section's course yet. Generation works on the courses of the sections you teach.",
440+ "qgen.pages": "Pages",
441+ "qgen.pagesHint": "Page numbers in the course notes, e.g. 3-7, 10",
442+ "qgen.pagesInvalid": "Write the pages like 3-7, 10.",
443+ "qgen.count": "Questions",
444+ "qgen.difficulty": "Difficulty",
445+ "qgen.seed": "Example question (optional)",
446+ "qgen.seedHint": "Given one, the set is variations of it.",
447+ "qgen.generate": "Generate",
448+ "qgen.generating": "Preparing questions…",
449+ "qgen.results": "Generated questions",
450+ "qgen.resultsEmpty": "Pick a course and a page range, and the questions appear here.",
451+ "qgen.noQuestions": "No questions could be drawn from this range.",
452+ "qgen.showAnswer": "Show answer",
453+ "qgen.hideAnswer": "Hide answer",
454+ "qgen.addToBank": "Add to bank",
455+ "qgen.copy": "Copy",
456+ "qgen.copied": "Copied",
457+ "qgen.unavailable": "Question generation is not available right now; the AI service for it is not connected.",
458+ "qgen.outOfScope": "This course and grade are not among the sections you teach.",
459+ "qgen.coveredPages": "Pages covered: {pages}",
460+ "qgen.savedToBank": "The question was added to the bank.",
436 "nav.parentCommunication": "Parent communication",461 "nav.parentCommunication": "Parent communication",
437 "nav.studyPlan": "Study plan",462 "nav.studyPlan": "Study plan",
438 "nav.topicMastery": "Topic mastery",463 "nav.topicMastery": "Topic mastery",
@@ -1343,6 +1368,8 @@ export const en: Dict = {
1343 "questions.title": "Questions",1368 "questions.title": "Questions",
1344 "questions.add": "Add question",1369 "questions.add": "Add question",
1345 "questions.edit": "Edit question",1370 "questions.edit": "Edit question",
1371+ "questions.addHelp": "Write the question, pick its subject and points, then mark the correct choice.",
1372+ "questions.editHelp": "Changes apply only to this exam.",
1346 "questions.empty": "No questions yet.",1373 "questions.empty": "No questions yet.",
1347 "questions.text": "Question text",1374 "questions.text": "Question text",
1348 "questions.kind": "Question kind",1375 "questions.kind": "Question kind",
@@ -1353,7 +1380,7 @@ export const en: Dict = {
1353 "questions.choicePlaceholder": "Choice {index}",1380 "questions.choicePlaceholder": "Choice {index}",
1354 "questions.correctAnswer": "Correct answer",1381 "questions.correctAnswer": "Correct answer",
1355 "questions.correct": "Mark correct",1382 "questions.correct": "Mark correct",
1356- "questions.correctHint": "Zero-based: first choice is 0.",1383+ "questions.correctHint": "Tap a letter to mark the correct answer.",
1357 "questions.kind.choice": "Choice",1384 "questions.kind.choice": "Choice",
1358 "questions.kind.text": "Text",1385 "questions.kind.text": "Text",
1359 "questions.image": "Question image",1386 "questions.image": "Question image",
src/i18n/locales/tr.tsmodified+28 -1
@@ -429,6 +429,31 @@ export const tr: Dict = {
429 "nav.studentAnalysis": "Öğrenci analizi",429 "nav.studentAnalysis": "Öğrenci analizi",
430 "nav.pendingApprovals": "Bekleyen onaylar",430 "nav.pendingApprovals": "Bekleyen onaylar",
431 "nav.questionGeneration": "Soru üretimi",431 "nav.questionGeneration": "Soru üretimi",
432+ "qgen.subtitle": "Kendi ders notlarının seçtiğin sayfa aralığından pratik sorular üret.",
433+ "qgen.scope": "Ders ve sınıf",
434+ "qgen.scopePlaceholder": "Ders seç",
435+ "qgen.noScopes": "Henüz bir şubenin dersine atanmadın. Soru üretimi, öğrettiğin şubelerin derslerinde çalışır.",
436+ "qgen.pages": "Sayfalar",
437+ "qgen.pagesHint": "Ders notlarındaki sayfa numaraları, ör. 3-7, 10",
438+ "qgen.pagesInvalid": "Sayfaları 3-7, 10 biçiminde yaz.",
439+ "qgen.count": "Soru sayısı",
440+ "qgen.difficulty": "Zorluk",
441+ "qgen.seed": "Örnek soru (isteğe bağlı)",
442+ "qgen.seedHint": "Yazarsan bu sorunun varyasyonları üretilir.",
443+ "qgen.generate": "Soru üret",
444+ "qgen.generating": "Sorular hazırlanıyor…",
445+ "qgen.results": "Üretilen sorular",
446+ "qgen.resultsEmpty": "Ders ve sayfa aralığı seç; sorular burada görünür.",
447+ "qgen.noQuestions": "Bu aralıktan soru çıkarılamadı.",
448+ "qgen.showAnswer": "Cevabı göster",
449+ "qgen.hideAnswer": "Cevabı gizle",
450+ "qgen.addToBank": "Bankaya ekle",
451+ "qgen.copy": "Kopyala",
452+ "qgen.copied": "Kopyalandı",
453+ "qgen.unavailable": "Soru üretimi şu an kullanılamıyor; bunun için yapay zekâ servisi bağlı değil.",
454+ "qgen.outOfScope": "Bu ders ve sınıf öğrettiğin şubeler arasında değil.",
455+ "qgen.coveredPages": "Kapsanan sayfalar: {pages}",
456+ "qgen.savedToBank": "Soru bankaya eklendi.",
432 "nav.parentCommunication": "Veli iletişimi",457 "nav.parentCommunication": "Veli iletişimi",
433 "nav.studyPlan": "Çalışma programım",458 "nav.studyPlan": "Çalışma programım",
434 "nav.topicMastery": "Konu yetkinliğim",459 "nav.topicMastery": "Konu yetkinliğim",
@@ -1339,6 +1364,8 @@ export const tr: Dict = {
1339 "questions.title": "Sorular",1364 "questions.title": "Sorular",
1340 "questions.add": "Soru ekle",1365 "questions.add": "Soru ekle",
1341 "questions.edit": "Soruyu düzenle",1366 "questions.edit": "Soruyu düzenle",
1367+ "questions.addHelp": "Soruyu yaz, konusunu ve puanını seç, ardından doğru seçeneği işaretle.",
1368+ "questions.editHelp": "Değişiklikler yalnızca bu sınavda geçerli olur.",
1342 "questions.empty": "Henüz soru yok.",1369 "questions.empty": "Henüz soru yok.",
1343 "questions.text": "Soru metni",1370 "questions.text": "Soru metni",
1344 "questions.kind": "Soru türü",1371 "questions.kind": "Soru türü",
@@ -1349,7 +1376,7 @@ export const tr: Dict = {
1349 "questions.choicePlaceholder": "Seçenek {index}",1376 "questions.choicePlaceholder": "Seçenek {index}",
1350 "questions.correctAnswer": "Doğru cevap",1377 "questions.correctAnswer": "Doğru cevap",
1351 "questions.correct": "Doğru seç",1378 "questions.correct": "Doğru seç",
1352- "questions.correctHint": "Sıfırdan başlar: ilk seçenek 0.",1379+ "questions.correctHint": "Doğru cevabı işaretlemek için harfe tıkla.",
1353 "questions.kind.choice": "Seçmeli",1380 "questions.kind.choice": "Seçmeli",
1354 "questions.kind.text": "Metin",1381 "questions.kind.text": "Metin",
1355 "questions.image": "Soru görseli",1382 "questions.image": "Soru görseli",
src/i18n/messages.tsmodified+27 -0
@@ -401,6 +401,31 @@ export type MessageKey =
401 | "nav.studentAnalysis"401 | "nav.studentAnalysis"
402 | "nav.pendingApprovals"402 | "nav.pendingApprovals"
403 | "nav.questionGeneration"403 | "nav.questionGeneration"
404+ | "qgen.subtitle"
405+ | "qgen.scope"
406+ | "qgen.scopePlaceholder"
407+ | "qgen.noScopes"
408+ | "qgen.pages"
409+ | "qgen.pagesHint"
410+ | "qgen.pagesInvalid"
411+ | "qgen.count"
412+ | "qgen.difficulty"
413+ | "qgen.seed"
414+ | "qgen.seedHint"
415+ | "qgen.generate"
416+ | "qgen.generating"
417+ | "qgen.results"
418+ | "qgen.resultsEmpty"
419+ | "qgen.noQuestions"
420+ | "qgen.showAnswer"
421+ | "qgen.hideAnswer"
422+ | "qgen.addToBank"
423+ | "qgen.copy"
424+ | "qgen.copied"
425+ | "qgen.unavailable"
426+ | "qgen.outOfScope"
427+ | "qgen.coveredPages"
428+ | "qgen.savedToBank"
404 | "nav.parentCommunication"429 | "nav.parentCommunication"
405 | "nav.studyPlan"430 | "nav.studyPlan"
406 | "nav.topicMastery"431 | "nav.topicMastery"
@@ -1242,6 +1267,8 @@ export type MessageKey =
1242 | "questions.title"1267 | "questions.title"
1243 | "questions.add"1268 | "questions.add"
1244 | "questions.edit"1269 | "questions.edit"
1270+ | "questions.addHelp"
1271+ | "questions.editHelp"
1245 | "questions.empty"1272 | "questions.empty"
1246 | "questions.text"1273 | "questions.text"
1247 | "questions.kind"1274 | "questions.kind"