When a gradebook web app loses school Wi-Fi mid-lesson, what should the teacher see, and which actions should stay available or be disabled?
answer
- onLine is a hint, not a verdict
- trust your own requests' outcomes
- saved here, not yet sent
- age stamps on every cached read
- disable with a reason, never hide
basics
~20 sKeep the lesson going: attendance and grades still save, each marked as not yet sent; cached rosters show their age; only live-only features such as parent messages are disabled with a reason. Treat navigator.onLine as a hint, never a gate.
solid answer
~40 sThe teacher should be able to finish the lesson. Attendance taps and grade entries still work: each is saved on the device and shown with a small "not yet sent" marker that clears when the server confirms it, plus a calm banner with the unsent count. Cached reads such as the roster carry an "as of 07:58" stamp. Features that cannot work offline, parent messages above all, stay visible but disabled with a short reason. I wouldn't gate any of this on `navigator.onLine`: a classroom network can count as online with no internet behind it, so the app judges reachability from its own requests timing out or failing and uses the `online` and `offline` events only as cues to try again. Sign-out stays available but warns about unsent marks.
go deeper
Recall that a write saved on the device is not yet on the server, and that the screen must show which is which.
Explain why navigator.onLine is only a hint, how request outcomes decide reachability, and which actions stay available or are disabled with a reason.
Design the pending, needs-attention and age states as one system, including the sign-out warning and recovery without reshuffling the screen.
Set the offline interface conventions every team's screens follow, so glyphs, wording and disabled states mean the same thing across the product.
## The goal: the lesson goes on When a web app is **offline**, the browser cannot reach the app's server, either because the device has no network or because the network it has goes nowhere. In a school gradebook this happens mid-lesson on patchy Wi-Fi, and the design target is simple: the teacher finishes the register and the grading, and knows exactly what has not reached the server yet. ## Knowing that you are offline The browser exposes `navigator.onLine` and fires `online` and `offline` events on the window. They are weaker than they look: - A connection to a local network generally counts as online **even if that network has no internet access**, so `true` does not prove the server is reachable. - The value changes only after the browser checks its connection, usually when a page or script requests something. - The platform's own guidance is not to disable features based on it, only to give hints. So the app decides from **its own requests**: a request that times out or fails at the network level marks the server unreachable; a later success marks it reachable again. The events are useful cues to *try* a request, not verdicts. ## What the teacher sees | Element | Online | Offline | |---|---|---| | Connection banner | Hidden | Calm, persistent: "Working offline. 4 marks saved on this laptop, not yet sent." | | Attendance mark | Marked | Marked, with a "not yet sent" glyph | | Grade cell | Saved value | Value plus "not yet sent" | | Roster, timetable | Live | Cached, with "as of 07:58" | | Parent messages | Available | Disabled: "Needs a connection" | | Sign-out | Normal | Warns about unsent work first | Three rules sit behind the table: 1. **Saved locally is not the same as sent.** Every pending write carries a visible marker until the server confirms it, so the teacher never assumes a grade reached the school's records when it did not. 2. **Stale data is labelled.** A cached roster is fine to work from, but its age must be visible so the teacher can judge it. 3. **Disable with a reason, never hide.** A greyed-out "Messages (needs a connection)" explains itself; a menu item that vanishes looks like a bug. ## What stays available, and what does not - **Available**: taking attendance, entering grades and comments, reading cached rosters, today's timetable and grade history. Writes go into a durable queue that sends when the server is reachable. - **Disabled with a reason**: the parent-messages page, which is never stored on the device; actions that need the server's answer before they mean anything, such as publishing a term's grades to parents. - **Available but guarded**: sign-out. On a shared laptop it will delete everything stored, including unsent marks, so it first says how many are unsent and offers to wait for them. ## What it must not do - **A full-screen offline overlay** blocks the very work that could continue. - **Spinners without timeouts** leave the teacher staring at a request that will never answer; every request needs a time limit so the cached path takes over. - **Hiding unsent writes** to keep the screen clean removes the one signal that tells the teacher whether the record is safe. - **Reloading or reshuffling** the register when the connection returns: replay should update markers in place. ## A phone in a pocket On a teacher's own phone the rules are the same, with one addition: the teacher switches apps mid-lesson, and a hidden page may later be frozen or discarded by the browser without warning. So a mark must be in durable storage the moment it is shown as saved, not when a timer or the page's unload gets round to it. Coming back to the tab is also a natural moment to check reachability and refresh the cached reads' age stamps. ## When the connection returns Pending markers clear one by one as the queue's entries are confirmed; the banner counts down; cached reads refresh in the background and update their stamps. If the server rejects a write, the marker turns into a "needs your decision" state rather than disappearing. That rejection flow, and how replay is ordered, are separate design questions; this one is about making the offline period honest and calm.
- How do you tell the screen reader user that marks are pending without announcing every tap?Keep the per-mark state in each control's accessible name or description ("Present, not yet sent"), so it is read when focused, and announce only the summary changes through one polite status region: going offline, the unsent count after a pause, and "all marks sent" on recovery. Announcing every tap and every confirmation floods the user during a register.
- The network returns but every request still times out. What should the banner say?Exactly what the app knows: the device reports a network, but the school's server isn't answering, and marks are still saved on this laptop. Keep the offline behaviour, because reachability is judged by requests succeeding, not by the online event. Retry on a backoff and on returning to the tab, and clear the banner only after a request actually succeeds.
A cheque you have written but the bank has not cleared: your own ledger shows it straight away, marked pending, and you neither forget it nor count it as settled until the statement confirms it.
- navigator.onLine is false, so grey out every button in the app.
- navigator.onLine is true, so the school's server is reachable.
- Hide unsent marks until they sync so the register looks clean.
- Show a full-screen 'You are offline' overlay until the network returns.
- Let the parent-messages page fall back to whatever was last cached.