fix(room): replay reveal payloads to students reconnecting mid-state

Students joining or reconnecting while the session is in question_closed
or finished previously got only a 'state' broadcast and nothing else,
leaving the SPA stuck on whatever was rendered before (typically the
join form's disabled state). Now send_student_snapshot replays the
question_closed message (and on finished, the session_ended payload)
so the SPA can render the reveal or final card immediately.

Mirrors the instructor-side reconnect fix in 22d1096.
This commit is contained in:
ameer
2026-05-02 23:03:17 +08:00
parent 22d109647e
commit 8e8d5cfff0

View File

@@ -267,6 +267,17 @@ class RoomManager:
ack = await self.existing_submit_ack(sid, identity["student_id"], session["current_question_idx"])
if ack:
await websocket.send_json(ack)
elif session["state"] == "question_closed":
# Replay the reveal so a student joining mid-reveal sees the
# closed-question card with their answer / correct option /
# leaderboard, instead of being stuck on the join form's
# disabled state waiting for an event that never arrives.
await websocket.send_json(await self.question_open_message(sid, session["current_question_idx"]))
await websocket.send_json(
await self.question_closed_message(sid, session["current_question_idx"], identity)
)
elif session["state"] == "finished":
await websocket.send_json(await self.ended_message(sid, identity))
async def send_instructor_snapshot(self, websocket: WebSocket, sid: str) -> None:
session = await self.get_session(sid)