diff --git a/README.md b/README.md index abb6d5b..fa6a256 100644 --- a/README.md +++ b/README.md @@ -460,10 +460,14 @@ deadline rules mid-sitting would be a different exam (`409`). The course's manager (its creator, or manager+) watches it all live: `GET /exams/{id}/live` returns one snapshot — -the enrolled roster joined with attempts and marks (`not_started` | +the enrolled roster joined with attempts and marks (`not_started` | `absent` | `in_progress` | `submitted` | `expired`, per-student `attempt` / `attempts_used` / `left_at` / `deadline` / `remaining_ms` / `mark`, always the -latest sitting) plus summary counts, all judged at a single `now`. +latest sitting) plus summary counts, all judged at a single `now`. Once the +window closes, `not_started` hardens into `absent` — the no-shows, flagged +right in the roster (open exams have no window, so never an `absent`). The +flag is informational: an absent student still has no mark until the teacher +records one through `POST /exams/{id}/results`. `GET /exams/{id}/live/stream` is the same JSON as Server-Sent Events: a `snapshot` event immediately on connect, then every ~2 s — attendance, ticking clocks, submissions, and marks land without polling: diff --git a/src/web/exams.rs b/src/web/exams.rs index 45edb1b..beed9c6 100644 --- a/src/web/exams.rs +++ b/src/web/exams.rs @@ -907,7 +907,10 @@ async fn finish_attempt( #[derive(Serialize, ToSchema)] struct LiveStudentResponse { user: PersonRef, - /// `not_started` | `in_progress` | `submitted` | `expired`. + /// `not_started` | `absent` | `in_progress` | `submitted` | `expired`. + /// `absent` is `not_started` after the window closed: the student never + /// sat and no longer can. Open exams have no window, so nobody is ever + /// absent from one. #[schema(example = "in_progress")] status: String, /// Which sitting the shown attempt is (1, 2, …); `null` before the first. @@ -934,7 +937,11 @@ struct LiveStudentResponse { #[derive(Serialize, ToSchema)] struct LiveCountsResponse { enrolled: u64, + /// Enrolled with no attempt while the window is still open (or the exam + /// has no window). not_started: u64, + /// Enrolled with no attempt and the window closed — the no-shows. + absent: u64, in_progress: u64, submitted: u64, expired: u64, @@ -1000,6 +1007,10 @@ async fn live_snapshot(exam: &Exam, db: &Database) -> Result= ends); let mut students: Vec = roster .iter() .map(|enrollment| { @@ -1009,9 +1020,12 @@ async fn live_snapshot(exam: &Exam, db: &Database) -> Result status.as_str(), + None if window_over => "absent", + None => "not_started", + } + .to_string(), attempt: attempt.map(ExamAttempt::get_seq), attempts_used: used.get(key).copied().unwrap_or(0), started_at: attempt.map(|a| a.get_started_at().as_millis()), @@ -1035,6 +1049,7 @@ async fn live_snapshot(exam: &Exam, db: &Database) -> Result Result