In a gradebook web app, a grade entered offline replays after a colleague changed that grade; how should the server reject it, and what should the teacher see?
answer
- the entry remembers what it was based on
- a failed precondition, not a silent overwrite
- park one target, send the rest
- both values, who and when
- the teacher decides, not a rule
basics
~20 sThe queued grade carries the revision the teacher saw; the server refuses it once the record has moved on, returning the current value. The app parks that entry and shows both versions: keep theirs, apply mine, or edit.
solid answer
~50 sThe queued entry carries the grade's revision as the teacher last saw it, sent as a precondition such as `If-Match`. If a colleague has changed the grade since, the server answers `412 Precondition Failed` (or `409 Conflict`) with the current value, who changed it and when. The client doesn't retry and doesn't overwrite: it parks that entry as "needs your decision", keeps it durable across reloads, holds back later edits to the same grade and lets the rest of the queue go. The teacher sees a quiet badge rather than a mid-lesson modal, and the resolution shows both values side by side with three choices: keep the colleague's grade, apply mine against the new revision, or edit and save. Rejections that aren't conflicts, such as a grade outside the scale or a class the teacher no longer teaches, get their own messages and no "apply mine".
code
http · 12 linesPUT /api/assessments/a-311/grades/p-2207 HTTP/1.1
If-Match: "rev-14"
Idempotency-Key: 6f1c2e9a-3b7d-4c55-9a0e-2d4f8b1c7e30
Content-Type: application/json
{"grade": "B+", "comment": "Strong method, weak conclusion"}
HTTP/1.1 412 Precondition Failed
Content-Type: application/json
{"current": {"grade": "A-", "comment": "Raised after moderation", "revision": "rev-15",
"changedBy": "Head of Science", "changedAt": "2026-10-07T10:40:00Z"}}go deeper
Recall that a write made offline can clash with someone else's change, and that the server needs to know what the write was based on.
Explain how a base revision sent as a precondition lets the server detect the clash, and what a 412 or 409 response should carry.
Design the parking, per-target blocking, the resolution view and the distinct handling of validation, authorisation and expired sessions.
Decide per kind of record whether a person or a server rule resolves conflicts, and make each rule visible to the teacher it affects.
## The situation A teacher grades a lab report offline at 10:12. At 10:40 the head of department, online, changes the same grade after moderation. At 11:05 the teacher's laptop reconnects and the queue replays the 10:12 grade. If the server simply applies it, the moderated grade is lost and nobody knows; that is the **lost update** problem. The design has two halves: the server must *detect* the clash, and the interface must let a person *decide* it. ## Detection: the entry remembers its base Every queued write records the **revision** of the record it was based on, the version the teacher saw when they typed. Replay sends it as a **precondition**: - With entity tags, the request carries `If-Match` with that revision; if the server's current revision differs, the condition is false and it answers `412 Precondition Failed`. - An API without entity tags can compare a revision field in the body and answer `409 Conflict`, which the HTTP specification describes as a conflict the user might be able to resolve and resubmit. Either way, the response should carry what the client needs to show the clash: the current value and comment, its revision, who changed it and when. The precondition mechanics themselves belong to the API contract; the design point is that **the base revision travels with the queued write**, captured at the moment of the edit, not at replay time. ## What the queue does with it 1. **Do not retry.** A failed precondition will fail again forever; backoff only delays the inevitable. 2. **Do not overwrite.** Resending automatically with the new revision silently discards the colleague's moderation. 3. **Do not drop.** Discarding the entry silently loses the teacher's work. 4. **Park it.** Mark the entry "needs your decision", keep it durable so it survives a reload, and skip later entries for the same pupil and assessment so they don't apply on top of an unresolved base. Entries for other pupils keep flowing. ## What the teacher sees | Moment | Interface | |---|---| | During the lesson | A small badge: "1 grade needs your decision". No modal. | | On the grade cell | A conflict marker instead of the pending marker | | Opening the conflict | Their value and comment, when entered; the colleague's value, comment, who and when | | Choices | Keep theirs · Apply mine · Edit | - **Keep theirs** deletes the parked entry and shows the server's grade. - **Apply mine** queues a *new* write against the new revision, an explicit, informed overwrite. - **Edit** opens the field pre-filled with both, and the save is a new write against the new revision. The teacher, not a timestamp rule, decides, because both edits are legitimate judgements and only a person knows whether the moderation already accounted for the lab report. ## Why not merge automatically Some clashes are mechanically separable: the teacher changed only the comment, the colleague only the grade. A server may accept such a write field by field, and that is a defensible rule, but the teacher should still see a notice that the grade beside their comment changed. When both touched the grade itself, there is nothing to merge: a grade is one judgement, and choosing between two judgements is a person's job. Conflict theory in general belongs elsewhere; the design call here is which records a rule may settle and which a teacher must. ## Not every rejection is a conflict - **Validation** (a grade outside the scheme) offers Edit, never Apply mine. - **Authorisation** (the teacher no longer teaches the class) explains who to contact, and offers to discard. - **Session expiry** stops replay altogether and asks the teacher to sign in again; the queue waits. Attendance can differ from grades: if the office has already recorded an authorised absence, the school may decide the office's record stands. That is a defensible server rule, but the teacher still sees a notice saying their mark was not applied and why. ## Before sign-out On a shared laptop, sign-out wipes the device. Parked entries must be resolved or explicitly discarded first, or the teacher's work disappears with no record that it ever conflicted. ## What it costs - **Server work**: revisions on every gradeable record, and responses rich enough to show both sides. - **Interface work**: a resolution view, a badge, and states for each rejection kind. - **Patience**: parked entries can wait hours; the design must not nag mid-lesson.
- The teacher made two offline edits to the same grade, and the first one conflicts. What happens to the second?It stays parked behind the first, because it was also based on the stale revision. When the teacher resolves the conflict, show the latest local value, not the first, as "yours", and drop the superseded local entry once a resolution is saved. Sending the second on its own would apply it over the colleague's grade without anyone deciding.
- Why not just show a toast saying the sync failed?A toast vanishes in seconds, says nothing about which grade or why, and leaves the teacher no way to act. Conflicts need a durable place, a badge and a list, that survives a reload and shows both values with who and when, because resolving one is a judgement the teacher may make hours later.
- Resend with the latest revision automatically; the offline value is newer.
- Drop the rejected entry quietly and refresh the cell from the server.
- Interrupt the lesson with a modal as soon as replay hits a conflict.
- Offer 'apply mine' for every rejection, including a revoked class.
- One rejected grade should block the whole queue until resolved.