✨ align with backend student-only gates - client: EN/TR error strings for new 400/403 messages (enroll/grade/roll-call targets, exam sit incl. exam-room WS frame) - exam-detail: own-result fetch + section gate on isStudent(), drop unused isTeacherPlus memo - docs: guard table isStudent() + student-filtered picker rows, next-steps entry
Browse files at this commit267d95ddf461b1033558ff890c4916aac3acae10Parent: 6097c05- feat
- ✨ align with backend student-only gates - client: EN/TR error strings for new 400/403 messages (enroll/grade/roll-call targets, exam sit incl. exam-room WS frame) - exam-detail: own-result fetch + section gate on isStudent(), drop unused isTeacherPlus memo - docs: guard table isStudent() + student-filtered picker rows, next-steps entry
4 changed files +21 -4
- docs/frontend-next-steps.md +1 -0
- docs/role-scope-matrix.md +2 -1
- src/api/client.ts +16 -0
- src/pages/exam-detail-page.tsx +2 -3
docs/frontend-next-steps.mdmodified+1 -0
| @@ -65,6 +65,7 @@ validation, and list filtering cleanup. | ||
| 65 | 65 | | Session edit | `patchSessionById` + edit SidePanel in course sessions | |
| 66 | 66 | | Manager work log | `/management/staff-work` + get/patch/delete work APIs | |
| 67 | 67 | | Work route guard | `beforeLoad` teacher+ on `/work` | |
| 68 | +| 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()` | | |
| 68 | 69 | |
| 69 | 70 | ### Incomplete Product Features |
| 70 | 71 |
docs/role-scope-matrix.mdmodified+2 -1
| @@ -103,7 +103,8 @@ | ||
| 103 | 103 | | `RouteGuard exactRole` | `/marks` | Student-only page (FE presentation; BE allows the own-data read) | |
| 104 | 104 | | `RouteGuard minRole` | Management pages | Teacher+ or manager+ | |
| 105 | 105 | | `beforeLoad` redirect (router) | Route definition | Redirects before page JS loads | |
| 106 | -| `!isTeacherPlus()` | In-page logic | Exam room CTA, event self-mark | | |
| 106 | +| `isStudent()` | In-page logic | Exam room CTA, own-result section on exam detail | | |
| 107 | +| `UserSearchSelect role="student"` | Enroll picker, student-marks lookup | Offers only students — matches the BE student-only walls | | |
| 107 | 108 | | `canManage()` / `hasCourseManagementRights()` | Detail pages | Course action visibility | |
| 108 | 109 | | `canCreate` | List pages | Create button visibility | |
| 109 | 110 | | Nav `exactRole` | Sidebar items | Student-only nav links | |
src/api/client.tsmodified+16 -0
| @@ -73,6 +73,22 @@ const API_ERROR_MESSAGES: Record<string, Record<Locale, string>> = { | ||
| 73 | 73 | en: "This attempt is closed. Answers are read-only.", |
| 74 | 74 | tr: "Bu oturum kapalı. Cevaplar salt okunur.", |
| 75 | 75 | }, |
| 76 | + "only students can sit exams": { | |
| 77 | + en: "Only students can take exams.", | |
| 78 | + tr: "Sınava yalnızca öğrenciler girebilir.", | |
| 79 | + }, | |
| 80 | + "user_id: only students can be enrolled in a course": { | |
| 81 | + en: "Only students can be enrolled in a course.", | |
| 82 | + tr: "Derse yalnızca öğrenciler kaydedilebilir.", | |
| 83 | + }, | |
| 84 | + "user_id: only students can be graded": { | |
| 85 | + en: "Only students can be graded.", | |
| 86 | + tr: "Yalnızca öğrencilere not verilebilir.", | |
| 87 | + }, | |
| 88 | + "user_id: only students can be marked present in a lesson": { | |
| 89 | + en: "Only students can be marked on a lesson roll call.", | |
| 90 | + tr: "Ders yoklamasında yalnızca öğrenciler işaretlenebilir.", | |
| 91 | + }, | |
| 76 | 92 | }; |
| 77 | 93 | |
| 78 | 94 | function currentLocale(): Locale { |
src/pages/exam-detail-page.tsxmodified+2 -3
| @@ -70,7 +70,6 @@ function ExamDetailContent() { | ||
| 70 | 70 | |
| 71 | 71 | const [exam, { refetch: refetchExam }] = createResource(id, (examId) => getExamById(examId)); |
| 72 | 72 | const [settings] = createResource(() => getSettings()); |
| 73 | - const isTeacherPlus = createMemo(() => hasMinRole(auth.user()?.role, "teacher")); | |
| 74 | 73 | const isStudent = createMemo(() => auth.user()?.role === "student"); |
| 75 | 74 | |
| 76 | 75 | const hasCourseManagementRights = () => { |
| @@ -97,7 +96,7 @@ function ExamDetailContent() { | ||
| 97 | 96 | }); |
| 98 | 97 | |
| 99 | 98 | const [ownResult] = createResource( |
| 100 | - () => (!isTeacherPlus() ? id() : null), | |
| 99 | + () => (isStudent() ? id() : null), | |
| 101 | 100 | async (examId) => { |
| 102 | 101 | if (!examId) return null; |
| 103 | 102 | try { |
| @@ -361,7 +360,7 @@ function ExamDetailContent() { | ||
| 361 | 360 | </div> |
| 362 | 361 | </SectionDisclosure> |
| 363 | 362 | |
| 364 | - <Show when={!isTeacherPlus() && !isScheduled()}> | |
| 363 | + <Show when={isStudent() && !isScheduled()}> | |
| 365 | 364 | <SectionDisclosure |
| 366 | 365 | open={openSections().ownResult} |
| 367 | 366 | onToggle={() => toggleSection("ownResult")} |