From 267d95ddf461b1033558ff890c4916aac3acae10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 15 Jul 2026 17:18:51 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20align=20with=20backend=20st?= =?UTF-8?q?udent-only=20gates=20-=20client:=20EN/TR=20error=20strings=20fo?= =?UTF-8?q?r=20new=20400/403=20messages=20(enroll/grade/roll-call=20target?= =?UTF-8?q?s,=20exam=20sit=20incl.=20exam-room=20WS=20frame)=20-=20exam-de?= =?UTF-8?q?tail:=20own-result=20fetch=20+=20section=20gate=20on=20isStuden?= =?UTF-8?q?t(),=20drop=20unused=20isTeacherPlus=20memo=20-=20docs:=20guard?= =?UTF-8?q?=20table=20isStudent()=20+=20student-filtered=20picker=20rows,?= =?UTF-8?q?=20next-steps=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/frontend-next-steps.md | 1 + docs/role-scope-matrix.md | 3 ++- src/api/client.ts | 16 ++++++++++++++++ src/pages/exam-detail-page.tsx | 5 ++--- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/frontend-next-steps.md b/docs/frontend-next-steps.md index 9cb22cc..9fd6607 100644 --- a/docs/frontend-next-steps.md +++ b/docs/frontend-next-steps.md @@ -65,6 +65,7 @@ validation, and list filtering cleanup. | Session edit | `patchSessionById` + edit SidePanel in course sessions | | Manager work log | `/management/staff-work` + get/patch/delete work APIs | | Work route guard | `beforeLoad` teacher+ on `/work` | +| BE student-only gates (enroll/sit/grade/roll call) | Localized error strings for the new 400/403 messages; student-marks lookup picker filters `role=student`; exam-detail own-result gates on `isStudent()` | ### Incomplete Product Features diff --git a/docs/role-scope-matrix.md b/docs/role-scope-matrix.md index 2de4f67..19ffcc8 100644 --- a/docs/role-scope-matrix.md +++ b/docs/role-scope-matrix.md @@ -103,7 +103,8 @@ | `RouteGuard exactRole` | `/marks` | Student-only page (FE presentation; BE allows the own-data read) | | `RouteGuard minRole` | Management pages | Teacher+ or manager+ | | `beforeLoad` redirect (router) | Route definition | Redirects before page JS loads | -| `!isTeacherPlus()` | In-page logic | Exam room CTA, event self-mark | +| `isStudent()` | In-page logic | Exam room CTA, own-result section on exam detail | +| `UserSearchSelect role="student"` | Enroll picker, student-marks lookup | Offers only students — matches the BE student-only walls | | `canManage()` / `hasCourseManagementRights()` | Detail pages | Course action visibility | | `canCreate` | List pages | Create button visibility | | Nav `exactRole` | Sidebar items | Student-only nav links | diff --git a/src/api/client.ts b/src/api/client.ts index 0b9806c..3ac3d75 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -73,6 +73,22 @@ const API_ERROR_MESSAGES: Record> = { en: "This attempt is closed. Answers are read-only.", tr: "Bu oturum kapalı. Cevaplar salt okunur.", }, + "only students can sit exams": { + en: "Only students can take exams.", + tr: "Sınava yalnızca öğrenciler girebilir.", + }, + "user_id: only students can be enrolled in a course": { + en: "Only students can be enrolled in a course.", + tr: "Derse yalnızca öğrenciler kaydedilebilir.", + }, + "user_id: only students can be graded": { + en: "Only students can be graded.", + tr: "Yalnızca öğrencilere not verilebilir.", + }, + "user_id: only students can be marked present in a lesson": { + en: "Only students can be marked on a lesson roll call.", + tr: "Ders yoklamasında yalnızca öğrenciler işaretlenebilir.", + }, }; function currentLocale(): Locale { diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index 9fa2b90..59ebce3 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -70,7 +70,6 @@ function ExamDetailContent() { const [exam, { refetch: refetchExam }] = createResource(id, (examId) => getExamById(examId)); const [settings] = createResource(() => getSettings()); - const isTeacherPlus = createMemo(() => hasMinRole(auth.user()?.role, "teacher")); const isStudent = createMemo(() => auth.user()?.role === "student"); const hasCourseManagementRights = () => { @@ -97,7 +96,7 @@ function ExamDetailContent() { }); const [ownResult] = createResource( - () => (!isTeacherPlus() ? id() : null), + () => (isStudent() ? id() : null), async (examId) => { if (!examId) return null; try { @@ -361,7 +360,7 @@ function ExamDetailContent() { - + toggleSection("ownResult")}