forge
Explore
Log in

Don't you dare go Hollow

✨ live exams, Turkish i18n, and mobile tab bar

Browse files at this commit

7024736eb0c0a0ef58377ff1f2aebd121d301944Ahmet Kaan GümüşParent: b2179ec
  • feat
    • ✨ live exams, Turkish i18n, and mobile tab bar
Show full message
feat: ✨ live exams, Turkish i18n, and mobile tab bar

- mirror the backend exam contract: schedule fields, attempts,
  questions/answers, live monitor, /time clock sync, ws proxy
- exam scheduling UI in plain words with client-side window validation
- teacher question authoring: choice/written, points, correct pick
- student exam room: server-judged countdown, WebSocket autosave with
  REST fallback, two-step turn-in, review after submit or expiry
- teacher live monitor over SSE with answer sheets, auto-score
  suggestion, and inline grading
- full English/Turkish dictionaries, persisted toggle, localized dates,
  document lang so Turkish casing renders İ correctly
- weight badges speak plain words ("counts ×2" / "×2 sayılır")
- bottom tab bar within thumb reach on small screens

32 changed files +3184 -406

src/app.tsxmodified+2 -0
@@ -16,6 +16,7 @@ const Courses = lazy(() => import("./pages/Courses"));
1616 const CourseDetail = lazy(() => import("./pages/CourseDetail"));
1717 const Exams = lazy(() => import("./pages/Exams"));
1818 const ExamDetail = lazy(() => import("./pages/ExamDetail"));
19+const ExamRoom = lazy(() => import("./pages/ExamRoom"));
1920 const Marks = lazy(() => import("./pages/Marks"));
2021 const Profile = lazy(() => import("./pages/Profile"));
2122 const Users = lazy(() => import("./pages/Users"));
@@ -46,6 +47,7 @@ export function App() {
4647 <Route path="/courses/:id" component={CourseDetail} />
4748 <Route path="/exams" component={Exams} />
4849 <Route path="/exams/:id" component={ExamDetail} />
50+ <Route path="/exams/:id/room" component={ExamRoom} />
4951 <Route path="/marks" component={Marks} />
5052 <Route path="/profile" component={Profile} />
5153 <Route path="/users" component={Users} />
src/components/ConfirmButton.tsxadded+49 -0
@@ -0,0 +1,49 @@
1+// Two-step destructive button: the first press arms it ("Really delete?"),
2+// the second fires. It disarms by itself after a moment or when focus leaves,
3+// so a stray tap never destroys anything.
4+
5+import { Show, createSignal, onCleanup, type JSX } from "solid-js";
6+import { t } from "../lib/i18n";
7+
8+export function ConfirmButton(props: {
9+ children: JSX.Element;
10+ onConfirm: () => void;
11+ /** Armed label; defaults to the localized "Really delete?". */
12+ confirmText?: string;
13+ /** Resting classes; defaults to "ghost danger". */
14+ class?: string;
15+ disabled?: boolean;
16+}) {
17+ const [armed, setArmed] = createSignal(false);
18+ let timer: ReturnType<typeof setTimeout> | undefined;
19+ onCleanup(() => clearTimeout(timer));
20+
21+ const disarm = () => {
22+ clearTimeout(timer);
23+ setArmed(false);
24+ };
25+
26+ const press = () => {
27+ if (armed()) {
28+ disarm();
29+ props.onConfirm();
30+ } else {
31+ setArmed(true);
32+ timer = setTimeout(disarm, 4000);
33+ }
34+ };
35+
36+ return (
37+ <button
38+ type="button"
39+ class={`${props.class ?? "ghost danger"}${armed() ? " confirm-armed" : ""}`}
40+ disabled={props.disabled}
41+ onClick={press}
42+ onBlur={disarm}
43+ >
44+ <Show when={armed()} fallback={props.children}>
45+ {props.confirmText ?? t("reallyDelete")}
46+ </Show>
47+ </button>
48+ );
49+}
src/components/ExamMonitor.tsxadded+219 -0
@@ -0,0 +1,219 @@
1+// The teacher's live view of a scheduled exam: who's in, who's still writing,
2+// time each student has left, marks as they land. Fed by the backend's SSE
3+// stream (a fresh snapshot every couple of seconds); the browser's
4+// EventSource reconnects by itself. Each row opens the student's answer
5+// sheet with the machine's auto-score suggestion and an inline grade box.
6+
7+import { For, Show, createResource, createSignal, onCleanup } from "solid-js";
8+import { createAction } from "../lib/action";
9+import { exams } from "../lib/api";
10+import { formatCountdown, personLabel } from "../lib/format";
11+import { t } from "../lib/i18n";
12+import type { Exam, ExamLive, LiveStudent, PersonRef } from "../lib/types";
13+import { LIMITS } from "../lib/types";
14+import { Empty, ErrorLine, Loading } from "./Feedback";
15+
16+export function ExamMonitor(props: { exam: Exam }) {
17+ const [snapshot, setSnapshot] = createSignal<ExamLive | null>(null);
18+ const [reviewing, setReviewing] = createSignal<PersonRef | null>(null);
19+
20+ const source = new EventSource(exams.liveStreamUrl(props.exam.id), {
21+ withCredentials: true,
22+ });
23+ source.addEventListener("snapshot", (event) => {
24+ setSnapshot(JSON.parse((event as MessageEvent).data) as ExamLive);
25+ });
26+ onCleanup(() => source.close());
27+
28+ const seconds = (student: LiveStudent) =>
29+ student.remaining_ms === null ? "—" : formatCountdown(student.remaining_ms);
30+
31+ const activity = (student: LiveStudent, now: number) => {
32+ if (student.last_activity === null) return "—";
33+ const secondsAgo = Math.max(0, Math.round((now - student.last_activity) / 1000));
34+ return secondsAgo < 120
35+ ? t("agoSeconds")(secondsAgo)
36+ : t("agoMinutes")(Math.round(secondsAgo / 60));
37+ };
38+
39+ return (
40+ <article class="stack gap-top">
41+ <h2>{t("liveMonitor")}</h2>
42+ <Show when={snapshot()} fallback={<Loading />}>
43+ {(live) => (
44+ <>
45+ <div class="live-counts">
46+ <span class="badge">{t("countEnrolled")(live().counts.enrolled)}</span>
47+ <span class="badge phase-open">{t("countWriting")(live().counts.in_progress)}</span>
48+ <span class="badge">{t("countTurnedIn")(live().counts.submitted)}</span>
49+ <span class="badge">{t("countNotStarted")(live().counts.not_started)}</span>
50+ <Show when={live().counts.expired > 0}>
51+ <span class="badge phase-closed">{t("countTimeUp")(live().counts.expired)}</span>
52+ </Show>
53+ <span class="badge">{t("countGraded")(live().counts.graded)}</span>
54+ </div>
55+
56+ <Show
57+ when={live().students.length}
58+ fallback={<Empty>{t("nobodyEnrolledCourse")}</Empty>}
59+ >
60+ <div class="table-wrap">
61+ <table>
62+ <thead>
63+ <tr>
64+ <th>{t("student")}</th>
65+ <th>{t("status")}</th>
66+ <th>{t("answeredCol")}</th>
67+ <th>{t("timeLeftCol")}</th>
68+ <th>{t("lastSaveCol")}</th>
69+ <th>{t("markCol")}</th>
70+ <th />
71+ </tr>
72+ </thead>
73+ <tbody>
74+ <For each={live().students}>
75+ {(student) => (
76+ <tr>
77+ <td>{personLabel(student.user)}</td>
78+ <td>
79+ <span class={`badge status-${student.status}`}>
80+ {t("liveStatusWord")(student.status)}
81+ </span>
82+ </td>
83+ <td>
84+ {student.answered} / {live().question_count}
85+ </td>
86+ <td>{seconds(student)}</td>
87+ <td class="meta">{activity(student, live().now)}</td>
88+ <td>{student.mark ?? "—"}</td>
89+ <td>
90+ <Show when={student.status !== "not_started"}>
91+ <button
92+ class="ghost"
93+ onClick={() =>
94+ setReviewing((current) =>
95+ current?.id === student.user.id ? null : student.user,
96+ )
97+ }
98+ >
99+ {reviewing()?.id === student.user.id ? t("close") : t("review")}
100+ </button>
101+ </Show>
102+ </td>
103+ </tr>
104+ )}
105+ </For>
106+ </tbody>
107+ </table>
108+ </div>
109+ </Show>
110+
111+ <Show when={reviewing()}>
112+ {(student) => <AnswerSheet examId={props.exam.id} student={student()} />}
113+ </Show>
114+ </>
115+ )}
116+ </Show>
117+ </article>
118+ );
119+}
120+
121+/** One student's judged answers plus the auto-score suggestion and a grade box. */
122+function AnswerSheet(props: { examId: string; student: PersonRef }) {
123+ const [sheet] = createResource(
124+ () => [props.examId, props.student.id] as const,
125+ ([examId, userId]) => exams.attemptAnswers(examId, userId),
126+ );
127+ // The authored questions (with text/choices/correct) to render rows against.
128+ const [questions] = createResource(() => props.examId, exams.questions);
129+
130+ const grade = createAction(async (form: HTMLFormElement) => {
131+ const data = new FormData(form);
132+ await exams.grade(props.examId, props.student.id, Number(data.get("mark")));
133+ });
134+
135+ const suggestion = () => {
136+ const auto = sheet()?.auto_score;
137+ return auto && auto.possible > 0
138+ ? Math.round((auto.earned / auto.possible) * 100)
139+ : undefined;
140+ };
141+
142+ return (
143+ <div class="card stack">
144+ <h3>{t("sheetTitle")(personLabel(props.student))}</h3>
145+ <Show when={sheet() && questions()} fallback={<Loading />}>
146+ <Show
147+ when={questions()!.length}
148+ fallback={<Empty>{t("noQuestionsSheet")}</Empty>}
149+ >
150+ <div class="stack">
151+ <For each={questions()}>
152+ {(question, index) => {
153+ const answer = () =>
154+ sheet()!.answers.find((a) => a.question === question.id);
155+ return (
156+ <div class="sheet-row">
157+ <p class="qtext">
158+ <strong>Q{index() + 1}.</strong> {question.text}
159+ <span class="badge">{t("pts")(question.points)}</span>
160+ </p>
161+ <Show when={answer()} fallback={<p class="muted">{t("noAnswer")}</p>}>
162+ {(current) => (
163+ <p
164+ classList={{
165+ "answer-ok": current().is_correct === true,
166+ "answer-bad": current().is_correct === false,
167+ }}
168+ >
169+ <Show
170+ when={question.kind === "choice"}
171+ fallback={<span class="prewrap">{current().text || "—"}</span>}
172+ >
173+ {question.choices?.[current().selected ?? -1] ?? "—"}
174+ <Show when={current().is_correct === true}> ✓</Show>
175+ <Show when={current().is_correct === false}>
176+ {t("rightAnswerIs")(question.choices?.[question.correct ?? -1] ?? "—")}
177+ </Show>
178+ </Show>
179+ </p>
180+ )}
181+ </Show>
182+ </div>
183+ );
184+ }}
185+ </For>
186+ </div>
187+
188+ <p class="meta">
189+ {t("autoScoreLine")(sheet()!.auto_score.earned, sheet()!.auto_score.possible)}
190+ </p>
191+ </Show>
192+
193+ <form
194+ class="row row-end"
195+ onSubmit={(e) => {
196+ e.preventDefault();
197+ void grade.run(e.currentTarget);
198+ }}
199+ >
200+ <label>
201+ {t("mark0100")}
202+ <input
203+ name="mark"
204+ type="number"
205+ required
206+ min={LIMITS.mark.min}
207+ max={LIMITS.mark.max}
208+ value={suggestion()}
209+ />
210+ </label>
211+ <button type="submit" disabled={grade.pending()}>
212+ {t("gradeAction")}
213+ </button>
214+ </form>
215+ <ErrorLine error={grade.error()} />
216+ </Show>
217+ </div>
218+ );
219+}
src/components/ExamQuestions.tsxadded+274 -0
@@ -0,0 +1,274 @@
1+// Question authoring for whoever manages the exam's course. Choice questions
2+// carry 2–10 options with the right one picked by radio; text questions are
3+// free-form and graded by a human. The backend freezes the list the moment
4+// anyone starts an attempt — that lands here as an error line, not a crash.
5+
6+import { For, Show, createResource, createSignal } from "solid-js";
7+import { createAction } from "../lib/action";
8+import { exams } from "../lib/api";
9+import { t } from "../lib/i18n";
10+import { LIMITS, type ExamQuestion, type QuestionKind } from "../lib/types";
11+import { ConfirmButton } from "./ConfirmButton";
12+import { Empty, ErrorLine, Loading } from "./Feedback";
13+import { IconPlus } from "./Icons";
14+
15+interface QuestionDraft {
16+ text: string;
17+ kind: string;
18+ points: number;
19+ choices: string[] | null;
20+ correct: number | null;
21+}
22+
23+export function ExamQuestions(props: { examId: string }) {
24+ const [list, { mutate }] = createResource(() => props.examId, exams.questions);
25+ const [adding, setAdding] = createSignal(false);
26+ const [editing, setEditing] = createSignal<string | null>(null);
27+
28+ const create = createAction(async (draft: QuestionDraft) => {
29+ const created = await exams.createQuestion(props.examId, draft);
30+ mutate((current) => [...(current ?? []), created]);
31+ setAdding(false);
32+ });
33+
34+ const save = createAction(async (qid: string, draft: QuestionDraft) => {
35+ const updated = await exams.updateQuestion(props.examId, qid, draft);
36+ mutate((current) => current?.map((q) => (q.id === qid ? updated : q)));
37+ setEditing(null);
38+ });
39+
40+ const remove = createAction(async (qid: string) => {
41+ await exams.removeQuestion(props.examId, qid);
42+ mutate((current) => current?.filter((q) => q.id !== qid));
43+ });
44+
45+ const totalPoints = () => (list() ?? []).reduce((sum, q) => sum + q.points, 0);
46+
47+ return (
48+ <article class="stack gap-top">
49+ <div class="section-head">
50+ <h2>{t("questionsTitle")}</h2>
51+ <Show when={list()?.length}>
52+ <span class="badge">{t("totalPoints")(totalPoints())}</span>
53+ </Show>
54+ <button class="ghost" onClick={() => setAdding((open) => !open)}>
55+ <IconPlus /> {t("addQuestion")}
56+ </button>
57+ </div>
58+
59+ <Show when={adding()}>
60+ <QuestionForm
61+ pending={create.pending()}
62+ onCancel={() => setAdding(false)}
63+ onSubmit={(draft) => void create.run(draft)}
64+ />
65+ <ErrorLine error={create.error()} />
66+ </Show>
67+
68+ <ErrorLine error={save.error() ?? remove.error()} />
69+
70+ <Show when={!list.loading} fallback={<Loading />}>
71+ <Show
72+ when={list()?.length}
73+ fallback={
74+ <Empty
75+ action={
76+ <button onClick={() => setAdding(true)}>
77+ <IconPlus /> {t("addQuestion")}
78+ </button>
79+ }
80+ >
81+ {t("noQuestionsYet")}
82+ </Empty>
83+ }
84+ >
85+ <div class="stack">
86+ <For each={list()}>
87+ {(question, index) => (
88+ <div class="card stack">
89+ <Show
90+ when={editing() !== question.id}
91+ fallback={
92+ <QuestionForm
93+ initial={question}
94+ pending={save.pending()}
95+ onCancel={() => setEditing(null)}
96+ onSubmit={(draft) => void save.run(question.id, draft)}
97+ />
98+ }
99+ >
100+ <header class="row">
101+ <strong>Q{index() + 1}</strong>
102+ <span class="badge">{t("pts")(question.points)}</span>
103+ <span class="badge">{t("questionKindWord")(question.kind)}</span>
104+ <span class="row-actions push">
105+ <button class="ghost" onClick={() => setEditing(question.id)}>
106+ {t("edit")}
107+ </button>
108+ <ConfirmButton
109+ disabled={remove.pending()}
110+ onConfirm={() => void remove.run(question.id)}
111+ >
112+ {t("deleteNote")}
113+ </ConfirmButton>
114+ </span>
115+ </header>
116+ <p class="prewrap">{question.text}</p>
117+ <Show when={question.choices}>
118+ <ol class="choices">
119+ <For each={question.choices}>
120+ {(choice, choiceIndex) => (
121+ <li classList={{ correct: choiceIndex() === question.correct }}>
122+ {choice}
123+ <Show when={choiceIndex() === question.correct}> ✓</Show>
124+ </li>
125+ )}
126+ </For>
127+ </ol>
128+ </Show>
129+ </Show>
130+ </div>
131+ )}
132+ </For>
133+ </div>
134+ </Show>
135+ </Show>
136+ </article>
137+ );
138+}
139+
140+/** Create/edit form; choice options are dynamic rows with a "right answer" radio. */
141+function QuestionForm(props: {
142+ initial?: ExamQuestion;
143+ pending: boolean;
144+ onSubmit: (draft: QuestionDraft) => void;
145+ onCancel: () => void;
146+}) {
147+ const [kind, setKind] = createSignal<QuestionKind>(props.initial?.kind ?? "choice");
148+ const [options, setOptions] = createSignal<string[]>(
149+ props.initial?.choices ?? ["", ""],
150+ );
151+ const [correct, setCorrect] = createSignal(props.initial?.correct ?? 0);
152+
153+ const removeOption = (index: number) => {
154+ setOptions((current) => current.filter((_, i) => i !== index));
155+ if (correct() === index) setCorrect(0);
156+ else if (correct() > index) setCorrect(correct() - 1);
157+ };
158+
159+ const submit = (form: HTMLFormElement) => {
160+ const data = new FormData(form);
161+ props.onSubmit({
162+ text: String(data.get("text")),
163+ kind: kind(),
164+ points: Number(data.get("points")),
165+ choices: kind() === "choice" ? options() : null,
166+ correct: kind() === "choice" ? correct() : null,
167+ });
168+ };
169+
170+ return (
171+ <form
172+ class="stack"
173+ onSubmit={(e) => {
174+ e.preventDefault();
175+ submit(e.currentTarget);
176+ }}
177+ >
178+ <label>
179+ {t("questionLabel")}
180+ <textarea
181+ name="text"
182+ rows={2}
183+ required
184+ maxLength={LIMITS.questionText}
185+ ref={(el) => queueMicrotask(() => el.focus())}
186+ >
187+ {props.initial?.text ?? ""}
188+ </textarea>
189+ </label>
190+ <div class="row">
191+ <label>
192+ {t("answerType")}
193+ <select
194+ value={kind()}
195+ onChange={(e) => setKind(e.currentTarget.value as QuestionKind)}
196+ >
197+ <option value="choice">{t("answerTypeChoice")}</option>
198+ <option value="text">{t("answerTypeText")}</option>
199+ </select>
200+ </label>
201+ <label>
202+ {t("points")}
203+ <input
204+ name="points"
205+ type="number"
206+ required
207+ min={LIMITS.questionPoints.min}
208+ max={LIMITS.questionPoints.max}
209+ value={props.initial?.points ?? 10}
210+ />
211+ </label>
212+ </div>
213+
214+ <Show when={kind() === "choice"}>
215+ <div class="stack">
216+ <span class="hint">{t("tickRightAnswer")}</span>
217+ <For each={options()}>
218+ {(option, index) => (
219+ <div class="option-row">
220+ <input
221+ type="radio"
222+ name="correct-pick"
223+ checked={correct() === index()}
224+ onChange={() => setCorrect(index())}
225+ aria-label={t("optionIsRight")(index() + 1)}
226+ />
227+ <input
228+ value={option}
229+ required
230+ maxLength={LIMITS.choiceText}
231+ placeholder={t("optionN")(index() + 1)}
232+ onInput={(e) => {
233+ const value = e.currentTarget.value;
234+ setOptions((current) =>
235+ current.map((v, i) => (i === index() ? value : v)),
236+ );
237+ }}
238+ />
239+ <button
240+ type="button"
241+ class="ghost icon-btn"
242+ aria-label={t("removeOption")}
243+ disabled={options().length <= LIMITS.questionChoices.min}
244+ onClick={() => removeOption(index())}
245+ >
246+ ×
247+ </button>
248+ </div>
249+ )}
250+ </For>
251+ <span class="row-actions">
252+ <button
253+ type="button"
254+ class="ghost"
255+ disabled={options().length >= LIMITS.questionChoices.max}
256+ onClick={() => setOptions((current) => [...current, ""])}
257+ >
258+ <IconPlus /> {t("addOption")}
259+ </button>
260+ </span>
261+ </div>
262+ </Show>
263+
264+ <span class="row-actions">
265+ <button type="submit" disabled={props.pending}>
266+ {t("saveQuestion")}
267+ </button>
268+ <button type="button" class="ghost" onClick={props.onCancel}>
269+ {t("cancel")}
270+ </button>
271+ </span>
272+ </form>
273+ );
274+}
src/components/Feedback.tsxmodified+7 -2
@@ -20,6 +20,11 @@ export function Loading() {
2020 );
2121 }
2222
23-export function Empty(props: { children: JSX.Element }) {
24- return <p class="empty">{props.children}</p>;
23+export function Empty(props: { children: JSX.Element; action?: JSX.Element }) {
24+ return (
25+ <div class="empty">
26+ <p>{props.children}</p>
27+ {props.action}
28+ </div>
29+ );
2530 }
src/components/Icons.tsxmodified+16 -0
@@ -114,3 +114,19 @@ export const IconArrow = () => (
114114 <path d="m13 6 6 6-6 6" />
115115 </Svg>
116116 );
117+
118+export const IconEye = () => (
119+ <Svg>
120+ <path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" />
121+ <circle cx="12" cy="12" r="3" />
122+ </Svg>
123+);
124+
125+export const IconEyeOff = () => (
126+ <Svg>
127+ <path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" />
128+ <path d="M14.084 14.158a3 3 0 0 1-4.242-4.242" />
129+ <path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" />
130+ <path d="m2 2 20 20" />
131+ </Svg>
132+);
src/components/Layout.tsxmodified+49 -12
@@ -1,9 +1,11 @@
11 // App shell: sidebar with navigation, user chip, and logout. Collapses into a
2-// top bar on narrow screens (pure CSS). Rendered only for authenticated routes.
2+// top bar on narrow screens (pure CSS), where the nav moves into a fixed
3+// bottom tab bar within thumb reach. Rendered only for authenticated routes.
34
45 import { A, useNavigate } from "@solidjs/router";
56 import { Show, type ParentProps } from "solid-js";
67 import { useAuth } from "../lib/auth";
8+import { lang, setLang, t } from "../lib/i18n";
79 import {
810 IconBook,
911 IconCalendar,
@@ -36,49 +38,84 @@ export function Layout(props: ParentProps) {
3638 </A>
3739 <nav>
3840 <A href="/" end>
39- <IconHome /> Home
41+ <IconHome /> {t("navHome")}
4042 </A>
4143 <A href="/notes">
42- <IconNote /> Notes
44+ <IconNote /> {t("navNotes")}
4345 </A>
4446 <A href="/events">
45- <IconCalendar /> Events
47+ <IconCalendar /> {t("navEvents")}
4648 </A>
4749 <A href="/courses">
48- <IconBook /> Courses
50+ <IconBook /> {t("navCourses")}
4951 </A>
5052 <A href="/exams">
51- <IconClipboard /> Exams
53+ <IconClipboard /> {t("navExams")}
5254 </A>
5355 <A href="/marks">
54- <IconChart /> Marks
56+ <IconChart /> {t("navMarks")}
5557 </A>
5658 <Show when={can("admin")}>
5759 <A href="/users">
58- <IconUsers /> Users
60+ <IconUsers /> {t("navUsers")}
5961 </A>
6062 </Show>
6163 </nav>
6264 <div class="sidebar-end">
6365 <Show when={user()}>
6466 {(current) => (
65- <A href="/profile" class="user-chip" title="Profile">
67+ <A href="/profile" class="user-chip" title={t("profileLink")}>
6668 <span class="avatar">
6769 {(current().name ?? current().username).slice(0, 1)}
6870 </span>
6971 <span class="user-meta">
7072 <strong>{current().name ?? current().username}</strong>
71- <span>{current().role}</span>
73+ <span>{t("roleWord")(current().role)}</span>
7274 </span>
7375 </A>
7476 )}
7577 </Show>
76- <button class="ghost icon-btn" onClick={onLogout} title="Log out">
77- <IconLogout />
78+ <button
79+ class="ghost lang-switch"
80+ onClick={() => setLang(lang() === "tr" ? "en" : "tr")}
81+ >
82+ {t("otherLanguage")}
83+ </button>
84+ <button class="ghost logout" onClick={onLogout}>
85+ <IconLogout /> <span>{t("logout")}</span>
7886 </button>
7987 </div>
8088 </header>
8189 <main>{props.children}</main>
90+
91+ {/* Thumb-reach duplicate of the nav on small screens (CSS-hidden on
92+ desktop); the sidebar collapses into a top bar with just the brand,
93+ profile chip, and logout. */}
94+ <nav class="tabbar">
95+ <A href="/" end>
96+ <IconHome /> {t("navHome")}
97+ </A>
98+ <A href="/notes">
99+ <IconNote /> {t("navNotes")}
100+ </A>
101+ <A href="/events">
102+ <IconCalendar /> {t("navEvents")}
103+ </A>
104+ <A href="/courses">
105+ <IconBook /> {t("navCourses")}
106+ </A>
107+ <A href="/exams">
108+ <IconClipboard /> {t("navExams")}
109+ </A>
110+ <A href="/marks">
111+ <IconChart /> {t("navMarks")}
112+ </A>
113+ <Show when={can("admin")}>
114+ <A href="/users">
115+ <IconUsers /> {t("navUsers")}
116+ </A>
117+ </Show>
118+ </nav>
82119 </div>
83120 );
84121 }
src/components/ProfileFields.tsxmodified+7 -6
@@ -5,6 +5,7 @@
55
66 import type { ProfilePatch } from "../lib/api";
77 import { today } from "../lib/format";
8+import { t } from "../lib/i18n";
89 import { LIMITS, type User } from "../lib/types";
910
1011 /** Matches the backend rule: optional leading +, separators, 7–15 digits. */
@@ -26,16 +27,16 @@ export function ProfileFields(props: { user: User }) {
2627 <>
2728 <div class="row">
2829 <label style={{ flex: 1 }}>
29- Name
30+ {t("nameField")}
3031 <input name="name" value={props.user.name ?? ""} maxLength={LIMITS.personName} />
3132 </label>
3233 <label style={{ flex: 1 }}>
33- Surname
34+ {t("surnameField")}
3435 <input name="surname" value={props.user.surname ?? ""} maxLength={LIMITS.personName} />
3536 </label>
3637 </div>
3738 <label>
38- Email
39+ {t("emailField")}
3940 <input
4041 name="email"
4142 type="email"
@@ -46,18 +47,18 @@ export function ProfileFields(props: { user: User }) {
4647 </label>
4748 <div class="row">
4849 <label style={{ flex: 1 }}>
49- Phone
50+ {t("phoneField")}
5051 <input
5152 name="phone"
5253 type="tel"
5354 value={props.user.phone ?? ""}
5455 pattern={PHONE_PATTERN}
55- title={`${LIMITS.phoneDigits.min} to ${LIMITS.phoneDigits.max} digits; +, spaces, dashes, and parentheses are allowed`}
56+ title={t("phoneTitle")(LIMITS.phoneDigits.min, LIMITS.phoneDigits.max)}
5657 placeholder="+90 555 123 45 67"
5758 />
5859 </label>
5960 <label style={{ flex: 1 }}>
60- Birth date
61+ {t("birthDateField")}
6162 <input
6263 name="birth_date"
6364 type="date"
src/components/ScheduleFields.tsxadded+105 -0
@@ -0,0 +1,105 @@
1+// The scheduling block shared by the exam create and edit forms: a mode
2+// picker in plain words, the window, and — for flexible exams — the
3+// per-student time budget. Unscheduled stays the quiet default.
4+
5+import { Show, createSignal } from "solid-js";
6+import { fromInputValue, toInputValue } from "../lib/format";
7+import { t } from "../lib/i18n";
8+import { LIMITS, type Exam, type ExamMode } from "../lib/types";
9+
10+/** Read the schedule unit out of a submitted form (all-null when untimed). */
11+export function scheduleFromForm(data: FormData): {
12+ mode: string | null;
13+ starts_at: number | null;
14+ ends_at: number | null;
15+ duration_ms: number | null;
16+} {
17+ const mode = String(data.get("mode") ?? "");
18+ if (mode === "") {
19+ return { mode: null, starts_at: null, ends_at: null, duration_ms: null };
20+ }
21+ return {
22+ mode,
23+ starts_at: fromInputValue(String(data.get("starts_at") ?? "")),
24+ ends_at: fromInputValue(String(data.get("ends_at") ?? "")),
25+ duration_ms:
26+ mode === "async" ? Number(data.get("duration_min")) * 60_000 : null,
27+ };
28+}
29+
30+export function ScheduleFields(props: { exam?: Exam }) {
31+ const [mode, setMode] = createSignal<"" | ExamMode>(props.exam?.mode ?? "");
32+ let starts!: HTMLInputElement;
33+ let ends!: HTMLInputElement;
34+
35+ // "YYYY-MM-DDTHH:mm" compares chronologically as a string, so the browser
36+ // can refuse a window that ends before it starts — before the server does.
37+ const checkOrder = () => {
38+ ends.setCustomValidity(
39+ starts.value && ends.value && ends.value <= starts.value
40+ ? t("endsAfterStarts")
41+ : "",
42+ );
43+ };
44+
45+ return (
46+ <div class="stack">
47+ <label>
48+ {t("timing")}
49+ <select
50+ name="mode"
51+ value={mode()}
52+ onChange={(e) => setMode(e.currentTarget.value as "" | ExamMode)}
53+ >
54+ <option value="">{t("timingNone")}</option>
55+ <option value="sync">{t("timingSync")}</option>
56+ <option value="async">{t("timingAsync")}</option>
57+ </select>
58+ </label>
59+ <Show when={mode()}>
60+ <div class="row">
61+ <label>
62+ {t("opens")}
63+ <input
64+ ref={starts}
65+ name="starts_at"
66+ type="datetime-local"
67+ required
68+ value={toInputValue(props.exam?.starts_at ?? null)}
69+ onInput={checkOrder}
70+ />
71+ </label>
72+ <label>
73+ {t("closes")}
74+ <input
75+ ref={ends}
76+ name="ends_at"
77+ type="datetime-local"
78+ required
79+ value={toInputValue(props.exam?.ends_at ?? null)}
80+ onInput={checkOrder}
81+ />
82+ </label>
83+ <Show when={mode() === "async"}>
84+ <label>
85+ {t("minutesPerStudent")}
86+ <input
87+ name="duration_min"
88+ type="number"
89+ required
90+ min={LIMITS.examDurationMin.min}
91+ max={LIMITS.examDurationMin.max}
92+ value={
93+ props.exam?.duration_ms
94+ ? Math.round(props.exam.duration_ms / 60_000)
95+ : 40
96+ }
97+ />
98+ </label>
99+ </Show>
100+ </div>
101+ <p class="hint">{mode() === "sync" ? t("syncHint") : t("asyncHint")}</p>
102+ </Show>
103+ </div>
104+ );
105+}
src/components/UserPicker.tsxadded+101 -0
@@ -0,0 +1,101 @@
1+// Search-as-you-type person picker: replaces every "paste a user id" input.
2+// The picked user's id travels in a hidden input, so forms keep reading
3+// FormData exactly as before. Native validation blocks submitting free text
4+// that was never picked from the list.
5+
6+import { For, Show, createSignal, onCleanup } from "solid-js";
7+import { users } from "../lib/api";
8+import { personLabel } from "../lib/format";
9+import { t } from "../lib/i18n";
10+import type { PersonRef } from "../lib/types";
11+
12+export function UserPicker(props: {
13+ /** Hidden field name the form reads, e.g. "user_id". */
14+ name: string;
15+ label: string;
16+ onPick?: (person: PersonRef | null) => void;
17+}) {
18+ const [query, setQuery] = createSignal("");
19+ const [results, setResults] = createSignal<PersonRef[]>([]);
20+ const [picked, setPicked] = createSignal<PersonRef | null>(null);
21+ const [open, setOpen] = createSignal(false);
22+ let input!: HTMLInputElement;
23+ let timer: ReturnType<typeof setTimeout> | undefined;
24+ let generation = 0; // an older search must never overwrite a newer one
25+ onCleanup(() => clearTimeout(timer));
26+
27+ const validity = () =>
28+ input.setCustomValidity(picked() ? "" : t("pickFromList"));
29+
30+ const choose = (person: PersonRef | null) => {
31+ setPicked(person);
32+ props.onPick?.(person);
33+ validity();
34+ };
35+
36+ const onInput = (value: string) => {
37+ setQuery(value);
38+ choose(null);
39+ clearTimeout(timer);
40+ const needle = value.trim();
41+ if (!needle) {
42+ setResults([]);
43+ setOpen(false);
44+ return;
45+ }
46+ timer = setTimeout(async () => {
47+ const current = ++generation;
48+ try {
49+ const found = await users.search(needle);
50+ if (current !== generation) return;
51+ setResults(found);
52+ setOpen(true);
53+ } catch {
54+ // A failed lookup just leaves the menu empty; submitting still
55+ // requires a pick, so nothing wrong can go through.
56+ if (current === generation) setResults([]);
57+ }
58+ }, 250);
59+ };
60+
61+ const pick = (person: PersonRef) => {
62+ choose(person);
63+ setQuery(personLabel(person));
64+ setOpen(false);
65+ };
66+
67+ return (
68+ <label class="picker">
69+ {props.label}
70+ <span class="picker-box">
71+ <input
72+ ref={input}
73+ value={query()}
74+ placeholder={t("typeAName")}
75+ autocomplete="off"
76+ required
77+ onInput={(e) => onInput(e.currentTarget.value)}
78+ onFocus={() => results().length && setOpen(true)}
79+ onBlur={() => setOpen(false)}
80+ onInvalid={validity}
81+ />
82+ <input type="hidden" name={props.name} value={picked()?.id ?? ""} />
83+ <Show when={open()}>
84+ <div class="picker-menu">
85+ <Show when={results().length} fallback={<p class="muted">{t("nobodyFound")}</p>}>
86+ <For each={results()}>
87+ {(person) => (
88+ // mousedown, not click: it must win against the input's blur.
89+ <button type="button" onMouseDown={() => pick(person)}>
90+ <strong>{personLabel(person)}</strong>
91+ <span>{person.username}</span>
92+ </button>
93+ )}
94+ </For>
95+ </Show>
96+ </div>
97+ </Show>
98+ </span>
99+ </label>
100+ );
101+}
src/lib/action.tsmodified+3 -2
@@ -3,6 +3,7 @@
33
44 import { batch, createSignal, type Accessor } from "solid-js";
55 import { ApiError } from "./api";
6+import { t } from "./i18n";
67
78 export interface Action<Args extends unknown[]> {
89 run: (...args: Args) => Promise<boolean>;
@@ -42,8 +43,8 @@ export function createAction<Args extends unknown[]>(
4243 function describe(err: unknown): string {
4344 if (err instanceof ApiError) {
4445 return err.retryAfterSecs !== undefined
45- ? `${err.message} — retry in ${err.retryAfterSecs}s`
46+ ? `${err.message} — ${t("retryIn")(err.retryAfterSecs)}`
4647 : err.message;
4748 }
48- return err instanceof Error ? err.message : "something went wrong";
49+ return err instanceof Error ? err.message : t("somethingWrong");
4950 }
src/lib/api.tsmodified+90 -3
@@ -3,20 +3,29 @@
33 // backend's `{ "error": "..." }` message and the HTTP status.
44
55 import type {
6+ AnswerSaved,
67 AppEvent,
78 Attendance,
89 AttendanceStatus,
10+ AttemptAnswers,
11+ AttemptQuestion,
912 Course,
1013 Enrollment,
1114 Exam,
15+ ExamAttempt,
16+ ExamLive,
17+ ExamQuestion,
1218 ExamResult,
1319 ExamStatistics,
1420 MarksReport,
1521 Note,
22+ PersonRef,
1623 Role,
1724 User,
1825 } from "./types";
1926
27+import { t } from "./i18n";
28+
2029 const BASE = import.meta.env.VITE_API_URL ?? "/api";
2130
2231 export class ApiError extends Error {
@@ -40,7 +49,7 @@ async function request<T>(method: string, path: string, body?: unknown): Promise
4049 body: body === undefined ? undefined : JSON.stringify(body),
4150 });
4251 } catch {
43- throw new ApiError(0, "network error — is the backend up?");
52+ throw new ApiError(0, t("networkError"));
4453 }
4554
4655 if (!res.ok) {
@@ -87,6 +96,8 @@ export interface ProfilePatch {
8796 export const users = {
8897 list: () => get<User[]>("/users"),
8998 get: (id: string) => get<User>(`/users/${id}`),
99+ /** Fragment search over username/name/surname; teacher+, max 10 rows. */
100+ search: (q: string) => get<PersonRef[]>(`/users/search?q=${encodeURIComponent(q)}`),
90101 setRole: (id: string, role: Role) => patch<User>(`/users/${id}/role`, { role }),
91102 /** The caller's own profile. */
92103 updateMyProfile: (body: ProfilePatch) => patch<User>("/users/me", body),
@@ -147,7 +158,17 @@ export const courses = {
147158 exams: (id: string) => get<Exam[]>(`/courses/${id}/exams`),
148159 createExam: (
149160 id: string,
150- body: { title: string; description?: string; kind: string; weight: number },
161+ body: {
162+ title: string;
163+ description?: string;
164+ kind: string;
165+ weight: number;
166+ /** Schedule as a unit: all null for an unscheduled exam. */
167+ mode: string | null;
168+ starts_at: number | null;
169+ ends_at: number | null;
170+ duration_ms: number | null;
171+ },
151172 ) => post<Exam>(`/courses/${id}/exams`, body),
152173 };
153174
@@ -155,9 +176,19 @@ export const exams = {
155176 list: () => get<Exam[]>("/exams"),
156177 get: (id: string) => get<Exam>(`/exams/${id}`),
157178 // Creation lives under the course: `courses.createExam`.
179+ /** Schedule fields are set-or-clear: explicit `null` clears, omit keeps. */
158180 update: (
159181 id: string,
160- body: { title?: string; description?: string; kind?: string; weight?: number },
182+ body: {
183+ title?: string;
184+ description?: string;
185+ kind?: string;
186+ weight?: number;
187+ mode?: string | null;
188+ starts_at?: number | null;
189+ ends_at?: number | null;
190+ duration_ms?: number | null;
191+ },
161192 ) => patch<Exam>(`/exams/${id}`, body),
162193 remove: (id: string) => del(`/exams/${id}`),
163194
@@ -167,9 +198,65 @@ export const exams = {
167198 post<ExamResult>(`/exams/${id}/results`, { mark, user_id: userId }),
168199 removeResult: (id: string, userId: string) => del(`/exams/${id}/results/${userId}`),
169200 statistics: (id: string) => get<ExamStatistics>(`/exams/${id}/statistics`),
201+
202+ // ---- attempts: sitting a scheduled exam ----
203+ /** Start or resume — the backend never resets a running clock. */
204+ startAttempt: (id: string) => post<ExamAttempt>(`/exams/${id}/attempt`),
205+ /** 404 until started. */
206+ myAttempt: (id: string) => get<ExamAttempt>(`/exams/${id}/attempt`),
207+ finishAttempt: (id: string) => post<ExamAttempt>(`/exams/${id}/attempt/finish`),
208+ /** The sitting student's questions (no `correct`), own answers embedded. */
209+ attemptQuestions: (id: string) => get<AttemptQuestion[]>(`/exams/${id}/attempt/questions`),
210+ saveAnswer: (id: string, body: { question_id: string; selected?: number; text?: string }) =>
211+ post<AnswerSaved>(`/exams/${id}/attempt/answers`, body),
212+
213+ // ---- questions: authored by teacher+ with course-management rights ----
214+ questions: (id: string) => get<ExamQuestion[]>(`/exams/${id}/questions`),
215+ createQuestion: (
216+ id: string,
217+ body: {
218+ text: string;
219+ kind: string;
220+ points: number;
221+ choices: string[] | null;
222+ correct: number | null;
223+ },
224+ ) => post<ExamQuestion>(`/exams/${id}/questions`, body),
225+ /** `choices`/`correct` are set-or-clear; send the full kind unit. */
226+ updateQuestion: (
227+ id: string,
228+ qid: string,
229+ body: {
230+ text?: string;
231+ points?: number;
232+ kind?: string;
233+ choices?: string[] | null;
234+ correct?: number | null;
235+ },
236+ ) => patch<ExamQuestion>(`/exams/${id}/questions/${qid}`, body),
237+ removeQuestion: (id: string, qid: string) => del(`/exams/${id}/questions/${qid}`),
238+
239+ // ---- live monitor (teacher+) ----
240+ live: (id: string) => get<ExamLive>(`/exams/${id}/live`),
241+ /** SSE endpoint for `EventSource` — one `snapshot` event every ~2 s. */
242+ liveStreamUrl: (id: string) => `${BASE}/exams/${id}/live/stream`,
243+ /** One student's judged answer sheet with the auto-score suggestion. */
244+ attemptAnswers: (id: string, userId: string) =>
245+ get<AttemptAnswers>(`/exams/${id}/attempts/${userId}/answers`),
246+ /** The student exam room WebSocket (autosave acks + server countdown). */
247+ attemptSocketUrl: (id: string) => {
248+ const proto = window.location.protocol === "https:" ? "wss:" : "ws:";
249+ const base = BASE.startsWith("http") ? BASE.replace(/^http/, "ws") : `${proto}//${window.location.host}${BASE}`;
250+ return `${base}/exams/${id}/attempt/ws`;
251+ },
170252 };
171253
172254 export const marks = {
173255 mine: () => get<MarksReport>("/marks/me"),
174256 forUser: (id: string) => get<MarksReport>(`/marks/${id}`),
175257 };
258+
259+export const meta = {
260+ /** Server clock, UTC unix-milliseconds — see `lib/clock.ts`. */
261+ time: () => get<{ now: number }>("/time"),
262+};
src/lib/clock.tsadded+42 -0
@@ -0,0 +1,42 @@
1+// Server-authoritative time. Every deadline in the API is judged by the
2+// backend clock, so countdowns and "is the window open?" checks must not
3+// trust the device clock: sync once, keep the offset, add it to Date.now().
4+
5+import { createSignal } from "solid-js";
6+import { meta } from "./api";
7+
8+const [offset, setOffset] = createSignal(0);
9+let syncing: Promise<void> | undefined;
10+
11+/** Fetch `/time` once and remember `server - device`. Safe to call again. */
12+export function syncClock(): Promise<void> {
13+ syncing ??= (async () => {
14+ try {
15+ const before = Date.now();
16+ const { now } = await meta.time();
17+ // Split the round trip: the server read sits roughly mid-flight.
18+ setOffset(now - (before + Date.now()) / 2);
19+ } catch {
20+ // Offline or backend down — fall back to the device clock (offset 0);
21+ // the server still enforces every deadline itself. Allow a retry.
22+ syncing = undefined;
23+ }
24+ })();
25+ return syncing;
26+}
27+
28+/** Best estimate of the server clock, UTC unix-milliseconds. Reactive. */
29+export function serverNow(): number {
30+ if (syncing === undefined) void syncClock();
31+ return Date.now() + offset();
32+}
33+
34+/**
35+ * A signal ticking with the (offset-corrected) server clock — for countdowns
36+ * and open/closed window checks that should re-render as time passes.
37+ */
38+export function createClock(intervalMs = 1000) {
39+ const [now, setNow] = createSignal(serverNow());
40+ const timer = setInterval(() => setNow(serverNow()), intervalMs);
41+ return { now, stop: () => clearInterval(timer) };
42+}
src/lib/format.tsmodified+28 -8
@@ -1,21 +1,29 @@
11 // Time helpers: the API speaks unix milliseconds, <input type="datetime-local">
2-// speaks "YYYY-MM-DDTHH:mm" in local time.
2+// speaks "YYYY-MM-DDTHH:mm" in local time. Plus the one person-display rule.
33
4-const formatter = new Intl.DateTimeFormat(undefined, {
5- dateStyle: "medium",
6- timeStyle: "short",
7-});
4+import { locale, t } from "./i18n";
5+import type { PersonRef } from "./types";
6+
7+/** What to call a person in the UI: their name if we have it, else username. */
8+export function personLabel(person: PersonRef): string {
9+ return person.display_name ?? person.username;
10+}
811
912 export function formatMillis(millis: number | null): string {
10- return millis === null ? "—" : formatter.format(new Date(millis));
13+ return millis === null
14+ ? "—"
15+ : new Intl.DateTimeFormat(locale(), {
16+ dateStyle: "medium",
17+ timeStyle: "short",
18+ }).format(new Date(millis));
1119 }
1220
1321 /** Human line for an event's time window. */
1422 export function formatWindow(starts: number | null, ends: number | null): string {
15- if (starts === null && ends === null) return "Unscheduled";
23+ if (starts === null && ends === null) return t("unscheduled");
1624 if (starts !== null && ends !== null)
1725 return `${formatMillis(starts)} → ${formatMillis(ends)}`;
18- return starts !== null ? formatMillis(starts) : `Until ${formatMillis(ends)}`;
26+ return starts !== null ? formatMillis(starts) : t("until")(formatMillis(ends));
1927 }
2028
2129 /** Unix ms → value for a datetime-local input ("" when null). */
@@ -34,6 +42,18 @@ export function fromInputValue(value: string): number | null {
3442 return value === "" ? null : new Date(value).getTime();
3543 }
3644
45+/** Milliseconds left → "m:ss" (or "h:mm:ss"), floored at zero. */
46+export function formatCountdown(ms: number): string {
47+ const total = Math.max(0, Math.floor(ms / 1000));
48+ const hours = Math.floor(total / 3600);
49+ const minutes = Math.floor((total % 3600) / 60);
50+ const seconds = total % 60;
51+ const pad = (n: number) => String(n).padStart(2, "0");
52+ return hours > 0
53+ ? `${hours}:${pad(minutes)}:${pad(seconds)}`
54+ : `${minutes}:${pad(seconds)}`;
55+}
56+
3757 /** The local date as "YYYY-MM-DD" — e.g. the max for a birth-date input. */
3858 export function today(): string {
3959 const date = new Date();
src/lib/i18n.tsadded+606 -0
@@ -0,0 +1,606 @@
1+// Two-language UI: English and Turkish, picked from what the device asks for
2+// and switchable in one tap (persisted). `t("key")` returns the entry in the
3+// current language — a plain string, or a function for parameterized lines —
4+// and re-runs reactively because it reads the `lang` signal.
5+//
6+// Server-sent error messages pass through untranslated: the backend speaks
7+// English, and inventing translations for unknown strings would lie to users.
8+
9+import { createSignal } from "solid-js";
10+import type {
11+ AttendanceStatus,
12+ ExamKind,
13+ LiveStudent,
14+ QuestionKind,
15+ Role,
16+} from "./types";
17+
18+export type Lang = "en" | "tr";
19+
20+const STORAGE_KEY = "hezarfen-lang";
21+
22+function initialLang(): Lang {
23+ const stored = localStorage.getItem(STORAGE_KEY);
24+ if (stored === "en" || stored === "tr") return stored;
25+ return navigator.language.toLowerCase().startsWith("tr") ? "tr" : "en";
26+}
27+
28+const [lang, setLangSignal] = createSignal<Lang>(initialLang());
29+export { lang };
30+
31+// The document language drives CSS text-transform casing rules — Turkish
32+// uppercases i → İ only when the browser knows the text is Turkish.
33+document.documentElement.lang = lang();
34+
35+export function setLang(next: Lang): void {
36+ setLangSignal(next);
37+ document.documentElement.lang = next;
38+ localStorage.setItem(STORAGE_KEY, next);
39+}
40+
41+/** BCP-47 tag for date formatting; undefined lets English follow the OS. */
42+export const locale = (): string | undefined =>
43+ lang() === "tr" ? "tr-TR" : undefined;
44+
45+const en = {
46+ // navigation & shell
47+ navHome: "Home",
48+ navNotes: "Notes",
49+ navEvents: "Events",
50+ navCourses: "Courses",
51+ navExams: "Exams",
52+ navMarks: "Marks",
53+ navUsers: "Users",
54+ logout: "Log out",
55+ profileLink: "Profile",
56+ otherLanguage: "Türkçe",
57+
58+ // shared bits
59+ save: "Save",
60+ cancel: "Cancel",
61+ close: "Close",
62+ edit: "Edit",
63+ remove: "Remove",
64+ apply: "Apply",
65+ you: " (you)",
66+ title: "Title",
67+ description: "Description",
68+ status: "Status",
69+ reallyDelete: "Really delete?",
70+ reallyRemove: "Really remove?",
71+ somethingWrong: "something went wrong",
72+ retryIn: (s: number) => `retry in ${s}s`,
73+ networkError: "network error — is the backend up?",
74+ unscheduled: "Unscheduled",
75+ until: (time: string) => `Until ${time}`,
76+
77+ // login
78+ loginWelcome: "Welcome back — log in to continue.",
79+ registerWelcome: "Create an account to get started.",
80+ username: "Username",
81+ password: "Password",
82+ showPassword: "Show password",
83+ hidePassword: "Hide password",
84+ atLeastChars: (n: number) => `At least ${n} characters.`,
85+ logIn: "Log in",
86+ createAccount: "Create account",
87+ switchToRegister: "New here? Register",
88+ switchToLogin: "Have an account? Log in",
89+
90+ // home
91+ greeting: (name: string, hour: number) =>
92+ `Good ${hour < 12 ? "morning" : hour < 18 ? "afternoon" : "evening"}, ${name}`,
93+ statNotes: "Notes",
94+ statUpcoming: "Upcoming events",
95+ statMyCourses: "My courses",
96+ statAverage: "Average",
97+ upcomingEvents: "Upcoming events",
98+ myCourses: "My courses",
99+ viewAll: "View all",
100+ nothingScheduled: "Nothing scheduled.",
101+ notEnrolledYet: "Not enrolled in any course yet.",
102+
103+ // notes
104+ notesTitle: "Notes",
105+ notesSub: "Your personal scratchpad — visible only to you.",
106+ newNote: "New note",
107+ content: "Content",
108+ writeSomething: "Write something…",
109+ addNote: "Add note",
110+ noNotesYet: "No notes yet — write your first one.",
111+ deleteNote: "Delete",
112+
113+ // events
114+ eventsTitle: "Events",
115+ eventsSub: "What's happening — open one to see or mark attendance.",
116+ newEvent: "New event",
117+ starts: "Starts",
118+ ends: "Ends",
119+ addEvent: "Add event",
120+ noEventsYet: "No events yet.",
121+ attendance: "Attendance",
122+ iAm: (status: AttendanceStatus) =>
123+ ({ present: "I'm here", absent: "I'm absent", late: "I'm late", excused: "I'm excused" })[status],
124+ attendanceWord: (status: AttendanceStatus) =>
125+ ({ present: "present", absent: "absent", late: "late", excused: "excused" })[status],
126+ person: "Person",
127+ markUser: "Mark user",
128+ nobodyMarkedYet: "Nobody marked yet.",
129+ userCol: "User",
130+ deleteEvent: "Delete event",
131+ reallyDeleteEvent: "Really delete event?",
132+ eventMissing: "This event does not exist.",
133+ eventLoadFailed: "Failed to load the event.",
134+
135+ // courses
136+ coursesTitle: "Courses",
137+ coursesSub: "Everything on offer — your enrollments are tagged.",
138+ newCourse: "New course",
139+ addCourse: "Add course",
140+ noCoursesYet: "No courses yet.",
141+ enrolledBadge: "enrolled",
142+ deleteCourse: "Delete course",
143+ reallyDeleteCourse: "Really delete course?",
144+ courseMissing: "This course does not exist.",
145+ courseLoadFailed: "Failed to load the course.",
146+ roster: "Roster",
147+ student: "Student",
148+ enrolledBy: "Enrolled by",
149+ enroll: "Enroll",
150+ unenroll: "Unenroll",
151+ nobodyEnrolledYet: "Nobody enrolled yet.",
152+
153+ // exams
154+ examsTitle: "Exams",
155+ examsSubAll: "All exams across courses.",
156+ examsSubCreate: "New ones are created inside a course.",
157+ coursePrefix: "Course:",
158+ newExam: "New exam",
159+ addExam: "Add exam",
160+ noExamsYet: "No exams yet.",
161+ kind: "Kind",
162+ weight: "Weight",
163+ kindWord: (kind: ExamKind) =>
164+ ({ homework: "homework", quiz: "quiz", midterm: "midterm", final: "final", project: "project", oral: "oral" })[kind],
165+ weightBadge: (n: number) => `counts ×${n}`,
166+ weightTitle: "how many times this exam counts toward the course average",
167+ deleteExam: "Delete exam",
168+ reallyDeleteExam: "Really delete exam?",
169+ examMissing: "This exam does not exist.",
170+ examLoadFailed: "Failed to load the exam.",
171+ myResult: "My result",
172+ notGradedYet: "Not graded yet.",
173+ statistics: "Statistics",
174+ gradedStat: "Graded",
175+ averageStat: "Average",
176+ minStat: "Min",
177+ maxStat: "Max",
178+ results: "Results",
179+ mark0100: "Mark (0–100)",
180+ gradeAction: "Grade",
181+ noResultsYet: "No results yet.",
182+
183+ // exam scheduling
184+ timing: "Timing",
185+ timingNone: "No timer — held outside the app",
186+ timingSync: "Live — everyone at the same time",
187+ timingAsync: "Flexible — own timer inside a window",
188+ opens: "Opens",
189+ closes: "Closes",
190+ minutesPerStudent: "Minutes per student",
191+ syncHint: "Students sit it together: everyone's time runs out when the exam closes.",
192+ asyncHint: "Each student's own timer starts when they enter, inside the open window.",
193+ endsAfterStarts: "The closing time must be after the opening time",
194+
195+ // sitting card
196+ examTime: "Exam time",
197+ phaseWord: (phase: "upcoming" | "open" | "closed") =>
198+ ({ upcoming: "Opens soon", open: "Open now", closed: "Closed" })[phase],
199+ minutesEach: (n: number) => `${n} minutes each`,
200+ turnedInAt: (time: string) => `Turned in ✓ ${time}`,
201+ seeMyAnswers: "See my answers",
202+ timeRanOut: "Time ran out — everything saved up to the end still counts.",
203+ continueExam: "Continue exam",
204+ answeredOf: (a: number, b: number) => `${a} / ${b} answered`,
205+ timeLeftShort: (countdown: string) => `${countdown} left`,
206+ enterExam: "Enter exam",
207+ startTimerConfirm: (n: number) => `Start now? Your ${n} minutes begin`,
208+ opensAt: (time: string) => `Opens ${time}.`,
209+ examOver: "This exam is over.",
210+
211+ // exam room
212+ notEnteredYet: "You haven't entered this exam yet.",
213+ backToExam: "Back to the exam",
214+ turnIn: "Turn in",
215+ turnInNow: "Turn in now?",
216+ turnInUnanswered: (n: number) => `Turn in with ${n} unanswered?`,
217+ turnedInBanner: (time: string) =>
218+ `Turned in ✓ ${time} — you can still read your answers below.`,
219+ timeUpBanner: "Time is up. Everything saved before the end still counts.",
220+ noQuestionsRoom: "No questions here — your teacher grades this exam by hand.",
221+ writeAnswerHere: "Write your answer here…",
222+ savingState: "Saving…",
223+ savedState: "Saved ✓",
224+ notSavedState: "Not saved!",
225+ turnedInChip: "Turned in",
226+ timeUpChip: "Time up",
227+ pts: (n: number) => `${n} pts`,
228+ savingFailed: "saving failed",
229+
230+ // question authoring
231+ questionsTitle: "Questions",
232+ totalPoints: (n: number) => `${n} points`,
233+ addQuestion: "Add question",
234+ noQuestionsYet: "No questions yet — students will see an empty exam.",
235+ questionLabel: "Question",
236+ answerType: "Answer type",
237+ answerTypeChoice: "Pick one option",
238+ answerTypeText: "Written answer",
239+ points: "Points",
240+ questionKindWord: (kind: QuestionKind) =>
241+ ({ choice: "choice", text: "written" })[kind],
242+ tickRightAnswer: "Tick the circle next to the right answer.",
243+ optionN: (n: number) => `Option ${n}`,
244+ optionIsRight: (n: number) => `Option ${n} is the right answer`,
245+ removeOption: "Remove this option",
246+ addOption: "Add option",
247+ saveQuestion: "Save question",
248+
249+ // live monitor
250+ liveMonitor: "Live monitor",
251+ countEnrolled: (n: number) => `${n} enrolled`,
252+ countWriting: (n: number) => `${n} writing`,
253+ countTurnedIn: (n: number) => `${n} turned in`,
254+ countNotStarted: (n: number) => `${n} not started`,
255+ countTimeUp: (n: number) => `${n} time up`,
256+ countGraded: (n: number) => `${n} graded`,
257+ liveStatusWord: (status: LiveStudent["status"]) =>
258+ ({ not_started: "Not started", in_progress: "Writing", submitted: "Turned in", expired: "Time up" })[status],
259+ answeredCol: "Answered",
260+ timeLeftCol: "Time left",
261+ lastSaveCol: "Last save",
262+ markCol: "Mark",
263+ review: "Review",
264+ nobodyEnrolledCourse: "Nobody is enrolled in this course yet.",
265+ sheetTitle: (name: string) => `${name}'s answers`,
266+ noAnswer: "No answer.",
267+ rightAnswerIs: (text: string) => ` ✗ (right: ${text})`,
268+ autoScoreLine: (earned: number, possible: number) =>
269+ `Auto-score over choice questions: ${earned} / ${possible} points — a suggestion, the mark below is yours to give.`,
270+ noQuestionsSheet: "This exam has no questions.",
271+ agoSeconds: (s: number) => `${s}s ago`,
272+ agoMinutes: (m: number) => `${m}m ago`,
273+
274+ // marks
275+ marksTitle: "My marks",
276+ marksSub: "Graded exams per course, weighted averages included.",
277+ marksLoadFailed: "Failed to load your marks.",
278+ overallAverage: "Overall average",
279+ courseAverageTitle: "weighted course average",
280+ overallAverageTitle: "mean of the course averages",
281+ studentLookup: "Student lookup",
282+ showMarks: "Show marks",
283+ reportFor: (name: string) => `Report for ${name}`,
284+ notEnrolledAny: "Not enrolled in any course.",
285+ nothingGradedYet: "Nothing graded yet.",
286+ examCol: "Exam",
287+
288+ // profile & users
289+ personalInfo: "Personal info",
290+ leaveEmptyToClear: "Leave a field empty to clear it.",
291+ nameField: "Name",
292+ surnameField: "Surname",
293+ emailField: "Email",
294+ phoneField: "Phone",
295+ birthDateField: "Birth date",
296+ savedDot: "Saved.",
297+ phoneTitle: (min: number, max: number) =>
298+ `${min} to ${max} digits; +, spaces, dashes, and parentheses are allowed`,
299+ usersTitle: "Users",
300+ usersSub: "Every account, with roles and personal records.",
301+ adminsOnly: "Admins only.",
302+ idCol: "Id",
303+ contactCol: "Contact",
304+ bornCol: "Born",
305+ roleCol: "Role",
306+ roleWord: (role: Role) =>
307+ ({ student: "student", teacher: "teacher", manager: "manager", admin: "admin" })[role],
308+ saveProfile: "Save profile",
309+ noUsers: "No users.",
310+
311+ // user picker
312+ typeAName: "Type a name…",
313+ nobodyFound: "Nobody found.",
314+ pickFromList: "Pick a person from the list",
315+
316+ // not found
317+ pageFlewAway: "This page flew away.",
318+ backHome: "Back home",
319+};
320+
321+type Dict = typeof en;
322+
323+const tr: Dict = {
324+ // navigation & shell
325+ navHome: "Ana sayfa",
326+ navNotes: "Not defteri",
327+ navEvents: "Etkinlikler",
328+ navCourses: "Dersler",
329+ navExams: "Sınavlar",
330+ navMarks: "Karnem",
331+ navUsers: "Kullanıcılar",
332+ logout: "Çıkış yap",
333+ profileLink: "Profilim",
334+ otherLanguage: "English",
335+
336+ // shared bits
337+ save: "Kaydet",
338+ cancel: "Vazgeç",
339+ close: "Kapat",
340+ edit: "Düzenle",
341+ remove: "Kaldır",
342+ apply: "Uygula",
343+ you: " (sen)",
344+ title: "Başlık",
345+ description: "Açıklama",
346+ status: "Durum",
347+ reallyDelete: "Silinsin mi?",
348+ reallyRemove: "Kaldırılsın mı?",
349+ somethingWrong: "bir şeyler ters gitti",
350+ retryIn: (s: number) => `${s} sn sonra tekrar dene`,
351+ networkError: "ağ hatası — sunucu çalışıyor mu?",
352+ unscheduled: "Tarihsiz",
353+ until: (time: string) => `Bitiş: ${time}`,
354+
355+ // login
356+ loginWelcome: "Tekrar hoş geldin — devam etmek için giriş yap.",
357+ registerWelcome: "Başlamak için bir hesap oluştur.",
358+ username: "Kullanıcı adı",
359+ password: "Şifre",
360+ showPassword: "Şifreyi göster",
361+ hidePassword: "Şifreyi gizle",
362+ atLeastChars: (n: number) => `En az ${n} karakter.`,
363+ logIn: "Giriş yap",
364+ createAccount: "Hesap oluştur",
365+ switchToRegister: "Yeni misin? Kayıt ol",
366+ switchToLogin: "Hesabın var mı? Giriş yap",
367+
368+ // home
369+ greeting: (name: string, hour: number) =>
370+ hour < 12 ? `Günaydın ${name}` : hour < 18 ? `İyi günler ${name}` : `İyi akşamlar ${name}`,
371+ statNotes: "Not defteri",
372+ statUpcoming: "Yaklaşan etkinlik",
373+ statMyCourses: "Derslerim",
374+ statAverage: "Ortalamam",
375+ upcomingEvents: "Yaklaşan etkinlikler",
376+ myCourses: "Derslerim",
377+ viewAll: "Tümünü gör",
378+ nothingScheduled: "Planlanmış bir şey yok.",
379+ notEnrolledYet: "Henüz bir derse kayıtlı değilsin.",
380+
381+ // notes
382+ notesTitle: "Not defteri",
383+ notesSub: "Kişisel defterin — sadece sen görürsün.",
384+ newNote: "Yeni not",
385+ content: "İçerik",
386+ writeSomething: "Bir şeyler yaz…",
387+ addNote: "Not ekle",
388+ noNotesYet: "Henüz not yok — ilkini yaz.",
389+ deleteNote: "Sil",
390+
391+ // events
392+ eventsTitle: "Etkinlikler",
393+ eventsSub: "Neler oluyor — yoklamayı görmek ya da işaretlemek için birine gir.",
394+ newEvent: "Yeni etkinlik",
395+ starts: "Başlangıç",
396+ ends: "Bitiş",
397+ addEvent: "Etkinlik ekle",
398+ noEventsYet: "Henüz etkinlik yok.",
399+ attendance: "Yoklama",
400+ iAm: (status: AttendanceStatus) =>
401+ ({ present: "Buradayım", absent: "Yokum", late: "Geç kaldım", excused: "İzinliyim" })[status],
402+ attendanceWord: (status: AttendanceStatus) =>
403+ ({ present: "geldi", absent: "gelmedi", late: "geç", excused: "izinli" })[status],
404+ person: "Kişi",
405+ markUser: "Kişiyi işaretle",
406+ nobodyMarkedYet: "Henüz kimse işaretlenmedi.",
407+ userCol: "Kullanıcı",
408+ deleteEvent: "Etkinliği sil",
409+ reallyDeleteEvent: "Etkinlik silinsin mi?",
410+ eventMissing: "Böyle bir etkinlik yok.",
411+ eventLoadFailed: "Etkinlik yüklenemedi.",
412+
413+ // courses
414+ coursesTitle: "Dersler",
415+ coursesSub: "Tüm dersler — kayıtlı oldukların işaretli.",
416+ newCourse: "Yeni ders",
417+ addCourse: "Ders ekle",
418+ noCoursesYet: "Henüz ders yok.",
419+ enrolledBadge: "kayıtlısın",
420+ deleteCourse: "Dersi sil",
421+ reallyDeleteCourse: "Ders silinsin mi?",
422+ courseMissing: "Böyle bir ders yok.",
423+ courseLoadFailed: "Ders yüklenemedi.",
424+ roster: "Sınıf listesi",
425+ student: "Öğrenci",
426+ enrolledBy: "Kaydeden",
427+ enroll: "Derse ekle",
428+ unenroll: "Dersten çıkar",
429+ nobodyEnrolledYet: "Henüz kimse kayıtlı değil.",
430+
431+ // exams
432+ examsTitle: "Sınavlar",
433+ examsSubAll: "Bütün derslerin sınavları.",
434+ examsSubCreate: "Yeni sınav ders sayfasında açılır.",
435+ coursePrefix: "Ders:",
436+ newExam: "Yeni sınav",
437+ addExam: "Sınav ekle",
438+ noExamsYet: "Henüz sınav yok.",
439+ kind: "Tür",
440+ weight: "Ağırlık",
441+ kindWord: (kind: ExamKind) =>
442+ ({ homework: "ödev", quiz: "küçük sınav", midterm: "ara sınav", final: "dönem sonu", project: "proje", oral: "sözlü" })[kind],
443+ weightBadge: (n: number) => `×${n} sayılır`,
444+ weightTitle: "bu sınav ders ortalamasına kaç kez sayılır",
445+ deleteExam: "Sınavı sil",
446+ reallyDeleteExam: "Sınav silinsin mi?",
447+ examMissing: "Böyle bir sınav yok.",
448+ examLoadFailed: "Sınav yüklenemedi.",
449+ myResult: "Sonucum",
450+ notGradedYet: "Henüz notlanmadı.",
451+ statistics: "İstatistik",
452+ gradedStat: "Notlanan",
453+ averageStat: "Ortalama",
454+ minStat: "En düşük",
455+ maxStat: "En yüksek",
456+ results: "Sonuçlar",
457+ mark0100: "Not (0–100)",
458+ gradeAction: "Notla",
459+ noResultsYet: "Henüz sonuç yok.",
460+
461+ // exam scheduling
462+ timing: "Zamanlama",
463+ timingNone: "Zamansız — uygulama dışında yapılır",
464+ timingSync: "Canlı — herkes aynı anda",
465+ timingAsync: "Esnek — açık aralıkta kendi süresi",
466+ opens: "Açılış",
467+ closes: "Kapanış",
468+ minutesPerStudent: "Öğrenci başına dakika",
469+ syncHint: "Herkes birlikte yazar: süre, sınav kapanınca herkes için biter.",
470+ asyncHint: "Her öğrencinin süresi, açık aralık içinde girdiği anda başlar.",
471+ endsAfterStarts: "Kapanış, açılıştan sonra olmalı",
472+
473+ // sitting card
474+ examTime: "Sınav zamanı",
475+ phaseWord: (phase: "upcoming" | "open" | "closed") =>
476+ ({ upcoming: "Yakında açılır", open: "Şimdi açık", closed: "Kapandı" })[phase],
477+ minutesEach: (n: number) => `herkese ${n} dakika`,
478+ turnedInAt: (time: string) => `Teslim edildi ✓ ${time}`,
479+ seeMyAnswers: "Cevaplarımı gör",
480+ timeRanOut: "Süre doldu — sona kadar kaydedilenler geçerli.",
481+ continueExam: "Sınava devam et",
482+ answeredOf: (a: number, b: number) => `${a} / ${b} cevaplandı`,
483+ timeLeftShort: (countdown: string) => `${countdown} kaldı`,
484+ enterExam: "Sınava gir",
485+ startTimerConfirm: (n: number) => `Başlasın mı? ${n} dakikan şimdi başlar`,
486+ opensAt: (time: string) => `${time} açılır.`,
487+ examOver: "Bu sınav bitti.",
488+
489+ // exam room
490+ notEnteredYet: "Bu sınava henüz girmedin.",
491+ backToExam: "Sınav sayfasına dön",
492+ turnIn: "Teslim et",
493+ turnInNow: "Teslim edilsin mi?",
494+ turnInUnanswered: (n: number) => `${n} soru boş — teslim edilsin mi?`,
495+ turnedInBanner: (time: string) =>
496+ `Teslim edildi ✓ ${time} — cevaplarını aşağıda görebilirsin.`,
497+ timeUpBanner: "Süre doldu. Bitmeden kaydedilen her şey geçerli.",
498+ noQuestionsRoom: "Burada soru yok — öğretmenin bu sınavı elden notlayacak.",
499+ writeAnswerHere: "Cevabını buraya yaz…",
500+ savingState: "Kaydediliyor…",
501+ savedState: "Kaydedildi ✓",
502+ notSavedState: "Kaydedilemedi!",
503+ turnedInChip: "Teslim edildi",
504+ timeUpChip: "Süre doldu",
505+ pts: (n: number) => `${n} puan`,
506+ savingFailed: "kaydedilemedi",
507+
508+ // question authoring
509+ questionsTitle: "Sorular",
510+ totalPoints: (n: number) => `${n} puan`,
511+ addQuestion: "Soru ekle",
512+ noQuestionsYet: "Henüz soru yok — öğrenciler boş sınav görür.",
513+ questionLabel: "Soru",
514+ answerType: "Cevap türü",
515+ answerTypeChoice: "Şıklı (tek doğru)",
516+ answerTypeText: "Yazılı cevap",
517+ points: "Puan",
518+ questionKindWord: (kind: QuestionKind) =>
519+ ({ choice: "şıklı", text: "yazılı" })[kind],
520+ tickRightAnswer: "Doğru cevabın yanındaki yuvarlağı işaretle.",
521+ optionN: (n: number) => `Seçenek ${n}`,
522+ optionIsRight: (n: number) => `Doğru cevap ${n}. seçenek`,
523+ removeOption: "Bu seçeneği kaldır",
524+ addOption: "Seçenek ekle",
525+ saveQuestion: "Soruyu kaydet",
526+
527+ // live monitor
528+ liveMonitor: "Canlı izleme",
529+ countEnrolled: (n: number) => `${n} kayıtlı`,
530+ countWriting: (n: number) => `${n} yazıyor`,
531+ countTurnedIn: (n: number) => `${n} teslim etti`,
532+ countNotStarted: (n: number) => `${n} başlamadı`,
533+ countTimeUp: (n: number) => `${n} süresi doldu`,
534+ countGraded: (n: number) => `${n} notlandı`,
535+ liveStatusWord: (status: LiveStudent["status"]) =>
536+ ({ not_started: "Başlamadı", in_progress: "Yazıyor", submitted: "Teslim etti", expired: "Süresi doldu" })[status],
537+ answeredCol: "Cevaplanan",
538+ timeLeftCol: "Kalan süre",
539+ lastSaveCol: "Son kayıt",
540+ markCol: "Not",
541+ review: "İncele",
542+ nobodyEnrolledCourse: "Bu derse henüz kimse kayıtlı değil.",
543+ sheetTitle: (name: string) => `${name} — cevaplar`,
544+ noAnswer: "Cevap yok.",
545+ rightAnswerIs: (text: string) => ` ✗ (doğrusu: ${text})`,
546+ autoScoreLine: (earned: number, possible: number) =>
547+ `Şıklı sorularda otomatik puan: ${earned} / ${possible} — sadece bir öneri, aşağıdaki notu sen verirsin.`,
548+ noQuestionsSheet: "Bu sınavda soru yok.",
549+ agoSeconds: (s: number) => `${s} sn önce`,
550+ agoMinutes: (m: number) => `${m} dk önce`,
551+
552+ // marks
553+ marksTitle: "Karnem",
554+ marksSub: "Ders ders notların, ağırlıklı ortalamalarınla birlikte.",
555+ marksLoadFailed: "Karnen yüklenemedi.",
556+ overallAverage: "Genel ortalama",
557+ courseAverageTitle: "ağırlıklı ders ortalaması",
558+ overallAverageTitle: "ders ortalamalarının ortalaması",
559+ studentLookup: "Öğrenci ara",
560+ showMarks: "Karneyi gör",
561+ reportFor: (name: string) => `${name} — karne`,
562+ notEnrolledAny: "Hiçbir derse kayıtlı değil.",
563+ nothingGradedYet: "Henüz not girilmedi.",
564+ examCol: "Sınav",
565+
566+ // profile & users
567+ personalInfo: "Kişisel bilgiler",
568+ leaveEmptyToClear: "Boş bıraktığın alan silinir.",
569+ nameField: "Ad",
570+ surnameField: "Soyad",
571+ emailField: "E-posta",
572+ phoneField: "Telefon",
573+ birthDateField: "Doğum tarihi",
574+ savedDot: "Kaydedildi.",
575+ phoneTitle: (min: number, max: number) =>
576+ `${min}–${max} rakam; +, boşluk, tire ve parantez kullanılabilir`,
577+ usersTitle: "Kullanıcılar",
578+ usersSub: "Bütün hesaplar: roller ve kişisel kayıtlar.",
579+ adminsOnly: "Sadece adminler.",
580+ idCol: "Kimlik",
581+ contactCol: "İletişim",
582+ bornCol: "Doğum",
583+ roleCol: "Rol",
584+ roleWord: (role: Role) =>
585+ ({ student: "öğrenci", teacher: "öğretmen", manager: "müdür", admin: "admin" })[role],
586+ saveProfile: "Profili kaydet",
587+ noUsers: "Kullanıcı yok.",
588+
589+ // user picker
590+ typeAName: "Bir isim yaz…",
591+ nobodyFound: "Kimse bulunamadı.",
592+ pickFromList: "Listeden birini seç",
593+
594+ // not found
595+ pageFlewAway: "Bu sayfa uçup gitmiş.",
596+ backHome: "Ana sayfaya dön",
597+};
598+
599+/**
600+ * The current-language entry for `key`: a string for plain lines, a function
601+ * for parameterized ones (call it: `t("pts")(10)`). Reactive — any JSX or
602+ * memo reading it re-renders on language switch.
603+ */
604+export function t<K extends keyof Dict>(key: K): Dict[K] {
605+ return (lang() === "tr" ? tr : en)[key];
606+}
src/lib/types.tsmodified+149 -6
@@ -22,6 +22,14 @@ export interface User {
2222 birth_date: string | null;
2323 }
2424
25+/** Who a row points at: the id plus something a human can read. */
26+export interface PersonRef {
27+ id: string;
28+ username: string;
29+ /** "Name Surname" when the profile has either; null otherwise. */
30+ display_name: string | null;
31+}
32+
2533 export interface Note {
2634 id: string;
2735 title: string;
@@ -44,9 +52,9 @@ export type AttendanceStatus = (typeof ATTENDANCE_STATUSES)[number];
4452 export interface Attendance {
4553 id: string;
4654 event: string;
47- user: string;
55+ user: PersonRef;
4856 status: AttendanceStatus;
49- marked_by: string;
57+ marked_by: PersonRef;
5058 }
5159
5260 export interface Course {
@@ -59,8 +67,8 @@ export interface Course {
5967 export interface Enrollment {
6068 id: string;
6169 course: string;
62- user: string;
63- enrolled_by: string;
70+ user: PersonRef;
71+ enrolled_by: PersonRef;
6472 }
6573
6674 /** Informational metadata only — `weight` drives the course average. */
@@ -74,6 +82,12 @@ export const EXAM_KINDS = [
7482 ] as const;
7583 export type ExamKind = (typeof EXAM_KINDS)[number];
7684
85+/**
86+ * How a scheduled exam is sat: `sync` (everyone shares one fixed window) or
87+ * `async` (each student starts inside the window and gets `duration_ms`).
88+ */
89+export type ExamMode = "sync" | "async";
90+
7791 export interface Exam {
7892 id: string;
7993 creator: string;
@@ -83,15 +97,137 @@ export interface Exam {
8397 kind: ExamKind;
8498 /** Counts `weight` times into the course average, 1–100. */
8599 weight: number;
100+ /** Null on an unscheduled (offline-graded) exam — so are the fields below. */
101+ mode: ExamMode | null;
102+ /** Window open, UTC unix-milliseconds. */
103+ starts_at: number | null;
104+ /** Window close, UTC unix-milliseconds. */
105+ ends_at: number | null;
106+ /** Per-student time budget in milliseconds (async exams only). */
107+ duration_ms: number | null;
108+}
109+
110+export type AttemptStatus = "in_progress" | "submitted" | "expired";
111+
112+/** The caller's sitting of an exam; `now` is the server clock at response time. */
113+export interface ExamAttempt {
114+ id: string;
115+ exam: string;
116+ user: PersonRef;
117+ started_at: number;
118+ finished_at: number | null;
119+ status: AttemptStatus;
120+ /** When the attempt closes, recomputed live from the exam's schedule. */
121+ deadline: number | null;
122+ /** `deadline - now`, floored at 0; null unless in progress. */
123+ remaining_ms: number | null;
124+ /** The caller's mark, once graded. */
125+ mark: number | null;
126+ answered: number;
127+ question_count: number;
128+ /** Server clock, UTC unix-milliseconds. */
129+ now: number;
130+}
131+
132+export type QuestionKind = "choice" | "text";
133+
134+/** A question as its author sees it — `correct` included. Teacher+ only. */
135+export interface ExamQuestion {
136+ id: string;
137+ exam: string;
138+ text: string;
139+ kind: QuestionKind;
140+ /** This question's share of the auto-score, 1–100. */
141+ points: number;
142+ /** The options of a `choice` question (2–10); null for `text`. */
143+ choices: string[] | null;
144+ /** Zero-based index of the right option; null for `text`. */
145+ correct: number | null;
146+}
147+
148+/** A student's own saved answer, embedded in their question view. */
149+export interface AnswerState {
150+ selected: number | null;
151+ text: string | null;
152+ updated_at: number;
153+}
154+
155+/** A question as the sitting student sees it: no `correct`, answer embedded. */
156+export interface AttemptQuestion {
157+ id: string;
158+ text: string;
159+ kind: QuestionKind;
160+ points: number;
161+ choices: string[] | null;
162+ answer: AnswerState | null;
163+}
164+
165+export interface AnswerSaved {
166+ question: string;
167+ selected: number | null;
168+ text: string | null;
169+ updated_at: number;
170+}
171+
172+/** One roster row of the teacher's live exam monitor. */
173+export interface LiveStudent {
174+ user: PersonRef;
175+ status: "not_started" | AttemptStatus;
176+ started_at: number | null;
177+ finished_at: number | null;
178+ deadline: number | null;
179+ remaining_ms: number | null;
180+ mark: number | null;
181+ answered: number;
182+ /** When this student last saved an answer; null before the first save. */
183+ last_activity: number | null;
184+}
185+
186+export interface LiveCounts {
187+ enrolled: number;
188+ not_started: number;
189+ in_progress: number;
190+ submitted: number;
191+ expired: number;
192+ graded: number;
193+}
194+
195+/** One SSE `snapshot` frame of `GET /exams/{id}/live/stream`. */
196+export interface ExamLive {
197+ exam: Exam;
198+ /** Server clock the snapshot was judged at. */
199+ now: number;
200+ question_count: number;
201+ counts: LiveCounts;
202+ students: LiveStudent[];
203+}
204+
205+/** One row of a student's answer sheet, as the grader sees it. */
206+export interface StudentAnswer {
207+ question: string;
208+ selected: number | null;
209+ text: string | null;
210+ updated_at: number;
211+ /** Whether `selected` hits `correct`; null for text questions. */
212+ is_correct: boolean | null;
213+}
214+
215+/** A student's full answer sheet with the machine's scoring suggestion. */
216+export interface AttemptAnswers {
217+ exam: string;
218+ user: PersonRef;
219+ answers: StudentAnswer[];
220+ /** Suggested score over choice questions — never the final mark. */
221+ auto_score: { earned: number; possible: number };
86222 }
87223
88224 export interface ExamResult {
89225 id: string;
90226 exam: string;
91- user: string;
227+ user: PersonRef;
92228 /** 0–100 inclusive. */
93229 mark: number;
94- graded_by: string;
230+ graded_by: PersonRef;
95231 }
96232
97233 export interface ExamStatistics {
@@ -146,4 +282,11 @@ export const LIMITS = {
146282 courseDescription: 2_000,
147283 mark: { min: 0, max: 100 },
148284 weight: { min: 1, max: 100 },
285+ /** Async per-student budget, minutes (backend: 60 s – 24 h in ms). */
286+ examDurationMin: { min: 1, max: 24 * 60 },
287+ questionText: 2_000,
288+ questionPoints: { min: 1, max: 100 },
289+ questionChoices: { min: 2, max: 10 },
290+ choiceText: 500,
291+ answerText: 10_000,
149292 } as const;
src/pages/CourseDetail.tsxmodified+95 -62
@@ -4,11 +4,16 @@
44
55 import { A, useNavigate, useParams } from "@solidjs/router";
66 import { For, Show, createResource, createSignal } from "solid-js";
7+import { ConfirmButton } from "../components/ConfirmButton";
78 import { Empty, ErrorLine, Loading } from "../components/Feedback";
89 import { IconEdit, IconPlus } from "../components/Icons";
10+import { ScheduleFields, scheduleFromForm } from "../components/ScheduleFields";
11+import { UserPicker } from "../components/UserPicker";
912 import { createAction } from "../lib/action";
1013 import { ApiError, courses } from "../lib/api";
1114 import { useAuth } from "../lib/auth";
15+import { personLabel } from "../lib/format";
16+import { t } from "../lib/i18n";
1217 import { EXAM_KINDS, LIMITS, type Enrollment } from "../lib/types";
1318
1419 export default function CourseDetail() {
@@ -52,7 +57,7 @@ export default function CourseDetail() {
5257 </div>
5358 <Show when={canManage()}>
5459 <button class="ghost" onClick={() => setEditing((open) => !open)}>
55- <IconEdit /> {editing() ? "Close" : "Edit"}
60+ <IconEdit /> {editing() ? t("close") : t("edit")}
5661 </button>
5762 </Show>
5863 </header>
@@ -69,31 +74,37 @@ export default function CourseDetail() {
6974 void save.run(e.currentTarget);
7075 }}
7176 >
72- <input
73- name="title"
74- value={current().title}
75- required
76- maxLength={LIMITS.courseTitle}
77- />
78- <textarea name="description" rows={3} maxLength={LIMITS.courseDescription}>
79- {current().description}
80- </textarea>
77+ <label>
78+ {t("title")}
79+ <input
80+ name="title"
81+ value={current().title}
82+ required
83+ maxLength={LIMITS.courseTitle}
84+ />
85+ </label>
86+ <label>
87+ {t("description")}
88+ <textarea name="description" rows={3} maxLength={LIMITS.courseDescription}>
89+ {current().description}
90+ </textarea>
91+ </label>
8192 <ErrorLine error={save.error() ?? remove.error()} />
8293 <span class="row-actions">
8394 <button type="submit" disabled={save.pending()}>
84- Save
95+ {t("save")}
8596 </button>
8697 <button type="button" class="ghost" onClick={() => setEditing(false)}>
87- Cancel
98+ {t("cancel")}
8899 </button>
89- <button
90- type="button"
100+ <ConfirmButton
91101 class="ghost danger push"
102+ confirmText={t("reallyDeleteCourse")}
92103 disabled={remove.pending()}
93- onClick={() => void remove.run()}
104+ onConfirm={() => void remove.run()}
94105 >
95- Delete course
96- </button>
106+ {t("deleteCourse")}
107+ </ConfirmButton>
97108 </span>
98109 </form>
99110 </Show>
@@ -120,6 +131,7 @@ function CourseExams(props: { courseId: string; canManage: boolean }) {
120131 description: String(data.get("description")),
121132 kind: String(data.get("kind")),
122133 weight: Number(data.get("weight")),
134+ ...scheduleFromForm(data),
123135 });
124136 mutate((current) => [created, ...(current ?? [])]);
125137 form.reset();
@@ -129,10 +141,10 @@ function CourseExams(props: { courseId: string; canManage: boolean }) {
129141 return (
130142 <article class="stack gap-top">
131143 <div class="section-head">
132- <h2>Exams</h2>
144+ <h2>{t("examsTitle")}</h2>
133145 <Show when={props.canManage}>
134146 <button class="ghost" onClick={() => setCreating((open) => !open)}>
135- <IconPlus /> New exam
147+ <IconPlus /> {t("newExam")}
136148 </button>
137149 </Show>
138150 </div>
@@ -145,28 +157,30 @@ function CourseExams(props: { courseId: string; canManage: boolean }) {
145157 void create.run(e.currentTarget);
146158 }}
147159 >
148- <input
149- name="title"
150- placeholder="Title"
151- required
152- maxLength={LIMITS.examTitle}
153- ref={(el) => queueMicrotask(() => el.focus())}
154- />
155- <textarea
156- name="description"
157- placeholder="Description"
158- rows={2}
159- maxLength={LIMITS.examDescription}
160- />
160+ <label>
161+ {t("title")}
162+ <input
163+ name="title"
164+ required
165+ maxLength={LIMITS.examTitle}
166+ ref={(el) => queueMicrotask(() => el.focus())}
167+ />
168+ </label>
169+ <label>
170+ {t("description")}
171+ <textarea name="description" rows={2} maxLength={LIMITS.examDescription} />
172+ </label>
161173 <div class="row">
162174 <label>
163- Kind
175+ {t("kind")}
164176 <select name="kind">
165- <For each={EXAM_KINDS}>{(kind) => <option value={kind}>{kind}</option>}</For>
177+ <For each={EXAM_KINDS}>
178+ {(kind) => <option value={kind}>{t("kindWord")(kind)}</option>}
179+ </For>
166180 </select>
167181 </label>
168182 <label>
169- Weight
183+ {t("weight")}
170184 <input
171185 name="weight"
172186 type="number"
@@ -177,29 +191,45 @@ function CourseExams(props: { courseId: string; canManage: boolean }) {
177191 />
178192 </label>
179193 </div>
194+ <ScheduleFields />
180195 <ErrorLine error={create.error()} />
181196 <span class="row-actions">
182197 <button type="submit" disabled={create.pending()}>
183- Add exam
198+ {t("addExam")}
184199 </button>
185200 <button type="button" class="ghost" onClick={() => setCreating(false)}>
186- Cancel
201+ {t("cancel")}
187202 </button>
188203 </span>
189204 </form>
190205 </Show>
191206
192207 <Show when={!list.loading} fallback={<Loading />}>
193- <Show when={list()?.length} fallback={<Empty>No exams yet.</Empty>}>
208+ <Show
209+ when={list()?.length}
210+ fallback={
211+ <Empty
212+ action={
213+ props.canManage ? (
214+ <button onClick={() => setCreating(true)}>
215+ <IconPlus /> {t("newExam")}
216+ </button>
217+ ) : undefined
218+ }
219+ >
220+ {t("noExamsYet")}
221+ </Empty>
222+ }
223+ >
194224 <div class="grid">
195225 <For each={list()}>
196226 {(exam) => (
197227 <A href={`/exams/${exam.id}`} class="card link-card stack">
198228 <header class="row">
199229 <h3>{exam.title}</h3>
200- <span class="badge">{exam.kind}</span>
201- <span class="badge" title="weight in the course average">
202- ×{exam.weight}
230+ <span class="badge">{t("kindWord")(exam.kind)}</span>
231+ <span class="badge" title={t("weightTitle")}>
232+ {t("weightBadge")(exam.weight)}
203233 </span>
204234 </header>
205235 <Show when={exam.description}>
@@ -225,45 +255,45 @@ function Roster(props: { courseId: string; canManage: boolean }) {
225255 const enrolled = await courses.enroll(props.courseId, String(data.get("user_id")));
226256 // Enrolling is an idempotent upsert; one row per (course, user).
227257 mutate((current) => [
228- ...(current ?? []).filter((e) => e.user !== enrolled.user),
258+ ...(current ?? []).filter((e) => e.user.id !== enrolled.user.id),
229259 enrolled,
230260 ]);
231261 form.reset();
232262 });
233263
234264 const unenroll = createAction(async (entry: Enrollment) => {
235- await courses.unenroll(props.courseId, entry.user);
236- mutate((current) => current?.filter((e) => e.user !== entry.user));
265+ await courses.unenroll(props.courseId, entry.user.id);
266+ mutate((current) => current?.filter((e) => e.user.id !== entry.user.id));
237267 });
238268
239269 return (
240270 <article class="stack gap-top">
241- <h2>Roster</h2>
271+ <h2>{t("roster")}</h2>
242272
243273 <Show when={props.canManage}>
244274 <form
245- class="row"
275+ class="row row-end"
246276 onSubmit={(e) => {
247277 e.preventDefault();
248278 void enroll.run(e.currentTarget);
249279 }}
250280 >
251- <input name="user_id" placeholder="Student id" required />
281+ <UserPicker name="user_id" label={t("student")} />
252282 <button type="submit" disabled={enroll.pending()}>
253- Enroll
283+ {t("enroll")}
254284 </button>
255285 </form>
256286 <ErrorLine error={enroll.error() ?? unenroll.error()} />
257287 </Show>
258288
259289 <Show when={!roster.loading} fallback={<Loading />}>
260- <Show when={roster()?.length} fallback={<Empty>Nobody enrolled yet.</Empty>}>
290+ <Show when={roster()?.length} fallback={<Empty>{t("nobodyEnrolledYet")}</Empty>}>
261291 <div class="table-wrap">
262292 <table>
263293 <thead>
264294 <tr>
265- <th>Student</th>
266- <th>Enrolled by</th>
295+ <th>{t("student")}</th>
296+ <th>{t("enrolledBy")}</th>
267297 <Show when={props.canManage}>
268298 <th />
269299 </Show>
@@ -273,17 +303,20 @@ function Roster(props: { courseId: string; canManage: boolean }) {
273303 <For each={roster()}>
274304 {(entry) => (
275305 <tr>
276- <td class="mono">{entry.user === user()?.id ? "you" : entry.user}</td>
277- <td class="mono">{entry.enrolled_by}</td>
306+ <td>
307+ {personLabel(entry.user)}
308+ <Show when={entry.user.id === user()?.id}>{t("you")}</Show>
309+ </td>
310+ <td class="meta">{personLabel(entry.enrolled_by)}</td>
278311 <Show when={props.canManage}>
279312 <td>
280- <button
281- class="ghost danger"
313+ <ConfirmButton
314+ confirmText={t("reallyRemove")}
282315 disabled={unenroll.pending()}
283- onClick={() => void unenroll.run(entry)}
316+ onConfirm={() => void unenroll.run(entry)}
284317 >
285- Unenroll
286- </button>
318+ {t("unenroll")}
319+ </ConfirmButton>
287320 </td>
288321 </Show>
289322 </tr>
@@ -299,9 +332,9 @@ function Roster(props: { courseId: string; canManage: boolean }) {
299332 }
300333
301334 function NotFoundMessage(props: { error: unknown }) {
302- const message =
335+ const message = () =>
303336 props.error instanceof ApiError && props.error.status === 404
304- ? "This course does not exist."
305- : "Failed to load the course.";
306- return <Empty>{message}</Empty>;
337+ ? t("courseMissing")
338+ : t("courseLoadFailed");
339+ return <Empty>{message()}</Empty>;
307340 }
src/pages/Courses.tsxmodified+36 -20
@@ -8,6 +8,7 @@ import { IconPlus } from "../components/Icons";
88 import { createAction } from "../lib/action";
99 import { courses } from "../lib/api";
1010 import { useAuth } from "../lib/auth";
11+import { t } from "../lib/i18n";
1112 import { LIMITS } from "../lib/types";
1213
1314 export default function Courses() {
@@ -32,12 +33,12 @@ export default function Courses() {
3233 <section class="page">
3334 <header class="page-head">
3435 <div>
35- <h1>Courses</h1>
36- <p class="sub">Everything on offer — your enrollments are tagged.</p>
36+ <h1>{t("coursesTitle")}</h1>
37+ <p class="sub">{t("coursesSub")}</p>
3738 </div>
3839 <Show when={can("teacher")}>
3940 <button onClick={() => setCreating((open) => !open)}>
40- <IconPlus /> New course
41+ <IconPlus /> {t("newCourse")}
4142 </button>
4243 </Show>
4344 </header>
@@ -50,33 +51,48 @@ export default function Courses() {
5051 void create.run(e.currentTarget);
5152 }}
5253 >
53- <input
54- name="title"
55- placeholder="Title"
56- required
57- maxLength={LIMITS.courseTitle}
58- ref={(el) => queueMicrotask(() => el.focus())}
59- />
60- <textarea
61- name="description"
62- placeholder="Description"
63- rows={2}
64- maxLength={LIMITS.courseDescription}
65- />
54+ <label>
55+ {t("title")}
56+ <input
57+ name="title"
58+ required
59+ maxLength={LIMITS.courseTitle}
60+ ref={(el) => queueMicrotask(() => el.focus())}
61+ />
62+ </label>
63+ <label>
64+ {t("description")}
65+ <textarea name="description" rows={2} maxLength={LIMITS.courseDescription} />
66+ </label>
6667 <ErrorLine error={create.error()} />
6768 <span class="row-actions">
6869 <button type="submit" disabled={create.pending()}>
69- Add course
70+ {t("addCourse")}
7071 </button>
7172 <button type="button" class="ghost" onClick={() => setCreating(false)}>
72- Cancel
73+ {t("cancel")}
7374 </button>
7475 </span>
7576 </form>
7677 </Show>
7778
7879 <Show when={!list.loading} fallback={<Loading />}>
79- <Show when={list()?.length} fallback={<Empty>No courses yet.</Empty>}>
80+ <Show
81+ when={list()?.length}
82+ fallback={
83+ <Empty
84+ action={
85+ can("teacher") ? (
86+ <button onClick={() => setCreating(true)}>
87+ <IconPlus /> {t("newCourse")}
88+ </button>
89+ ) : undefined
90+ }
91+ >
92+ {t("noCoursesYet")}
93+ </Empty>
94+ }
95+ >
8096 <div class="grid">
8197 <For each={list()}>
8298 {(course) => (
@@ -84,7 +100,7 @@ export default function Courses() {
84100 <header class="row">
85101 <h3>{course.title}</h3>
86102 <Show when={enrolled().has(course.id)}>
87- <span class="badge">enrolled</span>
103+ <span class="badge">{t("enrolledBadge")}</span>
88104 </Show>
89105 </header>
90106 <Show when={course.description}>
src/pages/EventDetail.tsxmodified+63 -48
@@ -4,12 +4,15 @@
44
55 import { useNavigate, useParams } from "@solidjs/router";
66 import { For, Show, createResource, createSignal } from "solid-js";
7+import { ConfirmButton } from "../components/ConfirmButton";
78 import { Empty, ErrorLine, Loading } from "../components/Feedback";
89 import { IconEdit } from "../components/Icons";
10+import { UserPicker } from "../components/UserPicker";
911 import { createAction } from "../lib/action";
1012 import { ApiError, events } from "../lib/api";
1113 import { useAuth } from "../lib/auth";
12-import { formatWindow, fromInputValue, toInputValue } from "../lib/format";
14+import { formatWindow, fromInputValue, personLabel, toInputValue } from "../lib/format";
15+import { t } from "../lib/i18n";
1316 import { ATTENDANCE_STATUSES, LIMITS, type AttendanceStatus } from "../lib/types";
1417
1518 export default function EventDetail() {
@@ -25,7 +28,7 @@ export default function EventDetail() {
2528 const current = event();
2629 return current !== undefined && (current.creator === user()?.id || can("manager"));
2730 };
28- const myStatus = () => roster()?.find((a) => a.user === user()?.id)?.status;
31+ const myStatus = () => roster()?.find((a) => a.user.id === user()?.id)?.status;
2932
3033 const save = createAction(async (form: HTMLFormElement) => {
3134 const data = new FormData(form);
@@ -49,14 +52,14 @@ export default function EventDetail() {
4952 const marked = await events.mark(params.id, status, userId);
5053 // The backend upserts one row per (event, user); mirror that.
5154 setRoster((current) => [
52- ...(current ?? []).filter((a) => a.user !== marked.user),
55+ ...(current ?? []).filter((a) => a.user.id !== marked.user.id),
5356 marked,
5457 ]);
5558 });
5659
5760 const unmark = createAction(async (userId: string) => {
5861 await events.unmark(params.id, userId);
59- setRoster((current) => current?.filter((a) => a.user !== userId));
62+ setRoster((current) => current?.filter((a) => a.user.id !== userId));
6063 });
6164
6265 return (
@@ -73,7 +76,7 @@ export default function EventDetail() {
7376 </div>
7477 <Show when={canManage()}>
7578 <button class="ghost" onClick={() => setEditing((open) => !open)}>
76- <IconEdit /> {editing() ? "Close" : "Edit"}
79+ <IconEdit /> {editing() ? t("close") : t("edit")}
7780 </button>
7881 </Show>
7982 </header>
@@ -90,18 +93,24 @@ export default function EventDetail() {
9093 void save.run(e.currentTarget);
9194 }}
9295 >
93- <input
94- name="title"
95- value={current().title}
96- required
97- maxLength={LIMITS.eventTitle}
98- />
99- <textarea name="description" rows={3} maxLength={LIMITS.eventDescription}>
100- {current().description}
101- </textarea>
96+ <label>
97+ {t("title")}
98+ <input
99+ name="title"
100+ value={current().title}
101+ required
102+ maxLength={LIMITS.eventTitle}
103+ />
104+ </label>
105+ <label>
106+ {t("description")}
107+ <textarea name="description" rows={3} maxLength={LIMITS.eventDescription}>
108+ {current().description}
109+ </textarea>
110+ </label>
102111 <div class="row">
103112 <label>
104- Starts
113+ {t("starts")}
105114 <input
106115 name="starts_at"
107116 type="datetime-local"
@@ -109,7 +118,7 @@ export default function EventDetail() {
109118 />
110119 </label>
111120 <label>
112- Ends
121+ {t("ends")}
113122 <input
114123 name="ends_at"
115124 type="datetime-local"
@@ -120,25 +129,25 @@ export default function EventDetail() {
120129 <ErrorLine error={save.error() ?? remove.error()} />
121130 <span class="row-actions">
122131 <button type="submit" disabled={save.pending()}>
123- Save
132+ {t("save")}
124133 </button>
125134 <button type="button" class="ghost" onClick={() => setEditing(false)}>
126- Cancel
135+ {t("cancel")}
127136 </button>
128- <button
129- type="button"
137+ <ConfirmButton
130138 class="ghost danger push"
139+ confirmText={t("reallyDeleteEvent")}
131140 disabled={remove.pending()}
132- onClick={() => void remove.run()}
141+ onConfirm={() => void remove.run()}
133142 >
134- Delete event
135- </button>
143+ {t("deleteEvent")}
144+ </ConfirmButton>
136145 </span>
137146 </form>
138147 </Show>
139148
140149 <article class="stack gap-top">
141- <h2>Attendance</h2>
150+ <h2>{t("attendance")}</h2>
142151 <div class="row-actions">
143152 <For each={ATTENDANCE_STATUSES}>
144153 {(status) => (
@@ -147,7 +156,7 @@ export default function EventDetail() {
147156 disabled={mark.pending()}
148157 onClick={() => void mark.run(status)}
149158 >
150- I'm {status}
159+ {t("iAm")(status)}
151160 </button>
152161 )}
153162 </For>
@@ -155,7 +164,7 @@ export default function EventDetail() {
155164
156165 <Show when={can("teacher")}>
157166 <form
158- class="row"
167+ class="row row-end"
159168 onSubmit={(e) => {
160169 e.preventDefault();
161170 const data = new FormData(e.currentTarget);
@@ -165,27 +174,30 @@ export default function EventDetail() {
165174 );
166175 }}
167176 >
168- <input name="user_id" placeholder="User id" required />
169- <select name="status">
170- <For each={ATTENDANCE_STATUSES}>
171- {(status) => <option value={status}>{status}</option>}
172- </For>
173- </select>
177+ <UserPicker name="user_id" label={t("person")} />
178+ <label>
179+ {t("status")}
180+ <select name="status">
181+ <For each={ATTENDANCE_STATUSES}>
182+ {(status) => <option value={status}>{t("attendanceWord")(status)}</option>}
183+ </For>
184+ </select>
185+ </label>
174186 <button type="submit" disabled={mark.pending()}>
175- Mark user
187+ {t("markUser")}
176188 </button>
177189 </form>
178190 </Show>
179191 <ErrorLine error={mark.error() ?? unmark.error()} />
180192
181193 <Show when={!roster.loading} fallback={<Loading />}>
182- <Show when={roster()?.length} fallback={<Empty>Nobody marked yet.</Empty>}>
194+ <Show when={roster()?.length} fallback={<Empty>{t("nobodyMarkedYet")}</Empty>}>
183195 <div class="table-wrap">
184196 <table>
185197 <thead>
186198 <tr>
187- <th>User</th>
188- <th>Status</th>
199+ <th>{t("userCol")}</th>
200+ <th>{t("status")}</th>
189201 <Show when={can("teacher")}>
190202 <th />
191203 </Show>
@@ -195,21 +207,24 @@ export default function EventDetail() {
195207 <For each={roster()}>
196208 {(entry) => (
197209 <tr>
198- <td class="mono">
199- {entry.user === user()?.id ? "you" : entry.user}
210+ <td>
211+ {personLabel(entry.user)}
212+ <Show when={entry.user.id === user()?.id}>{t("you")}</Show>
200213 </td>
201214 <td>
202- <span class={`badge badge-${entry.status}`}>{entry.status}</span>
215+ <span class={`badge badge-${entry.status}`}>
216+ {t("attendanceWord")(entry.status)}
217+ </span>
203218 </td>
204219 <Show when={can("teacher")}>
205220 <td>
206- <button
207- class="ghost danger"
221+ <ConfirmButton
222+ confirmText={t("reallyRemove")}
208223 disabled={unmark.pending()}
209- onClick={() => void unmark.run(entry.user)}
224+ onConfirm={() => void unmark.run(entry.user.id)}
210225 >
211- Remove
212- </button>
226+ {t("remove")}
227+ </ConfirmButton>
213228 </td>
214229 </Show>
215230 </tr>
@@ -228,9 +243,9 @@ export default function EventDetail() {
228243 }
229244
230245 function NotFoundMessage(props: { error: unknown }) {
231- const message =
246+ const message = () =>
232247 props.error instanceof ApiError && props.error.status === 404
233- ? "This event does not exist."
234- : "Failed to load the event.";
235- return <Empty>{message}</Empty>;
248+ ? t("eventMissing")
249+ : t("eventLoadFailed");
250+ return <Empty>{message()}</Empty>;
236251 }
src/pages/Events.tsxmodified+37 -21
@@ -9,6 +9,7 @@ import { createAction } from "../lib/action";
99 import { events } from "../lib/api";
1010 import { useAuth } from "../lib/auth";
1111 import { formatWindow, fromInputValue } from "../lib/format";
12+import { t } from "../lib/i18n";
1213 import { LIMITS } from "../lib/types";
1314
1415 export default function Events() {
@@ -35,12 +36,12 @@ export default function Events() {
3536 <section class="page">
3637 <header class="page-head">
3738 <div>
38- <h1>Events</h1>
39- <p class="sub">What's happening — open one to see or mark attendance.</p>
39+ <h1>{t("eventsTitle")}</h1>
40+ <p class="sub">{t("eventsSub")}</p>
4041 </div>
4142 <Show when={can("teacher")}>
4243 <button onClick={() => setCreating((open) => !open)}>
43- <IconPlus /> New event
44+ <IconPlus /> {t("newEvent")}
4445 </button>
4546 </Show>
4647 </header>
@@ -53,43 +54,58 @@ export default function Events() {
5354 void create.run(e.currentTarget);
5455 }}
5556 >
56- <input
57- name="title"
58- placeholder="Title"
59- required
60- maxLength={LIMITS.eventTitle}
61- ref={(el) => queueMicrotask(() => el.focus())}
62- />
63- <textarea
64- name="description"
65- placeholder="Description"
66- rows={2}
67- maxLength={LIMITS.eventDescription}
68- />
57+ <label>
58+ {t("title")}
59+ <input
60+ name="title"
61+ required
62+ maxLength={LIMITS.eventTitle}
63+ ref={(el) => queueMicrotask(() => el.focus())}
64+ />
65+ </label>
66+ <label>
67+ {t("description")}
68+ <textarea name="description" rows={2} maxLength={LIMITS.eventDescription} />
69+ </label>
6970 <div class="row">
7071 <label>
71- Starts
72+ {t("starts")}
7273 <input name="starts_at" type="datetime-local" />
7374 </label>
7475 <label>
75- Ends
76+ {t("ends")}
7677 <input name="ends_at" type="datetime-local" />
7778 </label>
7879 </div>
7980 <ErrorLine error={create.error()} />
8081 <span class="row-actions">
8182 <button type="submit" disabled={create.pending()}>
82- Add event
83+ {t("addEvent")}
8384 </button>
8485 <button type="button" class="ghost" onClick={() => setCreating(false)}>
85- Cancel
86+ {t("cancel")}
8687 </button>
8788 </span>
8889 </form>
8990 </Show>
9091
9192 <Show when={!list.loading} fallback={<Loading />}>
92- <Show when={list()?.length} fallback={<Empty>No events yet.</Empty>}>
93+ <Show
94+ when={list()?.length}
95+ fallback={
96+ <Empty
97+ action={
98+ can("teacher") ? (
99+ <button onClick={() => setCreating(true)}>
100+ <IconPlus /> {t("newEvent")}
101+ </button>
102+ ) : undefined
103+ }
104+ >
105+ {t("noEventsYet")}
106+ </Empty>
107+ }
108+ >
93109 <div class="grid">
94110 <For each={list()}>
95111 {(event) => (
src/pages/ExamDetail.tsxmodified+240 -62
@@ -3,13 +3,34 @@
33 // results, statistics.
44
55 import { A, useNavigate, useParams } from "@solidjs/router";
6-import { For, Show, createResource, createSignal } from "solid-js";
6+import {
7+ For,
8+ Match,
9+ Show,
10+ Switch,
11+ createResource,
12+ createSignal,
13+ onCleanup,
14+} from "solid-js";
15+import { ConfirmButton } from "../components/ConfirmButton";
16+import { ExamMonitor } from "../components/ExamMonitor";
17+import { ExamQuestions } from "../components/ExamQuestions";
718 import { Empty, ErrorLine, Loading } from "../components/Feedback";
819 import { IconEdit } from "../components/Icons";
20+import { ScheduleFields, scheduleFromForm } from "../components/ScheduleFields";
21+import { UserPicker } from "../components/UserPicker";
922 import { createAction } from "../lib/action";
1023 import { ApiError, courses, exams } from "../lib/api";
1124 import { useAuth } from "../lib/auth";
12-import { EXAM_KINDS, LIMITS, type ExamResult } from "../lib/types";
25+import { createClock } from "../lib/clock";
26+import { t } from "../lib/i18n";
27+import {
28+ formatCountdown,
29+ formatMillis,
30+ formatWindow,
31+ personLabel,
32+} from "../lib/format";
33+import { EXAM_KINDS, LIMITS, type Exam, type ExamResult } from "../lib/types";
1334
1435 export default function ExamDetail() {
1536 const params = useParams<{ id: string }>();
@@ -33,6 +54,7 @@ export default function ExamDetail() {
3354 description: String(data.get("description")),
3455 kind: String(data.get("kind")),
3556 weight: Number(data.get("weight")),
57+ ...scheduleFromForm(data),
3658 }),
3759 );
3860 setEditing(false);
@@ -54,13 +76,13 @@ export default function ExamDetail() {
5476 <div>
5577 <div class="row">
5678 <h1>{current().title}</h1>
57- <span class="badge">{current().kind}</span>
58- <span class="badge" title="weight in the course average">
59- ×{current().weight}
79+ <span class="badge">{t("kindWord")(current().kind)}</span>
80+ <span class="badge" title={t("weightTitle")}>
81+ {t("weightBadge")(current().weight)}
6082 </span>
6183 </div>
6284 <p class="sub">
63- Course:{" "}
85+ {t("coursePrefix")}{" "}
6486 <A href={`/courses/${current().course}`}>
6587 {course()?.title ?? current().course}
6688 </A>
@@ -68,7 +90,7 @@ export default function ExamDetail() {
6890 </div>
6991 <Show when={canManage()}>
7092 <button class="ghost" onClick={() => setEditing((open) => !open)}>
71- <IconEdit /> {editing() ? "Close" : "Edit"}
93+ <IconEdit /> {editing() ? t("close") : t("edit")}
7294 </button>
7395 </Show>
7496 </header>
@@ -85,30 +107,36 @@ export default function ExamDetail() {
85107 void save.run(e.currentTarget);
86108 }}
87109 >
88- <input
89- name="title"
90- value={current().title}
91- required
92- maxLength={LIMITS.examTitle}
93- />
94- <textarea name="description" rows={3} maxLength={LIMITS.examDescription}>
95- {current().description}
96- </textarea>
110+ <label>
111+ {t("title")}
112+ <input
113+ name="title"
114+ value={current().title}
115+ required
116+ maxLength={LIMITS.examTitle}
117+ />
118+ </label>
119+ <label>
120+ {t("description")}
121+ <textarea name="description" rows={3} maxLength={LIMITS.examDescription}>
122+ {current().description}
123+ </textarea>
124+ </label>
97125 <div class="row">
98126 <label>
99- Kind
127+ {t("kind")}
100128 <select name="kind" value={current().kind}>
101129 <For each={EXAM_KINDS}>
102130 {(kind) => (
103131 <option value={kind} selected={kind === current().kind}>
104- {kind}
132+ {t("kindWord")(kind)}
105133 </option>
106134 )}
107135 </For>
108136 </select>
109137 </label>
110138 <label>
111- Weight
139+ {t("weight")}
112140 <input
113141 name="weight"
114142 type="number"
@@ -119,28 +147,38 @@ export default function ExamDetail() {
119147 />
120148 </label>
121149 </div>
150+ <ScheduleFields exam={current()} />
122151 <ErrorLine error={save.error() ?? remove.error()} />
123152 <span class="row-actions">
124153 <button type="submit" disabled={save.pending()}>
125- Save
154+ {t("save")}
126155 </button>
127156 <button type="button" class="ghost" onClick={() => setEditing(false)}>
128- Cancel
157+ {t("cancel")}
129158 </button>
130- <button
131- type="button"
159+ <ConfirmButton
132160 class="ghost danger push"
161+ confirmText={t("reallyDeleteExam")}
133162 disabled={remove.pending()}
134- onClick={() => void remove.run()}
163+ onConfirm={() => void remove.run()}
135164 >
136- Delete exam
137- </button>
165+ {t("deleteExam")}
166+ </ConfirmButton>
138167 </span>
139168 </form>
140169 </Show>
141170
171+ <Show when={current().mode}>
172+ <Sitting exam={current()} />
173+ </Show>
142174 <MyResult examId={params.id} />
175+ <Show when={canManage()}>
176+ <ExamQuestions examId={params.id} />
177+ </Show>
143178 <Show when={can("teacher")}>
179+ <Show when={current().mode}>
180+ <ExamMonitor exam={current()} />
181+ </Show>
144182 <Statistics examId={params.id} />
145183 <Results examId={params.id} />
146184 </Show>
@@ -150,6 +188,141 @@ export default function ExamDetail() {
150188 );
151189 }
152190
191+/**
192+ * The student-facing "exam time" card of a scheduled exam: the window, whether
193+ * it is open right now (by the server clock), and the one action that makes
194+ * sense — enter, continue, or review what was written.
195+ */
196+function Sitting(props: { exam: Exam }) {
197+ const navigate = useNavigate();
198+ const clock = createClock();
199+ onCleanup(clock.stop);
200+
201+ const [attempt] = createResource(
202+ () => props.exam.id,
203+ async (id) => {
204+ try {
205+ return await exams.myAttempt(id);
206+ } catch (err) {
207+ if (err instanceof ApiError && err.status === 404) return null;
208+ throw err;
209+ }
210+ },
211+ );
212+
213+ const phase = () => {
214+ if (clock.now() < (props.exam.starts_at ?? 0)) return "upcoming" as const;
215+ if (clock.now() >= (props.exam.ends_at ?? 0)) return "closed" as const;
216+ return "open" as const;
217+ };
218+
219+ // The live view of a running attempt: the server said in_progress, but the
220+ // deadline may have passed since — judge it against the ticking clock.
221+ const running = () => {
222+ const current = attempt();
223+ return current?.status === "in_progress" &&
224+ (current.deadline === null || clock.now() < current.deadline)
225+ ? current
226+ : undefined;
227+ };
228+ const ranOut = () => {
229+ const current = attempt();
230+ return (
231+ current?.status === "expired" ||
232+ (current?.status === "in_progress" && !running())
233+ );
234+ };
235+
236+ const enter = createAction(async () => {
237+ // Idempotent on the backend: re-entering never resets the clock.
238+ await exams.startAttempt(props.exam.id);
239+ navigate(`/exams/${props.exam.id}/room`);
240+ });
241+
242+ const minutes = () => Math.round((props.exam.duration_ms ?? 0) / 60_000);
243+
244+ return (
245+ <article class="card stack sitting">
246+ <header class="row">
247+ <h2>{t("examTime")}</h2>
248+ <span class={`badge phase-${phase()}`}>{t("phaseWord")(phase())}</span>
249+ </header>
250+ <p class="meta">
251+ {formatWindow(props.exam.starts_at, props.exam.ends_at)}
252+ <Show when={props.exam.mode === "async"}> · {t("minutesEach")(minutes())}</Show>
253+ </p>
254+
255+ <Show when={!attempt.loading}>
256+ <Switch>
257+ <Match when={attempt()?.status === "submitted"}>
258+ <p>{t("turnedInAt")(formatMillis(attempt()!.finished_at))}</p>
259+ <span class="row-actions">
260+ <button class="ghost" onClick={() => navigate(`/exams/${props.exam.id}/room`)}>
261+ {t("seeMyAnswers")}
262+ </button>
263+ </span>
264+ </Match>
265+ <Match when={ranOut()}>
266+ <p>{t("timeRanOut")}</p>
267+ <span class="row-actions">
268+ <button class="ghost" onClick={() => navigate(`/exams/${props.exam.id}/room`)}>
269+ {t("seeMyAnswers")}
270+ </button>
271+ </span>
272+ </Match>
273+ <Match when={running()}>
274+ {(current) => (
275+ <span class="row-actions">
276+ <button
277+ class="cta"
278+ onClick={() => navigate(`/exams/${props.exam.id}/room`)}
279+ >
280+ {t("continueExam")}
281+ </button>
282+ <span class="meta">
283+ {t("answeredOf")(current().answered, current().question_count)}
284+ <Show when={current().deadline !== null}>
285+ {" · "}
286+ {t("timeLeftShort")(formatCountdown(current().deadline! - clock.now()))}
287+ </Show>
288+ </span>
289+ </span>
290+ )}
291+ </Match>
292+ <Match when={attempt() === null && phase() === "open"}>
293+ <span class="row-actions">
294+ <Show
295+ when={props.exam.mode === "async"}
296+ fallback={
297+ <button class="cta" disabled={enter.pending()} onClick={() => void enter.run()}>
298+ {t("enterExam")}
299+ </button>
300+ }
301+ >
302+ <ConfirmButton
303+ class="cta"
304+ confirmText={t("startTimerConfirm")(minutes())}
305+ disabled={enter.pending()}
306+ onConfirm={() => void enter.run()}
307+ >
308+ {t("enterExam")}
309+ </ConfirmButton>
310+ </Show>
311+ </span>
312+ </Match>
313+ <Match when={attempt() === null && phase() === "upcoming"}>
314+ <p class="muted">{t("opensAt")(formatMillis(props.exam.starts_at))}</p>
315+ </Match>
316+ <Match when={attempt() === null && phase() === "closed"}>
317+ <p class="muted">{t("examOver")}</p>
318+ </Match>
319+ </Switch>
320+ </Show>
321+ <ErrorLine error={enter.error()} />
322+ </article>
323+ );
324+}
325+
153326 /** The caller's own mark; the backend answers 404 while ungraded. */
154327 function MyResult(props: { examId: string }) {
155328 const [result] = createResource(
@@ -166,9 +339,9 @@ function MyResult(props: { examId: string }) {
166339
167340 return (
168341 <article class="stack gap-top">
169- <h2>My result</h2>
342+ <h2>{t("myResult")}</h2>
170343 <Show when={!result.loading} fallback={<Loading />}>
171- <Show when={result()} fallback={<Empty>Not graded yet.</Empty>}>
344+ <Show when={result()} fallback={<Empty>{t("notGradedYet")}</Empty>}>
172345 {(mine) => (
173346 <p class="mark">
174347 {mine().mark}
@@ -188,26 +361,26 @@ function Statistics(props: { examId: string }) {
188361
189362 return (
190363 <article class="stack gap-top">
191- <h2>Statistics</h2>
364+ <h2>{t("statistics")}</h2>
192365 <Show when={!stats.loading} fallback={<Loading />}>
193366 <Show when={stats()}>
194367 {(current) => (
195- <Show when={current().graded > 0} fallback={<Empty>Nothing graded yet.</Empty>}>
368+ <Show when={current().graded > 0} fallback={<Empty>{t("nothingGradedYet")}</Empty>}>
196369 <div class="stats">
197370 <div class="card stat">
198- <span class="stat-label">Graded</span>
371+ <span class="stat-label">{t("gradedStat")}</span>
199372 <span class="stat-value">{current().graded}</span>
200373 </div>
201374 <div class="card stat">
202- <span class="stat-label">Average</span>
375+ <span class="stat-label">{t("averageStat")}</span>
203376 <span class="stat-value">{round(current().average ?? 0)}</span>
204377 </div>
205378 <div class="card stat">
206- <span class="stat-label">Min</span>
379+ <span class="stat-label">{t("minStat")}</span>
207380 <span class="stat-value">{current().min}</span>
208381 </div>
209382 <div class="card stat">
210- <span class="stat-label">Max</span>
383+ <span class="stat-label">{t("maxStat")}</span>
211384 <span class="stat-value">{current().max}</span>
212385 </div>
213386 </div>
@@ -234,50 +407,52 @@ function Results(props: { examId: string }) {
234407 );
235408 // One result per (exam, user); grading again overwrites.
236409 mutate((current) => [
237- ...(current ?? []).filter((r) => r.user !== graded.user),
410+ ...(current ?? []).filter((r) => r.user.id !== graded.user.id),
238411 graded,
239412 ]);
240413 form.reset();
241414 });
242415
243416 const removeResult = createAction(async (result: ExamResult) => {
244- await exams.removeResult(props.examId, result.user);
245- mutate((current) => current?.filter((r) => r.user !== result.user));
417+ await exams.removeResult(props.examId, result.user.id);
418+ mutate((current) => current?.filter((r) => r.user.id !== result.user.id));
246419 });
247420
248421 return (
249422 <article class="stack gap-top">
250- <h2>Results</h2>
423+ <h2>{t("results")}</h2>
251424 <form
252- class="row"
425+ class="row row-end"
253426 onSubmit={(e) => {
254427 e.preventDefault();
255428 void grade.run(e.currentTarget);
256429 }}
257430 >
258- <input name="user_id" placeholder="Student id" required />
259- <input
260- name="mark"
261- type="number"
262- placeholder="Mark"
263- required
264- min={LIMITS.mark.min}
265- max={LIMITS.mark.max}
266- />
431+ <UserPicker name="user_id" label={t("student")} />
432+ <label>
433+ {t("mark0100")}
434+ <input
435+ name="mark"
436+ type="number"
437+ required
438+ min={LIMITS.mark.min}
439+ max={LIMITS.mark.max}
440+ />
441+ </label>
267442 <button type="submit" disabled={grade.pending()}>
268- Grade
443+ {t("gradeAction")}
269444 </button>
270445 </form>
271446 <ErrorLine error={grade.error() ?? removeResult.error()} />
272447
273448 <Show when={!results.loading} fallback={<Loading />}>
274- <Show when={results()?.length} fallback={<Empty>No results yet.</Empty>}>
449+ <Show when={results()?.length} fallback={<Empty>{t("noResultsYet")}</Empty>}>
275450 <div class="table-wrap">
276451 <table>
277452 <thead>
278453 <tr>
279- <th>Student</th>
280- <th>Mark</th>
454+ <th>{t("student")}</th>
455+ <th>{t("markCol")}</th>
281456 <th />
282457 </tr>
283458 </thead>
@@ -285,16 +460,19 @@ function Results(props: { examId: string }) {
285460 <For each={results()}>
286461 {(result) => (
287462 <tr>
288- <td class="mono">{result.user === user()?.id ? "you" : result.user}</td>
463+ <td>
464+ {personLabel(result.user)}
465+ <Show when={result.user.id === user()?.id}>{t("you")}</Show>
466+ </td>
289467 <td>{result.mark}</td>
290468 <td>
291- <button
292- class="ghost danger"
469+ <ConfirmButton
470+ confirmText={t("reallyRemove")}
293471 disabled={removeResult.pending()}
294- onClick={() => void removeResult.run(result)}
472+ onConfirm={() => void removeResult.run(result)}
295473 >
296- Remove
297- </button>
474+ {t("remove")}
475+ </ConfirmButton>
298476 </td>
299477 </tr>
300478 )}
@@ -309,9 +487,9 @@ function Results(props: { examId: string }) {
309487 }
310488
311489 function NotFoundMessage(props: { error: unknown }) {
312- const message =
490+ const message = () =>
313491 props.error instanceof ApiError && props.error.status === 404
314- ? "This exam does not exist."
315- : "Failed to load the exam.";
316- return <Empty>{message}</Empty>;
492+ ? t("examMissing")
493+ : t("examLoadFailed");
494+ return <Empty>{message()}</Empty>;
317495 }
src/pages/ExamRoom.tsxadded+370 -0
@@ -0,0 +1,370 @@
1+// The room a student sits a scheduled exam in: a server-judged countdown,
2+// one card per question, and autosave on every change — over the exam
3+// WebSocket when it's up, plain REST when it isn't. The page never *starts*
4+// an attempt (entering is an explicit choice on the exam page, because an
5+// async timer starts ticking); it resumes, reviews, or bounces back.
6+
7+import { A, useParams } from "@solidjs/router";
8+import {
9+ For,
10+ Match,
11+ Show,
12+ Switch,
13+ createEffect,
14+ createResource,
15+ createSignal,
16+ onCleanup,
17+} from "solid-js";
18+import { ConfirmButton } from "../components/ConfirmButton";
19+import { Empty, ErrorLine, Loading } from "../components/Feedback";
20+import { createAction } from "../lib/action";
21+import { ApiError, exams } from "../lib/api";
22+import { createClock } from "../lib/clock";
23+import { formatCountdown, formatMillis } from "../lib/format";
24+import { t } from "../lib/i18n";
25+import type { AttemptQuestion, AttemptStatus } from "../lib/types";
26+import { LIMITS } from "../lib/types";
27+
28+type SaveState = "saving" | "saved" | "error";
29+
30+export default function ExamRoom() {
31+ const params = useParams<{ id: string }>();
32+ const clock = createClock();
33+ onCleanup(clock.stop);
34+
35+ const [exam] = createResource(() => params.id, exams.get);
36+ const [attempt, { mutate: setAttempt }] = createResource(
37+ () => params.id,
38+ async (id) => {
39+ try {
40+ return await exams.myAttempt(id);
41+ } catch (err) {
42+ if (err instanceof ApiError && err.status === 404) return null;
43+ throw err;
44+ }
45+ },
46+ );
47+ const [questions, { mutate: setQuestions }] = createResource(
48+ // Questions 404 until an attempt exists — gate on it.
49+ () => (attempt() ? params.id : undefined),
50+ exams.attemptQuestions,
51+ );
52+
53+ // Live attempt state: seeded by the REST fetch, then driven by WS frames.
54+ const [status, setStatus] = createSignal<AttemptStatus | null>(null);
55+ const [deadline, setDeadline] = createSignal<number | null>(null);
56+ const [saveStates, setSaveStates] = createSignal<Record<string, SaveState>>({});
57+ const [roomError, setRoomError] = createSignal<string | null>(null);
58+ createEffect(() => {
59+ const current = attempt();
60+ if (current) {
61+ setStatus(current.status);
62+ setDeadline(current.deadline);
63+ }
64+ });
65+
66+ /** `in_progress` by the server, but also judged against the ticking clock. */
67+ const effectiveStatus = () => {
68+ const current = status();
69+ const until = deadline();
70+ return current === "in_progress" && until !== null && clock.now() >= until
71+ ? "expired"
72+ : current;
73+ };
74+ const running = () => effectiveStatus() === "in_progress";
75+ const remaining = () => (deadline() === null ? null : deadline()! - clock.now());
76+
77+ const answered = () =>
78+ (questions() ?? []).filter(
79+ (q) => q.answer !== null && (q.answer.selected !== null || (q.answer.text ?? "") !== ""),
80+ ).length;
81+ const total = () => questions()?.length ?? 0;
82+
83+ // ---- autosave plumbing ----------------------------------------------------
84+ let socket: WebSocket | undefined;
85+ let reconnect: ReturnType<typeof setTimeout> | undefined;
86+ let disposed = false;
87+ const textTimers = new Map<string, ReturnType<typeof setTimeout>>();
88+ onCleanup(() => {
89+ disposed = true;
90+ clearTimeout(reconnect);
91+ for (const timer of textTimers.values()) clearTimeout(timer);
92+ socket?.close();
93+ });
94+
95+ const markSave = (id: string, state: SaveState) =>
96+ setSaveStates((current) => ({ ...current, [id]: state }));
97+
98+ const connect = () => {
99+ if (disposed || socket !== undefined) return;
100+ const ws = new WebSocket(exams.attemptSocketUrl(params.id));
101+ socket = ws;
102+ ws.onmessage = (event) => {
103+ const frame = JSON.parse(String(event.data)) as Record<string, unknown>;
104+ switch (frame.type) {
105+ case "state":
106+ setStatus(frame.status as AttemptStatus);
107+ setDeadline((frame.deadline as number | null) ?? null);
108+ break;
109+ case "saved":
110+ markSave(String(frame.question_id), "saved");
111+ setRoomError(null);
112+ break;
113+ case "finished":
114+ setStatus("submitted");
115+ break;
116+ case "expired":
117+ setStatus("expired");
118+ break;
119+ case "error":
120+ setRoomError(String(frame.message));
121+ break;
122+ }
123+ };
124+ ws.onclose = () => {
125+ if (socket === ws) socket = undefined;
126+ // While the exam still runs, quietly retry; REST keeps saves flowing.
127+ if (!disposed && running()) reconnect = setTimeout(connect, 3000);
128+ };
129+ };
130+ createEffect(() => {
131+ if (running()) connect();
132+ });
133+
134+ /** Save one answer: WS when open (acked by a `saved` frame), REST otherwise. */
135+ const push = (questionId: string, payload: { selected?: number; text?: string }) => {
136+ markSave(questionId, "saving");
137+ if (socket?.readyState === WebSocket.OPEN) {
138+ socket.send(JSON.stringify({ type: "answer", question_id: questionId, ...payload }));
139+ return;
140+ }
141+ exams
142+ .saveAnswer(params.id, { question_id: questionId, ...payload })
143+ .then(() => {
144+ markSave(questionId, "saved");
145+ setRoomError(null);
146+ })
147+ .catch((err: unknown) => {
148+ markSave(questionId, "error");
149+ setRoomError(err instanceof Error ? err.message : t("savingFailed"));
150+ });
151+ };
152+
153+ const patchAnswer = (questionId: string, patch: { selected?: number; text?: string }) =>
154+ setQuestions((current) =>
155+ current?.map((q) =>
156+ q.id === questionId
157+ ? {
158+ ...q,
159+ answer: {
160+ selected: patch.selected ?? null,
161+ text: patch.text ?? null,
162+ updated_at: clock.now(),
163+ },
164+ }
165+ : q,
166+ ),
167+ );
168+
169+ const pickChoice = (questionId: string, index: number) => {
170+ patchAnswer(questionId, { selected: index });
171+ push(questionId, { selected: index });
172+ };
173+
174+ const typeText = (questionId: string, value: string) => {
175+ patchAnswer(questionId, { text: value });
176+ markSave(questionId, "saving");
177+ clearTimeout(textTimers.get(questionId));
178+ textTimers.set(
179+ questionId,
180+ setTimeout(() => push(questionId, { text: value }), 800),
181+ );
182+ };
183+
184+ const finish = createAction(async () => {
185+ const finished = await exams.finishAttempt(params.id);
186+ setAttempt(finished);
187+ });
188+
189+ return (
190+ <section class="page room">
191+ <Show when={!attempt.loading && exam()} fallback={<Loading />}>
192+ <Switch>
193+ <Match when={attempt() === null}>
194+ <Empty
195+ action={
196+ <A class="button-link" href={`/exams/${params.id}`}>
197+ {t("backToExam")}
198+ </A>
199+ }
200+ >
201+ {t("notEnteredYet")}
202+ </Empty>
203+ </Match>
204+ <Match when={attempt()}>
205+ <>
206+ <header class="room-head card">
207+ <div class="room-title">
208+ <h1>{exam()?.title}</h1>
209+ <span class="meta">{t("answeredOf")(answered(), total())}</span>
210+ </div>
211+ <Show when={running()} fallback={<StatusChip status={effectiveStatus()} />}>
212+ <div class="room-side">
213+ <Show when={remaining() !== null}>
214+ <span
215+ class="countdown"
216+ classList={{
217+ warn: remaining()! < 5 * 60_000,
218+ danger: remaining()! < 60_000,
219+ }}
220+ >
221+ {formatCountdown(remaining()!)}
222+ </span>
223+ </Show>
224+ <ConfirmButton
225+ class="cta"
226+ confirmText={
227+ answered() < total()
228+ ? t("turnInUnanswered")(total() - answered())
229+ : t("turnInNow")
230+ }
231+ disabled={finish.pending()}
232+ onConfirm={() => void finish.run()}
233+ >
234+ {t("turnIn")}
235+ </ConfirmButton>
236+ </div>
237+ </Show>
238+ </header>
239+
240+ <Show when={effectiveStatus() === "submitted"}>
241+ <div class="card notice-ok">
242+ {t("turnedInBanner")(formatMillis(attempt()!.finished_at))}
243+ </div>
244+ </Show>
245+ <Show when={effectiveStatus() === "expired"}>
246+ <div class="card notice-warn">{t("timeUpBanner")}</div>
247+ </Show>
248+ <ErrorLine error={roomError() ?? finish.error()} />
249+
250+ <Show when={!questions.loading} fallback={<Loading />}>
251+ <Show
252+ when={total()}
253+ fallback={<Empty>{t("noQuestionsRoom")}</Empty>}
254+ >
255+ <div class="stack">
256+ <For each={questions()}>
257+ {(question, index) => (
258+ <QuestionCard
259+ question={question}
260+ number={index() + 1}
261+ disabled={!running()}
262+ saveState={saveStates()[question.id]}
263+ onPick={(choice) => pickChoice(question.id, choice)}
264+ onType={(value) => typeText(question.id, value)}
265+ />
266+ )}
267+ </For>
268+ </div>
269+ <Show when={running()}>
270+ <span class="row-actions room-foot">
271+ <ConfirmButton
272+ class="cta"
273+ confirmText={
274+ answered() < total()
275+ ? t("turnInUnanswered")(total() - answered())
276+ : t("turnInNow")
277+ }
278+ disabled={finish.pending()}
279+ onConfirm={() => void finish.run()}
280+ >
281+ {t("turnIn")}
282+ </ConfirmButton>
283+ </span>
284+ </Show>
285+ </Show>
286+ </Show>
287+
288+ <p class="meta">
289+ <A href={`/exams/${params.id}`}>← {t("backToExam")}</A>
290+ </p>
291+ </>
292+ </Match>
293+ </Switch>
294+ </Show>
295+ </section>
296+ );
297+}
298+
299+function StatusChip(props: { status: AttemptStatus | null }) {
300+ return (
301+ <Switch>
302+ <Match when={props.status === "submitted"}>
303+ <span class="badge phase-closed">{t("turnedInChip")}</span>
304+ </Match>
305+ <Match when={props.status === "expired"}>
306+ <span class="badge phase-closed">{t("timeUpChip")}</span>
307+ </Match>
308+ </Switch>
309+ );
310+}
311+
312+function QuestionCard(props: {
313+ question: AttemptQuestion;
314+ number: number;
315+ disabled: boolean;
316+ saveState: SaveState | undefined;
317+ onPick: (choice: number) => void;
318+ onType: (value: string) => void;
319+}) {
320+ return (
321+ <div class="card stack question">
322+ <header class="row">
323+ <strong>Q{props.number}</strong>
324+ <span class="badge">{t("pts")(props.question.points)}</span>
325+ <span class="push save-state" classList={{ error: props.saveState === "error" }}>
326+ <Switch>
327+ <Match when={props.saveState === "saving"}>{t("savingState")}</Match>
328+ <Match when={props.saveState === "saved"}>{t("savedState")}</Match>
329+ <Match when={props.saveState === "error"}>{t("notSavedState")}</Match>
330+ </Switch>
331+ </span>
332+ </header>
333+ <p class="prewrap qtext">{props.question.text}</p>
334+ <Show
335+ when={props.question.kind === "choice"}
336+ fallback={
337+ <textarea
338+ rows={4}
339+ maxLength={LIMITS.answerText}
340+ placeholder={t("writeAnswerHere")}
341+ disabled={props.disabled}
342+ onInput={(e) => props.onType(e.currentTarget.value)}
343+ >
344+ {props.question.answer?.text ?? ""}
345+ </textarea>
346+ }
347+ >
348+ <div class="stack choice-pick">
349+ <For each={props.question.choices}>
350+ {(choice, index) => (
351+ <label
352+ class="choice-row"
353+ classList={{ picked: props.question.answer?.selected === index() }}
354+ >
355+ <input
356+ type="radio"
357+ name={`q-${props.question.id}`}
358+ checked={props.question.answer?.selected === index()}
359+ disabled={props.disabled}
360+ onChange={() => props.onPick(index())}
361+ />
362+ <span>{choice}</span>
363+ </label>
364+ )}
365+ </For>
366+ </div>
367+ </Show>
368+ </div>
369+ );
370+}
src/pages/Exams.tsxmodified+8 -7
@@ -6,6 +6,7 @@ import { For, Show, createResource } from "solid-js";
66 import { Empty, Loading } from "../components/Feedback";
77 import { exams } from "../lib/api";
88 import { useAuth } from "../lib/auth";
9+import { t } from "../lib/i18n";
910
1011 export default function Exams() {
1112 const { can } = useAuth();
@@ -15,28 +16,28 @@ export default function Exams() {
1516 <section class="page">
1617 <header class="page-head">
1718 <div>
18- <h1>Exams</h1>
19+ <h1>{t("examsTitle")}</h1>
1920 <p class="sub">
20- All exams across courses.
21+ {t("examsSubAll")}
2122 <Show when={can("teacher")}>
2223 {" "}
23- New ones are created inside a <A href="/courses">course</A>.
24+ <A href="/courses">{t("examsSubCreate")}</A>
2425 </Show>
2526 </p>
2627 </div>
2728 </header>
2829
2930 <Show when={!list.loading} fallback={<Loading />}>
30- <Show when={list()?.length} fallback={<Empty>No exams yet.</Empty>}>
31+ <Show when={list()?.length} fallback={<Empty>{t("noExamsYet")}</Empty>}>
3132 <div class="grid">
3233 <For each={list()}>
3334 {(exam) => (
3435 <A href={`/exams/${exam.id}`} class="card link-card stack">
3536 <header class="row">
3637 <h3>{exam.title}</h3>
37- <span class="badge">{exam.kind}</span>
38- <span class="badge" title="weight in the course average">
39- ×{exam.weight}
38+ <span class="badge">{t("kindWord")(exam.kind)}</span>
39+ <span class="badge" title={t("weightTitle")}>
40+ {t("weightBadge")(exam.weight)}
4041 </span>
4142 </header>
4243 <Show when={exam.description}>
src/pages/Home.tsxmodified+16 -19
@@ -8,6 +8,7 @@ import { IconBook, IconCalendar, IconChart, IconNote } from "../components/Icons
88 import { courses, events, marks, notes } from "../lib/api";
99 import { useAuth } from "../lib/auth";
1010 import { formatWindow } from "../lib/format";
11+import { locale, t } from "../lib/i18n";
1112
1213 export default function Home() {
1314 const { user } = useAuth();
@@ -24,14 +25,10 @@ export default function Home() {
2425 .sort((a, b) => (a.starts_at ?? Infinity) - (b.starts_at ?? Infinity));
2526 };
2627
27- const greeting = () => {
28- const hour = new Date().getHours();
29- const part = hour < 12 ? "morning" : hour < 18 ? "afternoon" : "evening";
30- return `Good ${part}, ${user()?.name ?? user()?.username}`;
31- };
32- const today = new Intl.DateTimeFormat(undefined, { dateStyle: "full" }).format(
33- new Date(),
34- );
28+ const greeting = () =>
29+ t("greeting")(user()?.name ?? user()?.username ?? "", new Date().getHours());
30+ const today = () =>
31+ new Intl.DateTimeFormat(locale(), { dateStyle: "full" }).format(new Date());
3532
3633 const average = () => {
3734 const value = report()?.overall_average;
@@ -43,32 +40,32 @@ export default function Home() {
4340 <header class="page-head">
4441 <div>
4542 <h1>{greeting()}</h1>
46- <p class="sub">{today}</p>
43+ <p class="sub">{today()}</p>
4744 </div>
4845 </header>
4946
5047 <div class="stats">
5148 <A href="/notes" class="card link-card stat">
5249 <span class="stat-label">
53- <IconNote /> Notes
50+ <IconNote /> {t("statNotes")}
5451 </span>
5552 <span class="stat-value">{noteList()?.length ?? "—"}</span>
5653 </A>
5754 <A href="/events" class="card link-card stat">
5855 <span class="stat-label">
59- <IconCalendar /> Upcoming events
56+ <IconCalendar /> {t("statUpcoming")}
6057 </span>
6158 <span class="stat-value">{eventList() ? upcoming().length : "—"}</span>
6259 </A>
6360 <A href="/courses" class="card link-card stat">
6461 <span class="stat-label">
65- <IconBook /> My courses
62+ <IconBook /> {t("statMyCourses")}
6663 </span>
6764 <span class="stat-value">{myCourses()?.length ?? "—"}</span>
6865 </A>
6966 <A href="/marks" class="card link-card stat">
7067 <span class="stat-label">
71- <IconChart /> Average
68+ <IconChart /> {t("statAverage")}
7269 </span>
7370 <span class="stat-value">
7471 {average() ?? "—"}
@@ -82,11 +79,11 @@ export default function Home() {
8279 <div class="cols">
8380 <section class="stack">
8481 <div class="section-head">
85- <h2>Upcoming events</h2>
86- <A href="/events">View all</A>
82+ <h2>{t("upcomingEvents")}</h2>
83+ <A href="/events">{t("viewAll")}</A>
8784 </div>
8885 <Show when={!eventList.loading} fallback={<Loading />}>
89- <Show when={upcoming().length} fallback={<Empty>Nothing scheduled.</Empty>}>
86+ <Show when={upcoming().length} fallback={<Empty>{t("nothingScheduled")}</Empty>}>
9087 <For each={upcoming().slice(0, 4)}>
9188 {(event) => (
9289 <A href={`/events/${event.id}`} class="card link-card stack">
@@ -101,13 +98,13 @@ export default function Home() {
10198
10299 <section class="stack">
103100 <div class="section-head">
104- <h2>My courses</h2>
105- <A href="/courses">View all</A>
101+ <h2>{t("myCourses")}</h2>
102+ <A href="/courses">{t("viewAll")}</A>
106103 </div>
107104 <Show when={!myCourses.loading} fallback={<Loading />}>
108105 <Show
109106 when={myCourses()?.length}
110- fallback={<Empty>Not enrolled in any course yet.</Empty>}
107+ fallback={<Empty>{t("notEnrolledYet")}</Empty>}
111108 >
112109 <For each={myCourses()?.slice(0, 4)}>
113110 {(course) => (
src/pages/Login.tsxmodified+36 -18
@@ -4,15 +4,17 @@
44 import { Navigate, useNavigate } from "@solidjs/router";
55 import { Show, createSignal } from "solid-js";
66 import { ErrorLine } from "../components/Feedback";
7-import { IconPlane } from "../components/Icons";
7+import { IconEye, IconEyeOff, IconPlane } from "../components/Icons";
88 import { createAction } from "../lib/action";
99 import { useAuth } from "../lib/auth";
10+import { lang, setLang, t } from "../lib/i18n";
1011 import { LIMITS } from "../lib/types";
1112
1213 export default function Login() {
1314 const { user, login, register } = useAuth();
1415 const navigate = useNavigate();
1516 const [mode, setMode] = createSignal<"login" | "register">("login");
17+ const [showPassword, setShowPassword] = createSignal(false);
1618
1719 const submit = createAction(async (form: HTMLFormElement) => {
1820 const data = new FormData(form);
@@ -44,14 +46,10 @@ export default function Login() {
4446 <IconPlane />
4547 </span>
4648 <h1>Hezarfen</h1>
47- <p>
48- {mode() === "login"
49- ? "Welcome back — log in to continue."
50- : "Create an account to get started."}
51- </p>
49+ <p>{mode() === "login" ? t("loginWelcome") : t("registerWelcome")}</p>
5250 </header>
5351 <label>
54- Username
52+ {t("username")}
5553 <input
5654 name="username"
5755 required
@@ -62,22 +60,42 @@ export default function Login() {
6260 />
6361 </label>
6462 <label>
65- Password
66- <input
67- name="password"
68- type="password"
69- required
70- minLength={LIMITS.password.min}
71- maxLength={LIMITS.password.max}
72- autocomplete={mode() === "login" ? "current-password" : "new-password"}
73- />
63+ {t("password")}
64+ <span class="input-group">
65+ <input
66+ name="password"
67+ type={showPassword() ? "text" : "password"}
68+ required
69+ minLength={LIMITS.password.min}
70+ maxLength={LIMITS.password.max}
71+ autocomplete={mode() === "login" ? "current-password" : "new-password"}
72+ />
73+ <button
74+ type="button"
75+ class="ghost icon-btn"
76+ aria-label={showPassword() ? t("hidePassword") : t("showPassword")}
77+ onClick={() => setShowPassword((shown) => !shown)}
78+ >
79+ {showPassword() ? <IconEyeOff /> : <IconEye />}
80+ </button>
81+ </span>
82+ <Show when={mode() === "register"}>
83+ <span class="hint">{t("atLeastChars")(LIMITS.password.min)}</span>
84+ </Show>
7485 </label>
7586 <ErrorLine error={submit.error()} />
7687 <button type="submit" disabled={submit.pending()}>
77- {mode() === "login" ? "Log in" : "Create account"}
88+ {mode() === "login" ? t("logIn") : t("createAccount")}
7889 </button>
7990 <button type="button" class="ghost" onClick={switchMode}>
80- {mode() === "login" ? "New here? Register" : "Have an account? Log in"}
91+ {mode() === "login" ? t("switchToRegister") : t("switchToLogin")}
92+ </button>
93+ <button
94+ type="button"
95+ class="ghost lang-switch"
96+ onClick={() => setLang(lang() === "tr" ? "en" : "tr")}
97+ >
98+ {t("otherLanguage")}
8199 </button>
82100 </form>
83101 </main>
src/pages/Marks.tsxmodified+27 -23
@@ -4,10 +4,13 @@
44 import { A } from "@solidjs/router";
55 import { For, Show, createResource, createSignal } from "solid-js";
66 import { Empty, ErrorLine, Loading } from "../components/Feedback";
7+import { UserPicker } from "../components/UserPicker";
78 import { createAction } from "../lib/action";
89 import { marks } from "../lib/api";
910 import { useAuth } from "../lib/auth";
10-import type { MarksReport } from "../lib/types";
11+import { personLabel } from "../lib/format";
12+import { t } from "../lib/i18n";
13+import type { MarksReport, PersonRef } from "../lib/types";
1114
1215 const round = (value: number) => (Math.round(value * 100) / 100).toString();
1316
@@ -19,13 +22,13 @@ export default function Marks() {
1922 <section class="page">
2023 <header class="page-head">
2124 <div>
22- <h1>My marks</h1>
23- <p class="sub">Graded exams per course, weighted averages included.</p>
25+ <h1>{t("marksTitle")}</h1>
26+ <p class="sub">{t("marksSub")}</p>
2427 </div>
2528 </header>
2629
2730 <Show when={!mine.loading} fallback={<Loading />}>
28- <Show when={mine()} fallback={<Empty>Failed to load your marks.</Empty>}>
31+ <Show when={mine()} fallback={<Empty>{t("marksLoadFailed")}</Empty>}>
2932 {(report) => <Report report={report()} />}
3033 </Show>
3134 </Show>
@@ -37,9 +40,10 @@ export default function Marks() {
3740 );
3841 }
3942
40-/** Teacher+ tool: fetch any student's report by id. */
43+/** Teacher+ tool: look up any student's report. */
4144 function Lookup() {
4245 const [report, setReport] = createSignal<MarksReport | null>(null);
46+ const [who, setWho] = createSignal<PersonRef | null>(null);
4347
4448 const fetch = createAction(async (form: HTMLFormElement) => {
4549 const data = new FormData(form);
@@ -48,17 +52,17 @@ function Lookup() {
4852
4953 return (
5054 <article class="card stack gap-top">
51- <h2>Student lookup</h2>
55+ <h2>{t("studentLookup")}</h2>
5256 <form
53- class="row"
57+ class="row row-end"
5458 onSubmit={(e) => {
5559 e.preventDefault();
5660 void fetch.run(e.currentTarget);
5761 }}
5862 >
59- <input name="user_id" placeholder="Student id" required />
63+ <UserPicker name="user_id" label={t("student")} onPick={setWho} />
6064 <button type="submit" disabled={fetch.pending()}>
61- Show marks
65+ {t("showMarks")}
6266 </button>
6367 </form>
6468 <ErrorLine error={fetch.error()} />
@@ -66,9 +70,9 @@ function Lookup() {
6670 <Show when={report()}>
6771 {(current) => (
6872 <>
69- <p class="meta">
70- Report for <span class="mono">{current().user}</span>
71- </p>
73+ <Show when={who()}>
74+ {(person) => <p class="meta">{t("reportFor")(personLabel(person()))}</p>}
75+ </Show>
7276 <Report report={current()} />
7377 </>
7478 )}
@@ -81,11 +85,11 @@ function Report(props: { report: MarksReport }) {
8185 return (
8286 <Show
8387 when={props.report.courses.length}
84- fallback={<Empty>Not enrolled in any course.</Empty>}
88+ fallback={<Empty>{t("notEnrolledAny")}</Empty>}
8589 >
8690 <div class="stack">
87- <div class="card row" title="mean of the course averages">
88- <span class="muted">Overall average</span>
91+ <div class="card row" title={t("overallAverageTitle")}>
92+ <span class="muted">{t("overallAverage")}</span>
8993 <p class="mark push">
9094 {props.report.overall_average === null ? (
9195 "—"
@@ -105,22 +109,22 @@ function Report(props: { report: MarksReport }) {
105109 <h3>
106110 <A href={`/courses/${block.course.id}`}>{block.course.title}</A>
107111 </h3>
108- <span class="badge" title="weighted course average">
112+ <span class="badge" title={t("courseAverageTitle")}>
109113 {block.average === null ? "—" : round(block.average)}
110114 </span>
111115 </header>
112116 <Show
113117 when={block.results.length}
114- fallback={<Empty>Nothing graded yet.</Empty>}
118+ fallback={<Empty>{t("nothingGradedYet")}</Empty>}
115119 >
116120 <div class="table-wrap">
117121 <table>
118122 <thead>
119123 <tr>
120- <th>Exam</th>
121- <th>Kind</th>
122- <th>Weight</th>
123- <th>Mark</th>
124+ <th>{t("examCol")}</th>
125+ <th>{t("kind")}</th>
126+ <th>{t("weight")}</th>
127+ <th>{t("markCol")}</th>
124128 </tr>
125129 </thead>
126130 <tbody>
@@ -131,9 +135,9 @@ function Report(props: { report: MarksReport }) {
131135 <A href={`/exams/${entry.exam}`}>{entry.title}</A>
132136 </td>
133137 <td>
134- <span class="badge">{entry.kind}</span>
138+ <span class="badge">{t("kindWord")(entry.kind)}</span>
135139 </td>
136- <td>×{entry.weight}</td>
140+ <td>{t("weightBadge")(entry.weight)}</td>
137141 <td>{entry.mark}</td>
138142 </tr>
139143 )}
src/pages/NotFound.tsxmodified+3 -2
@@ -1,12 +1,13 @@
11 import { A } from "@solidjs/router";
2+import { t } from "../lib/i18n";
23
34 export default function NotFound() {
45 return (
56 <main class="auth-page">
67 <div class="card stack" style={{ "text-align": "center", padding: "2.5rem 3rem" }}>
78 <h1 style={{ "font-size": "2.5rem" }}>404</h1>
8- <p class="muted">This page flew away.</p>
9- <A href="/">Back home</A>
9+ <p class="muted">{t("pageFlewAway")}</p>
10+ <A href="/">{t("backHome")}</A>
1011 </div>
1112 </main>
1213 );
src/pages/Notes.tsxmodified+59 -44
@@ -2,10 +2,12 @@
22 // the resource from the server's response — the UI never waits on a refetch.
33
44 import { For, Show, createResource, createSignal } from "solid-js";
5+import { ConfirmButton } from "../components/ConfirmButton";
56 import { Empty, ErrorLine, Loading } from "../components/Feedback";
67 import { IconEdit, IconPlus, IconTrash } from "../components/Icons";
78 import { createAction } from "../lib/action";
89 import { notes } from "../lib/api";
10+import { t } from "../lib/i18n";
911 import { LIMITS, type Note } from "../lib/types";
1012
1113 export default function Notes() {
@@ -31,11 +33,11 @@ export default function Notes() {
3133 <section class="page">
3234 <header class="page-head">
3335 <div>
34- <h1>Notes</h1>
35- <p class="sub">Your personal scratchpad — visible only to you.</p>
36+ <h1>{t("notesTitle")}</h1>
37+ <p class="sub">{t("notesSub")}</p>
3638 </div>
3739 <button onClick={() => setCreating((open) => !open)}>
38- <IconPlus /> New note
40+ <IconPlus /> {t("newNote")}
3941 </button>
4042 </header>
4143
@@ -47,26 +49,31 @@ export default function Notes() {
4749 void create.run(e.currentTarget);
4850 }}
4951 >
50- <input
51- name="title"
52- placeholder="Title"
53- required
54- maxLength={LIMITS.noteTitle}
55- ref={(el) => queueMicrotask(() => el.focus())}
56- />
57- <textarea
58- name="content"
59- placeholder="Write something…"
60- rows={3}
61- maxLength={LIMITS.noteContent}
62- />
52+ <label>
53+ {t("title")}
54+ <input
55+ name="title"
56+ required
57+ maxLength={LIMITS.noteTitle}
58+ ref={(el) => queueMicrotask(() => el.focus())}
59+ />
60+ </label>
61+ <label>
62+ {t("content")}
63+ <textarea
64+ name="content"
65+ placeholder={t("writeSomething")}
66+ rows={3}
67+ maxLength={LIMITS.noteContent}
68+ />
69+ </label>
6370 <ErrorLine error={create.error()} />
6471 <span class="row-actions">
6572 <button type="submit" disabled={create.pending()}>
66- Add note
73+ {t("addNote")}
6774 </button>
6875 <button type="button" class="ghost" onClick={() => setCreating(false)}>
69- Cancel
76+ {t("cancel")}
7077 </button>
7178 </span>
7279 </form>
@@ -75,7 +82,17 @@ export default function Notes() {
7582 <Show when={!list.loading} fallback={<Loading />}>
7683 <Show
7784 when={list()?.length}
78- fallback={<Empty>No notes yet — write your first one.</Empty>}
85+ fallback={
86+ <Empty
87+ action={
88+ <button onClick={() => setCreating(true)}>
89+ <IconPlus /> {t("newNote")}
90+ </button>
91+ }
92+ >
93+ {t("noNotesYet")}
94+ </Empty>
95+ }
7996 >
8097 <div class="grid">
8198 <For each={list()}>
@@ -119,28 +136,13 @@ function NoteCard(props: {
119136 <>
120137 <header class="row">
121138 <h3>{props.note.title}</h3>
122- <span class="row-actions">
123- <button
124- class="ghost icon-btn"
125- title="Edit"
126- onClick={() => setEditing(true)}
127- >
128- <IconEdit />
129- </button>
130- <button
131- class="ghost icon-btn danger"
132- title="Delete"
133- disabled={remove.pending()}
134- onClick={() => void remove.run()}
135- >
136- <IconTrash />
137- </button>
138- </span>
139+ <button class="ghost" onClick={() => setEditing(true)}>
140+ <IconEdit /> {t("edit")}
141+ </button>
139142 </header>
140143 <Show when={props.note.content}>
141144 <p class="prewrap">{props.note.content}</p>
142145 </Show>
143- <ErrorLine error={remove.error()} />
144146 </>
145147 }
146148 >
@@ -151,18 +153,31 @@ function NoteCard(props: {
151153 void save.run(e.currentTarget);
152154 }}
153155 >
154- <input name="title" value={props.note.title} required maxLength={LIMITS.noteTitle} />
155- <textarea name="content" rows={4} maxLength={LIMITS.noteContent}>
156- {props.note.content}
157- </textarea>
158- <ErrorLine error={save.error()} />
156+ <label>
157+ {t("title")}
158+ <input name="title" value={props.note.title} required maxLength={LIMITS.noteTitle} />
159+ </label>
160+ <label>
161+ {t("content")}
162+ <textarea name="content" rows={4} maxLength={LIMITS.noteContent}>
163+ {props.note.content}
164+ </textarea>
165+ </label>
166+ <ErrorLine error={save.error() ?? remove.error()} />
159167 <span class="row-actions">
160168 <button type="submit" disabled={save.pending()}>
161- Save
169+ {t("save")}
162170 </button>
163171 <button type="button" class="ghost" onClick={() => setEditing(false)}>
164- Cancel
172+ {t("cancel")}
165173 </button>
174+ <ConfirmButton
175+ class="ghost danger push"
176+ disabled={remove.pending()}
177+ onConfirm={() => void remove.run()}
178+ >
179+ <IconTrash /> {t("deleteNote")}
180+ </ConfirmButton>
166181 </span>
167182 </form>
168183 </Show>
src/pages/Profile.tsxmodified+7 -6
@@ -8,6 +8,7 @@ import { ProfileFields, profilePatch } from "../components/ProfileFields";
88 import { createAction } from "../lib/action";
99 import { users } from "../lib/api";
1010 import { useAuth } from "../lib/auth";
11+import { t } from "../lib/i18n";
1112
1213 export default function Profile() {
1314 const { user, update } = useAuth();
@@ -34,8 +35,8 @@ export default function Profile() {
3435 current().username}
3536 </h1>
3637 <p class="sub">
37- {current().username} · <span class="badge">{current().role}</span> ·{" "}
38- <span class="mono">{current().id}</span>
38+ {current().username} ·{" "}
39+ <span class="badge">{t("roleWord")(current().role)}</span>
3940 </p>
4041 </div>
4142 </div>
@@ -48,16 +49,16 @@ export default function Profile() {
4849 void save.run(e.currentTarget);
4950 }}
5051 >
51- <h2>Personal info</h2>
52- <p class="meta">Leave a field empty to clear it.</p>
52+ <h2>{t("personalInfo")}</h2>
53+ <p class="meta">{t("leaveEmptyToClear")}</p>
5354 <ProfileFields user={current()} />
5455 <ErrorLine error={save.error()} />
5556 <span class="row-actions">
5657 <button type="submit" disabled={save.pending()}>
57- Save
58+ {t("save")}
5859 </button>
5960 <Show when={saved() && !save.pending()}>
60- <span class="meta">Saved.</span>
61+ <span class="meta">{t("savedDot")}</span>
6162 </Show>
6263 </span>
6364 </form>
src/pages/Users.tsxmodified+61 -28
@@ -8,6 +8,7 @@ import { ProfileFields, profilePatch } from "../components/ProfileFields";
88 import { createAction } from "../lib/action";
99 import { users } from "../lib/api";
1010 import { useAuth } from "../lib/auth";
11+import { t } from "../lib/i18n";
1112 import { ROLES, type Role, type User } from "../lib/types";
1213
1314 export default function Users() {
@@ -36,26 +37,26 @@ export default function Users() {
3637 };
3738
3839 return (
39- <Show when={can("admin")} fallback={<Empty>Admins only.</Empty>}>
40+ <Show when={can("admin")} fallback={<Empty>{t("adminsOnly")}</Empty>}>
4041 <section class="page">
4142 <header class="page-head">
4243 <div>
43- <h1>Users</h1>
44- <p class="sub">Every account, with roles and personal records.</p>
44+ <h1>{t("usersTitle")}</h1>
45+ <p class="sub">{t("usersSub")}</p>
4546 </div>
4647 </header>
4748 <ErrorLine error={setRole.error()} />
4849 <Show when={!list.loading} fallback={<Loading />}>
49- <Show when={list()?.length} fallback={<Empty>No users.</Empty>}>
50+ <Show when={list()?.length} fallback={<Empty>{t("noUsers")}</Empty>}>
5051 <div class="table-wrap">
5152 <table>
5253 <thead>
5354 <tr>
54- <th>User</th>
55- <th>Id</th>
56- <th>Contact</th>
57- <th>Born</th>
58- <th>Role</th>
55+ <th>{t("userCol")}</th>
56+ <th>{t("idCol")}</th>
57+ <th>{t("contactCol")}</th>
58+ <th>{t("bornCol")}</th>
59+ <th>{t("roleCol")}</th>
5960 <th />
6061 </tr>
6162 </thead>
@@ -81,28 +82,18 @@ export default function Users() {
8182 <td>
8283 <Show
8384 when={entry.id !== user()?.id}
84- fallback={<em>{entry.role} (you)</em>}
85+ fallback={<em>{t("roleWord")(entry.role)}{t("you")}</em>}
8586 >
86- <select
87- value={entry.role}
88- disabled={setRole.pending()}
89- onChange={(e) =>
90- void setRole.run(entry, e.currentTarget.value as Role)
91- }
92- >
93- <For each={ROLES}>
94- {(role) => (
95- <option value={role} selected={role === entry.role}>
96- {role}
97- </option>
98- )}
99- </For>
100- </select>
87+ <RoleCell
88+ entry={entry}
89+ pending={setRole.pending()}
90+ onApply={(role) => setRole.run(entry, role)}
91+ />
10192 </Show>
10293 </td>
10394 <td>
10495 <button class="ghost" onClick={() => toggleEdit(entry.id)}>
105- {editing() === entry.id ? "Close" : "Edit"}
96+ {editing() === entry.id ? t("close") : t("edit")}
10697 </button>
10798 </td>
10899 </tr>
@@ -116,12 +107,12 @@ export default function Users() {
116107 void saveProfile.run(entry, e.currentTarget);
117108 }}
118109 >
119- <p class="meta">Leave a field empty to clear it.</p>
110+ <p class="meta">{t("leaveEmptyToClear")}</p>
120111 <ProfileFields user={entry} />
121112 <ErrorLine error={saveProfile.error()} />
122113 <span class="row-actions">
123114 <button type="submit" disabled={saveProfile.pending()}>
124- Save profile
115+ {t("saveProfile")}
125116 </button>
126117 </span>
127118 </form>
@@ -140,3 +131,45 @@ export default function Users() {
140131 </Show>
141132 );
142133 }
134+
135+/** Role dropdown that stages the pick behind Apply/Cancel — a stray scroll
136+ * over the select must never fire a role change on its own. */
137+function RoleCell(props: {
138+ entry: User;
139+ pending: boolean;
140+ onApply: (role: Role) => Promise<boolean>;
141+}) {
142+ const [staged, setStaged] = createSignal<Role | null>(null);
143+ const dirty = () => staged() !== null && staged() !== props.entry.role;
144+
145+ const apply = async () => {
146+ const next = staged();
147+ if (next && (await props.onApply(next))) setStaged(null);
148+ };
149+
150+ return (
151+ <span class="row-actions">
152+ <select
153+ value={staged() ?? props.entry.role}
154+ disabled={props.pending}
155+ onChange={(e) => setStaged(e.currentTarget.value as Role)}
156+ >
157+ <For each={ROLES}>
158+ {(role) => (
159+ <option value={role} selected={role === (staged() ?? props.entry.role)}>
160+ {t("roleWord")(role)}
161+ </option>
162+ )}
163+ </For>
164+ </select>
165+ <Show when={dirty()}>
166+ <button disabled={props.pending} onClick={() => void apply()}>
167+ {t("apply")}
168+ </button>
169+ <button class="ghost" disabled={props.pending} onClick={() => setStaged(null)}>
170+ {t("cancel")}
171+ </button>
172+ </Show>
173+ </span>
174+ );
175+}
src/styles.cssmodified+377 -7
@@ -14,6 +14,7 @@
1414 --accent-strong: #5468f0;
1515 --accent-2-strong: #7c5cf0;
1616 --danger: #f27d7d;
17+ --danger-strong: #c94747;
1718 --ok: #4ecf8a;
1819 --warn: #e8b44f;
1920 --radius: 14px;
@@ -37,6 +38,7 @@
3738 --accent-strong: #4a5fe0;
3839 --accent-2-strong: #7250e0;
3940 --danger: #d64545;
41+ --danger-strong: #c23b3b;
4042 --ok: #1f9d5f;
4143 --warn: #a87716;
4244 --shadow: 0 1px 2px rgb(20 25 40 / 0.06);
@@ -53,7 +55,7 @@ body {
5355 background: var(--bg);
5456 color: var(--text);
5557 font:
56- 15px/1.55 ui-sans-serif,
58+ 16px/1.55 ui-sans-serif,
5759 system-ui,
5860 -apple-system,
5961 "Segoe UI",
@@ -180,7 +182,7 @@ a:focus-visible {
180182 display: flex;
181183 align-items: center;
182184 gap: 0.65rem;
183- padding: 0.5rem 0.65rem;
185+ padding: 0.6rem 0.7rem;
184186 border-radius: var(--radius-sm);
185187 color: var(--muted);
186188 font-weight: 500;
@@ -201,10 +203,28 @@ a:focus-visible {
201203
202204 .sidebar-end {
203205 display: flex;
204- align-items: center;
206+ flex-direction: column;
207+ align-items: stretch;
205208 gap: 0.25rem;
206209 }
207210
211+.sidebar .logout,
212+.sidebar .lang-switch {
213+ justify-content: flex-start;
214+ padding: 0.6rem 0.7rem;
215+ color: var(--muted);
216+ border-color: transparent;
217+ font-weight: 500;
218+}
219+.sidebar .lang-switch {
220+ font-size: 0.82rem;
221+}
222+.sidebar .logout:hover:not(:disabled),
223+.sidebar .lang-switch:hover:not(:disabled) {
224+ color: var(--text);
225+ background: var(--surface-2);
226+}
227+
208228 .user-chip {
209229 flex: 1;
210230 min-width: 0;
@@ -288,7 +308,7 @@ main {
288308 display: none;
289309 }
290310 .sidebar nav a {
291- padding: 0.4rem 0.6rem;
311+ padding: 0.5rem 0.65rem;
292312 }
293313 .user-meta {
294314 display: none;
@@ -298,6 +318,17 @@ main {
298318 padding: 0.25rem;
299319 border-radius: 50%;
300320 }
321+ .sidebar-end {
322+ flex-direction: row;
323+ align-items: center;
324+ }
325+ .sidebar .logout,
326+ .sidebar .lang-switch {
327+ padding: 0.5rem;
328+ }
329+ .sidebar .logout span {
330+ display: none;
331+ }
301332 main {
302333 padding: 1.4rem 1rem 4rem;
303334 }
@@ -354,6 +385,12 @@ main {
354385 flex-wrap: wrap;
355386 }
356387
388+/* A row of labeled fields plus a button: align everything to the baseline
389+ of the inputs, not the center of the taller labeled column. */
390+.row-end {
391+ align-items: flex-end;
392+}
393+
357394 .grid {
358395 display: grid;
359396 grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
@@ -461,7 +498,7 @@ select {
461498 background: var(--surface-2);
462499 border: 1px solid var(--border);
463500 border-radius: var(--radius-sm);
464- padding: 0.5rem 0.75rem;
501+ padding: 0.55rem 0.8rem;
465502 transition:
466503 border-color 120ms,
467504 box-shadow 120ms;
@@ -480,6 +517,73 @@ textarea {
480517 color: color-mix(in srgb, var(--muted) 75%, transparent);
481518 }
482519
520+/* Input with a trailing button (e.g. the show-password toggle). */
521+.input-group {
522+ display: flex;
523+ gap: 0.4rem;
524+}
525+.input-group input {
526+ flex: 1;
527+ min-width: 0;
528+}
529+
530+/* Plain-language rule stated before the user can get it wrong. */
531+.hint {
532+ font-size: 0.8rem;
533+ font-weight: 400;
534+ color: var(--muted);
535+}
536+
537+/* --- user picker ------------------------------------------------------------ */
538+
539+.picker {
540+ min-width: 14rem;
541+}
542+.picker-box {
543+ position: relative;
544+ display: flex;
545+ flex-direction: column;
546+}
547+.picker-menu {
548+ position: absolute;
549+ top: calc(100% + 4px);
550+ left: 0;
551+ right: 0;
552+ z-index: 20;
553+ display: flex;
554+ flex-direction: column;
555+ gap: 2px;
556+ max-height: 15rem;
557+ overflow-y: auto;
558+ padding: 0.3rem;
559+ background: var(--surface);
560+ border: 1px solid var(--border);
561+ border-radius: var(--radius-sm);
562+ box-shadow: var(--shadow-lg);
563+}
564+.picker-menu p {
565+ padding: 0.4rem 0.6rem;
566+}
567+.picker-menu button {
568+ justify-content: flex-start;
569+ gap: 0.5rem;
570+ padding: 0.45rem 0.6rem;
571+ color: var(--text);
572+ background: transparent;
573+ border-color: transparent;
574+ font-weight: 500;
575+ text-align: left;
576+}
577+.picker-menu button:hover:not(:disabled) {
578+ background: var(--surface-2);
579+ filter: none;
580+}
581+.picker-menu button span {
582+ color: var(--muted);
583+ font-size: 0.82rem;
584+ font-weight: 400;
585+}
586+
483587 button {
484588 display: inline-flex;
485589 align-items: center;
@@ -491,7 +595,7 @@ button {
491595 background: linear-gradient(135deg, var(--accent-strong), var(--accent-2-strong));
492596 border: 1px solid transparent;
493597 border-radius: var(--radius-sm);
494- padding: 0.5rem 0.95rem;
598+ padding: 0.55rem 1rem;
495599 cursor: pointer;
496600 transition:
497601 filter 100ms,
@@ -530,8 +634,17 @@ button.danger:hover:not(:disabled) {
530634 background: color-mix(in srgb, var(--danger) 9%, transparent);
531635 }
532636
637+/* An armed ConfirmButton: unmistakably hot until it disarms itself. */
638+button.confirm-armed,
639+button.confirm-armed:hover:not(:disabled) {
640+ color: #fff;
641+ background: var(--danger-strong);
642+ border-color: transparent;
643+ filter: none;
644+}
645+
533646 button.icon-btn {
534- padding: 0.45rem;
647+ padding: 0.65rem;
535648 border-radius: var(--radius-sm);
536649 }
537650
@@ -658,6 +771,10 @@ td .mono {
658771 }
659772
660773 .empty {
774+ display: flex;
775+ flex-direction: column;
776+ align-items: center;
777+ gap: 0.9rem;
661778 color: var(--muted);
662779 padding: 2rem 1rem;
663780 text-align: center;
@@ -709,6 +826,259 @@ td .mono {
709826 }
710827 }
711828
829+/* --- exams: schedule, room, monitor ----------------------------------------- */
830+
831+/* The one action a page really wants pressed — bigger than everything else. */
832+button.cta {
833+ font-size: 1.02rem;
834+ padding: 0.75rem 1.5rem;
835+}
836+
837+/* An <A> that reads as a button (empty-state actions, back links). */
838+.button-link {
839+ display: inline-flex;
840+ align-items: center;
841+ gap: 0.45rem;
842+ font-weight: 600;
843+ color: #fff;
844+ background: linear-gradient(135deg, var(--accent-strong), var(--accent-2-strong));
845+ border-radius: var(--radius-sm);
846+ padding: 0.55rem 1rem;
847+}
848+.button-link:hover {
849+ text-decoration: none;
850+ filter: brightness(1.08);
851+}
852+
853+.badge.phase-open {
854+ color: var(--ok);
855+ background: color-mix(in srgb, var(--ok) 12%, transparent);
856+ border-color: color-mix(in srgb, var(--ok) 25%, transparent);
857+}
858+.badge.phase-upcoming {
859+ color: var(--warn);
860+ background: color-mix(in srgb, var(--warn) 12%, transparent);
861+ border-color: color-mix(in srgb, var(--warn) 25%, transparent);
862+}
863+.badge.phase-closed,
864+.badge.status-expired {
865+ color: var(--muted);
866+ background: color-mix(in srgb, var(--muted) 12%, transparent);
867+ border-color: color-mix(in srgb, var(--muted) 25%, transparent);
868+}
869+.badge.status-in_progress {
870+ color: var(--ok);
871+ background: color-mix(in srgb, var(--ok) 12%, transparent);
872+ border-color: color-mix(in srgb, var(--ok) 25%, transparent);
873+}
874+.badge.status-not_started {
875+ color: var(--warn);
876+ background: color-mix(in srgb, var(--warn) 12%, transparent);
877+ border-color: color-mix(in srgb, var(--warn) 25%, transparent);
878+}
879+
880+/* The student's sticky exam header: title, countdown, turn-in. */
881+.room-head {
882+ position: sticky;
883+ top: 0.5rem;
884+ z-index: 15;
885+ display: flex;
886+ align-items: center;
887+ justify-content: space-between;
888+ gap: 1rem;
889+ flex-wrap: wrap;
890+ background: color-mix(in srgb, var(--surface) 88%, transparent);
891+ backdrop-filter: blur(10px);
892+}
893+.room-title {
894+ display: flex;
895+ flex-direction: column;
896+ gap: 0.15rem;
897+ min-width: 0;
898+}
899+.room-side {
900+ display: flex;
901+ align-items: center;
902+ gap: 0.9rem;
903+}
904+.room-foot {
905+ justify-content: center;
906+}
907+
908+.countdown {
909+ font-family: ui-monospace, "JetBrains Mono", monospace;
910+ font-size: 1.5rem;
911+ font-weight: 650;
912+ font-variant-numeric: tabular-nums;
913+ letter-spacing: 0.02em;
914+}
915+.countdown.warn {
916+ color: var(--warn);
917+}
918+.countdown.danger {
919+ color: var(--danger);
920+}
921+
922+/* One tappable row per option — the whole row is the label. */
923+.choice-pick {
924+ gap: 0.5rem;
925+}
926+.choice-row {
927+ flex-direction: row;
928+ align-items: center;
929+ gap: 0.7rem;
930+ padding: 0.7rem 0.9rem;
931+ font-size: 1rem;
932+ font-weight: 500;
933+ color: var(--text);
934+ background: var(--surface-2);
935+ border: 1px solid var(--border);
936+ border-radius: var(--radius-sm);
937+ cursor: pointer;
938+ transition: border-color 120ms, background 120ms;
939+}
940+.choice-row:hover {
941+ border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
942+}
943+.choice-row.picked {
944+ border-color: var(--accent);
945+ background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
946+}
947+.choice-row input {
948+ width: 1.15rem;
949+ height: 1.15rem;
950+ accent-color: var(--accent);
951+ flex-shrink: 0;
952+}
953+
954+.save-state {
955+ font-size: 0.8rem;
956+ color: var(--ok);
957+}
958+.save-state.error {
959+ color: var(--danger);
960+ font-weight: 600;
961+}
962+
963+.notice-ok {
964+ border-color: color-mix(in srgb, var(--ok) 40%, var(--border));
965+ color: var(--ok);
966+ font-weight: 500;
967+}
968+.notice-warn {
969+ border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
970+ color: var(--warn);
971+ font-weight: 500;
972+}
973+
974+/* Question authoring: one row per option, radio marks the right one. */
975+.option-row {
976+ display: flex;
977+ align-items: center;
978+ gap: 0.6rem;
979+}
980+.option-row input[type="radio"] {
981+ width: 1.15rem;
982+ height: 1.15rem;
983+ accent-color: var(--ok);
984+ flex-shrink: 0;
985+}
986+.option-row input:not([type="radio"]) {
987+ flex: 1;
988+ min-width: 0;
989+}
990+
991+ol.choices {
992+ margin: 0;
993+ padding-left: 1.4rem;
994+ display: flex;
995+ flex-direction: column;
996+ gap: 0.25rem;
997+}
998+ol.choices li.correct {
999+ color: var(--ok);
1000+ font-weight: 600;
1001+}
1002+
1003+.live-counts {
1004+ display: flex;
1005+ gap: 0.5rem;
1006+ flex-wrap: wrap;
1007+}
1008+
1009+.sheet-row {
1010+ padding: 0.6rem 0;
1011+ border-bottom: 1px solid var(--border);
1012+}
1013+.sheet-row:last-child {
1014+ border-bottom: none;
1015+}
1016+.sheet-row .qtext .badge {
1017+ margin-left: 0.5rem;
1018+}
1019+.answer-ok {
1020+ color: var(--ok);
1021+ font-weight: 500;
1022+}
1023+.answer-bad {
1024+ color: var(--danger);
1025+ font-weight: 500;
1026+}
1027+
1028+/* --- bottom tab bar (small screens) ------------------------------------------ */
1029+
1030+.tabbar {
1031+ display: none;
1032+}
1033+
1034+@media (max-width: 860px) {
1035+ .sidebar nav {
1036+ display: none;
1037+ }
1038+ .tabbar {
1039+ position: fixed;
1040+ inset: auto 0 0 0;
1041+ z-index: 30;
1042+ display: grid;
1043+ grid-auto-flow: column;
1044+ grid-auto-columns: 1fr;
1045+ padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom));
1046+ background: color-mix(in srgb, var(--surface) 88%, transparent);
1047+ backdrop-filter: blur(14px);
1048+ border-top: 1px solid var(--border);
1049+ }
1050+ .tabbar a {
1051+ display: flex;
1052+ flex-direction: column;
1053+ align-items: center;
1054+ justify-content: center;
1055+ gap: 0.15rem;
1056+ min-height: 52px;
1057+ border-radius: var(--radius-sm);
1058+ color: var(--muted);
1059+ font-size: 0.66rem;
1060+ font-weight: 600;
1061+ letter-spacing: 0.01em;
1062+ }
1063+ .tabbar a:hover {
1064+ text-decoration: none;
1065+ }
1066+ .tabbar a.active {
1067+ color: var(--accent);
1068+ background: color-mix(in srgb, var(--accent) 11%, transparent);
1069+ }
1070+ .tabbar .icon {
1071+ width: 1.35em;
1072+ height: 1.35em;
1073+ }
1074+ main {
1075+ padding-bottom: 6rem;
1076+ }
1077+ .room-head {
1078+ top: 0;
1079+ }
1080+}
1081+
7121082 /* --- auth page ----------------------------------------------------------------- */
7131083
7141084 .auth-page {
vite.config.tsmodified+2 -0
@@ -11,6 +11,8 @@ export default defineConfig({
1111 "/api": {
1212 target: "http://127.0.0.1:8080",
1313 changeOrigin: true,
14+ // The exam room is a WebSocket under the same prefix.
15+ ws: true,
1416 rewrite: (path) => path.replace(/^\/api/, ""),
1517 },
1618 },