diff --git a/django/play/views.py b/django/play/views.py index e28b3ac..296ed6f 100644 --- a/django/play/views.py +++ b/django/play/views.py @@ -22,7 +22,8 @@ def lobby(request, join_code): } - + mode = request.GET.get('mode','default') + request.session['mode'] = mode if "host_id" in request.COOKIES: host_id = request.COOKIES['host_id'] if host_id == quiz_game.host_id: @@ -56,6 +57,8 @@ def select_mode(request,join_code): def create_participant(request, join_code): + mode = request.GET.get('mode','default') + request.session['mode'] = mode quiz_game = get_object_or_404(QuizGame, join_code=join_code) if mode!="learn": if "participant_id" in request.COOKIES: @@ -149,7 +152,7 @@ def finished(request, join_code): def scores(request, join_code): quiz_game = get_object_or_404(QuizGame, join_code=join_code) - + # Verify game state if quiz_game.current_state != 'scores': return redirect('play:lobby', join_code=join_code) @@ -167,9 +170,18 @@ def scores(request, join_code): current_question = questions[quiz_game.current_question_index] question_data = json.loads(current_question.data) + try: + my_participant = request.session.get('my_participant-participant_id') + participant = QuizGameParticipant.objects.get(participant_id=my_participant) + my_participant=participant + except: + participant = QuizGameParticipant.objects.none() + return render(request, 'play/game/score_overview.html', { 'quiz_game': quiz_game, 'participants': participants, + 'participant': participant, + 'my_participant':my_participant, 'is_host': is_host, 'host_id': quiz_game.host_id if is_host else None, 'is_last_question': quiz_game.current_question_index + 1 >= len(questions), @@ -244,8 +256,11 @@ def question(request, join_code): participant_id = request.COOKIES['participant_id'] try: participant = QuizGameParticipant.objects.get(participant_id=participant_id) + + except QuizGameParticipant.DoesNotExist: return redirect('play:create_participant', join_code=join_code) + request.session['my_participant-participant_id'] = participant.participant_id return render(request, 'play/game/question_participant.html', { 'quiz_game': quiz_game, @@ -281,7 +296,7 @@ def waiting_room(request, join_code): def selected_mode(request, join_code): - global mode + mode = request.GET.get('mode','default') request.session['mode'] = mode quiz_game = get_object_or_404(QuizGame, join_code=join_code) diff --git a/django/templates/play/game/finished.html b/django/templates/play/game/finished.html index b0300e1..9290126 100644 --- a/django/templates/play/game/finished.html +++ b/django/templates/play/game/finished.html @@ -7,7 +7,7 @@
Vielen Dank fürs Mitspielen!
+Vielen Dank fürs Spielen!
Frage {{ question_index|add:1 }} von {{ total_questions }}
Verbleibende Zeit
+Verbleibende Zeit
30
Antworten
0/0
@@ -43,18 +48,20 @@