Skip to content

Online exams that survive a power cut

  • Home
  • Blog
  • Online exams that survive a power cut
Online exams that survive a power cut

An online exam system survives a power cut by treating the student's device as the first copy of the data. Answers are written to local storage or IndexedDB as they are typed, the paper keeps running offline, and a retry queue syncs to the server once power and connectivity return — with idempotency keys so nothing is submitted twice.

Key Takeaways

  • Save the answer locally before you send it anywhere; a write that only exists in memory is a write you have already lost.
  • Give every answer a client-generated identity so the server can tell a retry from a genuine second submission.
  • The submit endpoint must be idempotent — same key in, same stored result out, no duplicate paper.
  • A "saved" indicator backed by real queue state stops candidates refreshing mid-paper, which causes its own outages.
  • Test with a physical power cut, not a mocked network failure; the failure modes are different.
  • Cap how late an offline submission may arrive, and flag anything past that window instead of accepting it silently.
How an online exam session survives a power cutFour stages showing the paper starting, answers saved on the device, an offline period after the power cut, and the sync queue reconciling with the server.How an exam session survives a power cut1Paper opens,session starts2Answers savedon the device3Power cuts,the link drops4Queue syncs,server reconciles
The four stages of a resilient exam session: local-first answer storage carries the candidate through the outage, and the sync queue reconciles once power returns.

What does online exam system reliability actually mean?

Reliability means the paper completes exactly once, no matter what the network, the mains supply or the device does mid-session. The measurable outcomes are narrow: no lost answers, no duplicate submissions, and a resume that returns the candidate to the same question seconds after the power comes back.

Why does a power cut break an exam that passes testing?

Most exam clients hold the answer in memory and POST it when the candidate clicks Next. Pull the plug at minute 40 of a 60-minute paper and everything typed since the last successful request disappears. The server has no session to restore, because the write never arrived.

When do you actually need offline-tolerant exam delivery?

You need it when candidates sit in school labs or rented halls with unreliable mains and shared Wi-Fi, and when a lost paper means a re-sit, a refund or a dispute. You do not need it for a proctored exam on locked-down campus machines behind a UPS and wired links — spend there on invigilation and network redundancy instead. If your wider continuity planning is thin, the same reasoning applies as in business continuity planning for web systems.

How does offline-first exam delivery work?

The client treats the device as the first copy of the record. Every answer change writes to IndexedDB or local storage and appends a job to an outbox queue; a background sync worker drains that queue when the link returns. Each queued item carries a stable idempotency key, so the server can reject a replay instead of storing a second submission.

The server stays the authority for deadlines and marking, but it is the second copy during the exam. That ordering is the whole design:

// Write locally first, then queue the sync job.
const attempt = { examId, questionId, answer, clientId };
await localDb.put('answers', attempt);        // durable on the device
await localDb.put('outbox', {
  ...attempt,
  key: examId + ':' + questionId + ':' + clientId
});

Our team can help you build that client and the sync endpoint behind it as part of custom software development, in your own repositories and cloud accounts.

Step-by-step: building an exam client that survives the cut

Build in this order, because the sync layer is worthless if the local write is not durable. Each step ends with something you can test on a single laptop before it reaches a lab or a paying candidate.

  1. Freeze the paper locally. Cache questions, images and the paper structure in a service worker or a bundled manifest, so a dropped link does not blank the screen mid-question.
  2. Write every answer twice. Persist to IndexedDB first, then enqueue the sync job. If the local write fails, the candidate should see that immediately rather than at submission.
  3. Give every answer a client-generated identity. A per-attempt UUID plus the question id makes replays detectable. Never depend on a server auto-increment id you have not received yet.
  4. Make the outbox an ordered queue with backoff. Retry on a timer with exponential backoff and jitter, and persist the queue across reloads. A short interval with jitter beats a tight fixed loop that hammers a recovering network.
  5. Make the submit endpoint idempotent. Store the idempotency key under a unique index and return the original result on replay instead of inserting again. Test it by sending the identical payload twice on purpose.
  6. Show real sync state. A small saved indicator wired to the queue, not to a timer, prevents panic refreshes — which cause more lost papers than power cuts do.
  7. Cap the offline window. Decide how late a submission may arrive and flag anything past it for human review. Silently accepting a four-hour-late paper is worse than a flagged one.

Which configuration actually matters on exam day?

Three settings decide most outcomes: the retry interval, the idempotency window, and how long the server keeps an unsubmitted attempt alive. Get them wrong and you either duplicate papers or lose the tail of a session that reconnects after the invigilator has already collected the devices.

SettingWhat it controlsSensible starting point
Retry intervalHow fast the outbox drains after reconnectionA few seconds with exponential backoff and jitter
Idempotency windowHow long a replayed key is still recognisedLonger than the exam plus the travel time home
Attempt TTLWhen an unfinished session is abandoned server-sideWell past the exam end, with an alert before it expires
Local storage quotaWhether a large paper can be cached offlineCheck the quota and fail loudly, never silently
Deadline clockWhether a late sync is acceptedServer time, never the device clock

How do you verify it before exam day?

Run a power-cut drill on real hardware, not only a unit test. Unplug the machine mid-answer, leave the client offline for a couple of minutes, reconnect, and confirm the answer lands exactly once. Repeat with a browser refresh, a device reboot and an abrupt network kill, and log what each drill produced.

Timeline of a power-cut drill on an exam clientA five-point timeline showing a paper starting, mains failing, the client detecting the drop, reconnecting, and reconciling the submission.What a power-cut drill should look like0:00Paper startsNormal0:42Mains failsFailure+3 sDetectedOffline+90 sReconnectRecovery10:00SubmittedReconciledNothing is lost while offline; the server catches up when the link returns.
A power-cut drill timeline: the client detects the drop within seconds, keeps serving the paper from local state, and reconciles the queued answers after reconnection.

Drills like this belong in the same runbook as your wider release checks, in the spirit of running a new system in parallel with the old one until you trust it.

What breaks first when the power goes?

The client's local write is the first thing to check, because everything else is downstream of it. If the answer never reached IndexedDB, no retry logic will recover it — and the server logs will look perfectly healthy, because nothing was ever sent.

Which exam failure mode to check firstFour rows mapping a failure mode to the symptom it produces and the first thing an engineer should inspect.What to check firstPower cutMains lost mid-paper; last answer must already be on diskNetwork dropWi-Fi flaps; queued writes retry without creating duplicatesDevice crashBrowser tab dies; resume restores the last saved answerDuplicate submitRetries land twice; one idempotency key collapses themCheck the client store first; the server log only shows what arrived.
Failure modes on an exam client map to different first checks — the local store explains most of them before you ever open a server log.

Failure modes and how to debug them

Start at the client, then move outward. Open the browser's application storage and confirm the answer and the outbox entry exist. Next, watch the network panel for the retry request and check its status. Finally, query the server for the idempotency key.

  • Answer present locally, no request ever sent: the sync worker is not running. Check that it is registered and that nothing cancelled it on page hide.
  • Request sent, 4xx response: usually an expired token. The client should refresh credentials on reconnect, then replay the queue, not drop it.
  • Two submissions in the database: the idempotency key is missing, or the unique index was never created. Fix the index before the next exam, not during it.
  • Queue drains but the paper looks empty on resume: the local read path reads a different store than the write path. One schema, two accessors, tested together.
  • Everything works, but the candidate refreshed: the saved indicator was lying. Wire it to queue state so people trust it enough not to reload.

For server-side visibility, expose queue depth and sync failures as metrics and alert on them; the Prometheus documentation covers the exposition format these clients and APIs usually emit.

What does this cost to run?

Cost is dominated by engineer time, not hosting. You are building a second persistence path, an idempotent endpoint and a reconciliation job, then testing all three under failure. The infrastructure itself is modest: a small API tier, a database, and storage for cached papers. Egress and storage class matter if you serve large media-heavy papers to many candidates at once. Confirm current figures with your cloud vendor's own calculator before committing, and treat UPS or generator coverage at the venue as part of the same budget conversation.

Security considerations

Offline mode means exam content sits on a device you do not control. Cache question text, not answer keys. Bind the local record to the candidate's session and re-authenticate on reconnect before the queue drains, so a shared lab machine cannot be used to submit someone else's paper. Set short-lived tokens with a refresh path that works offline, and clear local storage on logout. On the server side, treat every replayed payload as untrusted input, even when the key matches.

Common mistakes

  • Treating "offline support" as a retry wrapper around the same in-memory state.
  • Generating the idempotency key on the server, which defeats the purpose.
  • Using the device clock for deadlines; candidates can change it, and so can a flat battery.
  • Never rehearsing the human side — invigilators need a script for what to do when the lights go out, which is the same training problem as getting staff confident on a new system.
  • Testing only on fast office Wi-Fi with a laptop that has never run a three-hour paper.

A realistic scenario: 240 candidates, one substation

A college in the Kathmandu Valley runs an entrance exam for 240 candidates across four labs. At 11:42 the substation trips. Mains is out for six minutes, the labs' UPS units cover the switches but not the desktops, and two machines reboot outright. Because the client wrote each answer to local storage on every change, the only real loss is the candidates' composure. When power returns, the outbox drains, the server sees one submission per candidate, and the invigilators extend the paper by the lost time. The recovery is boring, which is the point. That kind of assessment build is close to the work we did for an assessment and analytics institute.

Alternatives compared

Offline-first is not the only option. A thin web client with server-only state is far cheaper to build and perfectly adequate behind reliable power; a desktop exam app with a local database buys durability at the cost of distribution and updates; paper remains the fallback that never needs a retry queue.

ApproachSurvives a power cutOperational overheadBest fit
Offline-first web clientYes, if local writes and idempotency are done properlyMedium — sync layer, reconciliation, drillsUnreliable mains or shared connectivity
Thin web client, server-only stateNoLowProctored labs with UPS and wired links
Desktop exam applicationYes, strong local durabilityHigh — installs, updates, device controlFixed centres running the same hardware
Paper fallback alongside digitalAlwaysMedium — printing, collection, manual markingAny exam where a re-sit is not acceptable

In short: save locally, sync later, submit once. Those three habits cover almost every power-cut scenario, and the rest is drilling them on real hardware before exam day.

People also search for

If you would rather not carry this yourself, our team can help you design the offline-first client, the idempotent sync endpoint and the hosting behind it, then run the drills with your invigilators before the first real paper. Get in touch and we will tell you plainly what your current setup would survive.

Frequently asked questions

  • The exam keeps running and the candidate's answers survive when a device, router or exam hall loses power. That means client-side autosave to local storage, idempotent server-side writes, and a resume token so the candidate can rejoin. Test it by pulling the plug mid-answer and confirming the answer and remaining time come back intact.

  • Autosave protects typed answers; offline mode keeps the candidate working while the network is down. A service worker with a local queue lets answers accumulate and sync on reconnect. For most exam halls, autosave plus a short reconnect window is enough. True offline-first also needs a conflict rule for duplicate submissions.

  • A backend that accepts idempotent answer submissions keyed by a client-generated ID, a durable store that commits before acknowledging, and a session model with a resumable token and server-authoritative timer. Add UPS protection on the exam-hall network gear and written candidate instructions for rejoining. Storage limits on client-side caches are browser-specific, so check current vendor docs.

  • Run a chaos test on staging: kill the client mid-answer, drop the network, expire the session, then restore each and confirm the answer and remaining time are intact. Check server logs for idempotency hits and the answer table for exactly one row per question per candidate. Replay after every change.

  • Typical failures are answers lost because the client only saved on blur, duplicate submissions after reconnect, and timers that reset to full on resume. Reproduce with browser devtools network throttling, then inspect the failed POST in the network tab and the retry key in the server logs. Confirm the fix by replaying the same scenario.

  • Offline caches are readable on the device, so never ship the full question bank or answer key to the client. Fetch questions one at a time, keep scoring server-side, sign and time-limit resume tokens, and log every reconnect. Proctoring signals degrade when offline, so decide up front what integrity you can genuinely enforce.

  • The server must be the clock of record. Store the exam start time and duration server-side, and send remaining seconds on each sync. A browser-only timer can be paused, edited or reset by a reload. On resume, recalculate from the server value and reject submissions past the deadline plus a small grace window.

  • Monitoring for sync failures, reconnect rates and submission latency; a load test before each exam window; UPS checks on hall networking; and a documented manual fallback if the platform is down. Cost drivers are peak concurrency during the window, answer-history storage and log retention. Discuss your numbers with the vendor or /contact.

  • Options include a managed exam platform with offline support, running exams in controlled centres with UPS-backed machines, or a paper fallback transcribed afterwards. Each trades control for effort and risk. Compare against what you already operate, pilot with one cohort, and keep the old path available until the new one proves out.

  • Web apps reach any device with a browser and can use a service worker for offline queues; native apps get more dependable local storage and background sync but need installs and update control. For exam halls with managed laptops, web plus UPS is usually simpler. For field exams on unreliable phones, native holds up better.

0 comments

Be the first to share your thoughts.

Leave a comment

Chat on WhatsApp