forge
Explore
Log in

Don't you dare go Hollow

Align OpenAPI + README with attempts/rejoin

Browse files at this commit

7341f2f7fe0522b77a9b431e8afe087a84830785Ahmet Kaan GümüşParent: c010b64
  • docs
    • align OpenAPI + README with attempts/rejoin
Show full message
📝 docs(exams): align OpenAPI + README with attempts/rejoin

The generated spec and README lagged the feature: the exams tag and
top-level description still said sync/async only, the intro paragraph
predated open mode, and several operation docs didn't say the sheet
and sitting views are always the latest attempt's.

- exams tag + API description: open mode, retake limits, rejoin door,
  draft-409 semantics, WS left_at behavior
- create-exam summary walks the mode matrix and both policy knobs;
  400 descriptions mention the attempt limit
- answer sheet / sitting view / live snapshot docs note latest-sitting
  semantics and left_at
- README: intro paragraph, and a note that the attempts/rejoin schema
  upgrade is fully automatic at boot (unlike the pre-course one)
README.mdmodified+14 -5
@@ -7,11 +7,14 @@ Session-cookie auth with four hierarchical roles (`student < teacher < manager
7 then mark users present / absent / late / excused. Marks are course-shaped7 then mark users present / absent / late / excused. Marks are course-shaped
8 (Google Classroom style): a teacher creates a course, enrolls students, adds8 (Google Classroom style): a teacher creates a course, enrolls students, adds
9 weighted exams inside it, and grades; students read a per-course weighted9 weighted exams inside it, and grades; students read a per-course weighted
10-average and an overall average from their mark report. Exams can be scheduled10+average and an overall average from their mark report. Exams run **sync** (one
11-**sync** (one fixed window) or **async** (start anytime inside the window, with11+fixed window), **async** (start anytime inside the window, with a personal
12-a personal time budget); students *sit* them via attempts, and teachers watch12+time budget), or **open** (sit anytime, optionally timed per attempt);
13-attendance, per-student remaining time, submissions, and marks land live on a13+students *sit* them via attempts — retakes metered by a per-exam limit
14-monitor endpoint (snapshot or SSE stream). Courses also carry **lesson14+(`0` = unlimited), leaving the exam room governed by a teacher-controlled
15+rejoin door — and teachers watch attendance, per-student remaining time,
16+sittings, walk-outs, submissions, and marks land live on a monitor endpoint
17+(snapshot or SSE stream). Courses also carry **lesson
15 sessions** with teacher-taken roll call (students never self-mark a lesson),18 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 an19 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).20 **attendance report** (event + per-course lesson tallies with rates).
@@ -477,6 +480,12 @@ roster but keeps the attempt and mark rows, mirroring the marks report.
477 > keep data, backfill manually with the SurrealDB CLI (server stopped), e.g.480 > keep data, backfill manually with the SurrealDB CLI (server stopped), e.g.
478 > `UPDATE exam SET course = course:<id>, weight = 1 WHERE course = NONE;`481 > `UPDATE exam SET course = course:<id>, weight = 1 WHERE course = NONE;`
479 > after creating a course to attach them to.482 > after creating a course to attach them to.
483+>
484+> **Upgrading to the attempts/rejoin build needs nothing manual**: the boot
485+> migration backfills `max_attempts = 1`, `allow_rejoin = true`, and attempt
486+> `seq = 1` on existing rows, and swaps the single-attempt unique index for
487+> the per-sitting one. Pre-upgrade attempts keep their record ids and count
488+> as sitting #1.
480 489
481 ## Taking an exam: questions, answers & the exam room490 ## Taking an exam: questions, answers & the exam room
482 491
src/lib.rsmodified+2 -2
@@ -32,7 +32,7 @@ use crate::state::AppState;
32 info(32 info(
33 title = "Hezarfen Backend API",33 title = "Hezarfen Backend API",
34 version = env!("CARGO_PKG_VERSION"),34 version = env!("CARGO_PKG_VERSION"),
35- description = "Notes, events, attendance, courses, and weighted exam marks behind cookie-session auth. Courses carry lesson sessions with teacher-taken roll call; staff clock in/out on a server-stamped work log; attendance reports tally events and per-course roll call with rates. School-varying policy (exam kinds, attendance statuses, grade-display bands) lives in an editable settings singleton, and courses may link to academic terms.",35+ description = "Notes, events, attendance, courses, and weighted exam marks behind cookie-session auth. 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. Courses carry lesson sessions with teacher-taken roll call; staff clock in/out on a server-stamped work log; attendance reports tally events and per-course roll call with rates. School-varying policy (exam kinds, attendance statuses, grade-display bands) lives in an editable settings singleton, and courses may link to academic terms.",
36 ),36 ),
37 modifiers(&SecurityAddon),37 modifiers(&SecurityAddon),
38 tags(38 tags(
@@ -45,7 +45,7 @@ use crate::state::AppState;
45 (name = "sessions", description = "Lesson sessions and their roll call (session teacher or course manager marks enrolled students; manager+ marks the teacher)"),45 (name = "sessions", description = "Lesson sessions and their roll call (session teacher or course manager marks enrolled students; manager+ marks the teacher)"),
46 (name = "work", description = "Staff work log: check-in/check-out stamped by the server clock, manager corrections"),46 (name = "work", description = "Staff work log: check-in/check-out stamped by the server clock, manager corrections"),
47 (name = "attendance", description = "Attendance summary reports: event tallies + per-course lesson roll call with rates"),47 (name = "attendance", description = "Attendance summary reports: event tallies + per-course lesson roll call with rates"),
48- (name = "exams", description = "Exams (per course, weighted): results, sync/async scheduling, attempts, questions/answers, and live monitoring. Not in this spec (WebSocket): the student exam room at `GET /exams/{id}/attempt/ws` — JSON frames, see the README's \"Taking an exam\" section for the protocol"),48+ (name = "exams", description = "Exams (per course, weighted): results, sync/async/open scheduling, attempts with retakes (`max_attempts`, 0 = unlimited) and a live rejoin door (`allow_rejoin`), questions/answers, and live monitoring. A modeless exam is an offline-graded draft — attempts on it are a 409. Not in this spec (WebSocket): the student exam room at `GET /exams/{id}/attempt/ws` — JSON frames; entering clears the attempt's `left_at`, leaving mid-attempt stamps it. See the README's \"Taking an exam\" section for the protocol"),
49 (name = "marks", description = "Weighted mark reports per course and overall, labeled by the school's grade bands when configured"),49 (name = "marks", description = "Weighted mark reports per course and overall, labeled by the school's grade bands when configured"),
50 (name = "settings", description = "School policy, one singleton: exam kinds, attendance statuses, grade-display bands. Read: any authenticated user; edit: manager+"),50 (name = "settings", description = "School policy, one singleton: exam kinds, attendance statuses, grade-display bands. Read: any authenticated user; edit: manager+"),
51 (name = "terms", description = "Academic terms (semester/trimester/quarter — whatever the school runs); courses may link to one. Read: any authenticated user; edit: manager+"),51 (name = "terms", description = "Academic terms (semester/trimester/quarter — whatever the school runs); courses may link to one. Read: any authenticated user; edit: manager+"),
src/web/courses.rsmodified+6 -1
@@ -488,6 +488,11 @@ async fn unenroll(
488 488
489 /// Create an exam inside a course. Requires teacher+ and course management489 /// Create an exam inside a course. Requires teacher+ and course management
490 /// rights; the exam's marks count `weight` times into the course average.490 /// rights; the exam's marks count `weight` times into the course average.
491+/// Omit `mode` for an offline-graded draft nobody can sit; `sync`/`async`
492+/// take a window (async also `duration_ms`), `open` is sittable anytime with
493+/// an optional per-attempt `duration_ms`. `max_attempts` (default 1, `0` =
494+/// unlimited) meters retakes and `allow_rejoin` (default `true`) is the
495+/// exam-room door — both stay editable while the exam runs.
491 #[utoipa::path(496 #[utoipa::path(
492 post,497 post,
493 path = "/{id}/exams",498 path = "/{id}/exams",
@@ -497,7 +502,7 @@ async fn unenroll(
497 request_body = CreateExamInCourse,502 request_body = CreateExamInCourse,
498 responses(503 responses(
499 (status = 201, description = "Exam created", body = ExamResponse),504 (status = 201, description = "Exam created", body = ExamResponse),
500- (status = 400, description = "Invalid fields, kind, weight, or schedule (malformed window, or times in the past)", body = ErrorResponse),505+ (status = 400, description = "Invalid fields, kind, weight, attempt limit, or schedule (malformed window, or times in the past)", body = ErrorResponse),
501 (status = 401, description = "Not authenticated", body = ErrorResponse),506 (status = 401, description = "Not authenticated", body = ErrorResponse),
502 (status = 403, description = "Not the course creator (and not a manager/admin)", body = ErrorResponse),507 (status = 403, description = "Not the course creator (and not a manager/admin)", body = ErrorResponse),
503 (status = 404, description = "Course not found", body = ErrorResponse),508 (status = 404, description = "Course not found", body = ErrorResponse),
src/web/exams.rsmodified+11 -8
@@ -232,7 +232,7 @@ async fn get_exam(
232 request_body = UpdateExam,232 request_body = UpdateExam,
233 responses(233 responses(
234 (status = 200, description = "Updated exam", body = ExamResponse),234 (status = 200, description = "Updated exam", body = ExamResponse),
235- (status = 400, description = "Invalid fields, kind, weight, or schedule (malformed window, or newly set times in the past)", body = ErrorResponse),235+ (status = 400, description = "Invalid fields, kind, weight, attempt limit, or schedule (malformed window, or newly set times in the past)", body = ErrorResponse),
236 (status = 401, description = "Not authenticated", body = ErrorResponse),236 (status = 401, description = "Not authenticated", body = ErrorResponse),
237 (status = 403, description = "Not the course creator (and not a manager/admin)", body = ErrorResponse),237 (status = 403, description = "Not the course creator (and not a manager/admin)", body = ErrorResponse),
238 (status = 404, description = "Not found", body = ErrorResponse),238 (status = 404, description = "Not found", body = ErrorResponse),
@@ -1056,8 +1056,9 @@ async fn live_snapshot(exam: &Exam, db: &Database) -> Result<ExamLiveResponse, A
1056 })1056 })
1057 }1057 }
1058 1058
1059-/// A one-shot live snapshot of the exam: who's in, who's still writing, time1059+/// A one-shot live snapshot of the exam: who's in, who's still writing (and
1060-/// each student has left, and marks as they land. Requires teacher+ and1060+/// on which sitting), who walked out of the room (`left_at`), time each
1061+/// student has left, and marks as they land. Requires teacher+ and
1061 /// management rights over the exam's course. For a self-updating feed of the1062 /// management rights over the exam's course. For a self-updating feed of the
1062 /// same shape, see `GET /exams/{id}/live/stream`.1063 /// same shape, see `GET /exams/{id}/live/stream`.
1063 #[utoipa::path(1064 #[utoipa::path(
@@ -1556,7 +1557,8 @@ pub(crate) async fn save_answer_checked(
1556 }1557 }
1557 1558
1558 /// The exam's questions as the sitting student sees them: `correct` stripped,1559 /// The exam's questions as the sitting student sees them: `correct` stripped,
1559-/// their own saved answers embedded. Requires an attempt — start one with1560+/// their own saved answers embedded — the latest sitting's, since a retake
1561+/// starts from a blank sheet. Requires an attempt — start one with
1560 /// `POST /exams/{id}/attempt` first (404 until then). Readable in every1562 /// `POST /exams/{id}/attempt` first (404 until then). Readable in every
1561 /// attempt state, so a submitted student can still review what they wrote.1563 /// attempt state, so a submitted student can still review what they wrote.
1562 #[utoipa::path(1564 #[utoipa::path(
@@ -1657,10 +1659,11 @@ async fn save_answer(
1657 }))1659 }))
1658 }1660 }
1659 1661
1660-/// One student's answer sheet with correctness flags. Every row carries the1662+/// One student's answer sheet with correctness flags — always the *latest*
1661-/// saved answer plus `is_correct` (`null` for text questions — those are the1663+/// sitting's answers (a retake starts from a blank sheet). Every row carries
1662-/// grader's call), and the machine's `auto_score` over the choice questions is1664+/// the saved answer plus `is_correct` (`null` for text questions — those are
1663-/// attached as a *suggestion*: the final mark stays human, via1665+/// the grader's call), and the machine's `auto_score` over the choice
1666+/// questions is attached as a *suggestion*: the final mark stays human, via
1664 /// `POST /exams/{id}/results`. Requires teacher+ and management rights over1667 /// `POST /exams/{id}/results`. Requires teacher+ and management rights over
1665 /// the exam's course.1668 /// the exam's course.
1666 #[utoipa::path(1669 #[utoipa::path(