forge
Explore
Log in

Don't you dare go Hollow

✨ add backend UI alignment plan

Browse files at this commit

bb43cead09a5441a976591199f40a6485e6aa188Burak BoduroğluParent: a0a38de
  • feat
    • ✨ add backend UI alignment plan
Show full message
feat: ✨ add backend UI alignment plan
- document remaining backend features for frontend support
- outline product principles and commit workflow
- specify UI changes and verification steps for upcoming commits
docs/backend-ui-alignment-plan.mdadded+484 -0
@@ -0,0 +1,484 @@
1+# Backend UI Alignment Plan
2+
3+## Context
4+
5+Backend README describes a broader contract than the current frontend supports. The frontend already completed these commits:
6+
7+- `3f49c18 fix: move exam weights to exam kinds`
8+- `a0a38de feat: align exams with school settings`
9+
10+Current frontend now supports:
11+
12+- `GET /settings` read path.
13+- Dynamic exam kind picker from settings.
14+- Dynamic event attendance status picker from settings.
15+- `open` exam mode in exam form, cards, detail, and room entry.
16+- Retake checkbox with `max_attempts`.
17+- Async duration derived from exam window.
18+- Open exams untimed by default.
19+
20+This plan covers the remaining backend features that need simple, low-complexity UI support.
21+
22+## Product Principles
23+
24+- Keep every UI basic and functional first.
25+- Prefer existing page sections over new complex layouts.
26+- Avoid large reusable abstractions unless multiple pages clearly need them.
27+- Add one backend area per commit.
28+- Run `bun run build` before every commit.
29+- Commit messages must follow repository rules and require explicit user approval.
30+
31+## Remaining Commit Order
32+
33+| Commit | Scope | Priority |
34+| --- | --- | --- |
35+| 1 | Live monitor + exam room attempt fields | High |
36+| 2 | Marks grade-band labels | High |
37+| 3 | Settings management page | High |
38+| 4 | Terms API + course term select | Medium |
39+| 5 | Course sessions + roll call | Medium |
40+| 6 | Attendance report page | Medium |
41+| 7 | Work log page | Medium |
42+
43+## Commit 1: Live Monitor And Exam Room Attempt Fields
44+
45+### Goal
46+
47+Expose backend attempt, no-show, and room-left fields without making the UI complex.
48+
49+### Backend Fields
50+
51+- `LiveRosterEntry.status`: includes `absent`.
52+- `LiveRosterEntry.attempt`.
53+- `LiveRosterEntry.attempts_used`.
54+- `LiveRosterEntry.left_at`.
55+- `LiveMonitor.counts.absent`.
56+- `ExamAttempt.attempt`.
57+- `ExamAttempt.attempts_used`.
58+- `ExamAttempt.max_attempts`.
59+- `ExamAttempt.left_at`.
60+
61+### Files To Touch
62+
63+- `src/api/types.ts`.
64+- `src/pages/live-monitor-page.tsx`.
65+- `src/components/exams/exam-room-ws.tsx`.
66+- `src/components/exams/student-exam-room.tsx`.
67+- `src/i18n/messages.ts`.
68+
69+### UI Changes
70+
71+- Add `absent` label as `No-show` / `Katılmadı`.
72+- Add `absent` count card in live monitor counts.
73+- Add a compact `Attempt` column in live monitor.
74+- Show `attempts_used / max_attempts` when both exist.
75+- Show `left_at` as `Left` / `Çıkış` in live monitor if present.
76+- In exam room summary, show attempt info as a small card.
77+- In exam room summary, show `left_at` as a small warning/info card if present.
78+- Do not add rejoin policy editing UI yet.
79+
80+### Verification
81+
82+- Run `bun run build`.
83+- Manually inspect type errors around nullable `remaining_ms` and optional attempt fields.
84+
85+## Commit 2: Marks Grade-Band Labels
86+
87+### Goal
88+
89+Show grade-band labels returned by backend while keeping numeric marks primary.
90+
91+### Backend Fields To Support
92+
93+Backend may include:
94+
95+- `grade` on mark entries.
96+- `average_grade` on course averages.
97+- `overall_grade` on report.
98+
99+Exact response shape should be tolerated as optional fields.
100+
101+### Files To Touch
102+
103+- `src/api/types.ts`.
104+- `src/components/marks/marks-report-view.tsx`.
105+- `src/i18n/messages.ts` only if new labels are needed.
106+
107+### UI Changes
108+
109+- Overall average stays numeric.
110+- If `overall_grade` exists, show a small badge next to numeric value.
111+- Course average badge becomes `85 / AA` or `85` if no grade.
112+- Exam result mark cell becomes `90 / AA` or `90`.
113+- Do not add new routes.
114+
115+### Verification
116+
117+- Run `bun run build`.
118+
119+## Commit 3: Settings Management Page
120+
121+### Goal
122+
123+Allow manager+ users to edit school policy from the frontend.
124+
125+### Backend Endpoints
126+
127+- `GET /settings`.
128+- `PATCH /settings`.
129+
130+### Files To Add
131+
132+- `src/api/patchSettings.ts`.
133+- `src/pages/settings-page.tsx`.
134+
135+### Files To Touch
136+
137+- `src/api/types.ts`.
138+- `src/routes/router.tsx`.
139+- `src/components/layout/side-nav.tsx`.
140+- `src/i18n/messages.ts`.
141+
142+### UI Route
143+
144+- Path: `/management/settings`.
145+- Minimum role: `manager`.
146+
147+### Simple UI
148+
149+- One page with three sections.
150+- Exam kinds as rows: `name` + `weight`.
151+- Attendance statuses as simple text inputs or rows.
152+- Grade bands as rows: `min` + `label`.
153+- Buttons:
154+ - Add row.
155+ - Remove row.
156+ - Save.
157+- Keep validation mostly backend-driven.
158+- Show backend errors with `formatApiError`.
159+
160+### API Payload
161+
162+- `PATCH /settings` should send only the changed lists if practical.
163+- If simpler, send all three lists from the current form.
164+- Preserve all-or-nothing validation errors from backend.
165+
166+### Verification
167+
168+- Run `bun run build`.
169+
170+## Commit 4: Terms API And Course Term Select
171+
172+### Goal
173+
174+Expose academic terms and allow courses to link to a term.
175+
176+### Backend Endpoints
177+
178+- `GET /terms`.
179+- `POST /terms`.
180+- `PATCH /terms/{id}`.
181+- `DELETE /terms/{id}`.
182+- `GET /terms/{id}` optional if needed.
183+
184+### Files To Add
185+
186+- `src/api/getTerms.ts`.
187+- `src/api/postTerm.ts`.
188+- `src/api/patchTermById.ts`.
189+- `src/api/deleteTermById.ts`.
190+- `src/pages/terms-page.tsx`.
191+
192+### Files To Touch
193+
194+- `src/api/types.ts`.
195+- `src/api/postCourse.ts`.
196+- `src/api/patchCourseById.ts`.
197+- `src/pages/courses-page.tsx`.
198+- `src/pages/course-detail-page.tsx`.
199+- `src/routes/router.tsx`.
200+- `src/components/layout/side-nav.tsx`.
201+- `src/i18n/messages.ts`.
202+
203+### Type Additions
204+
205+- `Term`.
206+- `Course.term_id?: string | null`.
207+- `PostCourseBody.term_id?: string | null`.
208+- `PatchCourseBody.term_id?: string | null`.
209+
210+### UI Route
211+
212+- Path: `/management/terms`.
213+- Minimum role: `manager`.
214+
215+### Simple UI
216+
217+- Terms page:
218+ - List terms.
219+ - Create term with name, `starts_at`, `ends_at`.
220+ - Edit/delete basic controls.
221+- Course create/edit:
222+ - Optional term select.
223+ - `Unassigned` option.
224+
225+### Verification
226+
227+- Run `bun run build`.
228+
229+## Commit 5: Course Sessions And Roll Call
230+
231+### Goal
232+
233+Add basic lesson session creation and teacher-taken roll call inside course detail.
234+
235+### Backend Endpoints
236+
237+- `POST /courses/{id}/sessions`.
238+- `GET /courses/{id}/sessions`.
239+- `GET /sessions/{id}`.
240+- `PATCH /sessions/{id}`.
241+- `DELETE /sessions/{id}`.
242+- `POST /sessions/{id}/attendance`.
243+- `GET /sessions/{id}/attendance`.
244+- `DELETE /sessions/{id}/attendance/{user}`.
245+
246+### Files To Add
247+
248+- `src/api/getCourseSessions.ts`.
249+- `src/api/postCourseSession.ts`.
250+- `src/api/patchSessionById.ts`.
251+- `src/api/deleteSessionById.ts`.
252+- `src/api/getSessionAttendance.ts`.
253+- `src/api/postSessionAttendance.ts`.
254+- `src/api/deleteSessionAttendanceByUserId.ts`.
255+- Components under `src/components/sessions/`.
256+
257+### Files To Touch
258+
259+- `src/api/types.ts`.
260+- `src/pages/course-detail-page.tsx`.
261+- `src/i18n/messages.ts`.
262+
263+### Type Additions
264+
265+- `CourseSession`.
266+- `SessionAttendance`.
267+
268+### Simple UI
269+
270+- Add `Lesson sessions` section to course detail.
271+- Teacher/manager can create a session.
272+- Each session row shows topic, teacher, starts, ends.
273+- `Roll call` button expands a simple roster table.
274+- Roster table uses enrolled students.
275+- Status picker uses existing dynamic `AttendanceStatusPicker`.
276+- Do not create a separate calendar view.
277+
278+### Verification
279+
280+- Run `bun run build`.
281+
282+## Commit 6: Attendance Report Page
283+
284+### Goal
285+
286+Let users view their attendance report, and teachers view another user's report.
287+
288+### Backend Endpoints
289+
290+- `GET /attendance/me`.
291+- `GET /attendance/{user}`.
292+
293+### Files To Add
294+
295+- `src/api/getMyAttendance.ts`.
296+- `src/api/getUserAttendance.ts`.
297+- `src/pages/attendance-page.tsx`.
298+- Optional `src/pages/student-attendance-page.tsx` for teacher lookup.
299+
300+### Files To Touch
301+
302+- `src/api/types.ts`.
303+- `src/routes/router.tsx`.
304+- `src/components/layout/side-nav.tsx`.
305+- `src/i18n/messages.ts`.
306+
307+### UI Routes
308+
309+- `/attendance`.
310+- Optional teacher route: `/management/student-attendance`.
311+
312+### Simple UI
313+
314+- Summary cards:
315+ - Events total/rate.
316+ - Sessions total/rate.
317+- Course breakdown table.
318+- Show `present`, `absent`, `late`, `excused`, `total`, `rate`.
319+- Keep custom status display simple if backend exposes custom tallies.
320+
321+### Verification
322+
323+- Run `bun run build`.
324+
325+## Commit 7: Work Log Page
326+
327+### Goal
328+
329+Support staff check-in/check-out and own work log.
330+
331+### Backend Endpoints
332+
333+- `POST /work/check-in`.
334+- `POST /work/check-out`.
335+- `GET /work/me`.
336+- Manager endpoints can be deferred unless user requests them:
337+ - `GET /work/{user}`.
338+ - `PATCH /work/entries/{id}`.
339+ - `DELETE /work/entries/{id}`.
340+
341+### Files To Add
342+
343+- `src/api/postWorkCheckIn.ts`.
344+- `src/api/postWorkCheckOut.ts`.
345+- `src/api/getMyWorkLog.ts`.
346+- `src/pages/work-log-page.tsx`.
347+
348+### Files To Touch
349+
350+- `src/api/types.ts`.
351+- `src/routes/router.tsx`.
352+- `src/components/layout/side-nav.tsx`.
353+- `src/i18n/messages.ts`.
354+
355+### UI Route
356+
357+- Path: `/work`.
358+- Minimum role: `teacher`.
359+
360+### Simple UI
361+
362+- One big button:
363+ - `Check in` if no open entry.
364+ - `Check out` if open entry exists.
365+- List newest work entries.
366+- Show check-in, check-out, duration.
367+- Do not implement manager corrections in first version.
368+
369+### Verification
370+
371+- Run `bun run build`.
372+
373+## Known UI Simplification Tasks
374+
375+### Exam Form
376+
377+- Keep the current layout:
378+ - Row 1: kind + mode.
379+ - Row 2: retake checkbox + max attempts input when enabled.
380+ - Row 3: schedule fields only for sync/async.
381+- Do not show rejoin controls unless user explicitly asks.
382+- Keep `allow_rejoin` default behavior hidden.
383+
384+### Course Detail
385+
386+As features grow, course detail risks becoming crowded. Use simple sections:
387+
388+- Course exams.
389+- Roster.
390+- Lesson sessions.
391+
392+Avoid adding tabs unless sections become unusable.
393+
394+### Settings Page
395+
396+Avoid over-designing. Use plain rows and a save button first.
397+
398+### Live Monitor
399+
400+Avoid too many columns. Recommended columns:
401+
402+- Student.
403+- Status.
404+- Attempt.
405+- Progress.
406+- Remaining.
407+- Left.
408+- Mark.
409+
410+## Commit Workflow
411+
412+For each commit:
413+
414+- Make only one feature-area change.
415+- Run `bun run build`.
416+- Show exact commit message to user.
417+- Wait for explicit approval.
418+- Commit only after approval.
419+
420+## Suggested Commit Messages
421+
422+### Commit 1
423+
424+```text
425+feat: ✨ show exam attempt state in live views
426+- show no-show counts and absent roster status in the live monitor
427+- add attempt count and left-room timestamps to monitor rows
428+- show current attempt and retake usage in the exam room summary
429+- keep untimed open exams readable with null remaining time
430+```
431+
432+### Commit 2
433+
434+```text
435+feat: ✨ show grade band labels on marks
436+- add optional grade labels to mark report types
437+- show overall, course, and exam grade badges when returned by the API
438+- keep numeric marks as the primary display
439+```
440+
441+### Commit 3
442+
443+```text
444+feat: ✨ manage school settings
445+- add settings patch API
446+- add manager settings page for exam kinds, attendance statuses, and grade bands
447+- wire settings navigation for manager roles
448+```
449+
450+### Commit 4
451+
452+```text
453+feat: ✨ add terms management
454+- add terms API functions and manager terms page
455+- support optional course term links in course create and edit payloads
456+- show selected term on course views
457+```
458+
459+### Commit 5
460+
461+```text
462+feat: ✨ add course sessions and roll call
463+- add course session API functions and course detail session list
464+- allow course managers to create lesson sessions
465+- add basic roll-call marking for enrolled students
466+```
467+
468+### Commit 6
469+
470+```text
471+feat: ✨ add attendance reports
472+- add attendance report API functions
473+- add user attendance summary page
474+- show event and lesson attendance rates with course breakdowns
475+```
476+
477+### Commit 7
478+
479+```text
480+feat: ✨ add staff work log
481+- add work check-in and check-out API functions
482+- add teacher work log page with open-stint action
483+- list recent work entries with durations
484+```