Compare commits
162 Commits
31-projekt
...
91-bilder-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d8e211c72 | ||
|
|
6da095c35e | ||
|
|
2dc9a077ee | ||
|
|
881bc3d6c1 | ||
|
|
b1e438229a | ||
|
|
97e4fa9505 | ||
|
|
3981dc31da | ||
|
|
7b86b0791c | ||
|
|
7faf931fb2 | ||
|
|
9245f928dc | ||
|
|
1f5a177060 | ||
|
|
ebbe4f7193 | ||
|
|
acd07bfb80 | ||
|
|
d824816be8 | ||
|
|
2c563b3471 | ||
|
|
4122f0631b | ||
|
|
2372cf7146 | ||
|
|
6305af9879 | ||
|
|
176a3cc15c | ||
|
|
fa9bb45d3f | ||
|
|
cc449997dc | ||
|
|
e813660722 | ||
|
|
1d6fab919e | ||
|
|
17195a221f | ||
|
|
3fc08cbd4e | ||
|
|
4cf6f45daf | ||
|
|
d2ad0f041f | ||
|
|
bcdfebf791 | ||
|
|
937fd4a2e4 | ||
|
|
a9343f285a | ||
|
|
d4252c1297 | ||
|
|
2052a702f0 | ||
|
|
a0292ce409 | ||
|
|
73cd52ea3d | ||
|
|
ffe636c6c7 | ||
|
|
e22ea40910 | ||
|
|
e269264f03 | ||
|
|
9fb9ab9198 | ||
|
|
4209dcbc2d | ||
|
|
70be6396aa | ||
|
|
5b4c76a1c8 | ||
|
|
9d9e1527f4 | ||
|
|
70741a5a34 | ||
|
|
8022602fc5 | ||
|
|
f0dcc2baad | ||
|
|
2221c99ad7 | ||
|
|
d84b44252e | ||
|
|
5a719de8ee | ||
|
|
7c8c142e34 | ||
|
|
093b0a7f83 | ||
|
|
a4442fe12e | ||
|
|
a59df8dd62 | ||
|
|
80390de6dc | ||
|
|
5f05964b1b | ||
|
|
d53240c710 | ||
|
|
1f3b551b94 | ||
|
|
2a7e39bbd0 | ||
|
|
04ce8104fe | ||
|
|
7ce0e6e9dd | ||
|
|
b0782868b8 | ||
|
|
a39c944f10 | ||
|
|
655e2a2e5d | ||
|
|
087d4cdddd | ||
|
|
77714d22a9 | ||
|
|
f405016f96 | ||
|
|
145d339ae1 | ||
|
|
4e6de6fe85 | ||
|
|
c4489c2301 | ||
|
|
bb60197c46 | ||
|
|
a89847f818 | ||
|
|
071e76b3af | ||
|
|
295c3aa6d5 | ||
|
|
2fab7683e1 | ||
|
|
f264d10cb8 | ||
|
|
95f2a82532 | ||
|
|
d9f3d07dd7 | ||
|
|
cf7a2fb8bb | ||
|
|
3f07ce4ec7 | ||
|
|
3637edce33 | ||
|
|
cd2e138f66 | ||
|
|
0062b1f9c9 | ||
|
|
a3ac9c474a | ||
|
|
783ae44ce1 | ||
|
|
0068e162f7 | ||
|
|
b0b4724b4a | ||
|
|
ad74ec8f29 | ||
|
|
00109d4694 | ||
|
|
0a91d70cd3 | ||
|
|
1cd6d66b85 | ||
|
|
3ef1abf35e | ||
|
|
e29b954438 | ||
|
|
8c3b365e0b | ||
|
|
33b0e256c4 | ||
|
|
21713498b2 | ||
|
|
8d1489f513 | ||
|
|
cbd02bece8 | ||
|
|
e135ff945f | ||
|
|
f3591bb9da | ||
|
|
fbb0787aa9 | ||
|
|
16fcaf6346 | ||
|
|
8a6d337392 | ||
|
|
5f4fd4345e | ||
|
|
7e93165c58 | ||
|
|
419160d144 | ||
|
|
0c6580e732 | ||
|
|
8f4b5d581d | ||
|
|
809d857e94 | ||
|
|
98142c91f3 | ||
|
|
93b2675b9e | ||
|
|
157daae740 | ||
|
|
f6459965e0 | ||
|
|
a3331543f2 | ||
|
|
9d71f2bbf3 | ||
|
|
8cceecf1bd | ||
|
|
c330c4bc70 | ||
|
|
26bf2a2c55 | ||
|
|
86958c6d16 | ||
|
|
83a3d1584a | ||
|
|
a07c66ad1a | ||
|
|
956e69b56f | ||
|
|
db71ea2a5b | ||
|
|
526e486fd3 | ||
|
|
b149cbcfee | ||
|
|
12c5cec7a1 | ||
|
|
e0bfda0dee | ||
|
|
d2375e136a | ||
|
|
23675bc69e | ||
|
|
94659791e6 | ||
|
|
17cc0af02d | ||
|
|
f28878e1b0 | ||
|
|
2a8b0b813c | ||
|
|
f18ed83f9d | ||
|
|
d1cca38595 | ||
|
|
1f1344522f | ||
|
|
7cad46063e | ||
|
|
55750bcf1f | ||
|
|
230944cbcd | ||
|
|
2f47ff8523 | ||
|
|
3ef7d61da6 | ||
|
|
7fe29c5bd4 | ||
|
|
5775e53bb8 | ||
|
|
57682d4607 | ||
|
|
915552ac4a | ||
| 861e89ae4d | |||
| 97fd326561 | |||
|
|
34a9ab6a43 | ||
|
|
4c597473b7 | ||
|
|
8119f202d3 | ||
| 6beccc772a | |||
|
|
4797a74111 | ||
|
|
30b5cd9731 | ||
|
|
6b83f26fc0 | ||
|
|
346ac69046 | ||
|
|
838eaab9be | ||
|
|
eba34fa2d4 | ||
|
|
9f51def959 | ||
| c8bf38dd36 | |||
|
|
7120dcd317 | ||
|
|
da419533e9 | ||
|
|
bd0aa651af | ||
|
|
d1b11a0c51 | ||
|
|
5dc849f551 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,3 +3,7 @@ __pycache__
|
|||||||
db.sqlite3
|
db.sqlite3
|
||||||
tailwindcss.exe
|
tailwindcss.exe
|
||||||
t-style.css
|
t-style.css
|
||||||
|
dump.rdb
|
||||||
|
media
|
||||||
|
node_modules
|
||||||
|
staticfiles
|
||||||
72
README.md
72
README.md
@@ -47,16 +47,62 @@ Um das Projekt erfolgreich zu starten, folge diesen Schritten:
|
|||||||
|
|
||||||
### Entwicklungsserver starten
|
### Entwicklungsserver starten
|
||||||
|
|
||||||
Um den Server zu starten, verwende einen der folgenden Befehle:
|
Für die Entwicklung mit WebSocket-Unterstützung verwenden wir Daphne:
|
||||||
|
|
||||||
- Standardport (8000):
|
1. Aktiviere die virtuelle Umgebung:
|
||||||
```sh
|
```sh
|
||||||
python3 core/manage.py runserver
|
source .venv/bin/activate # Linux
|
||||||
```
|
.venv\Scripts\activate # Windows
|
||||||
- Bestimmten Port (z. B. 9000):
|
```
|
||||||
```sh
|
|
||||||
python3 core/manage.py runserver 9000
|
2. Starte den Daphne-Server:
|
||||||
```
|
```sh
|
||||||
|
# Im Verzeichnis 'django'
|
||||||
|
daphne -b 127.0.0.1 -p 8000 core.asgi:application
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Starte den REDIS Server
|
||||||
|
```sh
|
||||||
|
redis-server
|
||||||
|
```
|
||||||
|
> **Hinweis:** Der Redis Server muss, wenn er nicht auf dem selben Gerät unter Standardeinstellungen läuft, in der Datei play/consumers/lobby.py und core/settings.py entsprechend umkonfiguriert werden!
|
||||||
|
|
||||||
|
|
||||||
|
Alternativ kannst du den Django-Entwicklungsserver verwenden, wenn du keine WebSocket-Funktionalität benötigst:
|
||||||
|
```sh
|
||||||
|
python3 core/manage.py runserver
|
||||||
|
```
|
||||||
|
|
||||||
|
### Produktionsserver starten
|
||||||
|
|
||||||
|
Für den Produktivbetrieb verwenden wir Daphne als ASGI-Server, der sowohl HTTP als auch WebSocket-Verbindungen unterstützt:
|
||||||
|
|
||||||
|
1. Aktiviere die virtuelle Umgebung wie oben beschrieben
|
||||||
|
|
||||||
|
2. Sammle die statischen Dateien:
|
||||||
|
```sh
|
||||||
|
python3 core/manage.py collectstatic
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Starte den Daphne-Server:
|
||||||
|
```sh
|
||||||
|
daphne -b 0.0.0.0 -p 8000 core.asgi:application
|
||||||
|
```
|
||||||
|
- `-b 0.0.0.0`: Bindet den Server an alle Netzwerk-Interfaces
|
||||||
|
- `-p 8000`: Port (anpassbar)
|
||||||
|
|
||||||
|
4. Cronjob für Bereinigung der Spiele in der Datenbank
|
||||||
|
- Zum bearbeiten der Cronjobs:
|
||||||
|
```sh
|
||||||
|
crontab -e
|
||||||
|
```
|
||||||
|
- Dann `0 0 * * * /path/to/venv/bin/python /path/to/your_project/manage.py cleanup_games` einfügen, damit um Mitternacht alle Spiele gelöscht werden
|
||||||
|
|
||||||
|
5. Starte den REDIS Server
|
||||||
|
```sh
|
||||||
|
redis-server
|
||||||
|
```
|
||||||
|
> **Hinweis:** Der Redis Server muss, wenn er nicht auf dem selben Gerät unter Standardeinstellungen läuft, in der Datei play/consumers/lobby.py und core/settings.py entsprechend umkonfiguriert werden!
|
||||||
|
|
||||||
Damit ist das Projekt erfolgreich eingerichtet und der Server kann gestartet werden!
|
Damit ist das Projekt erfolgreich eingerichtet und der Server kann gestartet werden!
|
||||||
|
|
||||||
@@ -100,10 +146,10 @@ npx @tailwindcss/cli -i <INPUT-DATEI> -o <OUTPUT-DATEI> --watch --minify
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# unter Linux mit Tailwind Binärdatei:
|
# unter Linux mit Tailwind Binärdatei:
|
||||||
tailwindcss -i core/static/homepage/t-input.css -o core/static/homepage/t-style.css --watch --minify
|
npx tailwindcss -i static/css/t-input.css -o static/css/t-style.css --watch --minify
|
||||||
|
|
||||||
# unter Windows mit NPM:
|
# unter Windows mit NPM (in bash mit '/' statt '\'):
|
||||||
npx @tailwindcss/cli -i .\core\static\homepage\t-input.css -o .\core\static\homepage\t-style.css --watch --minify
|
npx @tailwindcss/cli -i ./static/css/t-input.css -o ./static/css/t-style.css --watch --minify
|
||||||
```
|
```
|
||||||
|
|
||||||
## Issue - Merge Request - Merge
|
## Issue - Merge Request - Merge
|
||||||
@@ -112,6 +158,6 @@ Hier der vereinbarte Arbeitsablauf:
|
|||||||
|
|
||||||
1. Issue erstellen - das geht am einfachsten über die Webseite. Der Titel beschreibt kurz und klar, was angestrebt wird.
|
1. Issue erstellen - das geht am einfachsten über die Webseite. Der Titel beschreibt kurz und klar, was angestrebt wird.
|
||||||
|
|
||||||
2. Merge Request anlegen - dadurch wird der Bransch automatisch angelegt. Dieser kann mit `git pull` geholt und mit `git checkout <branch>` bearbeitet werden.
|
2. Merge Request anlegen - dadurch wird der Branch automatisch angelegt. Dieser kann mit `git pull` geholt und mit `git checkout <branch>` bearbeitet werden.
|
||||||
|
|
||||||
3. Nach dem Hochladen kann der Merge in den Master durchgeführt werden.
|
3. Nach dem Hochladen kann der Merge in den Master durchgeführt werden.
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
ASGI config for core project.
|
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
|
||||||
|
|
||||||
application = get_asgi_application()
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
from django import forms
|
|
||||||
from .models import QivipQuiz, QivipQuestion
|
|
||||||
|
|
||||||
class QuizForm(forms.ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = QivipQuiz
|
|
||||||
fields = ['name', 'description', 'status', 'category', 'tags',"difficulty"]
|
|
||||||
|
|
||||||
class QuestionForm(forms.ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = QivipQuestion
|
|
||||||
fields = ['quiz_id', 'data']
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.utils.text import slugify
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
class QivipQuiz(models.Model):
|
|
||||||
STATUS_VALUES = {
|
|
||||||
"public": "Öffentlich",
|
|
||||||
"hidden": "Versteckt",
|
|
||||||
"private": "Privat",
|
|
||||||
}
|
|
||||||
DIFFICULTY_VALUES = {
|
|
||||||
"1": "1",
|
|
||||||
"2": "2",
|
|
||||||
"3": "3",
|
|
||||||
"4": "4",
|
|
||||||
"5": "5",
|
|
||||||
"not defined":"nicht gesetzt",
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
|
||||||
user_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name='quiz')
|
|
||||||
creation_date = models.DateTimeField(auto_now_add=True)
|
|
||||||
update_date = models.DateTimeField(auto_now=True)
|
|
||||||
status = models.CharField(max_length=10, choices=list(STATUS_VALUES.items()), default="public")
|
|
||||||
category = models.ForeignKey('QuizCategory', related_name='quiz', on_delete=models.CASCADE)
|
|
||||||
tags = models.ManyToManyField('Tag', blank=True)
|
|
||||||
name = models.CharField(max_length=255)
|
|
||||||
description = models.TextField(blank=True, null=True, default="In dem Quiz geht es um ...")
|
|
||||||
difficulty= models.CharField(max_length=11, choices=list(DIFFICULTY_VALUES.items()), default="not defined", help_text="1: niedrigste Schwierigkeit und 5: höchste Schwierigkeit")
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
class QivipQuestion(models.Model):
|
|
||||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
|
||||||
quiz_id = models.ForeignKey(QivipQuiz, on_delete=models.CASCADE, related_name='question')
|
|
||||||
creation_date = models.DateTimeField(auto_now_add=True)
|
|
||||||
update_date = models.DateTimeField(auto_now=True)
|
|
||||||
data = models.TextField()
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.data[:50]
|
|
||||||
|
|
||||||
class Tag(models.Model):
|
|
||||||
name = models.CharField(max_length=100, unique=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
class QuizCategory(models.Model):
|
|
||||||
name = models.CharField(max_length=100, unique=True)
|
|
||||||
description = models.TextField(blank=True, null=True)
|
|
||||||
slug = models.SlugField(unique=True, blank=True)
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
if not self.slug:
|
|
||||||
self.slug = slugify(self.name)
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
@@ -1,295 +0,0 @@
|
|||||||
from django.shortcuts import render, redirect, get_object_or_404
|
|
||||||
from django.contrib.auth.decorators import login_required
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.contrib import messages
|
|
||||||
from .models import QivipQuiz, QivipQuestion
|
|
||||||
from .forms import QuizForm, QuestionForm
|
|
||||||
import json
|
|
||||||
|
|
||||||
# Übersicht aller Quizze
|
|
||||||
@login_required
|
|
||||||
def overview_quiz(request):
|
|
||||||
quizzes = QivipQuiz.objects.filter(user_id=request.user)
|
|
||||||
return render(request, 'library/overview_quiz.html', {'quizzes': quizzes})
|
|
||||||
|
|
||||||
# Neues Quiz erstellen
|
|
||||||
@login_required
|
|
||||||
def new_quiz(request):
|
|
||||||
if request.method == 'POST':
|
|
||||||
form = QuizForm(request.POST)
|
|
||||||
if form.is_valid():
|
|
||||||
quiz = form.save(commit=False)
|
|
||||||
quiz.user_id = request.user
|
|
||||||
quiz.save()
|
|
||||||
form.save_m2m() # Speichert die Many-to-Many Beziehungen (Tags)
|
|
||||||
return redirect('library:edit_quiz', pk=quiz.pk)
|
|
||||||
else:
|
|
||||||
form = QuizForm()
|
|
||||||
return render(request, 'library/form.html', {'form': form})
|
|
||||||
|
|
||||||
# Quiz bearbeiten
|
|
||||||
@login_required
|
|
||||||
def edit_quiz(request, pk):
|
|
||||||
quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
|
||||||
if request.method == 'POST':
|
|
||||||
form = QuizForm(request.POST, instance=quiz)
|
|
||||||
if form.is_valid():
|
|
||||||
form.save()
|
|
||||||
return redirect('library:overview_quiz')
|
|
||||||
else:
|
|
||||||
form = QuizForm(instance=quiz)
|
|
||||||
return render(request, 'library/form.html', {'form': form})
|
|
||||||
|
|
||||||
# Quiz löschen
|
|
||||||
@login_required
|
|
||||||
def delete_quiz(request, pk):
|
|
||||||
quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
|
||||||
if request.method == 'POST':
|
|
||||||
quiz.delete()
|
|
||||||
return redirect('library:overview_quiz')
|
|
||||||
return render(request, 'library/delete_confirmation.html', {'object': quiz})
|
|
||||||
|
|
||||||
# Quiz anzeigen
|
|
||||||
@login_required
|
|
||||||
def detail_quiz(request, pk):
|
|
||||||
quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
|
||||||
questions = QivipQuestion.objects.filter(quiz_id=quiz)
|
|
||||||
|
|
||||||
# Parse JSON data for each question
|
|
||||||
for question in questions:
|
|
||||||
if question.data:
|
|
||||||
question.data = json.loads(question.data)
|
|
||||||
|
|
||||||
context = {
|
|
||||||
'quiz': quiz,
|
|
||||||
'questions': questions
|
|
||||||
}
|
|
||||||
return render(request, 'library/detail_quiz.html', context)
|
|
||||||
|
|
||||||
# Übersicht aller Fragen
|
|
||||||
@login_required
|
|
||||||
def question_list(request):
|
|
||||||
questions = QivipQuestion.objects.filter(quiz_id__user_id=request.user)
|
|
||||||
|
|
||||||
# Parse JSON data for each question
|
|
||||||
for question in questions:
|
|
||||||
if question.data:
|
|
||||||
question.data = json.loads(question.data)
|
|
||||||
|
|
||||||
return render(request, 'library/question_list.html', {'questions': questions})
|
|
||||||
|
|
||||||
# Neue Frage erstellen
|
|
||||||
@login_required
|
|
||||||
def new_question(request):
|
|
||||||
question_type = request.GET.get('type')
|
|
||||||
quiz_id = request.GET.get('quiz_id')
|
|
||||||
|
|
||||||
if not quiz_id:
|
|
||||||
messages.error(request, 'Quiz ID muss angegeben werden.')
|
|
||||||
return redirect('library:overview_quiz')
|
|
||||||
|
|
||||||
try:
|
|
||||||
quiz = QivipQuiz.objects.get(pk=quiz_id, user_id=request.user)
|
|
||||||
except QivipQuiz.DoesNotExist:
|
|
||||||
messages.error(request, 'Quiz nicht gefunden oder keine Berechtigung.')
|
|
||||||
return redirect('library:overview_quiz')
|
|
||||||
|
|
||||||
if question_type not in ['multiple_choice', 'true_false']:
|
|
||||||
base_url = reverse('library:new_question')
|
|
||||||
return redirect(f'{base_url}?type=multiple_choice&quiz_id={quiz_id}')
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
question_text = request.POST.get('question', '')
|
|
||||||
|
|
||||||
# Handle different question types
|
|
||||||
if question_type == 'true_false':
|
|
||||||
correct_answer = request.POST.get('correct_answer') == 'true'
|
|
||||||
json_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': question_text,
|
|
||||||
'options': [
|
|
||||||
{'value': 'Wahr', 'is_correct': correct_answer},
|
|
||||||
{'value': 'Falsch', 'is_correct': not correct_answer}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
elif question_type == 'multiple_choice':
|
|
||||||
options = []
|
|
||||||
i = 1
|
|
||||||
# Limit to maximum 6 options
|
|
||||||
while request.POST.get(f'option_{i}') and i <= 6:
|
|
||||||
is_correct = request.POST.get(f'correct_{i}') == '1'
|
|
||||||
options.append({
|
|
||||||
'order': i,
|
|
||||||
'value': request.POST.get(f'option_{i}'),
|
|
||||||
'is_correct': is_correct
|
|
||||||
})
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
# Validate minimum 2 options
|
|
||||||
if len(options) < 2:
|
|
||||||
messages.error(request, 'Mindestens zwei Optionen müssen angegeben werden.')
|
|
||||||
return redirect(request.get_full_path())
|
|
||||||
|
|
||||||
json_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': question_text,
|
|
||||||
'options': options
|
|
||||||
}
|
|
||||||
|
|
||||||
question = QivipQuestion()
|
|
||||||
question.data = json.dumps(json_data)
|
|
||||||
question.quiz_id = quiz
|
|
||||||
question.save()
|
|
||||||
return redirect('library:detail_quiz', pk=quiz.pk)
|
|
||||||
else:
|
|
||||||
# Initialize empty question data for new questions
|
|
||||||
if question_type == 'true_false':
|
|
||||||
question_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': '',
|
|
||||||
'options': [
|
|
||||||
{'value': 'Wahr', 'is_correct': True},
|
|
||||||
{'value': 'Falsch', 'is_correct': False}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
elif question_type == 'multiple_choice':
|
|
||||||
question_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': '',
|
|
||||||
'options': [
|
|
||||||
{'value': '', 'is_correct': False},
|
|
||||||
{'value': '', 'is_correct': False}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
template_name = f'library/question/question_{question_type}.html'
|
|
||||||
context = {
|
|
||||||
'question': question_data,
|
|
||||||
'quiz_id': quiz_id,
|
|
||||||
'quiz': quiz
|
|
||||||
}
|
|
||||||
|
|
||||||
return render(request, template_name, context)
|
|
||||||
|
|
||||||
# Frage bearbeiten
|
|
||||||
@login_required
|
|
||||||
def edit_question(request, pk):
|
|
||||||
question = get_object_or_404(QivipQuestion, pk=pk, quiz_id__user_id=request.user)
|
|
||||||
if question.quiz_id.user_id != request.user:
|
|
||||||
return redirect('library:question_list')
|
|
||||||
|
|
||||||
# Parse the existing JSON data
|
|
||||||
try:
|
|
||||||
question_data = json.loads(question.data) if question.data else {}
|
|
||||||
question_type = question_data.get('type', 'multiple_choice')
|
|
||||||
|
|
||||||
# For true/false questions, get the correct answer from the options
|
|
||||||
if question_type == 'true_false':
|
|
||||||
# Default to true if no options exist
|
|
||||||
correct_answer = True
|
|
||||||
if question_data.get('options'):
|
|
||||||
correct_answer = question_data['options'][0].get('is_correct', True)
|
|
||||||
question_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': question_data.get('question', ''),
|
|
||||||
'correct_answer': correct_answer, # Add this for template compatibility
|
|
||||||
'options': [
|
|
||||||
{'value': 'Wahr', 'is_correct': correct_answer},
|
|
||||||
{'value': 'Falsch', 'is_correct': not correct_answer}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
# For multiple choice questions
|
|
||||||
question_data.setdefault('type', question_type)
|
|
||||||
question_data.setdefault('question', '')
|
|
||||||
question_data.setdefault('options', [])
|
|
||||||
|
|
||||||
except (json.JSONDecodeError, AttributeError):
|
|
||||||
# Handle invalid JSON or None data
|
|
||||||
question_type = question_data.get('type', 'multiple_choice')
|
|
||||||
if question_type == 'true_false':
|
|
||||||
question_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': '',
|
|
||||||
'correct_answer': True, # Default to true for new questions
|
|
||||||
'options': [
|
|
||||||
{'value': 'Wahr', 'is_correct': True},
|
|
||||||
{'value': 'Falsch', 'is_correct': False}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
question_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': '',
|
|
||||||
'options': []
|
|
||||||
}
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
question_text = request.POST.get('question', '')
|
|
||||||
|
|
||||||
# Handle different question types
|
|
||||||
if question_type == 'true_false':
|
|
||||||
correct_answer = request.POST.get('correct_answer') == 'true'
|
|
||||||
json_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': question_text,
|
|
||||||
'options': [
|
|
||||||
{'value': 'Wahr', 'is_correct': correct_answer},
|
|
||||||
{'value': 'Falsch', 'is_correct': not correct_answer}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
elif question_type == 'multiple_choice':
|
|
||||||
options = []
|
|
||||||
i = 1
|
|
||||||
# Limit to maximum 6 options
|
|
||||||
while request.POST.get(f'option_{i}') and i <= 6:
|
|
||||||
options.append({
|
|
||||||
'order': i,
|
|
||||||
'value': request.POST.get(f'option_{i}'),
|
|
||||||
'is_correct': request.POST.get(f'correct_{i}') == '1'
|
|
||||||
})
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
# Validate minimum 2 options
|
|
||||||
if len(options) < 2:
|
|
||||||
messages.error(request, 'Mindestens zwei Optionen müssen angegeben werden.')
|
|
||||||
return redirect(request.get_full_path())
|
|
||||||
|
|
||||||
# Validate maximum 6 options
|
|
||||||
if len(options) > 6:
|
|
||||||
messages.error(request, 'Maximal 6 Optionen sind erlaubt.')
|
|
||||||
return redirect(request.get_full_path())
|
|
||||||
|
|
||||||
json_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': question_text,
|
|
||||||
'options': options
|
|
||||||
}
|
|
||||||
|
|
||||||
question.data = json.dumps(json_data)
|
|
||||||
question.save()
|
|
||||||
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
|
||||||
else:
|
|
||||||
template_name = f'library/question/question_{question_type}.html'
|
|
||||||
context = {
|
|
||||||
'question': {'data': question_data}, # Wrap in data structure expected by template
|
|
||||||
'quiz_id': question.quiz_id.pk,
|
|
||||||
'quiz': question.quiz_id
|
|
||||||
}
|
|
||||||
|
|
||||||
return render(request, template_name, context)
|
|
||||||
|
|
||||||
# Frage löschen
|
|
||||||
@login_required
|
|
||||||
def delete_question(request, pk):
|
|
||||||
question = get_object_or_404(QivipQuestion, pk=pk, quiz_id__user_id=request.user)
|
|
||||||
|
|
||||||
# Parse JSON data for question
|
|
||||||
if question.data:
|
|
||||||
question.data = json.loads(question.data)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
question.delete()
|
|
||||||
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
|
||||||
return render(request, 'library/delete_confirmation.html', {'object': question})
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
from django.urls import path
|
|
||||||
from . import views
|
|
||||||
|
|
||||||
app_name = 'play'
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
path('lobby', views.lobby, name='lobby'),
|
|
||||||
path('join', views.join_game, name='join_game'),
|
|
||||||
]
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
def lobby(request):
|
|
||||||
return render(request, 'play/lobby.html')
|
|
||||||
|
|
||||||
def join_game(request):
|
|
||||||
return render(request, 'play/join_game.html')
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
@import 'tailwindcss';
|
|
||||||
|
|
||||||
qp-container {
|
|
||||||
@apply max-w-xl w-full mx-auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav div ul.qp-nav-list li {
|
|
||||||
@apply text-white hover:scale-110 hover:border-b-2 hover:border-white transition duration-200;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.qp-a-button {
|
|
||||||
@apply p-6 rounded-md font-extrabold hover:scale-105 transition duration-300 shadow-md;
|
|
||||||
}
|
|
||||||
a.qp-a-button-small {
|
|
||||||
@apply p-1 rounded-md hover:scale-105 transition duration-300 shadow-md;
|
|
||||||
}
|
|
||||||
.register input{@apply p-3 rounded-full bg-gray-200 focus:scale-105 transition duration-200 font-black w-full;}
|
|
||||||
|
|
||||||
.input-group {
|
|
||||||
@apply flex flex-col gap-4 max-w-md mx-auto p-6 bg-white rounded-xl shadow-lg;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-group form {
|
|
||||||
@apply flex flex-col gap-4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-group form p {
|
|
||||||
@apply flex flex-col gap-2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-group form p label {
|
|
||||||
@apply text-gray-900 font-semibold text-sm;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-group form p input {
|
|
||||||
@apply p-3 rounded-full bg-gray-200 focus:scale-105 transition duration-200 font-black
|
|
||||||
focus:outline-none focus:ring-2 focus:ring-blue-400 focus:bg-blue-100;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-group form p select {
|
|
||||||
@apply p-3 rounded-md bg-gray-200 focus:scale-105 transition duration-200 font-black
|
|
||||||
focus:outline-none focus:ring-2 focus:ring-blue-400 focus:bg-blue-100;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-group form p textarea {
|
|
||||||
@apply p-3 rounded-xl bg-gray-200 focus:scale-105 transition duration-200 font-black
|
|
||||||
focus:outline-none focus:ring-2 focus:ring-blue-400 focus:bg-blue-100 min-h-[100px];
|
|
||||||
}
|
|
||||||
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{% load static %}
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="de">
|
|
||||||
<head>
|
|
||||||
<link rel="icon" type="image/png" href="{% static 'icons/favicon.png' %}">
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="{% static 'css/t-style.css' %}">
|
|
||||||
<title>qivip</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% include 'partials/_nav.html' %}
|
|
||||||
{% block content%}{% endblock %}
|
|
||||||
{% include 'partials/_footer.html' %}
|
|
||||||
{% block extra_js %}{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="grid place-content-center md:h-screen h-150 w-full -z-50 top-0 p-4">
|
|
||||||
<div class="text-center">
|
|
||||||
<h2 class="font-bold md:text-8xl text-6xl md:mb-8 text-blue-600">qivip</h2>
|
|
||||||
<h3 class="italic font-extralight sm:text-2xl text-md">Interaktives Lernen neu definiert.</h3>
|
|
||||||
</div>
|
|
||||||
<div class="grid sm:grid-cols-3 place-items-stretch text-center mt-8 gap-4 p-4 border-3 bg-blue-100 border-blue-100 rounded-md">
|
|
||||||
<a class="qp-a-button bg-green-500 text-white" href="#">Teilnehmen</a>
|
|
||||||
<a class="qp-a-button bg-indigo-500 text-white" href="#">Moderieren</a>
|
|
||||||
<a class="qp-a-button bg-purple-500 text-white" href="#">Verwalten</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% block content%}
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<h1>Impressum</h1>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
Katharineum zu Lübeck
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Königsstraße 27-31
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
23552 Lübeck
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block content%}
|
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
Hallo, ich bin die Datenschutzerklärung!
|
|
||||||
</p>
|
|
||||||
</div
|
|
||||||
{% endblock %}
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="container mx-auto px-4">
|
|
||||||
<div class="flex justify-between items-center mb-6">
|
|
||||||
<h1 class="text-2xl font-bold">{{ quiz.name }}</h1>
|
|
||||||
<div class="flex space-x-2">
|
|
||||||
<a href="{% url 'library:edit_quiz' quiz.id %}" class="bg-green-500 text-white px-4 py-2 rounded-md text-sm lg:text-lg hover:bg-green-600 transition-colors">Quiz bearbeiten</a>
|
|
||||||
<a href="{% url 'library:delete_quiz' quiz.id %}" class="bg-red-500 text-white px-4 py-2 rounded-md text-sm lg:text-lg hover:bg-red-600 transition-colors">Quiz löschen</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if quiz.description %}
|
|
||||||
<p class="text-gray-600 mb-8">{{ quiz.description }}</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="bg-white rounded-lg shadow-md border-blue-600 border-2 rounded-xl shadow-md">
|
|
||||||
<div class="border-b border-gray-200 p-4">
|
|
||||||
<div class="flex justify-between items-center">
|
|
||||||
<h2 class="text-xl font-semibold">Fragen</h2>
|
|
||||||
<div class="flex space-x-2">
|
|
||||||
<a href="{% url 'library:new_question' %}?type=multiple_choice&quiz_id={{ quiz.id }}"
|
|
||||||
class="bg-blue-100 text-blue-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
|
|
||||||
Multiple Choice
|
|
||||||
</a>
|
|
||||||
<a href="{% url 'library:new_question' %}?type=true_false&quiz_id={{ quiz.id }}"
|
|
||||||
class="bg-purple-100 text-purple-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
|
|
||||||
Wahr/Falsch
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if questions %}
|
|
||||||
|
|
||||||
<div class="divide-y divide-gray-200">
|
|
||||||
{% for question in questions %}
|
|
||||||
|
|
||||||
<div class="w-full rounded-xl p-4 hover:bg-gray-50">
|
|
||||||
<a class="block flex h-full w-full" href="{% url 'library:edit_question' question.id %}" >
|
|
||||||
<div class="flex justify-between items-start">
|
|
||||||
|
|
||||||
<div class="flex-grow">
|
|
||||||
<p class="font-medium">{{ question.data.question }}</p>
|
|
||||||
<div class="mt-1">
|
|
||||||
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium {% if question.data.type == 'multiple_choice' %}bg-blue-100 text-blue-800{% else %}bg-purple-100 text-purple-800{% endif %}">
|
|
||||||
{% if question.data.type == 'multiple_choice' %}Multiple Choice{% else %}Wahr/Falsch{% endif %}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="mt-2">
|
|
||||||
{% if question.data.type == 'multiple_choice' %}
|
|
||||||
<ul class="space-y-1">
|
|
||||||
{% for option in question.data.options %}
|
|
||||||
<li class="flex items-center text-sm">
|
|
||||||
{% if option.is_correct %}
|
|
||||||
<svg class="h-4 w-4 text-green-500 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
|
|
||||||
</svg>
|
|
||||||
<span class="font-medium text-green-700">{{ option.value }}</span>
|
|
||||||
{% else %}
|
|
||||||
<svg class="h-4 w-4 text-gray-400 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 12H6"/>
|
|
||||||
</svg>
|
|
||||||
<span class="text-gray-600">{{ option.value }}</span>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% else %}
|
|
||||||
{% for option in question.data.options %}
|
|
||||||
{% if option.is_correct %}
|
|
||||||
<p class="text-sm">
|
|
||||||
<span class="text-gray-500">Richtige Antwort:</span>
|
|
||||||
<span class="ml-1 font-medium {% if option.value == "Wahr" %} text-green-700 {% else %}text-red-700{% endif %}">{{ option.value }}</span>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex h-full space-x-2 ml-4 items-center">
|
|
||||||
<!--
|
|
||||||
<a href="{% url 'library:edit_question' question.id %}"
|
|
||||||
class="bg-gray-100 text-gray-700 px-3 py-1 rounded hover:bg-gray-200 transition-colors">
|
|
||||||
Bearbeiten
|
|
||||||
</a>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<a href=" {% url 'library:delete_question' question.id %}"
|
|
||||||
class=" text-red-700 px-4 py-1 rounded hover:scale-110 ">
|
|
||||||
🗑
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
<div class="p-8 text-center">
|
|
||||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
|
|
||||||
</svg>
|
|
||||||
<p class="mt-2 text-sm text-gray-500">Noch keine Fragen vorhanden. Erstellen Sie eine neue Frage, um loszulegen!</p>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h1>Formular</h1>
|
|
||||||
<h2>{{ form.name.value }}</h2>
|
|
||||||
<div class="input-group border-blue-600 border-2 rounded-xl shadow-md">
|
|
||||||
<form method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
{{ form.as_p }}
|
|
||||||
<button type="submit">Speichern</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h1>Übersicht</h1>
|
|
||||||
<div class="flex justify-end">
|
|
||||||
<a href="{% url 'library:new_quiz' %}" class="text-white bg-blue-500 px-4 py-2 rounded-md mb-12">Neues Quiz erstellen</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 px-4 place-items-center">
|
|
||||||
{% for quiz in quizzes %}
|
|
||||||
<div class="bg-white w-full max-w-md rounded-lg p-4 shadow-md border-blue-600 border-2 rounded-xl">
|
|
||||||
<h2 class="text-lg font-bold"><a href="{% url 'library:edit_quiz' quiz.id %}">{{ quiz.name }}</a></h2>
|
|
||||||
<p class="text-sm text-gray-600 py-12">{{ quiz.description }}</p>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div class="flex justify-between items-center gap-2">
|
|
||||||
<a href="#" class="qp-a-button-small border-2 border-blue-600 text-black">Spiel starten</a>
|
|
||||||
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<a href="{% url 'library:detail_quiz' quiz.id %}" class="qp-a-button-small border-2 border-blue-600 text-white">✏</a>
|
|
||||||
<a href="{% url 'library:delete_quiz' quiz.id %}" class="qp-a-button-small border-2 border-blue-600 text-white">🗑</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<nav class="flex justify-between bg-blue-600 h-12 px-4 sm:px-6 lg:px-8 rounded-lg m-2 shadow-md">
|
|
||||||
<div class="flex items-center">
|
|
||||||
<h2 class="text-xl font-bold text-white hover:scale-110 transition duration-200"><a href="{% url 'homepage:home' %}">qivip</a></h2>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center">
|
|
||||||
<ul class="flex space-x-4 qp-nav-list">
|
|
||||||
<li><a href="{% url 'library:overview_quiz' %}">Bibliothek</a></li>
|
|
||||||
{% if user.is_authenticated %}
|
|
||||||
<li><a href="{% url 'accounts:home' %}">Konto</a></li>
|
|
||||||
{% else %}
|
|
||||||
<li><a href="{% url 'accounts:login' %}">Anmelden</a></li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="container mx-auto px-4">
|
|
||||||
<h1>Bundeslaender Deutschland Quiz</h1>
|
|
||||||
<div id="player-list">
|
|
||||||
<ul>
|
|
||||||
<li>Spieler 1</li>
|
|
||||||
<li>Spieler 2</li>
|
|
||||||
<li>Spieler 3</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<button class="w-full p-3 rounded-full bg-blue-600 text-white font-black hover:scale-105 transition duration-200" type="submit">Starten</button>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib.auth import login, authenticate
|
||||||
from .forms import RegisterForm
|
from .forms import RegisterForm
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@@ -11,8 +12,9 @@ def register(response):
|
|||||||
if response.method == "POST":
|
if response.method == "POST":
|
||||||
form = RegisterForm(response.POST)
|
form = RegisterForm(response.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
form.save()
|
user=form.save()
|
||||||
return redirect("home")
|
login(response, user) #automatischer Login nach Registrierung
|
||||||
|
return redirect("accounts:home")
|
||||||
else:
|
else:
|
||||||
form = RegisterForm()
|
form = RegisterForm()
|
||||||
|
|
||||||
28
django/core/asgi.py
Normal file
28
django/core/asgi.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
"""
|
||||||
|
ASGI config for core project.
|
||||||
|
|
||||||
|
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||||
|
from channels.auth import AuthMiddlewareStack
|
||||||
|
import django
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||||
|
django.setup()
|
||||||
|
|
||||||
|
from play.routing import websocket_urlpatterns
|
||||||
|
|
||||||
|
application = ProtocolTypeRouter({
|
||||||
|
'http': get_asgi_application(),
|
||||||
|
'websocket': AuthMiddlewareStack(
|
||||||
|
URLRouter(
|
||||||
|
websocket_urlpatterns
|
||||||
|
)
|
||||||
|
),
|
||||||
|
})
|
||||||
@@ -35,17 +35,20 @@ INSTALLED_APPS = [
|
|||||||
'homepage.apps.HomepageConfig',
|
'homepage.apps.HomepageConfig',
|
||||||
'components.apps.ComponentsConfig',
|
'components.apps.ComponentsConfig',
|
||||||
'accounts.apps.AccountsConfig',
|
'accounts.apps.AccountsConfig',
|
||||||
'play.apps.PlayConfig',
|
'play',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'channels',
|
||||||
|
'django_cleanup',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
@@ -73,6 +76,17 @@ TEMPLATES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'core.wsgi.application'
|
WSGI_APPLICATION = 'core.wsgi.application'
|
||||||
|
ASGI_APPLICATION = 'core.asgi.application'
|
||||||
|
|
||||||
|
CHANNEL_LAYERS = {
|
||||||
|
"default": {
|
||||||
|
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||||
|
"CONFIG": {
|
||||||
|
"hosts": [("127.0.0.1", 6379)],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
@@ -85,6 +99,15 @@ DATABASES = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STORAGES = {
|
||||||
|
"staticfiles": {
|
||||||
|
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
|
||||||
@@ -121,11 +144,22 @@ USE_TZ = True
|
|||||||
# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||||
STATICFILES_DIRS = [BASE_DIR / 'static']
|
STATICFILES_DIRS = [BASE_DIR / 'static']
|
||||||
|
|
||||||
|
# WhiteNoise configuration
|
||||||
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
|
||||||
|
WHITENOISE_SKIP_COMPRESS_EXTENSIONS = ['css', 'js']
|
||||||
|
# Return 404 instead of 500 for missing files
|
||||||
|
WHITENOISE_MISSING_FILE_ERRNO = None
|
||||||
|
|
||||||
# Default primary key field type
|
# Default primary key field type
|
||||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
LOGIN_URL = '/account/login/'
|
LOGIN_URL = '/account/login/'
|
||||||
|
import os
|
||||||
|
|
||||||
|
MEDIA_URL = '/media/' # URL, um auf Medien-Dateien zuzugreifen
|
||||||
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') # Speicherort für hochgeladene Dateien
|
||||||
@@ -14,6 +14,8 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib import admin # type: ignore
|
from django.contrib import admin # type: ignore
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
@@ -23,4 +25,8 @@ urlpatterns = [
|
|||||||
path('', include('homepage.urls')),
|
path('', include('homepage.urls')),
|
||||||
path('play/', include('play.urls')),
|
path('play/', include('play.urls')),
|
||||||
path('library/', include('library.urls')),
|
path('library/', include('library.urls')),
|
||||||
|
path('components/', include('components.urls'))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import QivipQuiz, QivipQuestion, QuizCategory, Tag
|
from .models import QivipQuiz, QivipQuestion, QivipQuizFavorite, QuizCategory
|
||||||
|
|
||||||
# Für das QivipQuiz Modell
|
# Für das QivipQuiz Modell
|
||||||
class QivipQuizAdmin(admin.ModelAdmin):
|
class QivipQuizAdmin(admin.ModelAdmin):
|
||||||
list_display = ('name', 'user_id', 'status', 'category', 'creation_date', 'update_date') # Welche Felder sollen in der Übersicht angezeigt werden
|
list_display = ('name', 'user_id', 'status', 'category', 'creation_date', 'update_date') # Welche Felder sollen in der Übersicht angezeigt werden
|
||||||
search_fields = ('name', 'user_id__username', 'category__name') # Suchfelder
|
search_fields = ('name', 'user_id__username', 'category__name') # Suchfelder
|
||||||
list_filter = ('status', 'category') # Filteroptionen
|
list_filter = ('status', 'category') # Filteroptionen
|
||||||
|
|
||||||
# Für das QivipQuestion Modell
|
# Für das QivipQuestion Modell
|
||||||
class QivipQuestionAdmin(admin.ModelAdmin):
|
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',)
|
search_fields = ('data',)
|
||||||
list_filter = ('quiz_id',)
|
list_filter = ('quiz_id',)
|
||||||
|
|
||||||
@@ -19,13 +18,13 @@ class QuizCategoryAdmin(admin.ModelAdmin):
|
|||||||
search_fields = ('name',)
|
search_fields = ('name',)
|
||||||
prepopulated_fields = {'slug': ('name',)} # Erstelle automatisch den Slug basierend auf dem Namen
|
prepopulated_fields = {'slug': ('name',)} # Erstelle automatisch den Slug basierend auf dem Namen
|
||||||
|
|
||||||
# Für das Tag Modell
|
|
||||||
class TagAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('name',) # Zeige nur den Namen des Tags
|
class QivipQuizFavoriteAdmin(admin.ModelAdmin):
|
||||||
search_fields = ('name',)
|
list_display = ('user', 'favorite', 'quiz') # Welche Felder sollen in der Übersicht angezeigt werden
|
||||||
|
|
||||||
# Registrierung der Modelle im Admin
|
# Registrierung der Modelle im Admin
|
||||||
admin.site.register(QivipQuiz, QivipQuizAdmin)
|
admin.site.register(QivipQuiz, QivipQuizAdmin)
|
||||||
admin.site.register(QivipQuestion, QivipQuestionAdmin)
|
admin.site.register(QivipQuestion, QivipQuestionAdmin)
|
||||||
admin.site.register(QuizCategory, QuizCategoryAdmin)
|
admin.site.register(QuizCategory, QuizCategoryAdmin)
|
||||||
admin.site.register(Tag, TagAdmin)
|
admin.site.register(QivipQuizFavorite, QivipQuizFavoriteAdmin)
|
||||||
31
django/library/forms.py
Normal file
31
django/library/forms.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
from django import forms
|
||||||
|
from .models import QivipQuiz, QivipQuestion
|
||||||
|
|
||||||
|
class QuizForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = QivipQuiz
|
||||||
|
fields = ['name', 'description','image', 'status', 'category','difficulty','credits']
|
||||||
|
|
||||||
|
class QuestionForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = QivipQuestion
|
||||||
|
fields = ['quiz_id', 'data','time_per_question']
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
class QuizFilterForm(forms.Form):
|
||||||
|
search = forms.CharField(required=False, label="Suche", widget=forms.TextInput(attrs={
|
||||||
|
'class': 'flex flex-grow rounded-lg p-2' ,'placeholder': 'Suche ...',
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
min_amout_questions = forms.IntegerField(required=False, min_value=1, label="Minimale Anzahl an Fragen", widget=forms.NumberInput(attrs={
|
||||||
|
'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
|
||||||
|
}))
|
||||||
|
|
||||||
|
max_amout_questions = forms.IntegerField(required=False, min_value=1, label="Maximale Anzahl an Fragen", widget=forms.NumberInput(attrs={
|
||||||
|
'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
|
||||||
|
}))
|
||||||
|
user = forms.CharField(required=False, label="von User", widget=forms.TextInput(attrs={
|
||||||
|
'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
|
||||||
|
}))
|
||||||
13
django/library/management/commands/cleanup_games.py
Normal file
13
django/library/management/commands/cleanup_games.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from play.models import QuizGame
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Bereinigt beendete Spiele'
|
||||||
|
|
||||||
|
def handle(self, *args, **kwargs):
|
||||||
|
expired_games = QuizGame.objects.filter(
|
||||||
|
updated_at__lt=timezone.now() - timezone.timedelta(minutes=5))
|
||||||
|
deleted_count = expired_games.count()
|
||||||
|
expired_games.delete()
|
||||||
|
self.stdout.write(f'{deleted_count} alte Spiele gelöscht.')
|
||||||
18
django/library/migrations/0016_alter_qivipquiz_status.py
Normal file
18
django/library/migrations/0016_alter_qivipquiz_status.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-16 12:53
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0015_alter_qivipquiz_difficulty'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='status',
|
||||||
|
field=models.CharField(choices=[('öffentlich', 'Öffentlich'), ('versteckt', 'Versteckt'), ('privat', 'Privat')], default='öffentlich', max_length=10),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
django/library/migrations/0017_alter_qivipquiz_difficulty.py
Normal file
18
django/library/migrations/0017_alter_qivipquiz_difficulty.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-16 12:54
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0016_alter_qivipquiz_status'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='difficulty',
|
||||||
|
field=models.CharField(choices=[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('nicht gesetzt', 'nicht gesetzt')], default='nicht gesetzt', help_text='1: niedrigste Schwierigkeit und 5: höchste Schwierigkeit', max_length=13),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-16 13:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0017_alter_qivipquiz_difficulty'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(blank=True, default='In dem Quiz geht es um ...', max_length=150, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-16 13:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0018_alter_qivipquiz_description'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(default='In dem Quiz geht es um ...', max_length=255, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-16 13:08
|
||||||
|
|
||||||
|
import library.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0019_alter_qivipquiz_description'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(default='In dem Quiz geht es um ...', max_length=255, validators=[library.models.QivipQuiz.validate_description]),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
django/library/migrations/0021_alter_qivipquiz_name.py
Normal file
18
django/library/migrations/0021_alter_qivipquiz_name.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-16 14:34
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0020_alter_qivipquiz_description'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=100),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-16 14:35
|
||||||
|
|
||||||
|
import library.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0021_alter_qivipquiz_name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(default='In dem Quiz geht es um ...', max_length=200, validators=[library.models.QivipQuiz.validate_description]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=75),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
django/library/migrations/0023_qivipquiz_image.py
Normal file
18
django/library/migrations/0023_qivipquiz_image.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-21 17:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0022_alter_qivipquiz_description_alter_qivipquiz_name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='image',
|
||||||
|
field=models.ImageField(blank=True, null=True, upload_to='quiz_images/'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
django/library/migrations/0024_alter_qivipquiz_image.py
Normal file
18
django/library/migrations/0024_alter_qivipquiz_image.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-03-22 10:22
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0023_qivipquiz_image'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='image',
|
||||||
|
field=models.ImageField(blank=True, max_length=256, null=True, upload_to='quiz_images/'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-03 16:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0024_alter_qivipquiz_image'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='modified_description',
|
||||||
|
field=models.TextField(blank=True, default='Das Quiz wurde modifiziert von:', editable=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-04 13:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0025_qivipquiz_modified_description'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='modified_description',
|
||||||
|
field=models.TextField(blank=True, editable=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
21
django/library/migrations/0027_qivipquiz_creator.py
Normal file
21
django/library/migrations/0027_qivipquiz_creator.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-04 13:37
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0026_alter_qivipquiz_modified_description'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='creator',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='creator_quiz', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
||||||
21
django/library/migrations/0028_alter_qivipquiz_creator.py
Normal file
21
django/library/migrations/0028_alter_qivipquiz_creator.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-04 13:57
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0027_qivipquiz_creator'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='creator',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='creator_quiz', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
django/library/migrations/0029_qivipquiz_credits.py
Normal file
18
django/library/migrations/0029_qivipquiz_credits.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-04 16:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0028_alter_qivipquiz_creator'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='credits',
|
||||||
|
field=models.TextField(blank=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-05 09:39
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0029_qivipquiz_credits'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='creator',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='modified_description',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='base_quiz',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='child_quizzes', to='library.qivipquiz'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-05 17:45
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0030_remove_qivipquiz_creator_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquestion',
|
||||||
|
name='quiz_id',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='library.qivipquiz'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-05 19:08
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0031_alter_qivipquestion_quiz_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='average_rating',
|
||||||
|
field=models.FloatField(default=3.0),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='rating_count',
|
||||||
|
field=models.IntegerField(default=0),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='QuizRating',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('participant_id', models.CharField(max_length=200)),
|
||||||
|
('rating', models.IntegerField(choices=[(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5')])),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('quiz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ratings', to='library.qivipquiz')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'unique_together': {('quiz', 'participant_id')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-08 14:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0032_qivipquiz_average_rating_qivipquiz_rating_count_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquestion',
|
||||||
|
name='time_per_question',
|
||||||
|
field=models.CharField(choices=[('10', 10), ('15', 15), ('30', 30), ('60', 60), ('90', 90), ('120', 120), ('180', 180), ('nicht gesetzt', 'nicht gesetzt')], default=30, help_text='Zeit pro Frage in Sekunden', max_length=13),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-10 13:59
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0032_qivipquiz_average_rating_qivipquiz_rating_count_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='tags',
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Tag',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-08 14:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0033_qivipquestion_time_per_question'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquestion',
|
||||||
|
name='time_per_question',
|
||||||
|
field=models.CharField(choices=[('10', 10), ('15', 15), ('30', 30), ('60', 60), ('90', 90), ('120', 120), ('180', 180)], default=30, help_text='Zeit pro Frage in Sekunden', max_length=13),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
django/library/migrations/0034_alter_qivipquiz_status.py
Normal file
18
django/library/migrations/0034_alter_qivipquiz_status.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-10 14:04
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0033_remove_qivipquiz_tags_delete_tag'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='status',
|
||||||
|
field=models.CharField(choices=[('öffentlich', 'Öffentlich'), ('privat', 'Privat')], default='öffentlich', max_length=10),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-08 14:21
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0034_alter_qivipquestion_time_per_question'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquestion',
|
||||||
|
name='time_per_question',
|
||||||
|
field=models.CharField(choices=[('10', 10), ('15', 15), ('30', 30), ('60', 60), ('90', 90), ('120', 120), ('180', 180)], default=30, help_text='Zeit pro Frage in Sekunden', max_length=3),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
django/library/migrations/0035_qivipquiz_favorite.py
Normal file
18
django/library/migrations/0035_qivipquiz_favorite.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-10 14:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0034_alter_qivipquiz_status'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='favorite',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-10 16:02
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0035_qivipquiz_favorite'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='favorite',
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='QuizFavorite',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('favorite', models.BooleanField(default=False)),
|
||||||
|
('quiz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='library.qivipquiz')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'unique_together': {('user', 'quiz')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-10 16:05
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0036_remove_qivipquiz_favorite_quizfavorite'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name='QuizFavorite',
|
||||||
|
new_name='QivipQuizFavorite',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-10 17:08
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0037_rename_quizfavorite_qivipquizfavorite'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquizfavorite',
|
||||||
|
name='quiz',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='favorites', to='library.qivipquiz'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-11 12:40
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0038_alter_qivipquizfavorite_quiz'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='qivipquizfavorite',
|
||||||
|
name='favorite_date',
|
||||||
|
field=models.DateTimeField(auto_now=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.1.7 on 2025-04-11 13:15
|
||||||
|
|
||||||
|
import library.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('library', '0039_qivipquizfavorite_favorite_date'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qivipquiz',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(default='In dem Quiz geht es um ...', max_length=200, validators=[library.models.QivipQuiz.validate_description], verbose_name='Beschreibung'),
|
||||||
|
),
|
||||||
|
]
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user