Compare commits
2 Commits
160-musik-
...
44-zurueck
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dc30f9cbc | ||
|
|
3df748dc96 |
@@ -11,9 +11,6 @@ import json
|
||||
|
||||
# Create your views here.
|
||||
def lobby(request, 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)
|
||||
context = {
|
||||
@@ -21,7 +18,6 @@ def lobby(request, join_code):
|
||||
'quiz_game': quiz_game,
|
||||
}
|
||||
|
||||
|
||||
mode = request.GET.get('mode','default')
|
||||
request.session['mode'] = mode
|
||||
if "host_id" in request.COOKIES:
|
||||
@@ -32,9 +28,6 @@ def lobby(request, join_code):
|
||||
elif mode=="learn":
|
||||
return redirect('play:create_participant', join_code=join_code)
|
||||
|
||||
|
||||
|
||||
|
||||
if not "participant_id" in request.COOKIES:
|
||||
return redirect('play:create_participant', join_code=join_code)
|
||||
|
||||
@@ -54,14 +47,12 @@ def lobby(request, join_code):
|
||||
def select_mode(request,join_code):
|
||||
return render(request, 'play/select_mode.html', {'join_code': 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:
|
||||
if request.method == 'GET' and "participant_id" in request.COOKIES:
|
||||
# Prüfe ob der Teilnehmer noch existiert
|
||||
participant_id = request.COOKIES['participant_id']
|
||||
try:
|
||||
@@ -70,7 +61,7 @@ def create_participant(request, join_code):
|
||||
participant.quiz_game = quiz_game
|
||||
participant.score = 0 # Reset score when joining new game
|
||||
participant.save()
|
||||
return redirect('play:lobby', join_code=join_code)
|
||||
return render(request, 'play/initialize_participant.html', {'participant': participant, 'join_code': quiz_game.join_code})
|
||||
except QuizGameParticipant.DoesNotExist:
|
||||
# Cookie löschen wenn Teilnehmer nicht mehr existiert
|
||||
response = HttpResponseRedirect(request.path)
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
required
|
||||
maxlength="20"
|
||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||
placeholder="Dein Spielername">
|
||||
placeholder="Dein Spielername"
|
||||
value="{{ participant.display_name }}">
|
||||
<p class="text-xs text-gray-500 mt-2">Maximal 20 Zeichen</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<span class="w-2 h-2 bg-green-500 rounded-full mr-2"></span>
|
||||
<span>Angemeldet als <b>{{ participant.display_name }}</b></span>
|
||||
</div>
|
||||
<a href="{% url 'play:create_participant' quiz_game.join_code %}">Auftreten ändern...</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user