From 01e7909e3ad02f24971e2279914228ee97acf24d Mon Sep 17 00:00:00 2001 From: ben8 Date: Thu, 8 May 2025 21:27:21 +0200 Subject: [PATCH] fix Eingabe --- django/play/consumers/game.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/django/play/consumers/game.py b/django/play/consumers/game.py index 07292d3..484fe7f 100644 --- a/django/play/consumers/game.py +++ b/django/play/consumers/game.py @@ -188,17 +188,20 @@ class GameConsumer(AsyncWebsocketConsumer): question_data = json.loads(current_question.data) print(answer_index) try: - #if answer_index >= 0 : # -1 means timeout - is_correct = question_data['options'][answer_index]['is_correct'] - print(is_correct) + #if answer_index >= 0 : # -1 means timeout + is_correct = question_data['options'][answer_index]['is_correct'] + print(is_correct) except: - user_input = str(answer_index).strip().lower() - correct_value = str(question_data['options'][0].get('value', '')).strip().lower() + user_input = str(answer_index).strip().lower().replace(" ", "") + correct_value = str(question_data['options'][0].get('value', '')).strip().lower().replace(" ", "") print("Richtig",correct_value) + print(user_input) if user_input == correct_value: is_correct=True - answer_index=0 + answer_index=int(0) print(is_correct) + else: + answer_index=int(1)