Skip to content

Commit

Permalink
✨ Decreasing the likelihood of collision during a quiz
Browse files Browse the repository at this point in the history
  • Loading branch information
mawoka-myblock committed Jan 3, 2024
1 parent 06423c0 commit 341796a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classquiz/socket_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,8 @@ async def submit_answer(sid: str, data: dict):
raise NotImplementedError
latency = int(float((await sio.get_session(sid))["ping"]))
time_q_started = datetime.fromisoformat(await redis.get(f"game:{session['game_pin']}:current_time"))
answers = await redis.get(f"game_session:{session['game_pin']}:{data.question_index}")
diff = (time_q_started - now).total_seconds() * 1000 # - timedelta(milliseconds=latency)

diff = (time_q_started - now).total_seconds() * 1000 # - timedelta(milliseconds=latency)
score = 0
if answer_right:
score = calculate_score(
Expand All @@ -443,6 +442,7 @@ async def submit_answer(sid: str, data: dict):
time_taken=abs(diff) - latency,
score=score,
)
answers = await redis.get(f"game_session:{session['game_pin']}:{data.question_index}")
answers = await set_answer(
answers, game_pin=session["game_pin"], data=answer_data, q_index=int(float(data.question_index))
)
Expand Down

0 comments on commit 341796a

Please sign in to comment.