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";
1919 import { Badge } from "@/components/ui/badge";
2020 import { Button } from "@/components/ui/button";
2121 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
22-import { FormDialog } from "@/components/ui/form-dialog";
2322 import { SidePanel } from "@/components/ui/side-panel";
2423 import { BankQuestionPicker } from "@/components/exams/bank-question-picker";
2524 import { QuestionForm, type QuestionValues } from "@/components/exams/question-form";
@@ -290,16 +289,23 @@ export function ExamQuestionsPanel(props: {
290289 />
291290 </SidePanel>
292291
293- <FormDialog
292+ {/* 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"
294298 open={formOpen() || editing() != null}
295299 onOpenChange={(open) => {
296300 if (!open) {
297- setEditing(null);
298- setFormOpen(false);
301+ closeAfterGesture(() => {
302+ setEditing(null);
303+ setFormOpen(false);
304+ });
299305 }
300306 }}
301307 title={editing() ? t("questions.edit") : t("questions.add")}
302- description={t("questions.title")}
308+ description={editing() ? t("questions.editHelp") : t("questions.addHelp")}
303309 >
304310 <QuestionForm
305311 initial={formInitial()}
@@ -309,8 +315,8 @@ export function ExamQuestionsPanel(props: {
309315 choiceImageSrc={(choiceId) => `/api/exams/${props.examId}/questions/${editing()?.id}/choices/${choiceId}/image`}
310316 loadImageBlob={editing() ? () => getExamQuestionImageBlob(props.examId, editing()!.id) : undefined}
311317 onCancel={() => {
312- // In-body Cancel bypasses FormDialog's deferred onOpenChange, so
313- // defer here too — otherwise the same tap can reopen the form.
318+ // Deferred like the panel's own close — otherwise the same tap
319+ // can land on the trigger underneath and reopen the form.
314320 closeAfterGesture(() => {
315321 setEditing(null);
316322 setFormOpen(false);
@@ -318,7 +324,7 @@ export function ExamQuestionsPanel(props: {
318324 }}
319325 onSubmit={submit}
320326 />
321- </FormDialog>
327+ </SidePanel>
322328
323329 {error() && <p class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>}
324330
src/components/exams/question-form.tsxmodified+18 -10
@@ -58,6 +58,8 @@ export type QuestionFormInitial = {
5858
5959 export function QuestionForm(props: {
6060 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 };
6163 subjects: Subject[];
6264 /** True while `subjects` is still loading, so a missing subject is not misreported. */
6365 subjectsPending?: boolean;
@@ -72,10 +74,10 @@ export function QuestionForm(props: {
7274 }) {
7375 const t = useT();
7476 let textAreaRef: HTMLTextAreaElement | undefined;
75- const [text, setText] = createSignal(props.initial?.text ?? "");
77+ const [text, setText] = createSignal(props.initial?.text ?? props.draft?.text ?? "");
7678 // No first-subject default: the subject is submitted, so the user picks it.
7779 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");
7981 const [points, setPoints] = createSignal(String(props.initial?.points ?? 1));
8082 const [choiceSet, setChoiceSet] = createSignal<ChoiceSet>(
8183 props.initial ? storedChoiceSet(props.initial.choices, props.initial.correct) : blankChoiceSet(),
@@ -99,9 +101,9 @@ export function QuestionForm(props: {
99101 createEffect(() => {
100102 const initial = props.initial;
101103 untrack(() => {
102- setText(initial?.text ?? "");
104+ setText(initial?.text ?? props.draft?.text ?? "");
103105 setSubjectId(initial?.subject ?? "");
104- setKind(initial?.kind ?? "choice");
106+ setKind(initial?.kind ?? props.draft?.kind ?? "choice");
105107 setPoints(String(initial?.points ?? 1));
106108 setChoiceSet(initial ? storedChoiceSet(initial.choices, initial.correct) : blankChoiceSet());
107109 setImage(null);
@@ -380,7 +382,10 @@ export function QuestionForm(props: {
380382 <Show when={kind() === "choice"}>
381383 <div class="rounded-lg border bg-card p-3.5 shadow-xs">
382384 <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>
384389 <Button type="button" variant="outline" size="sm" class="h-7 gap-1 text-xs" disabled={rows().length >= BANK_QUESTION_LIMITS.maxChoices} onClick={addChoice}>
385390 <IconPlus class="h-3.5 w-3.5" />
386391 {t("questions.addChoice")}
@@ -464,13 +469,16 @@ export function QuestionForm(props: {
464469
465470 {error() && <p class="rounded-sm bg-destructive/10 px-3 py-1.5 text-sm text-destructive-text">{error()}</p>}
466471
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">
468- <Button type="submit" class="h-8 text-xs font-semibold" disabled={pending()}>
469- {props.submitLabel ?? (props.initial ? t("common.update") : t("common.create"))}
470- </Button>
471- <Button type="button" variant="outline" class="h-8 text-xs font-semibold" onClick={props.onCancel}>
472+ {/* `-bottom-5 pb-5` reaches over the panel body's own bottom padding —
473+ with `bottom-0` the footer stuck above it and the form scrolled
474+ visibly underneath. */}
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">
476+ <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={props.onCancel}>
472477 {t("common.cancel")}
473478 </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>
474482 </div>
475483 </form>
476484 );
src/components/ui/data-table.tsxmodified+5 -1
@@ -400,7 +400,11 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
400400 </ul>
401401 </Show>
402402 <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}>
404408 <Table
405409 class={cn("data-table table-fixed", props.tableClass)}
406410 style={{ width: `max(100%, ${tableWidth()}px)` }}
src/i18n/locales/en.tsmodified+28 -1
@@ -433,6 +433,31 @@ export const en: Dict = {
433433 "nav.studentAnalysis": "Student analysis",
434434 "nav.pendingApprovals": "Pending approvals",
435435 "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.",
436461 "nav.parentCommunication": "Parent communication",
437462 "nav.studyPlan": "Study plan",
438463 "nav.topicMastery": "Topic mastery",
@@ -1343,6 +1368,8 @@ export const en: Dict = {
13431368 "questions.title": "Questions",
13441369 "questions.add": "Add question",
13451370 "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.",
13461373 "questions.empty": "No questions yet.",
13471374 "questions.text": "Question text",
13481375 "questions.kind": "Question kind",
@@ -1353,7 +1380,7 @@ export const en: Dict = {
13531380 "questions.choicePlaceholder": "Choice {index}",
13541381 "questions.correctAnswer": "Correct answer",
13551382 "questions.correct": "Mark correct",
1356- "questions.correctHint": "Zero-based: first choice is 0.",
1383+ "questions.correctHint": "Tap a letter to mark the correct answer.",
13571384 "questions.kind.choice": "Choice",
13581385 "questions.kind.text": "Text",
13591386 "questions.image": "Question image",
src/i18n/locales/tr.tsmodified+28 -1
@@ -429,6 +429,31 @@ export const tr: Dict = {
429429 "nav.studentAnalysis": "Öğrenci analizi",
430430 "nav.pendingApprovals": "Bekleyen onaylar",
431431 "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.",
432457 "nav.parentCommunication": "Veli iletişimi",
433458 "nav.studyPlan": "Çalışma programım",
434459 "nav.topicMastery": "Konu yetkinliğim",
@@ -1339,6 +1364,8 @@ export const tr: Dict = {
13391364 "questions.title": "Sorular",
13401365 "questions.add": "Soru ekle",
13411366 "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.",
13421369 "questions.empty": "Henüz soru yok.",
13431370 "questions.text": "Soru metni",
13441371 "questions.kind": "Soru türü",
@@ -1349,7 +1376,7 @@ export const tr: Dict = {
13491376 "questions.choicePlaceholder": "Seçenek {index}",
13501377 "questions.correctAnswer": "Doğru cevap",
13511378 "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.",
13531380 "questions.kind.choice": "Seçmeli",
13541381 "questions.kind.text": "Metin",
13551382 "questions.image": "Soru görseli",
src/i18n/messages.tsmodified+27 -0
@@ -401,6 +401,31 @@ export type MessageKey =
401401 | "nav.studentAnalysis"
402402 | "nav.pendingApprovals"
403403 | "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"
404429 | "nav.parentCommunication"
405430 | "nav.studyPlan"
406431 | "nav.topicMastery"
@@ -1242,6 +1267,8 @@ export type MessageKey =
12421267 | "questions.title"
12431268 | "questions.add"
12441269 | "questions.edit"
1270+ | "questions.addHelp"
1271+ | "questions.editHelp"
12451272 | "questions.empty"
12461273 | "questions.text"
12471274 | "questions.kind"