forge
Explore
Log in

Don't you dare go Hollow

Per-school policy guide, settings/terms endpoints

Browse files at this commit

caa814c843eb454dcd7e90b75975efb2a45c86f2Ahmet Kaan GümüşParent: e7fdc28
  • docs
    • per-school policy guide, settings/terms endpoints
Show full message
📝 docs: per-school policy guide, settings/terms endpoints
README.mdmodified+62 -3
@@ -15,6 +15,9 @@ monitor endpoint (snapshot or SSE stream). Courses also carry **lesson
15 sessions** with teacher-taken roll call (students never self-mark a lesson),15 sessions** with teacher-taken roll call (students never self-mark a lesson),
16 staff clock in/out on a server-stamped **work log**, and every user has an16 staff clock in/out on a server-stamped **work log**, and every user has an
17 **attendance report** (event + per-course lesson tallies with rates).17 **attendance report** (event + per-course lesson tallies with rates).
18+School-varying policy is data, not code: exam kinds, attendance statuses, and
19+grade-display bands live in an editable **settings** singleton, and academic
20+**terms** are plain rows courses can link to (see "Per-school policy").
18 21
19 Every field is a validated newtype (`Username(String)`, `NoteTitle(String)`, …)22 Every field is a validated newtype (`Username(String)`, `NoteTitle(String)`, …)
20 constructed only after its restrictions pass — invalid input can't be23 constructed only after its restrictions pass — invalid input can't be
@@ -171,6 +174,8 @@ effect on the user's very next call (no re-login).
171 | Read another user's mark report | teacher | Narrowed to the caller's managed courses; `manager`+ sees all |174 | Read another user's mark report | teacher | Narrowed to the caller's managed courses; `manager`+ sees all |
172 | Grade students | teacher | Target must be **enrolled**; grading never targets oneself |175 | Grade students | teacher | Target must be **enrolled**; grading never targets oneself |
173 | Edit **own** personal info (name, surname, email, phone, birth date) | student | Every account carries the same optional info fields |176 | Edit **own** personal info (name, surname, email, phone, birth date) | student | Every account carries the same optional info fields |
177+| Read the school settings and the term list | student | Clients need them to render kind/status pickers, grades, and the calendar |
178+| Edit school settings; create / edit / delete terms | manager | School policy (exam kinds, attendance statuses, grade bands) and the academic calendar are management's call |
174 | List users; look up one user; change a user's role; edit **any** user's personal info | admin | An admin cannot change **their own** role |179 | List users; look up one user; change a user's role; edit **any** user's personal info | admin | An admin cannot change **their own** role |
175 180
176 ### Bootstrapping the first admin181 ### Bootstrapping the first admin
@@ -298,10 +303,23 @@ marks/attendance reports narrow to the courses the caller manages.
298 | DELETE | `/work/entries/{id}` | manager | Delete a work entry (open or closed) |303 | DELETE | `/work/entries/{id}` | manager | Delete a work entry (open or closed) |
299 | GET | `/attendance/me` | student | Own attendance report: events + sessions + per-course tallies |304 | GET | `/attendance/me` | student | Own attendance report: events + sessions + per-course tallies |
300 | GET | `/attendance/{user}` | teacher | A user's attendance report, narrowed to the caller's courses (manager+: full) |305 | GET | `/attendance/{user}` | teacher | A user's attendance report, narrowed to the caller's courses (manager+: full) |
301-306+| GET | `/settings` | student | The school's policy: `exam_kinds`, `attendance_statuses`, `grade_bands` |
302-`status` ∈ `present | absent | late | excused`.307+| PATCH | `/settings` | manager | Replace any subset of the three lists, each wholesale (see "Per-school policy") |
303-`kind` ∈ `homework | quiz | midterm | final | project | oral` — informational308+| POST | `/terms` | manager | `{name, starts_at, ends_at}` — past dates allowed (calendar backfill) |
309+| GET | `/terms` | student | List terms, newest first |
310+| GET | `/terms/{id}` | student | Get one term |
311+| PATCH | `/terms/{id}` | manager | Edit a term (the merged range must stay ordered) |
312+| DELETE | `/terms/{id}` | manager | Delete a term — linked courses are unlinked, never deleted |
313+
314+`status` must be one of the school's attendance statuses (`GET /settings`);
315+the core four `present | absent | late | excused` always exist, plus whatever
316+the school added.
317+`kind` must be one of the school's exam kinds (`GET /settings`; defaults:
318+`homework | quiz | midterm | final | project | oral`) — informational
304 metadata; the average is driven by `weight`, an integer `1`–`100` set per exam.319 metadata; the average is driven by `weight`, an integer `1`–`100` set per exam.
320+A course may carry a `term_id` (`null` = unassigned); on `PATCH
321+/courses/{id}`, an omitted `term_id` keeps the link and an explicit `null`
322+clears it.
305 `role` ∈ `student | teacher | manager | admin`. Ids in responses are ULIDs.323 `role` ∈ `student | teacher | manager | admin`. Ids in responses are ULIDs.
306 An exam `mark` is an integer `0`–`100`; it lives in its own `exam_result` row,324 An exam `mark` is an integer `0`–`100`; it lives in its own `exam_result` row,
307 never in a `note`. Students never grade anyone — grading is teacher+ with325 never in a `note`. Students never grade anyone — grading is teacher+ with
@@ -337,6 +355,47 @@ seed them. A duplicate username on register is a `409`; that this reveals the
337 name is taken is a deliberate tradeoff (usernames are public handles here,355 name is taken is a deliberate tradeoff (usernames are public handles here,
338 unlike emails).356 unlike emails).
339 357
358+## Per-school policy (settings & terms)
359+
360+Every school runs differently; the parts that vary are data, not code. One
361+editable `settings` singleton (`GET /settings` for any signed-in user,
362+`PATCH /settings` for manager+) carries three knobs:
363+
364+- **`exam_kinds`** — the accepted `kind` values for new exams. Defaults to
365+ `homework, quiz, midterm, final, project, oral`; replace the list with
366+ whatever the school grades (`lab`, `presentation`, …). Kinds stay
367+ informational — `weight` drives every average.
368+- **`attendance_statuses`** — what attendance marking accepts. The core four
369+ (`present`, `absent`, `late`, `excused`) are mandatory because the
370+ attendance rate is defined over them (`(present+late) /
371+ (present+absent+late)`); school extras (say `online`) are **rate-neutral**
372+ and tally under `custom` in the attendance reports.
373+- **`grade_bands`** — how numeric marks display: a list of `{min, label}`
374+ bands (`85 → "AA"`, `50 → "CC"`, …). One band must start at `0` so every
375+ mark maps; an empty list (the default) means numeric-only. Storage and
376+ averaging stay `0`–`100` forever — bands only add `grade`,
377+ `average_grade`, and `overall_grade` labels to the mark report, so a school
378+ can switch display scales without touching a single stored mark.
379+
380+A `PATCH` replaces only the fields it carries, each wholesale, and validation
381+is all-or-nothing. Editing a list never rewrites history: an exam keeps its
382+retired kind, a roll-call row keeps its retired status — only **new writes**
383+are held to the current lists.
384+
385+Academic structure is data too. **Terms** (`/terms`) model whatever calendar
386+the school runs — semester, trimester, quarter systems are just rows with a
387+name and a date range. Courses may link to one via `term_id` (nullable), and
388+deleting a term only unlinks its courses. Term dates may lie in the past,
389+deliberately: a school adopting the app mid-year backfills its calendar —
390+unlike exam/lesson/event times, which reject backdating.
391+
392+What stays fixed is deliberate too: the four roles, the `0`–`100` mark scale,
393+validation bounds, and the UTC time policy are invariants, not preferences
394+(rename role labels in the frontend if a school says "principal" instead of
395+"manager"). Deployment knobs (ports, rate limits, admin seed, CORS) remain
396+environment variables — the model is **one school per deployment**, which
397+keeps every school's data physically isolated.
398+
340 ## Sync/async exams, attempts & live monitoring399 ## Sync/async exams, attempts & live monitoring
341 400
342 An exam is **unscheduled** by default (all schedule fields `null`) — graded401 An exam is **unscheduled** by default (all schedule fields `null`) — graded