Skip to main content

How do I design an offline mode so my study platform still saves student responses when school wifi drops?

Save every response to the device first, put it in a queue, and sync it to the server with a unique ID so a retry never creates a duplicate. Adding this to an existing study platform typically takes 60 to 120 hours of engineering, more when responses include audio, files or multi-step work.

Why dropped wifi is a research-validity problem

Lost responses are not random. Wifi fails more in some buildings, at some times of day and on older devices, so the gaps cluster by school, by classroom and sometimes by condition. The result is data missing not at random, which no amount of imputation in the efficacy analysis can fully correct.

Program officers and reviewers read this the same way. A study that lost 8% of responses at one site to the network has a threat to validity it has to write up. One that captured every response locally and reconciled it does not.

A worked example

Take a hypothetical pilot: 20 teachers, 25 students each, 40 items per student, so 20,000 expected responses. Suppose one district’s network drops for a few minutes in about one session in ten, and the platform saves only on submit.

Measure District with stable wifi District with unstable wifi
Expected responses 10,000 10,000
Lost without a queue about 100 (1%) about 1,000 (10%)
Lost with a local queue and sync 0 unexplained 0 unexplained
Effect on the analysis Minor Site effect mixed with missingness

Local queueing: write to the device before the network

Each response should be written to durable browser storage the moment the student produces it, before any network call. In a web app that means IndexedDB, not memory or localStorage, because IndexedDB survives a closed tab, a browser crash and a laptop lid shutting.

Store each queued item as a complete record that the server can accept with no further context:

  • A client-generated unique ID (a UUID) for the response
  • Student pseudonymous ID, session ID, item ID and study condition
  • The client timestamp and the device’s clock offset at last sync
  • The payload and a schema version, so a mid-study release cannot misread old items
  • A status: pending, sent or confirmed

On shared Chromebooks, the queue holds student data on a device other students use. Scope the queue to the logged-in student, clear confirmed items after sync, and block logout while items are pending. Your institution’s compliance office and the district decide whether this design meets FERPA and the data use agreement.

Idempotent sync: retries that never duplicate

A request that times out may still have reached the server. If the client retries it, a naive server stores the response twice, and the analysis now has a student who answered item 14 twice. Idempotent means the server can receive the same item any number of times and keep exactly one copy.

  1. The client sends items in small batches, oldest first, each with its UUID.
  2. The server upserts by UUID: insert if new, ignore if already stored.
  3. The server replies with the list of UUIDs it holds, and the client marks only those confirmed.
  4. Failed sends retry with exponential backoff, from about 2 seconds up to 60, so 30 laptops reconnecting at once do not flood the server.
  5. Sync triggers on reconnect, on a timer and on page load, not only when the student clicks Next.

For low bandwidth, keep payloads small: text responses are a few kilobytes. Upload audio and images separately in resumable chunks, with the text record pointing to the file by ID.

Conflict handling: prefer an append-only log

Conflicts happen when the same record changes in two places: a student edits an answer offline while a teacher resets the item, or the student switches devices partway through a session. The simplest defense is never to overwrite: log every change as an event and derive the current state from the events.

Data type Strategy Why
Item responses and clicks Append-only events The analysis needs every attempt, not just the last
Draft text in progress Last write wins, by client timestamp, with earlier versions kept Students expect their latest draft
Teacher actions (resets, unlocks) Server is authoritative and the client applies them on sync Protects study protocol
Condition assignment Server only, never changed offline Changing it offline breaks randomization

Because clocks on school devices drift, record both client and server timestamps. Order events within a session by a client sequence number, not by wall clock.

Save confirmation the student and teacher can trust

Students should never have to wonder whether their work saved, and they should never be stopped from working because the network is slow. Show three plain states next to each response or in a fixed corner of the screen:

  • Saved on this device: written to the queue, not yet on the server
  • Saved: confirmed by the server
  • Not saved, try again: shown only if the local write itself failed, which should be rare

Give teachers a dashboard count of unsynced items per student, and a warning before anyone logs out or closes the session with items pending. In a pilot, the teacher is your field operator; a visible count of unsent work prevents more loss than any retry logic.

How to test it before the pilot

Offline code tested only on office wifi will fail in a classroom. Budget roughly a third of the build hours for testing, on the device models the district actually uses:

  • Turn the network off mid-answer, keep working for 10 minutes, reconnect, and count the records
  • Throttle to a slow 3G profile in browser developer tools and run a full session
  • Close the tab and kill the browser while items are pending, then reopen
  • Drop the connection after the server stores a batch but before the client hears back, and check for duplicates
  • Release a new version while old-schema items sit in a queue
  • Test behind the district’s content filter and captive portal, which can return a login page instead of an error

In the study itself, run a nightly reconciliation report: expected responses from the session plan, received responses, and any gap by school and classroom. That report becomes your missing-data appendix. We built this discipline into an NSF-funded React and Firebase research platform used across several universities, where we made saving and loading student work 100% reliable.

Frequently asked questions

Is Firestore offline persistence enough for a research study?
It caches writes locally and syncs them later, but it does not give you per-response IDs, a confirmation state for students or a reconciliation report. Clearing browser data on a shared device can also remove pending writes. Most studies add an explicit queue and logging layer on top.

How long does it take to add offline mode to an existing study app?
Typically 60–120 engineering hours, including testing. Text-only responses on one device type sit at the low end. Audio, file uploads, multi-device sessions or a codebase with no tests push it toward the high end.

Do I need a native app to work offline in schools?
Usually not. A web app with IndexedDB storage and a service worker can keep working offline on Chromebooks, which is what most districts issue. A native app adds store review and device management work most pilots do not need.

Does storing responses on student devices create a FERPA problem?
It can raise questions, especially on shared devices, so the design should limit what is stored, scope it to the logged-in student and clear it after sync. Whether the design meets FERPA and your data use agreement is decided by your institution’s counsel or compliance office and the district.

How do I report lost data in my efficacy analysis?
Compare expected responses from the session plan with received responses, broken down by school, classroom and condition, and report the gap and its cause. With a local queue and a nightly reconciliation report, most gaps can be traced to a specific device or session. Your methodologist decides how to treat what remains.

Related answers

Planning a pilot on school networks?

We offer a free 30-minute review of your pilot plan or the technical section of your proposal. Bring the prototype’s repository or a demo, your pilot timeline and your funder’s data requirements, and we’ll show you where responses could be lost. Start a conversation.