Skip to content

A host can start a quiz that has no questions #162

Description

@TheCodeHeist-Coder

The organizer's Start button in the lobby only guards against having no players:

apps/frontend/src/screens/LiveQuiz.tsx (~line 349):

<button onClick={handleStart} disabled={participants.length === 0} ...>
  Start Game
</button>

Nothing checks that the quiz has any questions.

Starting an empty quiz walks the room through quiz:start → the 3-second "GET
READY!" screen → quiz:next-question with index 0, which finds no question and
immediately ends the session:

if (!sessionId || !questions[questionIndex]) {
    await endQuizSession(sessionId);
    ...
    broadcastToSession(sessionId, 'quiz:ended');
}

Every participant sees "GET READY!" and then, three seconds later, "Quiz
Finished! Congratulations Winners!" with an empty podium. The session is now
COMPLETED in the database, so the host has to create a new one.

The same applies to a quiz whose questions were all deleted, and it fails
identically with 1 participant and 0 questions.

Where to fix it. The lobby does not currently fetch the question list, so
this needs the count available client-side — either included in the session
payload the organizer already receives on join, or fetched separately.

Guarding only in the UI is not quite enough, since the WebSocket message can be
sent directly; a server-side check in quiz:start would be the complete fix.
Frontend-only is still a worthwhile first step — say in your PR which you did.

Definition of done:

  • The Start button is disabled when the quiz has no questions
  • The disabled state explains why, rather than just being greyed out
  • An empty quiz cannot be driven into a COMPLETED state by mistake

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    UI & UXThis is for frontendbugSomething isn't workingenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions