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")}