forge
Explore
Log in

Don't you dare go Hollow

README + knowledge base

Browse files at this commit

870de5b2a885beab103a5906f8bfcbd0c67ef107Ahmet Kaan GümüşParent: c54c660
  • docs
    • README + knowledge base
Show full message
📝 docs(homework): README + knowledge base
README.mdmodified+121 -12
@@ -5,7 +5,7 @@ Note, attendance, course + weighted exam mark backend. **Rust (edition 2024) ·
5 Session-cookie auth with five hierarchical roles (`parent < student < teacher5 Session-cookie auth with five hierarchical roles (`parent < student < teacher
6 < manager < admin`). A **`parent`** observes and changes nothing: admins tie6 < manager < admin`). A **`parent`** observes and changes nothing: admins tie
7 students to a parent account, and the parent reads those students' mark,7 students to a parent account, and the parent reads those students' mark,
8-attendance, and pomodoro reports — that's the whole role. Notes are per-user and carry **file attachments** (PDFs, documents,8+attendance, pomodoro, and homework reports — that's the whole role. Notes are per-user and carry **file attachments** (PDFs, documents,
9 …): blobs live on disk next to the database, metadata in the database, and the9 …): blobs live on disk next to the database, metadata in the database, and the
10 per-file size cap is school policy in settings (`max_file_bytes`, default10 per-file size cap is school policy in settings (`max_file_bytes`, default
11 5 MiB). Any two users can **message** each other, mail-style — subject +11 5 MiB). Any two users can **message** each other, mail-style — subject +
@@ -49,7 +49,15 @@ may be a picture of its own (pick the right city off the map) — raster
49 uploads capped by the same `max_file_bytes` policy as note files. Teachers49 uploads capped by the same `max_file_bytes` policy as note files. Teachers
50 watch attendance, per-student remaining time,50 watch attendance, per-student remaining time,
51 sittings, walk-outs, no-shows (`absent` once the window closes), submissions,51 sittings, walk-outs, no-shows (`absent` once the window closes), submissions,
52-and marks land live on a monitor endpoint (snapshot or SSE stream). Courses also carry **lesson52+and marks land live on a monitor endpoint (snapshot or SSE stream). Courses also hand out
53+**homework**: assigned to the whole class or a named subset (the unnamed never
54+even see it), tagged with a course subject, due by a required future `due_at`
55+— students hand in text and/or **files of any type** (same size cap, 10 per
56+submission, served back only as forced downloads), editable until the teacher
57+grades a status (`done`/`incomplete`/`missing`) with an optional 0–100 mark
58+(grading freezes the hand-in until the grade is removed); lateness is computed
59+from two stamps (first hand-in vs last touch), never stored, and homework
60+marks stay out of the weighted `/marks` averages. Courses also carry **lesson
53 sessions** with teacher-taken roll call (students never self-mark a lesson),61 sessions** with teacher-taken roll call (students never self-mark a lesson),
54 staff clock in/out on a server-stamped **work log**, students track study time62 staff clock in/out on a server-stamped **work log**, students track study time
55 with a server-stamped **pomodoro log** (the timer runs in the frontend; the63 with a server-stamped **pomodoro log** (the timer runs in the frontend; the
@@ -235,8 +243,8 @@ effect on the user's very next call (no re-login).
235 `parent` is the read-only observer at the bottom of the ladder: an admin ties243 `parent` is the read-only observer at the bottom of the ladder: an admin ties
236 any number of students to a parent account (`POST /users/{id}/students`), and244 any number of students to a parent account (`POST /users/{id}/students`), and
237 the tie is the parent's whole power — they list their students245 the tie is the parent's whole power — they list their students
238-(`GET /users/me/students`) and read each one's mark, attendance, and pomodoro246+(`GET /users/me/students`) and read each one's mark, attendance, pomodoro,
239-reports in full. Student-only checks are exact (`role == student`), so a247+and homework reports in full. Student-only checks are exact (`role == student`), so a
240 parent can never enroll, sit an exam, be graded, or land on a roll call; and248 parent can never enroll, sit an exam, be graded, or land on a roll call; and
241 sitting below every staff bar, they can't touch anything else either — except249 sitting below every staff bar, they can't touch anything else either — except
242 messages, which any role sends and receives (that's how a parent reaches a250 messages, which any role sends and receives (that's how a parent reaches a
@@ -278,13 +286,16 @@ course enrollments.
278 | Create courses | teacher | The creator manages the course, and owns it for good |286 | Create courses | teacher | The creator manages the course, and owns it for good |
279 | Assign / unassign a course's teachers | manager | Staffing is the office's call — a course's own creator cannot hand rights to peers; the assignee must be `teacher`+ |287 | Assign / unassign a course's teachers | manager | Staffing is the office's call — a course's own creator cannot hand rights to peers; the assignee must be `teacher`+ |
280 | Delete a course | teacher | Only the **creator**, or a `manager`+ — an assigned teacher runs the course but doesn't own it |288 | Delete a course | teacher | Only the **creator**, or a `manager`+ — an assigned teacher runs the course but doesn't own it |
281-| Manage inside a course: edit it, enroll/unenroll **students**, add/edit/delete its exams and **subjects**, grade, remove results | teacher | The **course creator**, a teacher **assigned** to it, or a `manager`+ for any course; only students can be enrolled; a subject still referenced by exam questions won't delete (`409`) |289+| Manage inside a course: edit it, enroll/unenroll **students**, add/edit/delete its exams and **subjects**, grade, remove results | teacher | The **course creator**, a teacher **assigned** to it, or a `manager`+ for any course; only students can be enrolled; a subject still referenced by exam questions or homework won't delete (`409`) |
282 | View a course's roster, an exam's result list / statistics | teacher | Course-management rights |290 | View a course's roster, an exam's result list / statistics | teacher | Course-management rights |
283 | Read another user's mark report | teacher | Narrowed to the caller's managed courses; `manager`+ sees all; a `parent` sees a linked student's in full |291 | Read another user's mark report | teacher | Narrowed to the caller's managed courses; `manager`+ sees all; a `parent` sees a linked student's in full |
284 | Grade students | teacher | Target must be an **enrolled student**; grading never targets oneself |292 | Grade students | teacher | Target must be an **enrolled student**; grading never targets oneself |
293+| Assign / edit / delete homework; grade it; read its roster | teacher | Course-management rights; an `assigned` subset (≤ 200 enrolled students) can't be narrowed over existing work (`409`); a grade (`done`/`incomplete`/`missing` + optional mark) freezes the submission until removed |
294+| Submit **own** homework (text + files); read own submission and grade | student | **Students only** — staff never submit; enrolled + in the audience; editable until graded; ≤ 10 files of any type, each ≤ `max_file_bytes`, always downloaded as attachments |
295+| Read another user's homework report | teacher | Narrowed to the caller's managed courses; `manager`+ sees all; a `parent` sees a linked student's in full — statuses/marks/flags, never files |
285 | Edit **own** personal info (name, surname, email, phone, birth date) | student | Every account carries the same optional info fields |296 | Edit **own** personal info (name, surname, email, phone, birth date) | student | Every account carries the same optional info fields |
286 | Edit **own** UI preferences (theme, language) | student | `null` until chosen — the client then follows the device preference |297 | Edit **own** UI preferences (theme, language) | student | `null` until chosen — the client then follows the device preference |
287-| List **own** linked students | parent | Read-only: the list plus each student's mark/attendance/pomodoro reports — a parent changes nothing, anywhere |298+| List **own** linked students | parent | Read-only: the list plus each student's mark/attendance/pomodoro/homework reports — a parent changes nothing, anywhere |
288 | Read the school settings and the term list | student | Clients need them to render kind/status pickers, grades, and the calendar |299 | Read the school settings and the term list | student | Clients need them to render kind/status pickers, grades, and the calendar |
289 | Edit school settings; create / edit / delete terms | manager | School policy (exam kinds, attendance statuses, grade bands, the note-file size limit) and the academic calendar are management's call |300 | Edit school settings; create / edit / delete terms | manager | School policy (exam kinds, attendance statuses, grade bands, the note-file size limit) and the academic calendar are management's call |
290 | List users; look up one user; change a user's role; edit **any** user's personal info or UI preferences; tie/untie students to a `parent` account | admin | An admin cannot change **their own** role |301 | List users; look up one user; change a user's role; edit **any** user's personal info or UI preferences; tie/untie students to a `parent` account | admin | An admin cannot change **their own** role |
@@ -424,7 +435,7 @@ their existing shapes: the student exam-room reads
424 | GET | `/courses/me` | student | The caller's **enrolled** courses · paged |435 | GET | `/courses/me` | student | The caller's **enrolled** courses · paged |
425 | GET | `/courses/{id}` | student | Get course (enrolled, creator, assigned teacher, or manager+) |436 | GET | `/courses/{id}` | student | Get course (enrolled, creator, assigned teacher, or manager+) |
426 | PATCH | `/courses/{id}` | teacher | Edit course incl. `kind` and `capacity` (`null` lifts the cap) (course manager) |437 | PATCH | `/courses/{id}` | teacher | Edit course incl. `kind` and `capacity` (`null` lifts the cap) (course manager) |
427-| DELETE | `/courses/{id}` | teacher | Delete course + its exams, results, enrollments, subjects (creator, or manager+ — **not** an assigned teacher) |438+| DELETE | `/courses/{id}` | teacher | Delete course + its exams, results, enrollments, subjects, and homework (submissions, files, and grades included) (creator, or manager+ — **not** an assigned teacher) |
428 | POST | `/courses/{id}/teachers` | manager | `{user_id}` — assign a **teacher+** to run the course (idempotent; returns the course) |439 | POST | `/courses/{id}/teachers` | manager | `{user_id}` — assign a **teacher+** to run the course (idempotent; returns the course) |
429 | DELETE | `/courses/{id}/teachers/{user}` | manager | Unassign a teacher (`404` if they weren't assigned) |440 | DELETE | `/courses/{id}/teachers/{user}` | manager | Unassign a teacher (`404` if they weren't assigned) |
430 | POST | `/courses/{id}/enrollments` | teacher | `{user_id}` — enroll a **student** (idempotent upsert; course manager; only students can be enrolled; `409` once a capped course is full) |441 | POST | `/courses/{id}/enrollments` | teacher | `{user_id}` — enroll a **student** (idempotent upsert; course manager; only students can be enrolled; `409` once a capped course is full) |
@@ -436,7 +447,7 @@ their existing shapes: the student exam-room reads
436 | GET | `/courses/{id}/subjects` | student | List the course's subjects, creation order (enrolled, creator, assigned teacher, or manager+) · paged |447 | GET | `/courses/{id}/subjects` | student | List the course's subjects, creation order (enrolled, creator, assigned teacher, or manager+) · paged |
437 | GET | `/subjects/{id}` | student | Get subject (enrolled, creator, or manager+) |448 | GET | `/subjects/{id}` | student | Get subject (enrolled, creator, or manager+) |
438 | PATCH | `/subjects/{id}` | teacher | Edit a subject's name/description (course manager; its course is fixed) |449 | PATCH | `/subjects/{id}` | teacher | Edit a subject's name/description (course manager; its course is fixed) |
439-| DELETE | `/subjects/{id}` | teacher | Delete a subject (course manager); `409` while exam questions reference it |450+| DELETE | `/subjects/{id}` | teacher | Delete a subject (course manager); `409` while exam questions or homework reference it |
440 | GET | `/sessions/{id}` | student | Get session (enrolled, session teacher, or course manager) |451 | GET | `/sessions/{id}` | student | Get session (enrolled, session teacher, or course manager) |
441 | PATCH | `/sessions/{id}` | teacher | Edit session (course manager; `null` clears `ends_at`) |452 | PATCH | `/sessions/{id}` | teacher | Edit session (course manager; `null` clears `ends_at`) |
442 | DELETE | `/sessions/{id}` | teacher | Delete session + its roll call (course manager) |453 | DELETE | `/sessions/{id}` | teacher | Delete session + its roll call (course manager) |
@@ -477,6 +488,23 @@ their existing shapes: the student exam-room reads
477 | GET | `/exams/{id}/attempt/ws` | student | **WebSocket** exam room (students only): state ticks, autosave, finish; entering clears `left_at`, leaving stamps it (see "Taking an exam") |488 | GET | `/exams/{id}/attempt/ws` | student | **WebSocket** exam room (students only): state ticks, autosave, finish; entering clears `left_at`, leaving stamps it (see "Taking an exam") |
478 | GET | `/exams/{id}/live` | teacher | Live monitor snapshot: roster × latest attempts × marks + per-student progress/`left_at`/`attempts_used` + counts; no-shows turn `absent` once the window closes (course manager) |489 | GET | `/exams/{id}/live` | teacher | Live monitor snapshot: roster × latest attempts × marks + per-student progress/`left_at`/`attempts_used` + counts; no-shows turn `absent` once the window closes (course manager) |
479 | GET | `/exams/{id}/live/stream` | teacher | The same snapshot as SSE `snapshot` events every ~2s (course manager) |490 | GET | `/exams/{id}/live/stream` | teacher | The same snapshot as SSE `snapshot` events every ~2s (course manager) |
491+| POST | `/courses/{id}/homework` | teacher | `{title, description?, subject_id, due_at, assigned?}` — assign homework tagged with a course subject, due in the future; `assigned` names an enrolled-student subset, ≤ 200 (omit/`[]` = the whole course) (course manager) |
492+| GET | `/courses/{id}/homework` | student | List the course's homework, newest first (enrolled, creator, assigned teacher, or manager+; students see only what they're assigned) · paged |
493+| GET | `/homework` | student | The caller's cross-course homework: their courses' (manager+: all; students only what they're assigned) · paged |
494+| GET | `/homework/{id}` | student | Get homework (course viewers; a subset homework is a `404` to students it doesn't name) |
495+| PATCH | `/homework/{id}` | teacher | Edit title/description/`due_at`/`subject_id`/`assigned` (course manager; a newly set due date is re-checked; `409` if narrowing `assigned` would strand an existing submission or grade — the blockers are named) |
496+| DELETE | `/homework/{id}` | teacher | Delete homework + its submissions, files, and grades — file blobs included (course manager) |
497+| POST | `/homework/{id}/submission` | student | `{text?}` — hand in / re-edit own work (**students only**, enrolled, assigned): text replaces whole (omit clears), `submitted_at` pins the first hand-in, `updated_at` moves; `409` once graded |
498+| GET | `/homework/{id}/submission` | student | Own submission: text, both stamps, computed `late`, files, grade-if-any (`404` until submitted) |
499+| DELETE | `/homework/{id}/submission` | student | Withdraw own submission + its files and blobs (`409` once graded) |
500+| POST | `/homework/{id}/submission/files` | student | Attach a file to own submission: `multipart/form-data`, one `file` part — **any** content type, ≤ `max_file_bytes`, ≤ 10 per submission; auto-creates the submission (a photo-only homework is one request); `409` once graded or full |
501+| GET | `/homework/{id}/submission/files/{fid}` | student | The file bytes as a **forced download** (`Content-Disposition: attachment`) — the owning student, or a course manager; observers never |
502+| DELETE | `/homework/{id}/submission/files/{fid}` | student | Remove own file, row then blob (`409` once graded) |
503+| GET | `/homework/{id}/submissions` | teacher | The grading roster: one row per audience student × submission/files/grade + computed `late`/`missing`/`unenrolled` — a straggler's stale work stays visible (course manager) · paged |
504+| POST | `/homework/{id}/results` | teacher | `{user, status, mark?}` — grade `done`/`incomplete`/`missing` (+ optional 0–100 mark) onto an enrolled, assigned **student** (upsert; course manager; never yourself; freezes the submission; unsubmitted work gradable — that's `missing`) |
505+| GET | `/homework/{id}/result` | student | The caller's **own** grade (`404` until graded) — readable even when nothing was submitted (a `missing` verdict) |
506+| DELETE | `/homework/{id}/results/{user}` | teacher | Remove a student's grade — un-grading reopens their submission (course manager) |
507+| GET | `/homework/report/{user}` | teacher* | Per-homework report rows — submitted/late/missing + the grade (manager+: full; a teacher: their managed courses); *or a `parent` linked to `{user}` — full, statuses and marks only, never files · paged |
480 | POST | `/questions` | student | `{title, body}` — ask into the school question pool (**students only**); born `pending`, visible to the asker + teacher+ |508 | POST | `/questions` | student | `{title, body}` — ask into the school question pool (**students only**); born `pending`, visible to the asker + teacher+ |
481 | GET | `/questions` | student | `?status=pending\|approved` — the pool questions visible to the caller, each with its `solution_count` · paged |509 | GET | `/questions` | student | `?status=pending\|approved` — the pool questions visible to the caller, each with its `solution_count` · paged |
482 | GET | `/questions/{id}` | student | Get one (a `pending` question is a `404` unless asker or teacher+) |510 | GET | `/questions/{id}` | student | Get one (a `pending` question is a `404` unless asker or teacher+) |
@@ -576,8 +604,9 @@ audiences convert on boot: each listed user becomes a signup row credited to
576 the event's creator, and the audience becomes an uncapped registration list.604 the event's creator, and the audience becomes an uncapped registration list.
577 Reading a child collection of a missing parent (`/events/{id}/attendance`,605 Reading a child collection of a missing parent (`/events/{id}/attendance`,
578 `/exams/{id}/results`, `/courses/{id}/enrollments`, `/courses/{id}/exams`,606 `/exams/{id}/results`, `/courses/{id}/enrollments`, `/courses/{id}/exams`,
579-`/courses/{id}/sessions`, `/courses/{id}/subjects`,607+`/courses/{id}/sessions`, `/courses/{id}/subjects`, `/courses/{id}/homework`,
580-`/sessions/{id}/attendance`) is a `404`, not an empty list.608+`/homework/{id}/submissions`, `/sessions/{id}/attendance`) is a `404`, not an
609+empty list.
581 Personal info (`name`, `surname`, `email`, `phone`, `birth_date`) is the same610 Personal info (`name`, `surname`, `email`, `phone`, `birth_date`) is the same
582 optional set on every account, whatever the role, and is `null` until filled611 optional set on every account, whatever the role, and is `null` until filled
583 in. On `PATCH /users/me` (or the admin `PATCH /users/{id}/profile`) each field612 in. On `PATCH /users/me` (or the admin `PATCH /users/{id}/profile`) each field
@@ -973,6 +1002,75 @@ The live monitor rides along: each roster row now carries `answered` and
973 The student's own `GET /exams/{id}/attempt` echoes the same1002 The student's own `GET /exams/{id}/attempt` echoes the same
974 `answered`/`question_count` pair.1003 `answered`/`question_count` pair.
975 1004
1005+## Homework
1006+
1007+A course hands out **homework**: `POST /courses/{id}/homework` with a title,
1008+an optional description, a **required subject** (one of the course's own — and
1009+the same delete guard questions have: a subject with homework refuses deletion
1010+with a `409` until the homework is re-tagged via `PATCH /homework/{id}` or
1011+deleted), and a **required `due_at`** that must not lie in the past (same 60s
1012+grace as every schedule field; late *submissions* are fine — a late
1013+*assignment* is not).
1014+
1015+**Audience.** By default the whole course, resolved live: whoever is enrolled
1016+*when they act* — a student enrolled after the assignment sees and submits it
1017+like everyone else. `assigned` (at create or PATCH) instead pins a named
1018+subset of currently enrolled students (at most 200). The unnamed must not even
1019+learn a subset exists: lists omit it, and direct reads and submits answer
1020+`404` — the same no-leak a hidden exam draft gets. Narrowing the subset later
1021+is refused with a `409` that names the blockers while any submission or grade
1022+belongs to a student the new list would strand.
1023+
1024+**Submitting.** Students only — staff and parents never submit — enrolled and
1025+in the audience, re-checked on every write. A submission is optional text plus
1026+up to **10 files of any content type** (each ≤ the school's
1027+`max_file_bytes`): text is replaced whole on each `POST` (omit to clear),
1028+files are added and removed one by one, and a file upload with no prior
1029+submission auto-creates an empty one, so a photo-only homework is a single
1030+request. Two stamps tell the lateness story: `submitted_at` pins the **first**
1031+hand-in forever, `updated_at` moves on every text edit and file add/remove,
1032+and `late` is **computed on read** (`updated_at > due_at`), never stored — so
1033+touching work after the deadline flips it late, and a `due_at` edit re-grades
1034+lateness for free. Late submissions are always accepted, only flagged. File
1035+bytes always come back as a forced download (`Content-Disposition:
1036+attachment`): homework accepts any content type, so rendering an uploaded
1037+HTML/SVG inline would run it in the viewer's session.
1038+
1039+**Grading.** A course manager records a status — `done`, `incomplete`, or
1040+`missing` — plus an optional 0–100 `mark` per student
1041+(`POST /homework/{id}/results`, one upsert row per homework+student; the
1042+exam walls apply: live students only, enrolled, in the audience, never the
1043+grader themselves). A stored grade **freezes** that submission — text edits,
1044+file changes, withdrawal all `409` — until
1045+`DELETE /homework/{id}/results/{user}` removes it and reopens editing.
1046+Grading before the due date, or before anything was submitted, is allowed —
1047+the latter is how never-handed-in work gets its `missing` verdict, and
1048+`GET /homework/{id}/result` is where its student reads it (their submission
1049+endpoints have nothing to show). The teacher-set `missing` **status** is a
1050+deliberate verdict; the roster and the report *also* compute a `missing`
1051+**flag** for anyone unsubmitted past due — the two are independent. Homework
1052+marks stay out of `/marks`: the weighted course average remains exam-only
1053+(the exam *kind* named `homework` still lives there), so nothing
1054+double-counts.
1055+
1056+**Roster & report.** `GET /homework/{id}/submissions` (course manager) is the
1057+grading table: one row per audience student — plus any straggler outside the
1058+audience who still owns a submission or grade (an unenrollment, a promotion,
1059+or an audience change leaves work behind; it stays visible, flagged
1060+`unenrolled`, though a stale student can neither submit nor be graded).
1061+`GET /homework/report/{user}` is the fourth observer read beside marks,
1062+attendance, and pomodoro: teacher+ (an exactly-teacher caller narrowed to the
1063+courses they manage), or a **parent linked** to the student — per-homework
1064+rows of submitted/late/missing plus the grade; statuses and marks only,
1065+**never the files**.
1066+
1067+Every delete collects its garbage: withdrawing a submission, deleting a
1068+homework, and deleting the whole course each cascade the rows (submissions,
1069+files, grades) and unlink the file blobs from disk. Role changes never sweep
1070+homework rows: a promoted student's work stays readable on the roster behind
1071+the `unenrolled` flag, while the live-role gates refuse fresh edits and
1072+grades.
1073+
976 ## Lesson sessions, roll call, the work log, pomodoro & attendance reports1074 ## Lesson sessions, roll call, the work log, pomodoro & attendance reports
977 1075
978 Events cover ad-hoc gatherings; **sessions** are a course's lessons. A session1076 Events cover ad-hoc gatherings; **sessions** are a course's lessons. A session
@@ -1172,6 +1270,17 @@ src/
1172 the school-wide pool; optional photo as metadata + disk blob)1270 the school-wide pool; optional photo as metadata + disk blob)
1173 solution.rs SolutionId · SolutionBody · Solution (discussion thread on an1271 solution.rs SolutionId · SolutionBody · Solution (discussion thread on an
1174 approved pool question; dies with the question)1272 approved pool question; dies with the question)
1273+ homework.rs HomeworkId · HomeworkTitle · HomeworkDescription · Homework
1274+ (per-course assignment; required subject; optional `assigned`
1275+ student subset — absent/empty = the whole enrolled course)
1276+ homework_submission.rs HomeworkSubmissionId · SubmissionText ·
1277+ HomeworkSubmission (one row per homework+user; immutable
1278+ submitted_at + moving updated_at — `late` is computed)
1279+ homework_file.rs HomeworkFileId · HomeworkFile (submission attachment
1280+ metadata; any content type; bytes on disk under FILES_PATH)
1281+ homework_result.rs HomeworkResultId · HomeworkStatus · HomeworkResult
1282+ (teacher grade: done/incomplete/missing + optional Mark; one
1283+ row per homework+user — its existence freezes the submission)
1175 web/ axum layer: DTOs (serde + OpenAPI schemas) + handlers +1284 web/ axum layer: DTOs (serde + OpenAPI schemas) + handlers +
1176 auth extractors1285 auth extractors
1177 extractor.rs CurrentUser · RequireTeacher · RequireManager · RequireAdmin1286 extractor.rs CurrentUser · RequireTeacher · RequireManager · RequireAdmin
@@ -1179,8 +1288,8 @@ src/
1179 exam_ws.rs the student exam-room WebSocket (state ticks, autosave, finish)1288 exam_ws.rs the student exam-room WebSocket (state ticks, autosave, finish)
1180 page.rs PageParams · Page<T> (shared pagination)1289 page.rs PageParams · Page<T> (shared pagination)
1181 auth.rs users.rs notes.rs messages.rs events.rs courses.rs subjects.rs1290 auth.rs users.rs notes.rs messages.rs events.rs courses.rs subjects.rs
1182- sessions.rs exams.rs questions.rs marks.rs work.rs pomodoro.rs1291+ sessions.rs exams.rs homework.rs questions.rs marks.rs work.rs
1183- attendance.rs settings.rs terms.rs1292+ pomodoro.rs attendance.rs settings.rs terms.rs
1184 ```1293 ```
1185 1294
1186 Tests: `cargo test` — unit (in-source), integration (`tower::oneshot` + in-memory1295 Tests: `cargo test` — unit (in-source), integration (`tower::oneshot` + in-memory
src/lib.rsmodified+3 -3
@@ -34,13 +34,13 @@ use crate::state::AppState;
34 info(34 info(
35 title = "Hezarfen Backend API",35 title = "Hezarfen Backend API",
36 version = env!("CARGO_PKG_VERSION"),36 version = env!("CARGO_PKG_VERSION"),
37- description = "Notes, events, attendance, courses, and weighted exam marks behind cookie-session auth. Notes carry file attachments (PDFs, documents — stored on disk, capped per file by the school's settings). Any two users can message each other one-to-one, mail-style: each side files its own copy through folders (recipient: inbox/archive/trash with a read flag the sender sees as a receipt; sender: sent/trash), and a message is truly gone only when both sides have deleted it from their trash. Exams run sync (one window), async (window + per-attempt duration), or open (sit anytime), with per-exam attempt limits (retakes) and a teacher-controlled rejoin door on the live exam room; questions can carry images — an illustration on any question, and per-option pictures on choice questions; students can attach an answer drawing to any question in their attempt. Enrollment, exam-sitting, roll call, and marks are student-only — staff run them, they don't take part. Every event carries an audience — the whole school, one role, a course's enrollment, or a registration list — that defines its expected-attendee roster (visibility is unaffected: everyone sees every event). Registration-audience events hold a signup list built one seat at a time: teachers register students (students never register themselves), staff register only themselves, the list optionally caps at a capacity, and it closes the moment the event starts. Event attendance is taken by teachers+ against that audience (students never self-mark), and a per-event roster report joins the expected list with the marks to show who missed. Courses come in three behaviorally identical kinds — `course` (a regular class), `study` (a supervised study session — etüt), and `club` (a student club — kulüp) — may cap their roster with an optional enroll-time `capacity` (a full course refuses new members), and carry lesson sessions with teacher-taken roll call. A course is run by whoever created it plus any teachers a manager assigns to it (`POST /courses/{id}/teachers`) — an assigned teacher manages everything inside the course (exams, sessions, subjects, roster, grading) but cannot delete the course or change who else teaches it, and a demotion below `teacher` drops their assignments. Each course also owns its curriculum as a list of subjects, and every exam question must be tagged with one of its course's subjects (a subject still referenced by questions cannot be deleted); staff clock in/out on a server-stamped work log; students run a pomodoro study timer whose focus sessions land in a server-stamped log (starting discards a dangling unfinished session; teachers can read any student's log and its total focus time); attendance reports tally events and per-course roll call with rates. School-varying policy (exam kinds with their course-average weights, attendance statuses, grade-display bands, the note-file size limit) lives in an editable settings singleton, and courses may link to academic terms. Each account also carries its own UI preferences — theme (`light`/`dark`) and language (`tr`/`en`) — self-managed, admin-editable for anyone, and `null` until chosen (the client then follows the device preference). A `parent` role observes without touching: admins tie any number of students to a parent account (`POST /users/{id}/students`), the parent lists them at `GET /users/me/students` and reads each one's mark, attendance, and pomodoro reports — and nothing else; parents hold no staff power and never act as students (no enrolling, sitting exams, or roll call). A school-wide **question pool** lets students ask for help: a student posts a question (optionally with a photo of the problem — same raster rules and size cap as question images), a teacher+ approves it into the pool (or deletes it — rejection is deletion, there is no rejected state), and every approved question is readable by the whole school (parents excepted), with anyone free to offer solutions under it — text plus an optional photo of the worked steps, both editable by the solution's author at any time, since solutions are unmoderated and never freeze — and every question row carries its `solution_count`; pending questions are visible only to their asker and to teacher+ (whose `?status=pending` list is the approval queue), and approval freezes the question's content so nothing unmoderated can slip into the pool afterwards. While the database connection is reconnecting (a restart, a dropped socket) requests briefly answer `503` with `Retry-After: 1` — transient, retry shortly. Every list endpoint accepts `?limit=&offset=` and returns a `{items, total, limit, offset}` page envelope — paging is opt-in, so omitting `limit` returns the full list and `total` always carries the unpaged count.",37+ description = "Notes, events, attendance, courses, and weighted exam marks behind cookie-session auth. Notes carry file attachments (PDFs, documents — stored on disk, capped per file by the school's settings). Any two users can message each other one-to-one, mail-style: each side files its own copy through folders (recipient: inbox/archive/trash with a read flag the sender sees as a receipt; sender: sent/trash), and a message is truly gone only when both sides have deleted it from their trash. Exams run sync (one window), async (window + per-attempt duration), or open (sit anytime), with per-exam attempt limits (retakes) and a teacher-controlled rejoin door on the live exam room; questions can carry images — an illustration on any question, and per-option pictures on choice questions; students can attach an answer drawing to any question in their attempt. Enrollment, exam-sitting, roll call, and marks are student-only — staff run them, they don't take part. Every event carries an audience — the whole school, one role, a course's enrollment, or a registration list — that defines its expected-attendee roster (visibility is unaffected: everyone sees every event). Registration-audience events hold a signup list built one seat at a time: teachers register students (students never register themselves), staff register only themselves, the list optionally caps at a capacity, and it closes the moment the event starts. Event attendance is taken by teachers+ against that audience (students never self-mark), and a per-event roster report joins the expected list with the marks to show who missed. Courses come in three behaviorally identical kinds — `course` (a regular class), `study` (a supervised study session — etüt), and `club` (a student club — kulüp) — may cap their roster with an optional enroll-time `capacity` (a full course refuses new members), and carry lesson sessions with teacher-taken roll call. A course is run by whoever created it plus any teachers a manager assigns to it (`POST /courses/{id}/teachers`) — an assigned teacher manages everything inside the course (exams, sessions, subjects, roster, grading) but cannot delete the course or change who else teaches it, and a demotion below `teacher` drops their assignments. Each course also owns its curriculum as a list of subjects, and every exam question and every homework must be tagged with one of its course's subjects (a subject still referenced by questions or homework cannot be deleted); staff clock in/out on a server-stamped work log; students run a pomodoro study timer whose focus sessions land in a server-stamped log (starting discards a dangling unfinished session; teachers can read any student's log and its total focus time); attendance reports tally events and per-course roll call with rates. Courses also hand out homework: teacher-assigned per course to the whole class or a named subset the unnamed never even see (404s, no existence leak), subject-tagged and due by a required future `due_at`; students submit optional text plus up to 10 files of any content type (each capped by `max_file_bytes`, always served back as forced attachment downloads), editable until a teacher grades a status (`done`/`incomplete`/`missing`) with an optional 0–100 mark — the grade freezes the submission until removed, work never handed in is gradable `missing`, lateness is computed from an immutable first-submit stamp and a moving last-touch stamp (never stored), the grading roster computes `missing` and `unenrolled` flags, and homework marks stay out of the weighted `/marks` averages. School-varying policy (exam kinds with their course-average weights, attendance statuses, grade-display bands, the note-file size limit) lives in an editable settings singleton, and courses may link to academic terms. Each account also carries its own UI preferences — theme (`light`/`dark`) and language (`tr`/`en`) — self-managed, admin-editable for anyone, and `null` until chosen (the client then follows the device preference). A `parent` role observes without touching: admins tie any number of students to a parent account (`POST /users/{id}/students`), the parent lists them at `GET /users/me/students` and reads each one's mark, attendance, pomodoro, and homework reports — and nothing else; parents hold no staff power and never act as students (no enrolling, sitting exams, or roll call). A school-wide **question pool** lets students ask for help: a student posts a question (optionally with a photo of the problem — same raster rules and size cap as question images), a teacher+ approves it into the pool (or deletes it — rejection is deletion, there is no rejected state), and every approved question is readable by the whole school (parents excepted), with anyone free to offer solutions under it — text plus an optional photo of the worked steps, both editable by the solution's author at any time, since solutions are unmoderated and never freeze — and every question row carries its `solution_count`; pending questions are visible only to their asker and to teacher+ (whose `?status=pending` list is the approval queue), and approval freezes the question's content so nothing unmoderated can slip into the pool afterwards. While the database connection is reconnecting (a restart, a dropped socket) requests briefly answer `503` with `Retry-After: 1` — transient, retry shortly. Every list endpoint accepts `?limit=&offset=` and returns a `{items, total, limit, offset}` page envelope — paging is opt-in, so omitting `limit` returns the full list and `total` always carries the unpaged count.",
38 ),38 ),
39 modifiers(&SecurityAddon),39 modifiers(&SecurityAddon),
40 tags(40 tags(
41 (name = "meta", description = "Liveness and service metadata"),41 (name = "meta", description = "Liveness and service metadata"),
42 (name = "auth", description = "Registration, login, session lifecycle"),42 (name = "auth", description = "Registration, login, session lifecycle"),
43- (name = "users", description = "User info: self-service profile and UI preferences (theme `light`/`dark`, language `tr`/`en` — returned on every user response, `null` until chosen), name search for the pickers (teacher+, optionally role-filtered), plus listing, lookup, and role/profile/preferences administration (admin only). Also the parent↔student ties: admins link students to a `parent` account under `/users/{id}/students` (link, list, unlink — a role change on either side drops its ties), and a parent lists their own students at `/users/me/students`; the tie grants the parent read access to those students' mark, attendance, and pomodoro reports and nothing else"),43+ (name = "users", description = "User info: self-service profile and UI preferences (theme `light`/`dark`, language `tr`/`en` — returned on every user response, `null` until chosen), name search for the pickers (teacher+, optionally role-filtered), plus listing, lookup, and role/profile/preferences administration (admin only). Also the parent↔student ties: admins link students to a `parent` account under `/users/{id}/students` (link, list, unlink — a role change on either side drops its ties), and a parent lists their own students at `/users/me/students`; the tie grants the parent read access to those students' mark, attendance, pomodoro, and homework reports and nothing else"),
44 (name = "notes", description = "Per-user notes CRUD, plus file attachments per note (multipart upload, download, delete — at most 10 per note, each at most the school's settings-configured `max_file_bytes`)"),44 (name = "notes", description = "Per-user notes CRUD, plus file attachments per note (multipart upload, download, delete — at most 10 per note, each at most the school's settings-configured `max_file_bytes`)"),
45 (name = "messages", description = "One-to-one mail-style messages between any two users (parents included — messaging is the one place a parent writes), each optionally tagged with a free-text `label` badge. Each party owns their copy independently: the recipient's moves through `inbox`/`archive`/`trash` with a read flag (visible to the sender as a read receipt), the sender's through `sent`/`trash`. `GET /messages?folder=` lists one folder (`&read=false` narrows to unread — with `limit=1`, `total` is the unread badge); permanent deletion (`DELETE`) works only from the trash and removes the row once both sides have deleted"),45 (name = "messages", description = "One-to-one mail-style messages between any two users (parents included — messaging is the one place a parent writes), each optionally tagged with a free-text `label` badge. Each party owns their copy independently: the recipient's moves through `inbox`/`archive`/`trash` with a read flag (visible to the sender as a read receipt), the sender's through `sent`/`trash`. `GET /messages?folder=` lists one folder (`&read=false` narrows to unread — with `limit=1`, `total` is the unread badge); permanent deletion (`DELETE`) works only from the trash and removes the row once both sides have deleted"),
46 (name = "events", description = "Events with an audience (school-wide, one role, a course's enrollment, or a registration signup list — the expected-attendee roster; every event stays visible to all) and their attendance: teacher+ marks people in the audience (students never mark, not even themselves), and the roster report joins the expected list with the marks to show who missed. Registration lists are filled seat by seat (teachers place students, staff place only themselves), optionally capped by `capacity`, and close once the event starts"),46 (name = "events", description = "Events with an audience (school-wide, one role, a course's enrollment, or a registration signup list — the expected-attendee roster; every event stays visible to all) and their attendance: teacher+ marks people in the audience (students never mark, not even themselves), and the roster report joins the expected list with the marks to show who missed. Registration lists are filled seat by seat (teachers place students, staff place only themselves), optionally capped by `capacity`, and close once the event starts"),
@@ -54,7 +54,7 @@ use crate::state::AppState;
54 (name = "marks", description = "Weighted mark reports per course and overall, labeled by the school's grade bands when configured. Each mark counts its exam kind's settings-configured weight times (weight 1 when the kind was since removed from settings). Own report at `/me`; another user's needs teacher+ (teachers narrowed to their courses) or a parent link to that student"),54 (name = "marks", description = "Weighted mark reports per course and overall, labeled by the school's grade bands when configured. Each mark counts its exam kind's settings-configured weight times (weight 1 when the kind was since removed from settings). Own report at `/me`; another user's needs teacher+ (teachers narrowed to their courses) or a parent link to that student"),
55 (name = "settings", description = "School policy, one singleton: exam kinds with their course-average weights, attendance statuses, grade-display bands, and the per-file upload size limit (`max_file_bytes` — note files and question images alike). Read: any authenticated user; edit: manager+"),55 (name = "settings", description = "School policy, one singleton: exam kinds with their course-average weights, attendance statuses, grade-display bands, and the per-file upload size limit (`max_file_bytes` — note files and question images alike). Read: any authenticated user; edit: manager+"),
56 (name = "subjects", description = "A course's curriculum topics. Created and listed under `/courses/{id}/subjects`; lookup/edit/delete at `/subjects/{id}`. Every exam question links to one of its course's subjects, so a subject in use cannot be deleted (409) — re-tag or delete the questions first. View follows the course (enrolled users, creator, assigned teachers, manager+); edit follows course management rights"),56 (name = "subjects", description = "A course's curriculum topics. Created and listed under `/courses/{id}/subjects`; lookup/edit/delete at `/subjects/{id}`. Every exam question links to one of its course's subjects, so a subject in use cannot be deleted (409) — re-tag or delete the questions first. View follows the course (enrolled users, creator, assigned teachers, manager+); edit follows course management rights"),
57- (name = "homework", description = "Course homework: a teacher assigns it per course (`POST /courses/{id}/homework`), tagged with one of the course's subjects and given a future `due_at`, to the whole enrolled course or an optional `assigned` subset (empty means the whole course — whoever is enrolled when they submit; a subset cannot later be narrowed so as to strand work that already exists). Students submit optional text plus files (photos/documents); a submission touched after `due_at` is flagged late (computed, never stored) and stays editable until it is graded. A teacher grades a status (`done`/`incomplete`/`missing`) with an optional 0–100 mark — grading freezes the submission until the grade is removed, and beyond a teacher-set `missing` the roster and reports also compute a `missing` for anyone unsubmitted past due. Students see and fetch only the homework they are assigned (others 404, so a subset assignment never leaks); a linked parent reads a student's homework report — statuses, late flags, marks — but never the submitted files"),57+ (name = "homework", description = "Course homework: a teacher assigns it per course (`POST /courses/{id}/homework`), tagged with one of the course's subjects (re-taggable; a subject with homework refuses deletion until it is re-tagged or removed) and given a future `due_at`, to the whole enrolled course or an optional `assigned` subset (empty means the whole course — whoever is enrolled when they submit; a subset cannot later be narrowed so as to strand work that already exists). Students submit optional text plus files — any content type, up to 10 per submission, each capped by the school's `max_file_bytes`, always served back as forced attachment downloads (never inline); a submission touched after `due_at` is flagged late (computed from the moving last-touch stamp, never stored — the first-submit stamp is immutable) and stays editable until it is graded. A teacher grades a status (`done`/`incomplete`/`missing`) with an optional 0–100 mark — grading freezes the submission until the grade is removed (un-grading reopens it), never targets the grader themselves, and covers work never handed in (that is how `missing` is set; the student reads the verdict at `GET /homework/{id}/result`). Beyond a teacher-set `missing` the roster and reports also compute a `missing` for anyone unsubmitted past due, and the roster keeps a straggler's stale work visible (flagged `unenrolled`) after an unenrollment or promotion. Homework marks stay out of the weighted `/marks` averages. Students see and fetch only the homework they are assigned (others 404, so a subset assignment never leaks); a linked parent reads a student's homework report — statuses, late flags, marks — but never the submitted files"),
58 (name = "terms", description = "Academic terms (semester/trimester/quarter — whatever the school runs); courses may link to one. Read: any authenticated user; edit: manager+"),58 (name = "terms", description = "Academic terms (semester/trimester/quarter — whatever the school runs); courses may link to one. Read: any authenticated user; edit: manager+"),
59 ),59 ),
60 )]60 )]