From e37d07827e293f03bb5d3b9846b3e64908b4cc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Sun, 12 Jul 2026 12:38:14 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20finished=20exam=20final=20s?= =?UTF-8?q?tate,=20restrictions,=20status=20badges=20&=20course=20accordio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/getExamLive.ts | 6 + src/api/getExamStatistics.ts | 6 + src/api/getStudentAnswers.ts | 6 + src/api/getTime.ts | 5 + src/api/getUserById.ts | 6 + src/api/patchMe.ts | 6 + src/api/patchUserProfile.ts | 6 + src/api/types.ts | 64 +++ src/components/exams/answer-sheet-view.tsx | 88 ++++ src/components/exams/exam-card.tsx | 55 +- src/components/exams/exam-questions-panel.tsx | 46 +- src/components/exams/exam-room-ws.tsx | 478 ++++++++++++++++++ src/components/layout/user-menu.tsx | 9 +- src/components/users/profile-form.tsx | 104 ++++ src/i18n/messages.ts | 131 ++++- src/pages/exam-detail-page.tsx | 138 ++++- src/pages/exam-room-page.tsx | 4 +- src/pages/exams-page.tsx | 70 ++- src/pages/live-monitor-page.tsx | 281 ++++++++++ src/pages/profile-page.tsx | 78 +++ src/routes/router.tsx | 16 + vite.config.ts | 2 +- 22 files changed, 1546 insertions(+), 59 deletions(-) create mode 100644 src/api/getExamLive.ts create mode 100644 src/api/getExamStatistics.ts create mode 100644 src/api/getStudentAnswers.ts create mode 100644 src/api/getTime.ts create mode 100644 src/api/getUserById.ts create mode 100644 src/api/patchMe.ts create mode 100644 src/api/patchUserProfile.ts create mode 100644 src/components/exams/answer-sheet-view.tsx create mode 100644 src/components/exams/exam-room-ws.tsx create mode 100644 src/components/users/profile-form.tsx create mode 100644 src/pages/live-monitor-page.tsx create mode 100644 src/pages/profile-page.tsx diff --git a/src/api/getExamLive.ts b/src/api/getExamLive.ts new file mode 100644 index 0000000..063ebbf --- /dev/null +++ b/src/api/getExamLive.ts @@ -0,0 +1,6 @@ +import { client } from "@/api/client"; +import type { LiveMonitor } from "@/api/types"; + +export async function getExamLive(examId: string, signal?: AbortSignal): Promise { + return client(`/exams/${encodeURIComponent(examId)}/live`, { signal }); +} diff --git a/src/api/getExamStatistics.ts b/src/api/getExamStatistics.ts new file mode 100644 index 0000000..012f5e6 --- /dev/null +++ b/src/api/getExamStatistics.ts @@ -0,0 +1,6 @@ +import { client } from "@/api/client"; +import type { ExamStatistics } from "@/api/types"; + +export async function getExamStatistics(examId: string, signal?: AbortSignal): Promise { + return client(`/exams/${encodeURIComponent(examId)}/statistics`, { signal }); +} diff --git a/src/api/getStudentAnswers.ts b/src/api/getStudentAnswers.ts new file mode 100644 index 0000000..7082c7b --- /dev/null +++ b/src/api/getStudentAnswers.ts @@ -0,0 +1,6 @@ +import { client } from "@/api/client"; +import type { StudentAnswerSheet } from "@/api/types"; + +export async function getStudentAnswers(examId: string, userId: string, signal?: AbortSignal): Promise { + return client(`/exams/${encodeURIComponent(examId)}/attempts/${encodeURIComponent(userId)}/answers`, { signal }); +} diff --git a/src/api/getTime.ts b/src/api/getTime.ts new file mode 100644 index 0000000..7a85fce --- /dev/null +++ b/src/api/getTime.ts @@ -0,0 +1,5 @@ +import { client } from "@/api/client"; + +export async function getTime(signal?: AbortSignal): Promise<{ now: number }> { + return client<{ now: number }>("/time", { signal }); +} diff --git a/src/api/getUserById.ts b/src/api/getUserById.ts new file mode 100644 index 0000000..2da83e0 --- /dev/null +++ b/src/api/getUserById.ts @@ -0,0 +1,6 @@ +import { client } from "@/api/client"; +import type { User } from "@/api/types"; + +export async function getUserById(id: string, signal?: AbortSignal): Promise { + return client(`/users/${encodeURIComponent(id)}`, { signal }); +} diff --git a/src/api/patchMe.ts b/src/api/patchMe.ts new file mode 100644 index 0000000..605ca53 --- /dev/null +++ b/src/api/patchMe.ts @@ -0,0 +1,6 @@ +import { client } from "@/api/client"; +import type { ProfileUpdate } from "@/api/types"; + +export async function patchMe(body: ProfileUpdate): Promise { + await client("/auth/me", { method: "PATCH", body }); +} diff --git a/src/api/patchUserProfile.ts b/src/api/patchUserProfile.ts new file mode 100644 index 0000000..5b33acf --- /dev/null +++ b/src/api/patchUserProfile.ts @@ -0,0 +1,6 @@ +import { client } from "@/api/client"; +import type { ProfileUpdate } from "@/api/types"; + +export async function patchUserProfile(id: string, body: ProfileUpdate): Promise { + await client(`/users/${encodeURIComponent(id)}/profile`, { method: "PATCH", body }); +} diff --git a/src/api/types.ts b/src/api/types.ts index 152f7dd..a87a04e 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -9,6 +9,19 @@ export type User = { id: string; username: string; role: Role; + name: string | null; + surname: string | null; + email: string | null; + phone: string | null; + birth_date: string | null; +}; + +export type ProfileUpdate = { + name?: string | null; + surname?: string | null; + email?: string | null; + phone?: string | null; + birth_date?: string | null; }; export type PersonRef = { @@ -136,6 +149,57 @@ export type MarksReport = { overall_average: number | null; }; +export type ExamStatistics = { + graded: number; + average: number | null; + min: number | null; + max: number | null; +}; + +export type GradedAnswer = { + question_id: string; + text: string; + kind: QuestionKind; + points: number; + choices: string[] | null; + correct: number | null; + selected: number | null; + text_answer: string | null; + is_correct: boolean | null; + auto_score: { earned: number; possible: number }; +}; + +export type StudentAnswerSheet = { + user: string; + answers: GradedAnswer[]; + auto_score: { earned: number; possible: number }; +}; + +export type LiveRosterEntry = { + user: string; + username: string; + display_name: string | null; + status: AttemptStatus | "not_started"; + deadline: number | null; + remaining_ms: number; + mark: number | null; + answered: number; + last_activity: number | null; +}; + +export type LiveMonitor = { + exam: string; + now: number; + question_count: number; + students: LiveRosterEntry[]; + counts: { + not_started: number; + in_progress: number; + submitted: number; + expired: number; + }; +}; + export const EXAM_KINDS: ExamKind[] = [ "homework", "quiz", diff --git a/src/components/exams/answer-sheet-view.tsx b/src/components/exams/answer-sheet-view.tsx new file mode 100644 index 0000000..4fdaa1f --- /dev/null +++ b/src/components/exams/answer-sheet-view.tsx @@ -0,0 +1,88 @@ +import { For, Show, Suspense, createResource } from "solid-js"; +import { getStudentAnswers } from "@/api/getStudentAnswers"; +import { Badge } from "@/components/ui/badge"; +import { PageSpinner } from "@/components/ui/page-spinner"; +import { useT } from "@/stores/preferences-context"; + +export function AnswerSheetView(props: { examId: string; userId: string }) { + const t = useT(); + const [sheet] = createResource( + () => [props.examId, props.userId] as const, + async ([examId, userId]) => getStudentAnswers(examId, userId), + ); + + return ( + }> + + {(s) => ( +
+
+

{props.userId}

+ + {t("exams.autoScore")}: {s().auto_score.earned}/{s().auto_score.possible} + +
+ + + {(answer, idx) => ( +
+
+ #{idx() + 1} + {answer.points} {t("questions.points")} + + {answer.is_correct === true ? t("exams.isCorrect") : + answer.is_correct === false ? "✗" : + answer.kind === "text" ? t("questions.kind.text") : "—"} + + {t("exams.autoScore")}: {answer.auto_score.earned}/{answer.auto_score.possible} +
+

{answer.text}

+ + +

{t("exams.textAnswer")}

+

{answer.text_answer || "—"}

+
+ } + > +
+ + {(choice, ci) => ( +
+ + {ci() === answer.correct || ci() === answer.selected + ? ci() === answer.correct && ci() === answer.selected + ? "✓" + : ci() === answer.correct + ? "✓" + : "✗" + : String.fromCharCode(65 + ci())} + + {choice} + {ci() === answer.correct && {t("questions.correct")}} +
+ )} +
+
+ +
+ )} + + + )} +
+
+ ); +} diff --git a/src/components/exams/exam-card.tsx b/src/components/exams/exam-card.tsx index d582f0e..91f5cf3 100644 --- a/src/components/exams/exam-card.tsx +++ b/src/components/exams/exam-card.tsx @@ -1,11 +1,13 @@ +import { Show } from "solid-js"; import { Link } from "@tanstack/solid-router"; import type { Exam } from "@/api/types"; import { Badge } from "@/components/ui/badge"; +import { cn } from "@/lib/cn"; import { examKindLabel } from "@/lib/exam-labels"; import { examDurationMs, formatDateTime, formatDurationMinutes } from "@/lib/format"; import { usePreferences, useT } from "@/stores/preferences-context"; -export function ExamCard(props: { exam: Exam }) { +export function ExamCard(props: { exam: Exam; courseTitle?: string }) { const t = useT(); const { locale } = usePreferences(); const modeLabel = () => { @@ -14,16 +16,55 @@ export function ExamCard(props: { exam: Exam }) { return t("exams.unscheduled"); }; + const status = () => { + const now = Date.now(); + if (props.exam.ends_at != null && props.exam.ends_at < now) return "finished"; + if (props.exam.starts_at != null && props.exam.starts_at > now) return "upcoming"; + return "active"; + }; + + const statusLabel = () => { + const s = status(); + if (s === "finished") return t("exams.finished"); + if (s === "upcoming") return t("exams.upcoming"); + return t("exams.active"); + }; + + const statusClass = () => { + const s = status(); + if (s === "finished") return "bg-muted text-muted-foreground border-muted"; + if (s === "upcoming") return "bg-amber-500/15 text-amber-600 border-amber-500/30"; + return "bg-emerald-500/15 text-emerald-600 border-emerald-500/30"; + }; + + const statusDot = () => { + const s = status(); + if (s === "finished") return "bg-muted-foreground"; + if (s === "upcoming") return "bg-amber-600"; + return "bg-emerald-600"; + }; + return (
-

- {props.exam.title} -

- - {examKindLabel(String(props.exam.kind), t)} - +
+ +

{props.courseTitle}

+
+

+ {props.exam.title} +

+
+
+ + + {statusLabel()} + + + {examKindLabel(String(props.exam.kind), t)} + +

diff --git a/src/components/exams/exam-questions-panel.tsx b/src/components/exams/exam-questions-panel.tsx index 34be09c..702b3e1 100644 --- a/src/components/exams/exam-questions-panel.tsx +++ b/src/components/exams/exam-questions-panel.tsx @@ -25,7 +25,7 @@ type QuestionValues = { correct: number | null; }; -export function ExamQuestionsPanel(props: { examId: string }) { +export function ExamQuestionsPanel(props: { examId: string; readOnly?: boolean }) { const t = useT(); const [questions, { refetch }] = createResource(() => props.examId, async (examId) => { try { @@ -63,18 +63,20 @@ export function ExamQuestionsPanel(props: { examId: string }) {

{t("questions.title")}

- + + +
@@ -121,14 +123,16 @@ export function ExamQuestionsPanel(props: { examId: string }) {
-
- - -
+ +
+ + +
+
)} diff --git a/src/components/exams/exam-room-ws.tsx b/src/components/exams/exam-room-ws.tsx new file mode 100644 index 0000000..28827e8 --- /dev/null +++ b/src/components/exams/exam-room-ws.tsx @@ -0,0 +1,478 @@ +import { For, Show, Suspense, createEffect, createMemo, createSignal, onCleanup } from "solid-js"; +import { getExamAttempt } from "@/api/getExamAttempt"; +import { getExamAttemptQuestions } from "@/api/getExamAttemptQuestions"; +import { postExamAttempt } from "@/api/postExamAttempt"; +import { postExamAttemptAnswer } from "@/api/postExamAttemptAnswer"; +import { postExamAttemptFinish } from "@/api/postExamAttemptFinish"; +import { formatApiError } from "@/api/client"; +import type { AttemptQuestion, Exam, ExamAttempt } from "@/api/types"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { ConfirmDialog } from "@/components/ui/confirm-dialog"; +import { PageSpinner } from "@/components/ui/page-spinner"; +import { Textarea } from "@/components/ui/textarea"; +import { formatDateTime } from "@/lib/format"; +import { usePreferences, useT } from "@/stores/preferences-context"; + +type WsState = "connecting" | "connected" | "disconnected"; +type WsMessage = + | { type: "state"; status: string; deadline: number | null; remaining_ms: number; now: number; answered: number; question_count: number } + | { type: "saved"; question_id: string; updated_at: number } + | { type: "finished"; finished_at: number } + | { type: "expired" } + | { type: "pong" } + | { type: "error"; message: string }; + +function formatRemaining(ms: number): string { + const safe = Math.max(0, ms); + const totalSeconds = Math.floor(safe / 1000); + const hours = Math.floor(totalSeconds / 3600); + const minutes = Math.floor((totalSeconds % 3600) / 60); + const seconds = totalSeconds % 60; + return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`; +} + +export function ExamRoomWS(props: { exam: Exam }) { + const t = useT(); + const [error, setError] = createSignal(""); + const [pending, setPending] = createSignal(false); + const [finishOpen, setFinishOpen] = createSignal(false); + const [roomOpen, setRoomOpen] = createSignal(false); + const [attempt, setAttempt] = createSignal(null); + const [questions, setQuestions] = createSignal([]); + const [remainingMs, setRemainingMs] = createSignal(0); + const [wsState, setWsState] = createSignal("disconnected"); + const scheduled = createMemo(() => props.exam.mode === "sync" || props.exam.mode === "async"); + const canWrite = createMemo(() => attempt()?.status === "in_progress" && remainingMs() > 0); + + let ws: WebSocket | null = null; + + const wsUrl = () => { + const proto = window.location.protocol === "https:" ? "wss:" : "ws:"; + return `${proto}//${window.location.host}/exams/${encodeURIComponent(props.exam.id)}/attempt/ws`; + }; + + const connectWs = () => { + if (ws) ws.close(); + setWsState("connecting"); + const socket = new WebSocket(wsUrl()); + ws = socket; + + socket.onopen = () => setWsState("connected"); + socket.onclose = () => { + setWsState("disconnected"); + ws = null; + }; + socket.onerror = () => { + setWsState("disconnected"); + ws = null; + }; + + socket.onmessage = (event) => { + try { + const msg: WsMessage = JSON.parse(event.data); + handleWsMessage(msg); + } catch { + // ignore + } + }; + }; + + const handleWsMessage = (msg: WsMessage) => { + switch (msg.type) { + case "state": { + setAttempt((prev) => + prev + ? { ...prev, status: msg.status as any, deadline: msg.deadline, remaining_ms: msg.remaining_ms, answered: msg.answered, question_count: msg.question_count, now: msg.now } + : { + id: undefined, + exam: props.exam.id, + status: msg.status as any, + deadline: msg.deadline, + remaining_ms: msg.remaining_ms, + mark: null, + answered: msg.answered, + question_count: msg.question_count, + now: msg.now, + }, + ); + setRemainingMs(msg.remaining_ms); + break; + } + case "saved": { + setQuestions((prev) => + prev.map((q) => + q.id === msg.question_id + ? { ...q, answer: { ...q.answer, updated_at: msg.updated_at } } + : q, + ), + ); + break; + } + case "finished": { + setAttempt((prev) => (prev ? { ...prev, status: "submitted" as any, remaining_ms: 0 } : prev)); + setRemainingMs(0); + break; + } + case "expired": { + setAttempt((prev) => (prev ? { ...prev, status: "expired" as any, remaining_ms: 0 } : prev)); + setRemainingMs(0); + break; + } + case "pong": { + break; + } + case "error": { + setError(msg.message); + break; + } + } + }; + + const sendWs = (data: unknown) => { + if (ws && ws.readyState === WebSocket.OPEN) { + ws.send(JSON.stringify(data)); + } + }; + + const start = async () => { + setPending(true); + setError(""); + try { + const next = await postExamAttempt(props.exam.id); + setAttempt(next); + setRoomOpen(true); + const qs = await getExamAttemptQuestions(props.exam.id); + setQuestions(qs); + connectWs(); + } catch (err) { + setError(formatApiError(err)); + } finally { + setPending(false); + } + }; + + const resume = async () => { + setRoomOpen(true); + try { + const next = await getExamAttempt(props.exam.id); + setAttempt(next); + const qs = await getExamAttemptQuestions(props.exam.id); + setQuestions(qs); + connectWs(); + } catch (err) { + setError(formatApiError(err)); + } + }; + + const saveAnswer = async (question: AttemptQuestion, value: string) => { + setError(""); + if (ws && ws.readyState === WebSocket.OPEN) { + const payload: Record = { type: "answer", question_id: question.id }; + if (question.kind === "choice") { + payload.selected = Number(value); + } else { + payload.text = value; + } + sendWs(payload); + setQuestions((prev) => + prev.map((q) => (q.id === question.id ? { ...q, answer: { ...q.answer, selected: question.kind === "choice" ? Number(value) : undefined, text: question.kind === "text" ? value : undefined } } : q)), + ); + } else { + setPending(true); + try { + if (question.kind === "choice") { + await postExamAttemptAnswer(props.exam.id, { question_id: question.id, selected: Number(value) }); + } else { + await postExamAttemptAnswer(props.exam.id, { question_id: question.id, text: value }); + } + const next = await getExamAttempt(props.exam.id); + setAttempt(next); + const qs = await getExamAttemptQuestions(props.exam.id); + setQuestions(qs); + } catch (err) { + setError(formatApiError(err)); + } finally { + setPending(false); + } + } + }; + + const finish = async () => { + setPending(true); + setError(""); + try { + if (ws && ws.readyState === WebSocket.OPEN) { + sendWs({ type: "finish" }); + } else { + await postExamAttemptFinish(props.exam.id); + const next = await getExamAttempt(props.exam.id); + setAttempt(next); + } + } catch (err) { + setError(formatApiError(err)); + } finally { + setPending(false); + } + }; + + onCleanup(() => { + if (ws) ws.close(); + }); + + createEffect(() => { + const current = attempt(); + if (!current || current.status !== "in_progress" || current.remaining_ms <= 0) return; + const startedAt = Date.now(); + const initial = current.remaining_ms; + const timer = window.setInterval(() => { + setRemainingMs(Math.max(0, initial - (Date.now() - startedAt))); + }, 1000); + onCleanup(() => window.clearInterval(timer)); + }); + + return ( +
+ +
+
+

{t("attempt.title")}

+

+ {props.exam.mode === "sync" ? t("exams.mode.sync") : props.exam.mode === "async" ? t("exams.mode.async") : t("attempt.unscheduled")} +

+
+ {t("attempt.unscheduled")}}> + void start()}> + {t("attempt.start")} + + } + > + + + +
+
+ + {error() &&

{error()}

} + + }> + + {t("attempt.notStarted")}

}> + {(a) => } +
+
+ + + +

{t("attempt.closed")}

+
+
+
+ + {(question, index) => ( + saveAnswer(question, value)} + /> + )} + +
+ +
+
+
+ + +
+ ); +} + +function AttemptSummaryWS(props: { attempt: ExamAttempt; remainingMs: number; wsState: WsState }) { + const t = useT(); + const { locale } = usePreferences(); + const statusLabel = () => { + if (props.attempt.status === "in_progress") return t("attempt.inProgress"); + if (props.attempt.status === "submitted") return t("attempt.submitted"); + if (props.attempt.status === "expired") return t("attempt.expired"); + return props.attempt.status; + }; + const wsLabel = () => { + if (props.wsState === "connecting") return t("ws.connecting"); + if (props.wsState === "connected") return t("ws.connected"); + return t("ws.disconnected"); + }; + return ( +
+
+

{t("attempt.status")}

+

{statusLabel()}

+
+
+

{t("attempt.remaining")}

+

{formatRemaining(props.remainingMs)}

+
+
+

{t("attempt.progress")}

+

{props.attempt.answered} / {props.attempt.question_count}

+
+
+

{t("attempt.deadline")}

+

{formatDateTime(props.attempt.deadline, locale())}

+
+
+

{t("attempt.serverNow")}

+

{formatDateTime(props.attempt.now, locale())}

+
+
+

{t("ws.ping")}

+

{wsLabel()}

+
+ +
+

{t("attempt.mark")}

+

{props.attempt.mark}

+
+
+
+ ); +} + +function QuestionAnswerCardWS(props: { + index: number; + nextQuestionId?: string; + question: AttemptQuestion; + disabled: boolean; + onSave: (value: string) => Promise; +}) { + const t = useT(); + const { locale } = usePreferences(); + const [value, setValue] = createSignal( + props.question.kind === "choice" + ? props.question.answer?.selected != null + ? String(props.question.answer.selected) + : "" + : props.question.answer?.text ?? "", + ); + const [saved, setSaved] = createSignal(false); + + createEffect(() => { + setValue( + props.question.kind === "choice" + ? props.question.answer?.selected != null + ? String(props.question.answer.selected) + : "" + : props.question.answer?.text ?? "", + ); + setSaved(false); + }); + + const save = async () => { + await props.onSave(value()); + setSaved(true); + if (props.nextQuestionId) { + document.getElementById(`question-${props.nextQuestionId}`)?.scrollIntoView({ behavior: "smooth", block: "start" }); + } + }; + + return ( +
+
+ #{props.index} + {props.question.points} {t("questions.points")} + + {t("attempt.saved")} + + + {(updatedAt) => {t("attempt.savedAt")}: {formatDateTime(updatedAt(), locale())}} + +
+

{props.question.text}

+ { + setSaved(false); + setValue(e.currentTarget.value); + }} + /> + } + > +
+ + {(choice, choiceIndex) => ( + + )} + +
+
+ +
+ ); +} diff --git a/src/components/layout/user-menu.tsx b/src/components/layout/user-menu.tsx index 31d0a06..a031254 100644 --- a/src/components/layout/user-menu.tsx +++ b/src/components/layout/user-menu.tsx @@ -12,7 +12,7 @@ import { DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { IconGlobe, IconLogout, IconMoon, IconSun } from "@/components/ui/icons"; +import { IconEdit, IconGlobe, IconLogout, IconMoon, IconSun } from "@/components/ui/icons"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; import { cn } from "@/lib/cn"; @@ -164,6 +164,13 @@ export function UserMenu() { + void navigate({ to: "/profile" })}> + + {t("profile.edit")} + + + + void onLogout()}> {t("nav.logout")} diff --git a/src/components/users/profile-form.tsx b/src/components/users/profile-form.tsx new file mode 100644 index 0000000..9ac00f2 --- /dev/null +++ b/src/components/users/profile-form.tsx @@ -0,0 +1,104 @@ +import { createSignal } from "solid-js"; +import { patchMe } from "@/api/patchMe"; +import type { ProfileUpdate, User } from "@/api/types"; +import { formatApiError } from "@/api/client"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { useT } from "@/stores/preferences-context"; + +const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; +const PHONE_RE = /^\+?[\d\s().-]{7,20}$/; +const DATE_RE = /^\d{4}-\d{2}-\d{2}$/; + +function isFutureDate(iso: string) { + const d = new Date(`${iso}T00:00:00Z`); + if (Number.isNaN(d.getTime())) return true; + const tomorrow = new Date(); + tomorrow.setUTCDate(tomorrow.getUTCDate() + 1); + tomorrow.setUTCHours(0, 0, 0, 0); + return d.getTime() > tomorrow.getTime(); +} + +export function ProfileForm(props: { user: User; onSaved: () => void }) { + const t = useT(); + const [name, setName] = createSignal(props.user.name ?? ""); + const [surname, setSurname] = createSignal(props.user.surname ?? ""); + const [email, setEmail] = createSignal(props.user.email ?? ""); + const [phone, setPhone] = createSignal(props.user.phone ?? ""); + const [birthDate, setBirthDate] = createSignal(props.user.birth_date ?? ""); + const [error, setError] = createSignal(""); + const [pending, setPending] = createSignal(false); + + const validate = (): string | null => { + const e = email().trim(); + const p = phone().trim(); + const b = birthDate().trim(); + if (e && !EMAIL_RE.test(e)) return t("profile.emailInvalid"); + if (p && !PHONE_RE.test(p)) return t("profile.phoneInvalid"); + if (b && (!DATE_RE.test(b) || isFutureDate(b))) return t("profile.dateInvalid"); + return null; + }; + + const buildBody = (): ProfileUpdate => { + const b: ProfileUpdate = {}; + const n = name().trim(); + const s = surname().trim(); + const e = email().trim(); + const p = phone().trim(); + const d = birthDate().trim(); + if (n !== (props.user.name ?? "")) b.name = n || null; + if (s !== (props.user.surname ?? "")) b.surname = s || null; + if (e !== (props.user.email ?? "")) b.email = e || null; + if (p !== (props.user.phone ?? "")) b.phone = p || null; + if (d !== (props.user.birth_date ?? "")) b.birth_date = d || null; + return b; + }; + + const submit = async (e: Event) => { + e.preventDefault(); + setError(""); + const msg = validate(); + if (msg) { setError(msg); return; } + const body = buildBody(); + if (Object.keys(body).length === 0) { props.onSaved(); return; } + setPending(true); + try { + await patchMe(body); + props.onSaved(); + } catch (err) { + setError(formatApiError(err)); + } finally { + setPending(false); + } + }; + + return ( +
+
+
+ + setName(e.currentTarget.value)} /> +
+
+ + setSurname(e.currentTarget.value)} /> +
+
+
+ + setEmail(e.currentTarget.value)} /> +
+
+ + setPhone(e.currentTarget.value)} /> +
+
+ + setBirthDate(e.currentTarget.value)} /> +
+ {error() &&

{error()}

} + +
+ ); +} diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 7313339..44c4f5d 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -291,7 +291,50 @@ export type MessageKey = | "marks.exam" | "marks.weight" | "marks.mark" - | "exams.mustBelongCourse"; + | "exams.mustBelongCourse" + | "exams.statistics" + | "exams.graded" + | "exams.average" + | "exams.min" + | "exams.max" + | "exams.finished" + | "exams.active" + | "exams.upcoming" + | "exams.liveMonitor" + | "exams.liveMonitorDesc" + | "exams.finalState" + | "exams.finalStateDesc" + | "exams.liveRoster" + | "exams.notStarted" + | "exams.lastActivity" + | "exams.answerSheet" + | "exams.autoScore" + | "exams.earned" + | "exams.possible" + | "exams.isCorrect" + | "exams.textAnswer" + | "exams.nameless" + | "exams.emptyRoster" + | "exams.selectStudent" + | "exams.viewSheet" + | "profile.title" + | "profile.subtitle" + | "profile.name" + | "profile.surname" + | "profile.email" + | "profile.phone" + | "profile.birthDate" + | "profile.edit" + | "profile.saved" + | "profile.emailInvalid" + | "profile.phoneInvalid" + | "profile.dateInvalid" + | "profile.clearField" + | "ws.connecting" + | "ws.connected" + | "ws.disconnected" + | "ws.error" + | "ws.ping"; type Dict = Record; @@ -601,6 +644,49 @@ const en: Dict = { "marks.weight": "Weight", "marks.mark": "Mark", "exams.mustBelongCourse": "Exams are created under a course. Open a course to add one.", + "exams.statistics": "Statistics", + "exams.graded": "Graded", + "exams.average": "Average", + "exams.min": "Min", + "exams.max": "Max", + "exams.finished": "Finished", + "exams.active": "Active", + "exams.upcoming": "Upcoming", + "exams.liveMonitor": "Live Monitor", + "exams.liveMonitorDesc": "Real-time exam roster, progress, and marks.", + "exams.finalState": "Final State", + "exams.finalStateDesc": "Final exam results, progress, and marks.", + "exams.liveRoster": "Live Roster", + "exams.notStarted": "Not started", + "exams.lastActivity": "Last activity", + "exams.answerSheet": "Answer Sheet", + "exams.autoScore": "Auto-score", + "exams.earned": "Earned", + "exams.possible": "Possible", + "exams.isCorrect": "Correct", + "exams.textAnswer": "Text answer", + "exams.nameless": "Unnamed", + "exams.emptyRoster": "No enrolled students yet.", + "exams.selectStudent": "Select a student from the roster", + "exams.viewSheet": "View answers", + "profile.title": "My Profile", + "profile.subtitle": "Personal information (optional).", + "profile.name": "Name", + "profile.surname": "Surname", + "profile.email": "Email", + "profile.phone": "Phone", + "profile.birthDate": "Birth date", + "profile.edit": "Edit profile", + "profile.saved": "Profile saved", + "profile.emailInvalid": "Enter a valid email address (e.g. name@example.com)", + "profile.phoneInvalid": "Enter a valid phone number (7-15 digits, optional +)", + "profile.dateInvalid": "Enter a real YYYY-MM-DD date, not in the future", + "profile.clearField": "Clear", + "ws.connecting": "Connecting…", + "ws.connected": "Connected", + "ws.disconnected": "Disconnected", + "ws.error": "Connection error", + "ws.ping": "Ping", }; const tr: Dict = { @@ -909,6 +995,49 @@ const tr: Dict = { "marks.weight": "Ağırlık", "marks.mark": "Not", "exams.mustBelongCourse": "Sınavlar ders altında oluşturulur. Eklemek için bir ders aç.", + "exams.statistics": "İstatistikler", + "exams.graded": "Notlanan", + "exams.average": "Ortalama", + "exams.min": "En düşük", + "exams.max": "En yüksek", + "exams.finished": "Bitti", + "exams.active": "Aktif", + "exams.upcoming": "Yakında", + "exams.liveMonitor": "Canlı İzleme", + "exams.liveMonitorDesc": "Sınav durumu, ilerleme ve notlar gerçek zamanlı.", + "exams.finalState": "Son Durum", + "exams.finalStateDesc": "Sınav sonuçları, ilerleme ve notlar.", + "exams.liveRoster": "Canlı Liste", + "exams.notStarted": "Başlamadı", + "exams.lastActivity": "Son hareket", + "exams.answerSheet": "Cevap Kâğıdı", + "exams.autoScore": "Otomatik puan", + "exams.earned": "Alınan", + "exams.possible": "Mümkün", + "exams.isCorrect": "Doğru", + "exams.textAnswer": "Metin cevap", + "exams.nameless": "İsimsiz", + "exams.emptyRoster": "Henüz kayıtlı öğrenci yok.", + "exams.selectStudent": "Listeden bir öğrenci seç", + "exams.viewSheet": "Cevapları gör", + "profile.title": "Profilim", + "profile.subtitle": "Kişisel bilgiler (isteğe bağlı).", + "profile.name": "Ad", + "profile.surname": "Soyad", + "profile.email": "E-posta", + "profile.phone": "Telefon", + "profile.birthDate": "Doğum tarihi", + "profile.edit": "Profili düzenle", + "profile.saved": "Profil kaydedildi", + "profile.emailInvalid": "Geçerli bir e-posta adresi girin (örn. ad@ornek.com)", + "profile.phoneInvalid": "Geçerli bir telefon numarası girin (7-15 hane, isteğe bağlı +)", + "profile.dateInvalid": "Geçerli bir YYYY-AA-GG tarihi girin, gelecekte olmasın", + "profile.clearField": "Temizle", + "ws.connecting": "Bağlanıyor…", + "ws.connected": "Bağlı", + "ws.disconnected": "Bağlantı kesildi", + "ws.error": "Bağlantı hatası", + "ws.ping": "Ping", }; export const messages: Record = { en, tr }; diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index a216e41..c9c67a7 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -5,12 +5,14 @@ import { deleteExamResultByUserId } from "@/api/deleteExamResultByUserId"; import { getExamById } from "@/api/getExamById"; import { getExamResult } from "@/api/getExamResult"; import { getExamResults } from "@/api/getExamResults"; +import { getExamStatistics } from "@/api/getExamStatistics"; import { getCourseEnrollments } from "@/api/getCourseEnrollments"; import { patchExamById } from "@/api/patchExamById"; import { postExamResult } from "@/api/postExamResult"; import { ApiError, formatApiError } from "@/api/client"; import { ExamForm } from "@/components/exams/exam-form"; import { ExamQuestionsPanel } from "@/components/exams/exam-questions-panel"; +import { AnswerSheetView } from "@/components/exams/answer-sheet-view"; import { ExamResultBadge } from "@/components/exams/exam-result-badge"; import { GradeForm } from "@/components/exams/grade-form"; import { RouteGuard } from "@/components/layout/route-guard"; @@ -19,7 +21,7 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; -import { IconChevronLeft, IconEdit, IconExam, IconTrash } from "@/components/ui/icons"; +import { IconChevronLeft, IconEdit, IconExam, IconEye, IconTrash } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; import { Table, @@ -32,6 +34,7 @@ import { import { hasMinRole } from "@/lib/roles"; import { examKindLabel } from "@/lib/exam-labels"; import { examDurationMs, formatDateTime, formatDurationMinutes } from "@/lib/format"; +import { cn } from "@/lib/cn"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -74,6 +77,17 @@ function ExamDetailContent() { return getExamResults(examId); }, ); + const [stats] = createResource( + () => (isTeacherPlus() ? id() : null), + async (examId) => { + if (!examId) return null; + try { + return await getExamStatistics(examId); + } catch { + return null; + } + }, + ); const [roster] = createResource( () => (isTeacherPlus() ? exam()?.course ?? null : null), async (courseId) => (courseId ? getCourseEnrollments(courseId) : []), @@ -84,11 +98,24 @@ function ExamDetailContent() { const [pending, setPending] = createSignal(false); const [deleteOpen, setDeleteOpen] = createSignal(false); const [removeUserId, setRemoveUserId] = createSignal(null); + const [sheetUserId, setSheetUserId] = createSignal(null); + + const examStatus = () => { + const e = exam(); + if (!e) return { finished: false, upcoming: false }; + const now = Date.now(); + const finished = e.ends_at != null && e.ends_at < now; + const upcoming = e.starts_at != null && e.starts_at > now; + return { finished, upcoming }; + }; + const isFinished = () => examStatus().finished; + const isUpcoming = () => examStatus().upcoming; const canManage = () => { const e = exam(); const u = auth.user(); if (!e || !u) return false; + if (isFinished()) return false; return e.creator === u.id || hasMinRole(u.role, "manager"); }; @@ -147,7 +174,7 @@ function ExamDetailContent() { {t("common.back")} - + + + + + +
+ + + + + )} diff --git a/src/pages/exam-room-page.tsx b/src/pages/exam-room-page.tsx index ec82e78..06e629b 100644 --- a/src/pages/exam-room-page.tsx +++ b/src/pages/exam-room-page.tsx @@ -2,7 +2,7 @@ import { Link, useLocation } from "@tanstack/solid-router"; import { Show, Suspense, createResource } from "solid-js"; import { getExamById } from "@/api/getExamById"; import { ApiError } from "@/api/client"; -import { StudentExamRoom } from "@/components/exams/student-exam-room"; +import { ExamRoomWS } from "@/components/exams/exam-room-ws"; import { RouteGuard } from "@/components/layout/route-guard"; import { PageHeader } from "@/components/layout/page-header"; import { Alert } from "@/components/ui/alert"; @@ -56,7 +56,7 @@ function ExamRoomContent() {
} /> - + )}
diff --git a/src/pages/exams-page.tsx b/src/pages/exams-page.tsx index 005b942..c9bdf7c 100644 --- a/src/pages/exams-page.tsx +++ b/src/pages/exams-page.tsx @@ -1,12 +1,16 @@ -import { For, Show, Suspense, createResource } from "solid-js"; +import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; import { Link } from "@tanstack/solid-router"; +import { getCourses } from "@/api/getCourses"; import { getExams } from "@/api/getExams"; import { ExamCard } from "@/components/exams/exam-card"; import { RouteGuard } from "@/components/layout/route-guard"; import { PageHeader } from "@/components/layout/page-header"; import { CollapsibleHelp } from "@/components/ui/collapsible-help"; +import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; +import { IconChevronRight } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; +import { cn } from "@/lib/cn"; import { useAuth } from "@/stores/auth-context"; import { useT } from "@/stores/preferences-context"; import { hasMinRole } from "@/lib/roles"; @@ -23,8 +27,28 @@ function ExamsContent() { const auth = useAuth(); const t = useT(); const [exams] = createResource(() => getExams()); + const [courses] = createResource(() => getCourses()); + const [openCourse, setOpenCourse] = createSignal(null); const canCreate = () => hasMinRole(auth.user()?.role, "teacher"); + const courseSections = createMemo(() => { + const all = exams(); + if (!all) return []; + const grouped = new Map(); + for (const exam of all) { + const cid = exam.course; + if (!grouped.has(cid)) grouped.set(cid, []); + grouped.get(cid)!.push(exam); + } + return (courses() ?? []) + .filter((c) => (grouped.get(c.id)?.length ?? 0) > 0) + .map((c) => ({ id: c.id, title: c.title, exams: grouped.get(c.id)! })); + }); + + const toggleCourse = (id: string) => { + setOpenCourse((prev) => (prev === id ? null : id)); + }; + return (
} > -
    - - {(exam) => ( -
  • - -
  • - )} +
    + + {(section) => { + const isOpen = () => openCourse() === section.id; + return ( +
    + + +
    +
      + + {(exam) => ( +
    • + +
    • + )} +
      +
    +
    +
    +
    + ); + }}
    -
+
)} diff --git a/src/pages/live-monitor-page.tsx b/src/pages/live-monitor-page.tsx new file mode 100644 index 0000000..54dd0f5 --- /dev/null +++ b/src/pages/live-monitor-page.tsx @@ -0,0 +1,281 @@ +import { For, Show, Suspense, createEffect, createResource, createSignal, onCleanup } from "solid-js"; +import { Link, useLocation } from "@tanstack/solid-router"; +import { getExamLive } from "@/api/getExamLive"; +import { getExamById } from "@/api/getExamById"; +import { ApiError } from "@/api/client"; +import type { LiveMonitor, LiveRosterEntry } from "@/api/types"; +import type { MessageKey } from "@/i18n/messages"; +import { RouteGuard } from "@/components/layout/route-guard"; +import { PageHeader } from "@/components/layout/page-header"; +import { Alert } from "@/components/ui/alert"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons"; +import { PageSpinner } from "@/components/ui/page-spinner"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { usePreferences, useT } from "@/stores/preferences-context"; +import { formatDateTime } from "@/lib/format"; +import { cn } from "@/lib/cn"; + +type SortKey = "username" | "status" | "progress" | "remaining" | "activity" | "mark"; + +const PAGE_SIZE = 10; + +export default function LiveMonitorPage() { + return ( + + + + ); +} + +const STATUS_KEY: Record = { + not_started: "exams.notStarted", + in_progress: "attempt.inProgress", + submitted: "attempt.submitted", + expired: "attempt.expired", +}; + +function labelFromStatus(status: string, t: (key: MessageKey) => string): string { + const k = STATUS_KEY[status]; + return k ? t(k) : status; +} + +function LiveMonitorContent() { + const location = useLocation(); + const t = useT(); + const { locale } = usePreferences(); + const id = () => decodeURIComponent(location().pathname.split("/")[2] ?? ""); + + const [exam] = createResource(id, (eid) => getExamById(eid)); + const [snapshot, setSnapshot] = createSignal(null); + const [error, setError] = createSignal(""); + const [sortKey, setSortKey] = createSignal("status"); + const [sortDir, setSortDir] = createSignal<"asc" | "desc">("asc"); + const [page, setPage] = createSignal(0); + + const isFinished = () => { + const e = exam(); + if (!e || e.ends_at == null) return false; + return e.ends_at < Date.now(); + }; + + const fetchSnapshot = async () => { + try { + const data = await getExamLive(id()); + setSnapshot(data); + } catch (err) { + console.error("[live-monitor] fetch error:", err); + setError(err instanceof ApiError ? err.message : "Failed to load"); + } + }; + + createEffect(() => { + const eid = id(); + if (!eid) return; + void fetchSnapshot(); + if (isFinished()) return; + const interval = setInterval(fetchSnapshot, 2000); + onCleanup(() => clearInterval(interval)); + }); + + const toggleSort = (key: SortKey) => { + setPage(0); + if (sortKey() === key) { + setSortDir((d) => (d === "asc" ? "desc" : "asc")); + } else { + setSortKey(key); + setSortDir("asc"); + } + }; + + const sortFn = (a: LiveRosterEntry, b: LiveRosterEntry) => { + const d = sortDir(); + const cmp = (() => { + const k = sortKey(); + if (k === "username") return (a.display_name || a.username || "").localeCompare(b.display_name || b.username || ""); + if (k === "status") return labelFromStatus(a.status, t).localeCompare(labelFromStatus(b.status, t)); + if (k === "progress") return (a.answered ?? 0) - (b.answered ?? 0); + if (k === "remaining") return (a.remaining_ms ?? 0) - (b.remaining_ms ?? 0); + if (k === "activity") return (a.last_activity ?? 0) - (b.last_activity ?? 0); + if (k === "mark") return (a.mark ?? -1) - (b.mark ?? -1); + return 0; + })(); + return d === "asc" ? cmp : -cmp; + }; + + return ( + }> +
+ + {(ex) => ( + + + + +
+ } + /> + )} + + + {error() && {error()}} + + + {(s) => { + const m = s(); + if (!m) return null; + const counts = m.counts ?? { not_started: 0, in_progress: 0, submitted: 0, expired: 0 }; + const raw = Array.isArray(m.students) ? m.students : []; + const sorted = [...raw].sort(sortFn); + const totalPages = Math.max(1, Math.ceil(sorted.length / PAGE_SIZE)); + const safePage = Math.min(page(), totalPages - 1); + const pageItems = sorted.slice(safePage * PAGE_SIZE, (safePage + 1) * PAGE_SIZE); + + return ( + <> +
+
+

{t("exams.notStarted")}

+

{counts.not_started}

+
+
+

{t("attempt.inProgress")}

+

{counts.in_progress}

+
+
+

{t("attempt.submitted")}

+

{counts.submitted}

+
+
+

{t("attempt.expired")}

+

{counts.expired}

+
+
+ +
+

{t("exams.liveRoster")}

+ 0} + fallback={

{t("exams.emptyRoster")}

} + > + + + + + + + + + + + + + + {(entry) => ( + + + {entry.display_name || entry.username || t("exams.nameless")} + + + + {labelFromStatus(entry.status, t)} + + + {entry.answered}/{m.question_count} + + {entry.status === "in_progress" && entry.remaining_ms > 0 + ? `${Math.ceil(entry.remaining_ms / 60000)}dk` + : entry.status === "in_progress" && entry.remaining_ms <= 0 + ? `<1dk` + : "—"} + + + {entry.last_activity ? formatDateTime(entry.last_activity, locale()) : "—"} + + + {entry.mark != null ? entry.mark : "—"} + + + )} + + +
+ + PAGE_SIZE}> +
+ + + {t("common.pageOf", { page: safePage + 1, total: totalPages })} + + +
+
+
+
+ + ); + }} +
+ +
+ ); +} + +function SortHead(props: { + label: string; + sortKey: SortKey; + currentKey: SortKey; + currentDir: "asc" | "desc"; + onSort: (key: SortKey) => void; + class?: string; +}) { + const active = () => props.sortKey === props.currentKey; + return ( + props.onSort(props.sortKey)} + > + + {props.label} + + {props.currentDir === "asc" ? "▲" : "▼"} + + + + ); +} diff --git a/src/pages/profile-page.tsx b/src/pages/profile-page.tsx new file mode 100644 index 0000000..a7aa344 --- /dev/null +++ b/src/pages/profile-page.tsx @@ -0,0 +1,78 @@ +import { Show, Suspense } from "solid-js"; +import { useNavigate } from "@tanstack/solid-router"; +import { ProfileForm } from "@/components/users/profile-form"; +import { RouteGuard } from "@/components/layout/route-guard"; +import { PageHeader } from "@/components/layout/page-header"; +import { PageSpinner } from "@/components/ui/page-spinner"; +import { useAuth } from "@/stores/auth-context"; +import { useT } from "@/stores/preferences-context"; + +export default function ProfilePage() { + return ( + + + + ); +} + +function ProfileContent() { + const auth = useAuth(); + const t = useT(); + const navigate = useNavigate(); + + return ( + }> + + {(u) => ( +
+ + +
+
+

{t("profile.edit")}

+ { + await auth.refresh(); + void navigate({ to: "/" }); + }} + /> +
+ +
+

{t("nav.account")}

+
+
+

{t("profile.name")}

+

{u().name || "—"}

+
+
+

{t("profile.surname")}

+

{u().surname || "—"}

+
+
+

{t("profile.email")}

+

{u().email || "—"}

+
+
+

{t("profile.phone")}

+

{u().phone || "—"}

+
+
+

{t("profile.birthDate")}

+

{u().birth_date || "—"}

+
+
+
+
+
+ )} +
+
+ ); +} diff --git a/src/routes/router.tsx b/src/routes/router.tsx index a1ebb36..9d1e552 100644 --- a/src/routes/router.tsx +++ b/src/routes/router.tsx @@ -31,6 +31,8 @@ const ExamRoomPage = lazyRoute(() => import("@/pages/exam-room-page")); const CoursesPage = lazyRoute(() => import("@/pages/courses-page")); const CourseDetailPage = lazyRoute(() => import("@/pages/course-detail-page")); const MarksPage = lazyRoute(() => import("@/pages/marks-page")); +const ProfilePage = lazyRoute(() => import("@/pages/profile-page")); +const LiveMonitorPage = lazyRoute(() => import("@/pages/live-monitor-page")); const AdminUsersPage = lazyRoute(() => import("@/pages/admin-users-page")); const GuidePage = lazyRoute(() => import("@/pages/guide-page")); @@ -126,6 +128,18 @@ const marksRoute = createRoute({ component: MarksPage, }); +const liveMonitorRoute = createRoute({ + getParentRoute: () => rootRoute, + path: "/exams/$id/live", + component: LiveMonitorPage, +}); + +const profileRoute = createRoute({ + getParentRoute: () => rootRoute, + path: "/profile", + component: ProfilePage, +}); + const adminUsersRoute = createRoute({ getParentRoute: () => rootRoute, path: "/admin/users", @@ -147,10 +161,12 @@ const routeTree = rootRoute.addChildren([ eventDetailRoute, examDetailRoute, examRoomRoute, + liveMonitorRoute, examsRoute, coursesRoute, courseDetailRoute, marksRoute, + profileRoute, adminUsersRoute, guideRoute, ]); diff --git a/vite.config.ts b/vite.config.ts index 20c4562..4834faf 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,7 +13,7 @@ export default defineConfig({ }, server: { proxy: Object.fromEntries( - ["/auth", "/users", "/notes", "/events", "/exams", "/courses", "/marks", "/health"].map((p) => [ + ["/auth", "/users", "/notes", "/events", "/exams", "/courses", "/marks", "/health", "/time"].map((p) => [ p, { target, changeOrigin: true }, ]),