diff --git a/django/play/consumers/game.py b/django/play/consumers/game.py index 14b7e7d..21ac078 100644 --- a/django/play/consumers/game.py +++ b/django/play/consumers/game.py @@ -232,8 +232,10 @@ class GameConsumer(AsyncWebsocketConsumer): # Parse the coordinates target_location = parse_coords(target_location) + answer_location_coords = answer_location answer_location = parse_coords(answer_location) + if not target_location or not answer_location: print("Invalid coordinates, cannot calculate score") is_correct = False @@ -312,6 +314,7 @@ class GameConsumer(AsyncWebsocketConsumer): participant.last_score = score participant.score += score + participant.coordinate_answer= answer_location_coords participant.last_answer_correct = is_correct participant.save() diff --git a/django/play/migrations/0016_quizgameparticipant_coordinate_answer.py b/django/play/migrations/0016_quizgameparticipant_coordinate_answer.py new file mode 100644 index 0000000..a0d3b7f --- /dev/null +++ b/django/play/migrations/0016_quizgameparticipant_coordinate_answer.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.7 on 2025-11-01 15:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('play', '0015_alter_quizgame_current_state'), + ] + + operations = [ + migrations.AddField( + model_name='quizgameparticipant', + name='coordinate_answer', + field=models.CharField(blank=True, max_length=256, null=True), + ), + ] diff --git a/django/play/models.py b/django/play/models.py index 81bca6a..6d47299 100644 --- a/django/play/models.py +++ b/django/play/models.py @@ -50,6 +50,7 @@ class QuizGameParticipant(models.Model): avatar = models.CharField(max_length=200, blank=True, default="") last_heartbeat = models.DateTimeField(auto_now_add=True) last_answer = models.IntegerField(null=True, blank=True) + coordinate_answer = models.CharField(null=True, blank=True,max_length=256) last_answer_correct = models.BooleanField(null=True, blank=True) def save(self, *args, **kwargs): diff --git a/django/templates/play/game/score_overview.html b/django/templates/play/game/score_overview.html index bdc76d8..e9ea22b 100644 --- a/django/templates/play/game/score_overview.html +++ b/django/templates/play/game/score_overview.html @@ -12,7 +12,7 @@ {% if question_data.type == "map" %} -