Merge branch '124-qr-code' into 'master'

Resolve "QR Code"

Closes #124

See merge request enrichment-2024/qivip!82
This commit is contained in:
ben8
2025-05-19 16:31:54 +00:00
4 changed files with 24 additions and 5 deletions

View File

@@ -8,10 +8,20 @@ from django.contrib import messages
from django.conf import settings
import json
import qrcode
import base64
from io import BytesIO
from django.shortcuts import render
# Create your views here.
def lobby(request, join_code):
relative_url = reverse("play:create_participant", kwargs={"join_code": join_code})
full_url = request.build_absolute_uri(relative_url)
qr = qrcode.make(full_url)
buffer = BytesIO()
qr.save(buffer, format="PNG")
img_base64 = base64.b64encode(buffer.getvalue()).decode("utf-8")
@@ -20,6 +30,7 @@ def lobby(request, join_code):
context = {
'quiz': quiz,
'quiz_game': quiz_game,
"qr_code_base64": img_base64,
}
@@ -29,6 +40,7 @@ def lobby(request, join_code):
host_id = request.COOKIES['host_id']
if host_id == quiz_game.host_id:
context['host_id'] = host_id
context["qr_code_base64"] = img_base64
return render(request, 'play/lobby.html', context=context)
elif mode=="learn":
return redirect('play:create_participant', join_code=join_code)
@@ -50,6 +62,7 @@ def lobby(request, join_code):
return redirect('play:create_participant', join_code=join_code)
context['participant'] = participant
context["qr_code_base64"] = img_base64
return render(request, 'play/lobby.html', context=context)
def select_mode(request,join_code):
@@ -334,5 +347,5 @@ def selected_mode(request, join_code):
return redirect('play:question',join_code)
return redirect('play:lobby', join_code=join_code)
return render(request, 'play/lobby.html', context=context)

View File

@@ -68,7 +68,7 @@
<br>
- alle öffentlichen Quizze können auch ohne Account gespielt werden
<br>
- qivip ist 100% kostenlos
- qivip ist zu 100% kostenlos
<br>
- es gibt keine Werbung
<br>
@@ -133,7 +133,7 @@
<br>
<br>
<b>Moderator: </b>Der Moderator selbst spielt nicht mit. Gehen Sie entweder auf die Startseite und klicken Sie auf "Moderieren" oder klicken einfach auf "spielen" (eines von Ihnen ausgewählten Quizzes) und dann auf Moderiermodus.
Der Moderator kann das Spiel, wenn die Teilnehmer da sind starten.
Der Moderator kann das Spiel, wenn die Teilnehmer da sind, starten.
<br>
<br>
<b>Teilnehmer: </b>Gehen Sie auf die Startseite und klicken Sie auf "Teilnehmen" und geben Sie dann den beim Moderator angegebenen Zahlencode ein. Anschließlich können Sie noch einen Anzeigenamen eingeben.

View File

@@ -8,12 +8,17 @@
<div class="text-center mb-8">
<h3 class="text-xl text-gray-600 mb-2">{{ quiz.name }}</h3>
{% if request.session.mode != "learn" %}
{% if host_id %}
<div class="bg-blue-100 rounded-lg p-4 mb-4">
<h1 class="text-4xl font-bold text-blue-800">{{ quiz_game.join_code }}</h1>
<div class="w-full flex justify-center my-2">
<img src="data:image/png;base64,{{ qr_code_base64 }}" class="h-50 w-50" alt="QR-Code">
</div>
<p class="text-sm text-blue-600 mt-1">Spiel-Code</p>
</div>
</div>
{% endif %}
{% endif %}
<!-- Participant Info -->
{% if participant %}

View File

@@ -8,3 +8,4 @@ django-cleanup
redis
channels_redis
python-dotenv # Production server safety
qrcode~=7.4.2