diff --git a/django/library/admin.py b/django/library/admin.py index 14c0c5b..6e8d08b 100644 --- a/django/library/admin.py +++ b/django/library/admin.py @@ -9,7 +9,7 @@ class QivipQuizAdmin(admin.ModelAdmin): # Für das QivipQuestion Modell class QivipQuestionAdmin(admin.ModelAdmin): - list_display = ('quiz_id', 'data', 'creation_date', 'update_date') + list_display = ('id', 'quiz_id', 'data', 'creation_date', 'update_date') search_fields = ('data',) list_filter = ('quiz_id',) diff --git a/django/play/urls.py b/django/play/urls.py index 32285c1..1cd6093 100644 --- a/django/play/urls.py +++ b/django/play/urls.py @@ -4,7 +4,9 @@ from . import views app_name = 'play' urlpatterns = [ - path('lobby/', views.lobby, name='lobby'), - path('lobby//participate', views.create_participant, name='create_participant'), + path('game/', views.lobby, name='lobby'), + path('game//participate', views.create_participant, name='create_participant'), path('join', views.join_game, name='join_game'), + path('game//', views.question, name='question'), + path('game///participant', views.question_participant, name='question_participant'), ] \ No newline at end of file diff --git a/django/play/views.py b/django/play/views.py index 23f0abb..abf4ae0 100644 --- a/django/play/views.py +++ b/django/play/views.py @@ -1,9 +1,11 @@ from django.shortcuts import render from django.shortcuts import render, redirect, get_object_or_404, reverse from play.models import QuizGame, QuizGameParticipant -from library.models import QivipQuiz +from library.models import QivipQuiz, QivipQuestion from django.http import HttpResponseRedirect +import json + # Create your views here. def lobby(request, join_code): if not "participant_id" in request.COOKIES: @@ -57,4 +59,28 @@ def join_game(request): except QuizGame.DoesNotExist: # TODO: Mit message eine Fehlermeldung weitergeben (und im entsprechenden Template Designen) pass - return render(request, 'play/join_game.html') \ No newline at end of file + return render(request, 'play/join_game.html') + +def question(request, join_code, question_id): + question = get_object_or_404(QivipQuestion, pk=question_id) + + if question.data: + question.data = json.loads(question.data) + + context = { + 'question': question, + } + + return render(request, 'play/game/question_host.html', {'question': question, 'debug': "debug"}) + +def question_participant(request, join_code, question_id): + question = get_object_or_404(QivipQuestion, pk=question_id) + + if question.data: + question.data = json.loads(question.data) + + context = { + 'question': question, + } + + return render(request, 'play/game/question_participant.html', {'question': question, 'debug': "debug"}) \ No newline at end of file diff --git a/django/static/css/t-input.css b/django/static/css/t-input.css index 13759aa..118ff99 100644 --- a/django/static/css/t-input.css +++ b/django/static/css/t-input.css @@ -50,4 +50,61 @@ a.qp-a-button-small { .input-group form p button { @apply p-3 rounded-full bg-indigo-500 hover:bg-indigo-600 text-white focus:scale-105 transition duration-200 font-black shadow-md hover:shadow-lg; +} + + + + + + + + + + + +div.qp-answer-container { + @apply grid grid-cols-2 h-screen; +} + +div.qp-answer-container div { + @apply grid place-content-center rounded-xl m-2 place-self-stretch text-white transition duration-300; + @apply nth-1:bg-blue-500 hover:nth-1:bg-blue-600; + @apply nth-2:bg-red-500 hover:nth-2:bg-red-600; + @apply nth-3:bg-green-500 hover:nth-3:bg-green-600; + @apply nth-4:bg-yellow-500 hover:nth-4:bg-yellow-600; + @apply nth-5:bg-purple-500 hover:nth-5:bg-purple-600; + @apply nth-6:bg-black hover:nth-6:bg-slate-800; +} + +div.qp-answer-container div p { + @apply font-black text-xl sm:text-2xl md:text-4xl; +} + + + + +div.qp-answer-container-host { + @apply grid grid-cols-2 absolute bottom-0 w-screen xl:px-20 xl:pb-10; +} + +div.qp-answer-container-host div { + @apply grid place-content-center rounded-xl m-1 place-self-stretch text-white transition duration-300; + @apply nth-1:bg-blue-500 hover:nth-1:bg-blue-600; + @apply nth-2:bg-red-500 hover:nth-2:bg-red-600; + @apply nth-3:bg-green-500 hover:nth-3:bg-green-600; + @apply nth-4:bg-yellow-500 hover:nth-4:bg-yellow-600; + @apply nth-5:bg-purple-500 hover:nth-5:bg-purple-600; + @apply nth-6:bg-black hover:nth-6:bg-slate-800; +} + +div.qp-answer-container-host div p { + @apply font-black text-xl p-4; +} + +div.qp-question-container { + @apply text-center text-3xl px-4 py-9 h-screen; +} + +div.qp-question-container img { + @apply max-w-[50vw] max-h-[40vh] mx-auto; } \ No newline at end of file diff --git a/django/templates/play/game/question_host.html b/django/templates/play/game/question_host.html new file mode 100644 index 0000000..c3c78bf --- /dev/null +++ b/django/templates/play/game/question_host.html @@ -0,0 +1,35 @@ +{% load static %} + + + + + + + qivip + + +
+
+

Frage X

+ +

Frage: {{ question.data.question }}

+
+
+

Verbleibende Zeit:

+

36

+
+
+

7/14 Antworten

+
+
+
+
+ {% for option in question.data.options %} +
+

{{ option.value }}

+
+ {% endfor %} +
+
+ + \ No newline at end of file diff --git a/django/templates/play/game/question_participant.html b/django/templates/play/game/question_participant.html new file mode 100644 index 0000000..0449a28 --- /dev/null +++ b/django/templates/play/game/question_participant.html @@ -0,0 +1,19 @@ +{% load static %} + + + + + + + qivip + + +
+ {% for option in question.data.options %} +
+

{{ option.value }}

+
+ {% endfor %} +
+ + \ No newline at end of file