No-past scheduling rule (60 s grace, kept-value exemption)
Browse files at this commitf17d0efc367fd50d9c2a02b28b3ab1b624c11595Parent: e70e5f5- docs
- no-past scheduling rule (60 s grace, kept-value exemption)
1 changed file +19 -6
- README.md +19 -6
README.mdmodified+19 -6
| @@ -88,6 +88,15 @@ Timezones and clock differences cannot corrupt data, by construction: | ||
| 88 | 88 | the writer's wall, not an instant: validation accepts up to UTC-tomorrow, |
| 89 | 89 | since a client ahead of UTC (up to UTC+14) legitimately writes a date the |
| 90 | 90 | server's UTC calendar hasn't reached yet. |
| 91 | +- **Nothing schedules in the past.** A request-supplied schedule instant — an | |
| 92 | + exam window, a lesson's `starts_at`/`ends_at`, an event time — must not lie | |
| 93 | + before the server's now, on create and on every `PATCH` that sets it: a | |
| 94 | + deadline that starts in the past is dead on arrival, so it's a `400`. A | |
| 95 | + 60-second grace absorbs request latency and client-clock skew ("starts now" | |
| 96 | + survives its own round trip). Values a `PATCH` merely keeps are exempt — a | |
| 97 | + running exam's `starts_at` is legitimately past, and a rename or deadline | |
| 98 | + extension must not trip over it. (Work-log corrections are records of past | |
| 99 | + work, not schedules, and stay free.) | |
| 91 | 100 | - **Frontends can sync to the server clock.** `GET /time` (no auth) returns |
| 92 | 101 | `{"now": <UTC unix-millis>}`. Fetch once, keep |
| 93 | 102 | `offset = now - Date.now()`, and use `Date.now() + offset` for countdowns |
| @@ -292,8 +301,9 @@ course averages. Unenrolling keeps result rows: the marks drop out of the | ||
| 292 | 301 | report until re-enrollment, but stay visible on the exam itself. Deleting a |
| 293 | 302 | course cascades its exams, their results, and all enrollments. |
| 294 | 303 | Event `starts_at`/`ends_at` are optional **unix-millisecond** integers; if both |
| 295 | -are given, `ends_at` must not precede `starts_at` (else `400`). On `PATCH`, an | |
| 296 | -omitted time keeps its value and an explicit `null` clears it. | |
| 304 | +are given, `ends_at` must not precede `starts_at`, and neither may be set in | |
| 305 | +the past (else `400`). On `PATCH`, an omitted time keeps its value and an | |
| 306 | +explicit `null` clears it. | |
| 297 | 307 | Reading a child collection of a missing parent (`/events/{id}/attendance`, |
| 298 | 308 | `/exams/{id}/results`, `/courses/{id}/enrollments`, `/courses/{id}/exams`, |
| 299 | 309 | `/courses/{id}/sessions`, `/sessions/{id}/attendance`) is a `404`, not an |
| @@ -320,8 +330,10 @@ setting, as one consistent unit (validated together on create and after every | ||
| 320 | 330 | starts anywhere inside the window and gets |
| 321 | 331 | `min(started_at + duration_ms, ends_at)` as their personal deadline. |
| 322 | 332 | `duration_ms` is 1 minute to 24 hours. |
| 323 | -- `ends_at` must be strictly after `starts_at`. All instants are the usual UTC | |
| 324 | - unix-milliseconds, judged only by the server clock (`GET /time` for sync). | |
| 333 | +- `ends_at` must be strictly after `starts_at`, and neither may be *set* in | |
| 334 | + the past — on create or `PATCH` (kept values are exempt, so a running exam | |
| 335 | + stays editable). All instants are the usual UTC unix-milliseconds, judged | |
| 336 | + only by the server clock (`GET /time` for sync). | |
| 325 | 337 | |
| 326 | 338 | A student **sits** a scheduled exam through their attempt (one per exam+user, |
| 327 | 339 | by construction — the row id is the composite key): |
| @@ -454,7 +466,8 @@ Events cover ad-hoc gatherings; **sessions** are a course's lessons. A session | ||
| 454 | 466 | belongs to a course and carries a `teacher` (defaults to whoever creates it; |
| 455 | 467 | any explicit `teacher_id` must hold teacher+ — a student cannot teach), an |
| 456 | 468 | optional `topic`, a required `starts_at`, and an optional `ends_at` (when both |
| 457 | -are set, `ends_at` must not precede `starts_at`). Sessions are created, edited, | |
| 469 | +are set, `ends_at` must not precede `starts_at`; neither may be set in the | |
| 470 | +past). Sessions are created, edited, | |
| 458 | 471 | and deleted under course-management rights, exactly like exams; session lists |
| 459 | 472 | are ordered by `starts_at` (a timetable, not a creation log). |
| 460 | 473 | |
| @@ -538,7 +551,7 @@ curl -s -b $JAR $BASE/exams/$EX/statistics | ||
| 538 | 551 | # lesson sessions + roll call (course manager creates; the session's teacher |
| 539 | 552 | # or a course manager marks enrolled students) |
| 540 | 553 | SE=$(curl -s -b $JAR $BASE/courses/$CO/sessions -H 'content-type: application/json' \ |
| 541 | - -d '{"topic":"limits","starts_at":1752275000000}' | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4) | |
| 554 | + -d '{"topic":"limits","starts_at":1900000000000}' | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4) | |
| 542 | 555 | curl -s -b $JAR $BASE/sessions/$SE/attendance -H 'content-type: application/json' \ |
| 543 | 556 | -d "{\"status\":\"present\",\"user_id\":\"$SID\"}" |
| 544 | 557 |