Align OpenAPI + README with attempts/rejoin
Browse files at this commit7341f2f7fe0522b77a9b431e8afe087a84830785Parent: c010b64- docs
- align OpenAPI + README with attempts/rejoin
4 changed files +33 -16
- README.md +14 -5
- src/lib.rs +2 -2
- src/web/courses.rs +6 -1
- src/web/exams.rs +11 -8
README.mdmodified+14 -5
| @@ -7,11 +7,14 @@ Session-cookie auth with four hierarchical roles (`student < teacher < manager | ||
| 7 | 7 | then mark users present / absent / late / excused. Marks are course-shaped |
| 8 | 8 | (Google Classroom style): a teacher creates a course, enrolls students, adds |
| 9 | 9 | 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 scheduled | |
| 11 | -**sync** (one fixed window) or **async** (start anytime inside the window, with | |
| 12 | -a personal time budget); students *sit* them via attempts, and teachers watch | |
| 13 | -attendance, per-student remaining time, submissions, and marks land live on a | |
| 14 | -monitor endpoint (snapshot or SSE stream). Courses also carry **lesson | |
| 10 | +average and an overall average from their mark report. Exams run **sync** (one | |
| 11 | +fixed window), **async** (start anytime inside the window, with a personal | |
| 12 | +time budget), or **open** (sit anytime, optionally timed per attempt); | |
| 13 | +students *sit* them via attempts — retakes metered by a per-exam limit | |
| 14 | +(`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 | 18 | sessions** with teacher-taken roll call (students never self-mark a lesson), |
| 16 | 19 | staff clock in/out on a server-stamped **work log**, and every user has an |
| 17 | 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 | 480 | > keep data, backfill manually with the SurrealDB CLI (server stopped), e.g. |
| 478 | 481 | > `UPDATE exam SET course = course:<id>, weight = 1 WHERE course = NONE;` |
| 479 | 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 | 490 | ## Taking an exam: questions, answers & the exam room |
| 482 | 491 |
src/lib.rsmodified+2 -2
| @@ -32,7 +32,7 @@ use crate::state::AppState; | ||
| 32 | 32 | info( |
| 33 | 33 | title = "Hezarfen Backend API", |
| 34 | 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 | 37 | modifiers(&SecurityAddon), |
| 38 | 38 | tags( |
| @@ -45,7 +45,7 @@ use crate::state::AppState; | ||
| 45 | 45 | (name = "sessions", description = "Lesson sessions and their roll call (session teacher or course manager marks enrolled students; manager+ marks the teacher)"), |
| 46 | 46 | (name = "work", description = "Staff work log: check-in/check-out stamped by the server clock, manager corrections"), |
| 47 | 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 | 49 | (name = "marks", description = "Weighted mark reports per course and overall, labeled by the school's grade bands when configured"), |
| 50 | 50 | (name = "settings", description = "School policy, one singleton: exam kinds, attendance statuses, grade-display bands. Read: any authenticated user; edit: manager+"), |
| 51 | 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 | 489 | /// Create an exam inside a course. Requires teacher+ and course management |
| 490 | 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 | 496 | #[utoipa::path( |
| 492 | 497 | post, |
| 493 | 498 | path = "/{id}/exams", |
| @@ -497,7 +502,7 @@ async fn unenroll( | ||
| 497 | 502 | request_body = CreateExamInCourse, |
| 498 | 503 | responses( |
| 499 | 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 | 506 | (status = 401, description = "Not authenticated", body = ErrorResponse), |
| 502 | 507 | (status = 403, description = "Not the course creator (and not a manager/admin)", body = ErrorResponse), |
| 503 | 508 | (status = 404, description = "Course not found", body = ErrorResponse), |
src/web/exams.rsmodified+11 -8
| @@ -232,7 +232,7 @@ async fn get_exam( | ||
| 232 | 232 | request_body = UpdateExam, |
| 233 | 233 | responses( |
| 234 | 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 | 236 | (status = 401, description = "Not authenticated", body = ErrorResponse), |
| 237 | 237 | (status = 403, description = "Not the course creator (and not a manager/admin)", body = ErrorResponse), |
| 238 | 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, time | |
| 1060 | -/// each student has left, and marks as they land. Requires teacher+ and | |
| 1059 | +/// A one-shot live snapshot of the exam: who's in, who's still writing (and | |
| 1060 | +/// 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 | 1062 | /// management rights over the exam's course. For a self-updating feed of the |
| 1062 | 1063 | /// same shape, see `GET /exams/{id}/live/stream`. |
| 1063 | 1064 | #[utoipa::path( |
| @@ -1556,7 +1557,8 @@ pub(crate) async fn save_answer_checked( | ||
| 1556 | 1557 | } |
| 1557 | 1558 | |
| 1558 | 1559 | /// The exam's questions as the sitting student sees them: `correct` stripped, |
| 1559 | -/// their own saved answers embedded. Requires an attempt — start one with | |
| 1560 | +/// 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 | 1562 | /// `POST /exams/{id}/attempt` first (404 until then). Readable in every |
| 1561 | 1563 | /// attempt state, so a submitted student can still review what they wrote. |
| 1562 | 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 the | |
| 1661 | -/// saved answer plus `is_correct` (`null` for text questions — those are the | |
| 1662 | -/// grader's call), and the machine's `auto_score` over the choice questions is | |
| 1663 | -/// attached as a *suggestion*: the final mark stays human, via | |
| 1662 | +/// One student's answer sheet with correctness flags — always the *latest* | |
| 1663 | +/// sitting's answers (a retake starts from a blank sheet). Every row carries | |
| 1664 | +/// the saved answer plus `is_correct` (`null` for text questions — those are | |
| 1665 | +/// 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 | 1667 | /// `POST /exams/{id}/results`. Requires teacher+ and management rights over |
| 1665 | 1668 | /// the exam's course. |
| 1666 | 1669 | #[utoipa::path( |