A quiz played together has one hard requirement: everyone sees the same question and the same time remaining. If each browser runs its own countdown, players drift apart within a few questions, and a leaderboard fetched by polling is always a step behind.
LiveQuiz is built on Django Channels. Each quiz room is a WebSocket group, served by the Daphne ASGI server with Redis as the channel layer. When a host opens a room, the server draws the questions at random for the chosen education level, field of study, subject and topic, and holds the room's state: its questions, the scores so far and who has answered.
The countdown runs on the server. Each tick, each new question, each score update and the final leaderboard are sent to the whole group at once with a group broadcast. Browsers display what they are told; none of them decides when time is up.
The same state drives the rest of the room's behaviour. The number of questions and the time allowed come from the host's plan. Rooms lock after a short delay so players cannot join mid-quiz. Rooms can be grouped into a battle for team play.
Work that does not belong in a request runs in the background: APScheduler sends subscription expiry reminders and clears out old guest submissions, so guests can play without accumulating data forever.
The general lesson holds beyond quizzes: when several people must agree on what is happening right now, give one place the authority to say so, and push that to everyone.
Get new articles by email
Occasional notes on building and running business software.
Related reading
Building a result manager that works without the internet
Why we built a school's result software as an offline desktop program, and the details that matter when every student needs a correct, prin…
One record per pupil: how our school platforms are structured
Why fees, results, hostel billing and parent messages in our school systems all hang off a single student record — and what that changes fo…