From 6656424110e89daf4b34a8d797b9658e6b98e07f Mon Sep 17 00:00:00 2001 From: iTrooz Date: Wed, 22 Apr 2026 15:48:14 +0200 Subject: [PATCH] fix: Check that player question_index input is the current question --- classquiz/socket_server/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/classquiz/socket_server/__init__.py b/classquiz/socket_server/__init__.py index 52875cc..253864d 100644 --- a/classquiz/socket_server/__init__.py +++ b/classquiz/socket_server/__init__.py @@ -292,10 +292,16 @@ async def submit_answer(sid: str, data: dict): session = await get_session(sid, sio) question_index = int(float(data.question_index)) game_data = await PlayGame.get_from_redis(session["game_pin"]) + + if game_data.current_question != question_index: + await sio.emit("question_not_active", room=sid) + return + already_answered = await has_already_answered(session["game_pin"], question_index, session["username"]) if already_answered: await sio.emit("already_replied", room=sid) return + answer_right, answer = check_answer(game_data, data) latency = int(float(session["ping"])) time_q_started = datetime.fromisoformat(await redis.get(f"game:{session['game_pin']}:current_time"))