Merge branch '41-quiz-id-updaten-wenn-participant-ein-anderes-quiz-beitritt' into 'master'

Resolve "Quiz ID updaten wenn Participant einem anderen Quiz beitritt"

Closes #41

See merge request enrichment-2024/qivip!13
This commit is contained in:
Juhn-Vitus Saß
2025-03-16 12:18:35 +00:00
2 changed files with 14 additions and 3 deletions

View File

@@ -8,11 +8,22 @@ from django.http import HttpResponseRedirect
def lobby(request, join_code): def lobby(request, join_code):
if not "participant_id" in request.COOKIES: if not "participant_id" in request.COOKIES:
return redirect('play:create_participant', join_code=join_code) return redirect('play:create_participant', join_code=join_code)
participant_id = request.COOKIES['participant_id'] participant_id = request.COOKIES['participant_id']
quiz_game = get_object_or_404(QuizGame, join_code=join_code) quiz_game = get_object_or_404(QuizGame, join_code=join_code)
quiz = get_object_or_404(QivipQuiz, pk=quiz_game.quiz_id.id)
participant = get_object_or_404(QuizGameParticipant, participant_id=participant_id) participant = get_object_or_404(QuizGameParticipant, participant_id=participant_id)
return render(request, 'play/lobby.html', {'debug': "test", 'participant': participant})
if not participant.quiz_game.join_code == join_code:
participant.quiz_game = quiz_game
participant.save()
context = {
'debug': "test",
'participant': participant,
'quiz': quiz,
}
return render(request, 'play/lobby.html', context=context)
def create_participant(request, join_code): def create_participant(request, join_code):
if "participant_id" in request.COOKIES: # Umleiten, falls Teilnehmer bereits erstellt if "participant_id" in request.COOKIES: # Umleiten, falls Teilnehmer bereits erstellt

View File

@@ -2,7 +2,7 @@
{% block content %} {% block content %}
<div class="container mx-auto px-4"> <div class="container mx-auto px-4">
<h1>Bundeslaender Deutschland Quiz</h1> <h1>{{ quiz.name }}</h1>
<div class="mt-4 mb-4 text-center"> <div class="mt-4 mb-4 text-center">
<h3>Sichtbar als <b>{{ participant.display_name }}</b></h3> <h3>Sichtbar als <b>{{ participant.display_name }}</b></h3>
</div> </div>