Compare commits
2 Commits
116-react-
...
44-zurueck
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dc30f9cbc | ||
|
|
3df748dc96 |
29
README.md
29
README.md
@@ -7,7 +7,6 @@
|
|||||||
3. [Superuser erstellen](#superuser-erstellen)
|
3. [Superuser erstellen](#superuser-erstellen)
|
||||||
4. [Tailwind-Nutzung](#tailwind-nutzung)
|
4. [Tailwind-Nutzung](#tailwind-nutzung)
|
||||||
5. [Issue - Merge Request - Merge](#issue-mergerequest-merge)
|
5. [Issue - Merge Request - Merge](#issue-mergerequest-merge)
|
||||||
6. [Konfiguration](#konfiguration)
|
|
||||||
|
|
||||||
## Initialisierung des Projekts
|
## Initialisierung des Projekts
|
||||||
|
|
||||||
@@ -62,13 +61,6 @@ Für die Entwicklung mit WebSocket-Unterstützung verwenden wir Daphne:
|
|||||||
daphne -b 127.0.0.1 -p 8000 core.asgi:application
|
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:
|
Alternativ kannst du den Django-Entwicklungsserver verwenden, wenn du keine WebSocket-Funktionalität benötigst:
|
||||||
```sh
|
```sh
|
||||||
python3 core/manage.py runserver
|
python3 core/manage.py runserver
|
||||||
@@ -92,19 +84,6 @@ Für den Produktivbetrieb verwenden wir Daphne als ASGI-Server, der sowohl HTTP
|
|||||||
- `-b 0.0.0.0`: Bindet den Server an alle Netzwerk-Interfaces
|
- `-b 0.0.0.0`: Bindet den Server an alle Netzwerk-Interfaces
|
||||||
- `-p 8000`: Port (anpassbar)
|
- `-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!
|
||||||
|
|
||||||
## Superuser erstellen
|
## Superuser erstellen
|
||||||
@@ -162,11 +141,3 @@ Hier der vereinbarte Arbeitsablauf:
|
|||||||
2. Merge Request anlegen - dadurch wird der Branch 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.
|
||||||
|
|
||||||
## Konfiguration
|
|
||||||
|
|
||||||
Die Konfiguration des Projekts befindet sich im `config/qivip_config.json`.
|
|
||||||
|
|
||||||
| Variable | Bedeutung | Optionen |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| ENABLE_RATING_SYSTEM | Soll das Bewertungssystem aktiviert werden? | true [Standard], false |
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"ENABLE_RATING_SYSTEM": true
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ For the full list of settings and their values, see
|
|||||||
https://docs.djangoproject.com/en/5.1/ref/settings/
|
https://docs.djangoproject.com/en/5.1/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
@@ -28,9 +27,6 @@ DEBUG = True
|
|||||||
|
|
||||||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '*']
|
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '*']
|
||||||
|
|
||||||
# Konfigurationsdatei für Projekt
|
|
||||||
with open(BASE_DIR / 'config' / 'qivip_config.json') as config_file:
|
|
||||||
QIVIP_CONFIG = json.load(config_file)
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
@@ -83,16 +79,12 @@ WSGI_APPLICATION = 'core.wsgi.application'
|
|||||||
ASGI_APPLICATION = 'core.asgi.application'
|
ASGI_APPLICATION = 'core.asgi.application'
|
||||||
|
|
||||||
CHANNEL_LAYERS = {
|
CHANNEL_LAYERS = {
|
||||||
"default": {
|
'default': {
|
||||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
'BACKEND': 'channels.layers.InMemoryChannelLayer'
|
||||||
"CONFIG": {
|
}
|
||||||
"hosts": [("127.0.0.1", 6379)],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import QivipQuiz, QivipQuestion, QivipQuizFavorite, QuestionImage, QuizCategory, QuizImage
|
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):
|
||||||
@@ -23,17 +23,8 @@ class QuizCategoryAdmin(admin.ModelAdmin):
|
|||||||
class QivipQuizFavoriteAdmin(admin.ModelAdmin):
|
class QivipQuizFavoriteAdmin(admin.ModelAdmin):
|
||||||
list_display = ('user', 'favorite', 'quiz') # Welche Felder sollen in der Übersicht angezeigt werden
|
list_display = ('user', 'favorite', 'quiz') # Welche Felder sollen in der Übersicht angezeigt werden
|
||||||
|
|
||||||
|
|
||||||
class QuizImageAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('image',)
|
|
||||||
|
|
||||||
class QuestionImageAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('image',)
|
|
||||||
|
|
||||||
# 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(QivipQuizFavorite, QivipQuizFavoriteAdmin)
|
admin.site.register(QivipQuizFavorite, QivipQuizFavoriteAdmin)
|
||||||
admin.site.register(QuizImage, QuizImageAdmin)
|
|
||||||
admin.site.register(QuestionImage, QuestionImageAdmin)
|
|
||||||
@@ -4,7 +4,7 @@ from .models import QivipQuiz, QivipQuestion
|
|||||||
class QuizForm(forms.ModelForm):
|
class QuizForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = QivipQuiz
|
model = QivipQuiz
|
||||||
fields = ['name', 'description', 'status', 'category','difficulty','credits']
|
fields = ['name', 'description','image', 'status', 'category','difficulty','credits']
|
||||||
|
|
||||||
class QuestionForm(forms.ModelForm):
|
class QuestionForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
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.')
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# Generated by Django 5.1.7 on 2025-04-22 16:04
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('library', '0049_alter_qivipquestion_image'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='QuestionImage',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('image', models.ImageField(blank=True, null=True, upload_to='question_images/', verbose_name='Bild')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='QuizImage',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('image', models.ImageField(blank=True, max_length=256, null=True, upload_to='quiz_images/', verbose_name='Bild')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquestion',
|
|
||||||
name='image',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='questions', to='library.questionimage'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquiz',
|
|
||||||
name='image',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='quizzes', to='library.QuizImage'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
# Generated by Django 5.1.7 on 2025-04-23 12:04
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('library', '0050_questionimage_quizimages_alter_qivipquestion_image_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquestion',
|
|
||||||
name='image',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='library.questionimage'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquiz',
|
|
||||||
name='image',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='quizzes', to='library.quizimage'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Generated by Django 5.1.7 on 2025-04-23 12:21
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('library', '0051_alter_qivipquestion_image_alter_qivipquiz_image'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquestion',
|
|
||||||
name='image',
|
|
||||||
field=models.ImageField(blank=True, null=True, upload_to='question_images/', verbose_name='Bild'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquiz',
|
|
||||||
name='image',
|
|
||||||
field=models.ImageField(blank=True, max_length=256, null=True, upload_to='quiz_images/', verbose_name='Bild'),
|
|
||||||
),
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='QuestionImage',
|
|
||||||
),
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='QuizImage',
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# Generated by Django 5.1.7 on 2025-04-23 13:15
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('library', '0052_alter_qivipquestion_image_alter_qivipquiz_image_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='QuestionImage',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('image', models.ImageField(blank=True, null=True, upload_to='question_images/', verbose_name='Bild')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='QuizImage',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('image', models.ImageField(blank=True, max_length=256, null=True, upload_to='quiz_images/', verbose_name='Bild')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquestion',
|
|
||||||
name='image',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='questions', to='library.questionimage'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='qivipquiz',
|
|
||||||
name='image',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='quizzes', to='library.quizimage'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -4,15 +4,6 @@ from django.utils.text import slugify
|
|||||||
import uuid
|
import uuid
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class QuizImage(models.Model):
|
|
||||||
image = models.ImageField(max_length=256,verbose_name="Bild", upload_to='quiz_images/', blank=True, null=True) # Bild speichern in media/quiz_images/
|
|
||||||
|
|
||||||
|
|
||||||
class QuestionImage(models.Model):
|
|
||||||
image = models.ImageField(verbose_name="Bild", upload_to="question_images/", blank=True, null=True)
|
|
||||||
|
|
||||||
|
|
||||||
class QivipQuiz(models.Model):
|
class QivipQuiz(models.Model):
|
||||||
STATUS_VALUES = {
|
STATUS_VALUES = {
|
||||||
"öffentlich": "Öffentlich",
|
"öffentlich": "Öffentlich",
|
||||||
@@ -36,15 +27,7 @@ class QivipQuiz(models.Model):
|
|||||||
if value.strip() == "In dem Quiz geht es um ...":
|
if value.strip() == "In dem Quiz geht es um ...":
|
||||||
raise ValidationError("Bitte gib eine aussagekräftige Beschreibung ein.")
|
raise ValidationError("Bitte gib eine aussagekräftige Beschreibung ein.")
|
||||||
|
|
||||||
image = models.ForeignKey(
|
image = models.ImageField(max_length=256,verbose_name="Bild", upload_to='quiz_images/', blank=True, null=True) # Bild speichern in media/quiz_images/
|
||||||
QuizImage,
|
|
||||||
null=True,
|
|
||||||
blank=True,
|
|
||||||
on_delete=models.PROTECT,
|
|
||||||
related_name="quizzes"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||||
user_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name='quiz')
|
user_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name='quiz')
|
||||||
#creator = models.ForeignKey(User, on_delete=models.SET_NULL,blank=True, null=True, related_name='creator_quiz')
|
#creator = models.ForeignKey(User, on_delete=models.SET_NULL,blank=True, null=True, related_name='creator_quiz')
|
||||||
@@ -91,14 +74,7 @@ class QivipQuestion(models.Model):
|
|||||||
update_date = models.DateTimeField(auto_now=True)
|
update_date = models.DateTimeField(auto_now=True)
|
||||||
data = models.TextField()
|
data = models.TextField()
|
||||||
time_per_question = models.CharField(max_length=3, choices=list(TIME_VALUES.items()), default=30, help_text="Zeit pro Frage in Sekunden")
|
time_per_question = models.CharField(max_length=3, choices=list(TIME_VALUES.items()), default=30, help_text="Zeit pro Frage in Sekunden")
|
||||||
image = models.ForeignKey(
|
image = models.ImageField(verbose_name="Bild", upload_to="question_images/", blank=True, null=True)
|
||||||
QuestionImage,
|
|
||||||
null=True,
|
|
||||||
blank=True,
|
|
||||||
on_delete=models.PROTECT,
|
|
||||||
related_name="questions"
|
|
||||||
)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.data[:50]
|
return self.data[:50]
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from .models import QivipQuiz, QivipQuestion, QivipQuizFavorite, QuestionImage, QuizImage
|
from .models import QivipQuiz, QivipQuestion, QivipQuizFavorite
|
||||||
from .forms import QuizForm, QuestionForm
|
from .forms import QuizForm, QuestionForm
|
||||||
import json
|
import json
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
@@ -173,6 +173,9 @@ def favorite_quiz(request, pk):
|
|||||||
|
|
||||||
if favorite.favorite==True:
|
if favorite.favorite==True:
|
||||||
favorite.favorite_date = timezone.now()
|
favorite.favorite_date = timezone.now()
|
||||||
|
|
||||||
|
statement="Das Quiz '"+ favorite.quiz.name+ "' wurde erfolgreich zu den Favoriten hinzugefügt!"
|
||||||
|
messages.success(request,statement )
|
||||||
favorite.save()
|
favorite.save()
|
||||||
else:
|
else:
|
||||||
favorite.favorite_date = None
|
favorite.favorite_date = None
|
||||||
@@ -182,32 +185,18 @@ def favorite_quiz(request, pk):
|
|||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
favorite=QivipQuizFavorite.objects.create(user=request.user, quiz=quiz, favorite=True, favorite_date=timezone.now())
|
QivipQuizFavorite.objects.create(user=request.user, quiz=quiz, favorite=True, favorite_date=timezone.now())
|
||||||
statement="Das Quiz '"+ favorite.quiz.name+ "' wurde erfolgreich zu den Favoriten hinzugefügt!"
|
|
||||||
messages.success(request,statement )
|
|
||||||
return redirect(request.META.get('HTTP_REFERER', 'library:overview_quiz'))
|
return redirect(request.META.get('HTTP_REFERER', 'library:overview_quiz'))
|
||||||
|
|
||||||
|
|
||||||
# Neues Quiz erstellen
|
# Neues Quiz erstellen
|
||||||
@login_required
|
@login_required
|
||||||
def new_quiz(request):
|
def new_quiz(request):
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
||||||
|
|
||||||
form = QuizForm(request.POST, request.FILES)
|
form = QuizForm(request.POST, request.FILES)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
quiz = form.save(commit=False)
|
quiz = form.save(commit=False)
|
||||||
try:
|
|
||||||
quiz_image=request.FILES['quiz_image']
|
|
||||||
imagequiz=QuizImage.objects.create(image=quiz_image)
|
|
||||||
quiz.image=imagequiz
|
|
||||||
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
quiz.user_id = request.user
|
quiz.user_id = request.user
|
||||||
#quiz.creator = request.user
|
#quiz.creator = request.user
|
||||||
quiz.save()
|
quiz.save()
|
||||||
@@ -226,27 +215,7 @@ def edit_quiz(request, pk):
|
|||||||
form = QuizForm(request.POST, instance=quiz, files=request.FILES)
|
form = QuizForm(request.POST, instance=quiz, files=request.FILES)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
|
||||||
if 'reset_image' in request.POST:
|
|
||||||
quiz.image = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
quiz_image=request.FILES['quiz_image']
|
|
||||||
imagequiz=QuizImage.objects.create(image=quiz_image)
|
|
||||||
quiz.image=imagequiz
|
|
||||||
|
|
||||||
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
form.save()
|
form.save()
|
||||||
for img in QuizImage.objects.all():
|
|
||||||
try:
|
|
||||||
img.delete()
|
|
||||||
img.image.delete(save=False)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return redirect('library:detail_quiz', pk=pk)
|
return redirect('library:detail_quiz', pk=pk)
|
||||||
#return modified(request, pk)
|
#return modified(request, pk)
|
||||||
|
|
||||||
@@ -260,19 +229,6 @@ def delete_quiz(request, pk):
|
|||||||
quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
quiz.delete()
|
quiz.delete()
|
||||||
for img in QuizImage.objects.all():
|
|
||||||
try:
|
|
||||||
img.delete()
|
|
||||||
img.image.delete(save=False)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for img in QuestionImage.objects.all():
|
|
||||||
try:
|
|
||||||
img.delete()
|
|
||||||
img.image.delete(save=False)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return redirect('library:overview_quiz')
|
return redirect('library:overview_quiz')
|
||||||
return render(request, 'library/delete_confirmation.html', {'object': quiz})
|
return render(request, 'library/delete_confirmation.html', {'object': quiz})
|
||||||
|
|
||||||
@@ -300,7 +256,6 @@ def copy_quiz(request, pk):
|
|||||||
original_quiz = get_object_or_404(QivipQuiz, pk=pk)
|
original_quiz = get_object_or_404(QivipQuiz, pk=pk)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Quiz kopieren (ohne ID, damit ein neues Objekt erstellt wird)
|
# Quiz kopieren (ohne ID, damit ein neues Objekt erstellt wird)
|
||||||
|
|
||||||
# Quiz kopieren (ohne ID, damit ein neues Objekt erstellt wird)
|
# Quiz kopieren (ohne ID, damit ein neues Objekt erstellt wird)
|
||||||
@@ -309,10 +264,9 @@ def copy_quiz(request, pk):
|
|||||||
new_quiz.pk = None # Setzt die ID auf None, damit Django es als neues Objekt erkennt
|
new_quiz.pk = None # Setzt die ID auf None, damit Django es als neues Objekt erkennt
|
||||||
new_quiz.uuid = uuid.uuid4() # Neue UUID generieren
|
new_quiz.uuid = uuid.uuid4() # Neue UUID generieren
|
||||||
new_quiz.user_id = request.user # Neuer Besitzer ist der aktuelle User
|
new_quiz.user_id = request.user # Neuer Besitzer ist der aktuelle User
|
||||||
new_quiz.name += " - Kopie"
|
new_quiz.name += " - Kopie" # Optional: Name anpassen
|
||||||
new_quiz.base_quiz_id = pk
|
new_quiz.base_quiz_id = pk
|
||||||
new_quiz.rating_count = 0
|
#new_quiz.creator = original_quiz.creator or request.user
|
||||||
new_quiz.average_rating = 3.0
|
|
||||||
new_quiz.save() # Speichern als neues Objekt
|
new_quiz.save() # Speichern als neues Objekt
|
||||||
# Optional: Beschreibung anpassen
|
# Optional: Beschreibung anpassen
|
||||||
# Alle zugehörigen Fragen kopieren
|
# Alle zugehörigen Fragen kopieren
|
||||||
@@ -322,7 +276,6 @@ def copy_quiz(request, pk):
|
|||||||
question.pk = None # Setze pk auf None, damit es als neues Objekt gespeichert wird
|
question.pk = None # Setze pk auf None, damit es als neues Objekt gespeichert wird
|
||||||
question.quiz_id = original_quiz # Verknüpfe mit dem neuen Quiz
|
question.quiz_id = original_quiz # Verknüpfe mit dem neuen Quiz
|
||||||
question.data = question.data # `data`-Feld wird explizit übernommen # Verknüpfe mit dem neuen Quiz
|
question.data = question.data # `data`-Feld wird explizit übernommen # Verknüpfe mit dem neuen Quiz
|
||||||
|
|
||||||
question.save()
|
question.save()
|
||||||
|
|
||||||
messages.success(request, "Quiz wurde erfolgreich kopiert!")
|
messages.success(request, "Quiz wurde erfolgreich kopiert!")
|
||||||
@@ -357,12 +310,13 @@ def new_question(request):
|
|||||||
messages.error(request, 'Quiz nicht gefunden oder keine Berechtigung.')
|
messages.error(request, 'Quiz nicht gefunden oder keine Berechtigung.')
|
||||||
return redirect('library:overview_quiz')
|
return redirect('library:overview_quiz')
|
||||||
|
|
||||||
if question_type not in ['multiple_choice', 'true_false','input']:
|
if question_type not in ['multiple_choice', 'true_false']:
|
||||||
base_url = reverse('library:new_question')
|
base_url = reverse('library:new_question')
|
||||||
return redirect(f'{base_url}?type=multiple_choice&quiz_id={quiz_id}')
|
return redirect(f'{base_url}?type=multiple_choice&quiz_id={quiz_id}')
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
question_text = request.POST.get('question', '')
|
question_text = request.POST.get('question', '')
|
||||||
|
question_image = request.FILES.get('question_image', None)
|
||||||
|
|
||||||
# Handle different question types
|
# Handle different question types
|
||||||
if question_type == 'true_false':
|
if question_type == 'true_false':
|
||||||
@@ -375,17 +329,6 @@ def new_question(request):
|
|||||||
{'value': 'Falsch', 'is_correct': not correct_answer}
|
{'value': 'Falsch', 'is_correct': not correct_answer}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
elif question_type == 'input':
|
|
||||||
correct_answer = request.POST.get('correct_answer')
|
|
||||||
json_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': question_text,
|
|
||||||
'options': [
|
|
||||||
{'value': correct_answer, 'is_correct': True}
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
elif question_type == 'multiple_choice':
|
elif question_type == 'multiple_choice':
|
||||||
options = []
|
options = []
|
||||||
i = 1
|
i = 1
|
||||||
@@ -413,14 +356,7 @@ def new_question(request):
|
|||||||
question = QivipQuestion()
|
question = QivipQuestion()
|
||||||
question.data = json.dumps(json_data)
|
question.data = json.dumps(json_data)
|
||||||
question.quiz_id = quiz
|
question.quiz_id = quiz
|
||||||
try:
|
question.image = question_image
|
||||||
question_image=request.FILES['question_image']
|
|
||||||
imagequestion=QuestionImage.objects.create(image=question_image)
|
|
||||||
question.image=imagequestion
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
question.time_per_question = request.POST.get('time_per_question', '30')
|
question.time_per_question = request.POST.get('time_per_question', '30')
|
||||||
question.save()
|
question.save()
|
||||||
#return modified(request, pk=quiz.pk)
|
#return modified(request, pk=quiz.pk)
|
||||||
@@ -437,18 +373,6 @@ def new_question(request):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
standard_time_per_question = 30
|
standard_time_per_question = 30
|
||||||
|
|
||||||
elif question_type == 'input':
|
|
||||||
question_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': '',
|
|
||||||
'options': [
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
standard_time_per_question = 30
|
|
||||||
|
|
||||||
elif question_type == 'multiple_choice':
|
elif question_type == 'multiple_choice':
|
||||||
question_data = {
|
question_data = {
|
||||||
'type': question_type,
|
'type': question_type,
|
||||||
@@ -474,8 +398,6 @@ def new_question(request):
|
|||||||
@login_required
|
@login_required
|
||||||
def edit_question(request, pk):
|
def edit_question(request, pk):
|
||||||
question = get_object_or_404(QivipQuestion, pk=pk, quiz_id__user_id=request.user)
|
question = get_object_or_404(QivipQuestion, pk=pk, quiz_id__user_id=request.user)
|
||||||
if 'reset_ques_image' in request.POST:
|
|
||||||
question.image = None
|
|
||||||
if question.quiz_id.user_id != request.user:
|
if question.quiz_id.user_id != request.user:
|
||||||
return redirect('library:question_list')
|
return redirect('library:question_list')
|
||||||
|
|
||||||
@@ -529,9 +451,7 @@ def edit_question(request, pk):
|
|||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
question_text = request.POST.get('question', '')
|
question_text = request.POST.get('question', '')
|
||||||
try:
|
try:
|
||||||
question_image=request.FILES['question_image']
|
question_image = request.FILES['question_image']
|
||||||
imagequestion=QuestionImage.objects.create(image=question_image)
|
|
||||||
question.image=imagequestion
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -546,17 +466,6 @@ def edit_question(request, pk):
|
|||||||
{'value': 'Falsch', 'is_correct': not correct_answer}
|
{'value': 'Falsch', 'is_correct': not correct_answer}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
elif question_type == 'input':
|
|
||||||
correct_answer = request.POST.get('correct_answer')
|
|
||||||
json_data = {
|
|
||||||
'type': question_type,
|
|
||||||
'question': question_text,
|
|
||||||
'options': [
|
|
||||||
{'value': correct_answer,'is_correct':True}
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
elif question_type == 'multiple_choice':
|
elif question_type == 'multiple_choice':
|
||||||
options = []
|
options = []
|
||||||
i = 1
|
i = 1
|
||||||
@@ -587,15 +496,8 @@ def edit_question(request, pk):
|
|||||||
|
|
||||||
question.data = json.dumps(json_data)
|
question.data = json.dumps(json_data)
|
||||||
question.time_per_question = request.POST.get('time_per_question', '30')
|
question.time_per_question = request.POST.get('time_per_question', '30')
|
||||||
|
question.image = question_image
|
||||||
|
|
||||||
question.save()
|
question.save()
|
||||||
for img in QuestionImage.objects.all():
|
|
||||||
try:
|
|
||||||
img.delete()
|
|
||||||
img.image.delete(save=False)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
#return modified(request, question.quiz_id.pk)
|
#return modified(request, question.quiz_id.pk)
|
||||||
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
||||||
|
|
||||||
@@ -623,11 +525,5 @@ def delete_question(request, pk):
|
|||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
question.delete()
|
question.delete()
|
||||||
for img in QuestionImage.objects.all():
|
|
||||||
try:
|
|
||||||
img.delete()
|
|
||||||
img.image.delete(save=False)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
||||||
return render(request, 'library/delete_confirmation.html', {'object': question})
|
return render(request, 'library/delete_confirmation.html', {'object': question})
|
||||||
|
|||||||
903
django/package-lock.json
generated
903
django/package-lock.json
generated
@@ -9,884 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/cli": "^4.1.5",
|
"swiper": "^11.2.6"
|
||||||
"swiper": "^11.2.6",
|
|
||||||
"tailwindcss": "^4.1.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"dependencies": {
|
|
||||||
"detect-libc": "^1.0.3",
|
|
||||||
"is-glob": "^4.0.3",
|
|
||||||
"micromatch": "^4.0.5",
|
|
||||||
"node-addon-api": "^7.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"@parcel/watcher-android-arm64": "2.5.1",
|
|
||||||
"@parcel/watcher-darwin-arm64": "2.5.1",
|
|
||||||
"@parcel/watcher-darwin-x64": "2.5.1",
|
|
||||||
"@parcel/watcher-freebsd-x64": "2.5.1",
|
|
||||||
"@parcel/watcher-linux-arm-glibc": "2.5.1",
|
|
||||||
"@parcel/watcher-linux-arm-musl": "2.5.1",
|
|
||||||
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
|
|
||||||
"@parcel/watcher-linux-arm64-musl": "2.5.1",
|
|
||||||
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
|
||||||
"@parcel/watcher-linux-x64-musl": "2.5.1",
|
|
||||||
"@parcel/watcher-win32-arm64": "2.5.1",
|
|
||||||
"@parcel/watcher-win32-ia32": "2.5.1",
|
|
||||||
"@parcel/watcher-win32-x64": "2.5.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-android-arm64": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"android"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-darwin-arm64": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-darwin-x64": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-freebsd-x64": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"freebsd"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-linux-arm-glibc": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-linux-arm-musl": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==",
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-linux-arm64-glibc": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-linux-arm64-musl": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-linux-x64-glibc": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-linux-x64-musl": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-win32-arm64": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-win32-ia32": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==",
|
|
||||||
"cpu": [
|
|
||||||
"ia32"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@parcel/watcher-win32-x64": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/cli": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/cli/-/cli-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-Kr567rDwDjY1VUnfqh5/+DCpRf4B8lPs5O9flP4kri7n4AM2aubrIxGSh5GN8s+awUKw/U4+6kNlEnZbBNfUeg==",
|
|
||||||
"dependencies": {
|
|
||||||
"@parcel/watcher": "^2.5.1",
|
|
||||||
"@tailwindcss/node": "4.1.5",
|
|
||||||
"@tailwindcss/oxide": "4.1.5",
|
|
||||||
"enhanced-resolve": "^5.18.1",
|
|
||||||
"mri": "^1.2.0",
|
|
||||||
"picocolors": "^1.1.1",
|
|
||||||
"tailwindcss": "4.1.5"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"tailwindcss": "dist/index.mjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/node": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-CBhSWo0vLnWhXIvpD0qsPephiaUYfHUX3U9anwDaHZAeuGpTiB3XmsxPAN6qX7bFhipyGBqOa1QYQVVhkOUGxg==",
|
|
||||||
"dependencies": {
|
|
||||||
"enhanced-resolve": "^5.18.1",
|
|
||||||
"jiti": "^2.4.2",
|
|
||||||
"lightningcss": "1.29.2",
|
|
||||||
"tailwindcss": "4.1.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-1n4br1znquEvyW/QuqMKQZlBen+jxAbvyduU87RS8R3tUSvByAkcaMTkJepNIrTlYhD+U25K4iiCIxE6BGdRYA==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"@tailwindcss/oxide-android-arm64": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-darwin-arm64": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-darwin-x64": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-freebsd-x64": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-linux-arm64-gnu": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-linux-arm64-musl": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-linux-x64-gnu": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-linux-x64-musl": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-wasm32-wasi": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-win32-arm64-msvc": "4.1.5",
|
|
||||||
"@tailwindcss/oxide-win32-x64-msvc": "4.1.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-android-arm64": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-LVvM0GirXHED02j7hSECm8l9GGJ1RfgpWCW+DRn5TvSaxVsv28gRtoL4aWKGnXqwvI3zu1GABeDNDVZeDPOQrw==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"android"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-darwin-arm64": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-//TfCA3pNrgnw4rRJOqavW7XUk8gsg9ddi8cwcsWXp99tzdBAZW0WXrD8wDyNbqjW316Pk2hiN/NJx/KWHl8oA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-darwin-x64": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-XQorp3Q6/WzRd9OalgHgaqgEbjP3qjHrlSUb5k1EuS1Z9NE9+BbzSORraO+ecW432cbCN7RVGGL/lSnHxcd+7Q==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-freebsd-x64": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-bPrLWbxo8gAo97ZmrCbOdtlz/Dkuy8NK97aFbVpkJ2nJ2Jo/rsCbu0TlGx8joCuA3q6vMWTSn01JY46iwG+clg==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"freebsd"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-1gtQJY9JzMAhgAfvd/ZaVOjh/Ju/nCoAsvOVJenWZfs05wb8zq+GOTnZALWGqKIYEtyNpCzvMk+ocGpxwdvaVg==",
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-linux-arm64-gnu": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-dtlaHU2v7MtdxBXoqhxwsWjav7oim7Whc6S9wq/i/uUMTWAzq/gijq1InSgn2yTnh43kR+SFvcSyEF0GCNu1PQ==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-linux-arm64-musl": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-fg0F6nAeYcJ3CriqDT1iVrqALMwD37+sLzXs8Rjy8Z1ZHshJoYceodfyUwGJEsQoTyWbliFNRs2wMQNXtT7MVA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-linux-x64-gnu": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-SO+F2YEIAHa1AITwc8oPwMOWhgorPzzcbhWEb+4oLi953h45FklDmM8dPSZ7hNHpIk9p/SCZKUYn35t5fjGtHA==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-linux-x64-musl": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-6UbBBplywkk/R+PqqioskUeXfKcBht3KU7juTi1UszJLx0KPXUo10v2Ok04iBJIaDPkIFkUOVboXms5Yxvaz+g==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-wasm32-wasi": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-hwALf2K9FHuiXTPqmo1KeOb83fTRNbe9r/Ixv9ZNQ/R24yw8Ge1HOWDDgTdtzntIaIUJG5dfXCf4g9AD4RiyhQ==",
|
|
||||||
"bundleDependencies": [
|
|
||||||
"@napi-rs/wasm-runtime",
|
|
||||||
"@emnapi/core",
|
|
||||||
"@emnapi/runtime",
|
|
||||||
"@tybys/wasm-util",
|
|
||||||
"@emnapi/wasi-threads",
|
|
||||||
"tslib"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"wasm32"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@emnapi/core": "^1.4.3",
|
|
||||||
"@emnapi/runtime": "^1.4.3",
|
|
||||||
"@emnapi/wasi-threads": "^1.0.2",
|
|
||||||
"@napi-rs/wasm-runtime": "^0.2.9",
|
|
||||||
"@tybys/wasm-util": "^0.9.0",
|
|
||||||
"tslib": "^2.8.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=14.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-oDKncffWzaovJbkuR7/OTNFRJQVdiw/n8HnzaCItrNQUeQgjy7oUiYpsm9HUBgpmvmDpSSbGaCa2Evzvk3eFmA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/oxide-win32-x64-msvc": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-WiR4dtyrFdbb+ov0LK+7XsFOsG+0xs0PKZKkt41KDn9jYpO7baE3bXiudPVkTqUEwNfiglCygQHl2jklvSBi7Q==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/braces": {
|
|
||||||
"version": "3.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
|
||||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
|
||||||
"dependencies": {
|
|
||||||
"fill-range": "^7.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/detect-libc": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==",
|
|
||||||
"bin": {
|
|
||||||
"detect-libc": "bin/detect-libc.js"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/enhanced-resolve": {
|
|
||||||
"version": "5.18.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.1.tgz",
|
|
||||||
"integrity": "sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg==",
|
|
||||||
"dependencies": {
|
|
||||||
"graceful-fs": "^4.2.4",
|
|
||||||
"tapable": "^2.2.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.13.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/fill-range": {
|
|
||||||
"version": "7.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
|
||||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
|
||||||
"dependencies": {
|
|
||||||
"to-regex-range": "^5.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/graceful-fs": {
|
|
||||||
"version": "4.2.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
|
||||||
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
|
|
||||||
},
|
|
||||||
"node_modules/is-extglob": {
|
|
||||||
"version": "2.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
|
||||||
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-glob": {
|
|
||||||
"version": "4.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
|
||||||
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
|
||||||
"dependencies": {
|
|
||||||
"is-extglob": "^2.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-number": {
|
|
||||||
"version": "7.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
|
||||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.12.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/jiti": {
|
|
||||||
"version": "2.4.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz",
|
|
||||||
"integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==",
|
|
||||||
"bin": {
|
|
||||||
"jiti": "lib/jiti-cli.mjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-6b6gd/RUXKaw5keVdSEtqFVdzWnU5jMxTUjA2bVcMNPLwSQ08Sv/UodBVtETLCn7k4S1Ibxwh7k68IwLZPgKaA==",
|
|
||||||
"dependencies": {
|
|
||||||
"detect-libc": "^2.0.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"lightningcss-darwin-arm64": "1.29.2",
|
|
||||||
"lightningcss-darwin-x64": "1.29.2",
|
|
||||||
"lightningcss-freebsd-x64": "1.29.2",
|
|
||||||
"lightningcss-linux-arm-gnueabihf": "1.29.2",
|
|
||||||
"lightningcss-linux-arm64-gnu": "1.29.2",
|
|
||||||
"lightningcss-linux-arm64-musl": "1.29.2",
|
|
||||||
"lightningcss-linux-x64-gnu": "1.29.2",
|
|
||||||
"lightningcss-linux-x64-musl": "1.29.2",
|
|
||||||
"lightningcss-win32-arm64-msvc": "1.29.2",
|
|
||||||
"lightningcss-win32-x64-msvc": "1.29.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-darwin-arm64": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-cK/eMabSViKn/PG8U/a7aCorpeKLMlK0bQeNHmdb7qUnBkNPnL+oV5DjJUo0kqWsJUapZsM4jCfYItbqBDvlcA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-darwin-x64": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-j5qYxamyQw4kDXX5hnnCKMf3mLlHvG44f24Qyi2965/Ycz829MYqjrVg2H8BidybHBp9kom4D7DR5VqCKDXS0w==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-freebsd-x64": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-wDk7M2tM78Ii8ek9YjnY8MjV5f5JN2qNVO+/0BAGZRvXKtQrBC4/cn4ssQIpKIPP44YXw6gFdpUF+Ps+RGsCwg==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"freebsd"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-linux-arm-gnueabihf": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-IRUrOrAF2Z+KExdExe3Rz7NSTuuJ2HvCGlMKoquK5pjvo2JY4Rybr+NrKnq0U0hZnx5AnGsuFHjGnNT14w26sg==",
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-linux-arm64-gnu": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-KKCpOlmhdjvUTX/mBuaKemp0oeDIBBLFiU5Fnqxh1/DZ4JPZi4evEH7TKoSBFOSOV3J7iEmmBaw/8dpiUvRKlQ==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-linux-arm64-musl": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-Q64eM1bPlOOUgxFmoPUefqzY1yV3ctFPE6d/Vt7WzLW4rKTv7MyYNky+FWxRpLkNASTnKQUaiMJ87zNODIrrKQ==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-linux-x64-gnu": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-0v6idDCPG6epLXtBH/RPkHvYx74CVziHo6TMYga8O2EiQApnUPZsbR9nFNrg2cgBzk1AYqEd95TlrsL7nYABQg==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-linux-x64-musl": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-rMpz2yawkgGT8RULc5S4WiZopVMOFWjiItBT7aSfDX4NQav6M44rhn5hjtkKzB+wMTRlLLqxkeYEtQ3dd9696w==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-win32-arm64-msvc": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-nL7zRW6evGQqYVu/bKGK+zShyz8OVzsCotFgc7judbt6wnB2KbiKKJwBE4SGoDBQ1O94RjW4asrCjQL4i8Fhbw==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss-win32-x64-msvc": {
|
|
||||||
"version": "1.29.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.29.2.tgz",
|
|
||||||
"integrity": "sha512-EdIUW3B2vLuHmv7urfzMI/h2fmlnOQBk1xlsDxkN1tCWKjNFjfLhGxYk8C8mzpSfr+A6jFFIi8fU6LbQGsRWjA==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/parcel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lightningcss/node_modules/detect-libc": {
|
|
||||||
"version": "2.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
|
|
||||||
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/micromatch": {
|
|
||||||
"version": "4.0.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
|
||||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
|
||||||
"dependencies": {
|
|
||||||
"braces": "^3.0.3",
|
|
||||||
"picomatch": "^2.3.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mri": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/node-addon-api": {
|
|
||||||
"version": "7.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
|
|
||||||
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ=="
|
|
||||||
},
|
|
||||||
"node_modules/picocolors": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
|
|
||||||
},
|
|
||||||
"node_modules/picomatch": {
|
|
||||||
"version": "2.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
|
||||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.6"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/swiper": {
|
"node_modules/swiper": {
|
||||||
@@ -907,30 +30,6 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 4.7.0"
|
"node": ">= 4.7.0"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"node_modules/tailwindcss": {
|
|
||||||
"version": "4.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.5.tgz",
|
|
||||||
"integrity": "sha512-nYtSPfWGDiWgCkwQG/m+aX83XCwf62sBgg3bIlNiiOcggnS1x3uVRDAuyelBFL+vJdOPPCGElxv9DjHJjRHiVA=="
|
|
||||||
},
|
|
||||||
"node_modules/tapable": {
|
|
||||||
"version": "2.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
|
|
||||||
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/to-regex-range": {
|
|
||||||
"version": "5.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
|
||||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"is-number": "^7.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/cli": "^4.1.5",
|
"swiper": "^11.2.6"
|
||||||
"swiper": "^11.2.6",
|
|
||||||
"tailwindcss": "^4.1.5"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,80 @@ from channels.generic.websocket import AsyncWebsocketConsumer
|
|||||||
from channels.db import database_sync_to_async
|
from channels.db import database_sync_to_async
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.db import models
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from play.models import QuizGame, QuizGameParticipant, QuizAnswer
|
from play.models import QuizGame, QuizGameParticipant, QuizAnswer
|
||||||
from django.conf import settings
|
|
||||||
|
# Dictionary to track inactive check tasks per game
|
||||||
|
game_check_tasks = {}
|
||||||
|
|
||||||
|
|
||||||
class GameConsumer(AsyncWebsocketConsumer):
|
class GameConsumer(AsyncWebsocketConsumer):
|
||||||
|
@classmethod
|
||||||
|
async def start_inactive_check(cls, join_code, channel_layer):
|
||||||
|
"""Start the inactive player check for a game if not already running."""
|
||||||
|
if join_code not in game_check_tasks or game_check_tasks[join_code].done():
|
||||||
|
async def check_inactive_players():
|
||||||
|
game_group_name = f'game_{join_code}'
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
await asyncio.sleep(30) # Check every 30 seconds
|
||||||
|
try:
|
||||||
|
game = await database_sync_to_async(QuizGame.objects.get)(join_code=join_code)
|
||||||
|
cutoff_time = timezone.now() - timedelta(minutes=1)
|
||||||
|
|
||||||
|
# Get active and inactive participants
|
||||||
|
all_participants = await database_sync_to_async(lambda: list(
|
||||||
|
game.participants.all().values('participant_id', 'display_name', 'last_heartbeat')
|
||||||
|
))()
|
||||||
|
|
||||||
|
# Konvertiere datetime zu ISO Format String
|
||||||
|
for p in all_participants:
|
||||||
|
if p['last_heartbeat']:
|
||||||
|
p['last_heartbeat'] = p['last_heartbeat'].isoformat()
|
||||||
|
|
||||||
|
active_participants = [p for p in all_participants if p['last_heartbeat'] and timezone.datetime.fromisoformat(p['last_heartbeat']) >= cutoff_time]
|
||||||
|
inactive_participants = [p for p in all_participants if not p['last_heartbeat'] or timezone.datetime.fromisoformat(p['last_heartbeat']) < cutoff_time]
|
||||||
|
|
||||||
|
# Remove inactive participants
|
||||||
|
if inactive_participants:
|
||||||
|
for p in inactive_participants:
|
||||||
|
# Benachrichtige andere über den gekickten Spieler
|
||||||
|
await channel_layer.group_send(
|
||||||
|
game_group_name,
|
||||||
|
{
|
||||||
|
'type': 'player_left',
|
||||||
|
'player_name': p['display_name'],
|
||||||
|
'was_kicked': True
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# Lösche den inaktiven Teilnehmer
|
||||||
|
await database_sync_to_async(QuizGameParticipant.objects.filter(
|
||||||
|
participant_id=p['participant_id']
|
||||||
|
).delete)()
|
||||||
|
|
||||||
|
# Broadcast update to all clients
|
||||||
|
if active_participants or inactive_participants:
|
||||||
|
await channel_layer.group_send(
|
||||||
|
game_group_name,
|
||||||
|
{
|
||||||
|
'type': 'participant_list_update',
|
||||||
|
'participants': active_participants
|
||||||
|
}
|
||||||
|
)
|
||||||
|
except QuizGame.DoesNotExist:
|
||||||
|
break # Stop checking if game no longer exists
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Error checking inactive players in game: {e}')
|
||||||
|
await asyncio.sleep(5) # Wait before retry
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Error in game inactive check loop: {e}')
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
|
||||||
|
game_check_tasks[join_code] = asyncio.create_task(check_inactive_players())
|
||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
self.join_code = self.scope['url_route']['kwargs']['join_code']
|
self.join_code = self.scope['url_route']['kwargs']['join_code']
|
||||||
@@ -21,6 +91,9 @@ class GameConsumer(AsyncWebsocketConsumer):
|
|||||||
|
|
||||||
await self.accept()
|
await self.accept()
|
||||||
|
|
||||||
|
# Ensure inactive check is running for this game
|
||||||
|
await self.start_inactive_check(self.join_code, self.channel_layer)
|
||||||
|
|
||||||
async def disconnect(self, close_code):
|
async def disconnect(self, close_code):
|
||||||
# Leave game group
|
# Leave game group
|
||||||
await self.channel_layer.group_discard(
|
await self.channel_layer.group_discard(
|
||||||
@@ -73,6 +146,21 @@ class GameConsumer(AsyncWebsocketConsumer):
|
|||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if message_type == 'heartbeat':
|
||||||
|
participant_id = text_data_json.get('participant_id')
|
||||||
|
if participant_id:
|
||||||
|
await self.update_participant_heartbeat(participant_id)
|
||||||
|
# Update participants list after heartbeat
|
||||||
|
participants = await self.get_participants()
|
||||||
|
await self.channel_layer.group_send(
|
||||||
|
self.game_group_name,
|
||||||
|
{
|
||||||
|
'type': 'participant_list_update',
|
||||||
|
'participants': participants
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
if message_type == 'submit_rating':
|
if message_type == 'submit_rating':
|
||||||
participant_id = text_data_json['participant_id']
|
participant_id = text_data_json['participant_id']
|
||||||
rating = text_data_json['rating']
|
rating = text_data_json['rating']
|
||||||
@@ -84,10 +172,7 @@ class GameConsumer(AsyncWebsocketConsumer):
|
|||||||
|
|
||||||
elif message_type == 'submit_answer':
|
elif message_type == 'submit_answer':
|
||||||
participant_id = text_data_json['participant_id']
|
participant_id = text_data_json['participant_id']
|
||||||
try:
|
answer = text_data_json['answer']
|
||||||
answer = text_data_json['answer']
|
|
||||||
except:
|
|
||||||
answer=-1
|
|
||||||
time_remaining = text_data_json.get('time_remaining', 0)
|
time_remaining = text_data_json.get('time_remaining', 0)
|
||||||
|
|
||||||
# Save answer and update participant score
|
# Save answer and update participant score
|
||||||
@@ -165,6 +250,17 @@ class GameConsumer(AsyncWebsocketConsumer):
|
|||||||
'redirect_url': event.get('redirect_url')
|
'redirect_url': event.get('redirect_url')
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
async def update_participant_heartbeat(self, participant_id):
|
||||||
|
"""Update the last heartbeat timestamp for a participant."""
|
||||||
|
try:
|
||||||
|
participant = await database_sync_to_async(QuizGameParticipant.objects.get)(
|
||||||
|
participant_id=participant_id
|
||||||
|
)
|
||||||
|
participant.last_heartbeat = timezone.now()
|
||||||
|
await database_sync_to_async(participant.save)()
|
||||||
|
except QuizGameParticipant.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
@database_sync_to_async
|
@database_sync_to_async
|
||||||
def verify_host(self, host_id):
|
def verify_host(self, host_id):
|
||||||
try:
|
try:
|
||||||
@@ -185,30 +281,15 @@ class GameConsumer(AsyncWebsocketConsumer):
|
|||||||
|
|
||||||
# Check if answer is correct
|
# Check if answer is correct
|
||||||
is_correct = False
|
is_correct = False
|
||||||
question_data = json.loads(current_question.data)
|
if answer_index >= 0: # -1 means timeout
|
||||||
print(answer_index)
|
question_data = json.loads(current_question.data)
|
||||||
try:
|
|
||||||
#if answer_index >= 0 : # -1 means timeout
|
|
||||||
is_correct = question_data['options'][answer_index]['is_correct']
|
is_correct = question_data['options'][answer_index]['is_correct']
|
||||||
print(is_correct)
|
|
||||||
except:
|
|
||||||
user_input = str(answer_index).strip().lower()
|
|
||||||
correct_value = str(question_data['options'][0].get('value', '')).strip().lower()
|
|
||||||
print("Richtig",correct_value)
|
|
||||||
if user_input == correct_value:
|
|
||||||
is_correct=True
|
|
||||||
answer_index=0
|
|
||||||
print(is_correct)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Calculate score based on correctness and time
|
# Calculate score based on correctness and time
|
||||||
score = 0
|
score = 0
|
||||||
if is_correct:
|
if is_correct:
|
||||||
base_score = 1000
|
base_score = 1000
|
||||||
time_factor = time_remaining / int(current_question.time_per_question)/int(1000)
|
time_factor = time_remaining / 30000 # 30 seconds max
|
||||||
score = int(base_score * (0.5 + 0.5 * time_factor))
|
score = int(base_score * (0.5 + 0.5 * time_factor))
|
||||||
|
|
||||||
# Update or create answer in QuizAnswer table
|
# Update or create answer in QuizAnswer table
|
||||||
@@ -260,8 +341,6 @@ class GameConsumer(AsyncWebsocketConsumer):
|
|||||||
|
|
||||||
@database_sync_to_async
|
@database_sync_to_async
|
||||||
def save_rating(self, participant_id, rating):
|
def save_rating(self, participant_id, rating):
|
||||||
if not settings.QIVIP_CONFIG['ENABLE_RATING_SYSTEM']:
|
|
||||||
return False
|
|
||||||
from library.models import QuizRating
|
from library.models import QuizRating
|
||||||
try:
|
try:
|
||||||
game = QuizGame.objects.get(join_code=self.join_code)
|
game = QuizGame.objects.get(join_code=self.join_code)
|
||||||
@@ -290,16 +369,20 @@ class GameConsumer(AsyncWebsocketConsumer):
|
|||||||
try:
|
try:
|
||||||
game = QuizGame.objects.get(join_code=self.join_code)
|
game = QuizGame.objects.get(join_code=self.join_code)
|
||||||
|
|
||||||
|
# Get all active participants (heartbeat within last minute)
|
||||||
|
from django.utils import timezone
|
||||||
active_participants = QuizGameParticipant.objects.filter(
|
active_participants = QuizGameParticipant.objects.filter(
|
||||||
quiz_game=game
|
quiz_game=game,
|
||||||
|
last_heartbeat__gte=timezone.now() - timezone.timedelta(minutes=1)
|
||||||
).count()
|
).count()
|
||||||
|
|
||||||
if active_participants == 0:
|
# If no active participants and game is finished for more than 5 minutes, delete it
|
||||||
game.delete()
|
if active_participants == 0 and game.current_state == 'finished':
|
||||||
|
if game.question_start_time and (timezone.now() - game.question_start_time).total_seconds() > 300:
|
||||||
|
game.delete()
|
||||||
except QuizGame.DoesNotExist:
|
except QuizGame.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@database_sync_to_async
|
@database_sync_to_async
|
||||||
def get_participants(self):
|
def get_participants(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -3,15 +3,53 @@ import json
|
|||||||
import asyncio
|
import asyncio
|
||||||
from ..models import QuizGame, QuizGameParticipant
|
from ..models import QuizGame, QuizGameParticipant
|
||||||
from channels.db import database_sync_to_async
|
from channels.db import database_sync_to_async
|
||||||
import redis
|
|
||||||
|
|
||||||
# Dictionary to track inactive check tasks and active connections per game
|
# Dictionary to track inactive check tasks and active connections per game
|
||||||
game_check_tasks = {}
|
game_check_tasks = {}
|
||||||
game_connections = {}
|
game_connections = {}
|
||||||
|
|
||||||
class LobbyConsumer(AsyncWebsocketConsumer):
|
class LobbyConsumer(AsyncWebsocketConsumer):
|
||||||
|
@classmethod
|
||||||
|
async def start_inactive_check(cls, join_code, channel_layer):
|
||||||
|
"""Start the inactive player check for a game if not already running."""
|
||||||
|
if join_code not in game_check_tasks or game_check_tasks[join_code].done():
|
||||||
|
async def check_inactive_players():
|
||||||
|
room_group_name = f'lobby_{join_code}'
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
await asyncio.sleep(10) # Check every 10 seconds to match frontend heartbeat
|
||||||
|
# Get participants list and broadcast update
|
||||||
|
try:
|
||||||
|
from django.utils import timezone
|
||||||
|
from datetime import timedelta
|
||||||
|
game = await database_sync_to_async(QuizGame.objects.get)(join_code=join_code)
|
||||||
|
cutoff_time = timezone.now() - timedelta(seconds=20) # Consider inactive after 20 seconds (2 missed heartbeats)
|
||||||
|
# Get current active participants with full info
|
||||||
|
active_participants = await database_sync_to_async(lambda: list(
|
||||||
|
game.participants.filter(last_heartbeat__gte=cutoff_time)
|
||||||
|
.values('participant_id', 'display_name')
|
||||||
|
))()
|
||||||
|
|
||||||
r = redis.Redis(host='localhost', port=6379, db=0, decode_responses=True)
|
# Send update to all clients
|
||||||
|
await channel_layer.group_send(
|
||||||
|
room_group_name,
|
||||||
|
{
|
||||||
|
'type': 'participants_list_update',
|
||||||
|
'participants': active_participants
|
||||||
|
}
|
||||||
|
)
|
||||||
|
except QuizGame.DoesNotExist:
|
||||||
|
break # Stop checking if game no longer exists
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Error checking inactive players: {e}')
|
||||||
|
await asyncio.sleep(5) # Wait before retry
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Error in inactive check loop: {e}')
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
|
||||||
|
game_check_tasks[join_code] = asyncio.create_task(check_inactive_players())
|
||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
self.join_code = self.scope['url_route']['kwargs']['join_code']
|
self.join_code = self.scope['url_route']['kwargs']['join_code']
|
||||||
@@ -25,6 +63,9 @@ class LobbyConsumer(AsyncWebsocketConsumer):
|
|||||||
game_connections[self.join_code] = set()
|
game_connections[self.join_code] = set()
|
||||||
game_connections[self.join_code].add(self.channel_name)
|
game_connections[self.join_code].add(self.channel_name)
|
||||||
|
|
||||||
|
# Start inactive check task if not already running
|
||||||
|
await self.start_inactive_check(self.join_code, self.channel_layer)
|
||||||
|
|
||||||
# Join room group
|
# Join room group
|
||||||
await self.channel_layer.group_add(
|
await self.channel_layer.group_add(
|
||||||
self.room_group_name,
|
self.room_group_name,
|
||||||
@@ -66,6 +107,11 @@ class LobbyConsumer(AsyncWebsocketConsumer):
|
|||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if message_type == 'heartbeat':
|
||||||
|
participant_id = data.get('participant_id')
|
||||||
|
if participant_id:
|
||||||
|
await self.update_participant_heartbeat(participant_id)
|
||||||
|
# Don't update participants list after heartbeat - let the background task handle it
|
||||||
elif message_type in ['leave_game', 'kick_player']:
|
elif message_type in ['leave_game', 'kick_player']:
|
||||||
participant_id = data.get('participant_id')
|
participant_id = data.get('participant_id')
|
||||||
if participant_id:
|
if participant_id:
|
||||||
@@ -134,32 +180,36 @@ class LobbyConsumer(AsyncWebsocketConsumer):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@database_sync_to_async
|
||||||
|
def update_participant_heartbeat(self, participant_id):
|
||||||
|
try:
|
||||||
|
participant = QuizGameParticipant.objects.get(participant_id=participant_id)
|
||||||
|
from django.utils import timezone
|
||||||
|
participant.last_heartbeat = timezone.now()
|
||||||
|
participant.save()
|
||||||
|
return True
|
||||||
|
except QuizGameParticipant.DoesNotExist:
|
||||||
|
return False
|
||||||
|
|
||||||
async def get_participants_list(self):
|
async def get_participants_list(self):
|
||||||
try:
|
try:
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
game = await database_sync_to_async(QuizGame.objects.get)(join_code=self.join_code)
|
game = await database_sync_to_async(QuizGame.objects.get)(join_code=self.join_code)
|
||||||
|
# Only return participants that have been seen in the last minute
|
||||||
|
cutoff_time = timezone.now() - timedelta(seconds=20) # Consider inactive after 20 seconds (2 missed heartbeats)
|
||||||
participants = await database_sync_to_async(lambda: list(
|
participants = await database_sync_to_async(lambda: list(
|
||||||
game.participants
|
game.participants.filter(last_heartbeat__gte=cutoff_time)
|
||||||
.values('participant_id', 'display_name')
|
.values('participant_id', 'display_name')
|
||||||
))()
|
))()
|
||||||
|
|
||||||
|
|
||||||
# Zustand laden
|
# Send join notification for new participants
|
||||||
try:
|
try:
|
||||||
r = redis.Redis(host='localhost', port=6379, db=0, decode_responses=True)
|
prev_names = set(p['display_name'] for p in self.last_participants) if hasattr(self, 'last_participants') else set()
|
||||||
|
|
||||||
# Alte Teilnehmer aus Redis holen
|
|
||||||
data = r.get(f"last_participants_{self.room_group_name}")
|
|
||||||
prev_names = set(json.loads(data)) if data else set()
|
|
||||||
|
|
||||||
# Aktuelle Teilnehmer aus dem Argument extrahieren
|
|
||||||
current_names = set(p['display_name'] for p in participants)
|
current_names = set(p['display_name'] for p in participants)
|
||||||
|
|
||||||
# Neue Teilnehmer bestimmen
|
|
||||||
new_participants = current_names - prev_names
|
new_participants = current_names - prev_names
|
||||||
|
|
||||||
# Benachrichtigung für neue Teilnehmer versenden
|
|
||||||
for name in new_participants:
|
for name in new_participants:
|
||||||
await self.channel_layer.group_send(
|
await self.channel_layer.group_send(
|
||||||
self.room_group_name,
|
self.room_group_name,
|
||||||
@@ -168,12 +218,9 @@ class LobbyConsumer(AsyncWebsocketConsumer):
|
|||||||
'player_name': name
|
'player_name': name
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Teilnehmerliste in Redis aktualisieren
|
|
||||||
r.set(f"last_participants_{self.room_group_name}", json.dumps(list(current_names)))
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error in send_join_notifications: {e}")
|
print(f'Error sending join notifications: {e}')
|
||||||
|
|
||||||
self.last_participants = participants
|
self.last_participants = participants
|
||||||
return participants
|
return participants
|
||||||
except QuizGame.DoesNotExist:
|
except QuizGame.DoesNotExist:
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 5.1.7 on 2025-04-21 11:27
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('play', '0010_alter_quizgameparticipant_last_heartbeat'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='quizgame',
|
|
||||||
name='updated_at',
|
|
||||||
field=models.DateTimeField(auto_now=True),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -19,7 +19,6 @@ class QuizGame(models.Model):
|
|||||||
current_state = models.CharField(max_length=20, choices=GAME_STATES, default='lobby')
|
current_state = models.CharField(max_length=20, choices=GAME_STATES, default='lobby')
|
||||||
current_question_index = models.IntegerField(default=0)
|
current_question_index = models.IntegerField(default=0)
|
||||||
question_start_time = models.DateTimeField(null=True, blank=True)
|
question_start_time = models.DateTimeField(null=True, blank=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.join_code:
|
if not self.join_code:
|
||||||
|
|||||||
@@ -2,19 +2,15 @@ from django.utils import timezone
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.shortcuts import render, redirect, get_object_or_404, reverse
|
from django.shortcuts import render, redirect, get_object_or_404, reverse
|
||||||
from play.models import QuizGame, QuizGameParticipant
|
from play.models import QuizGame, QuizGameParticipant
|
||||||
from library.models import QivipQuiz
|
from library.models import QivipQuiz, QivipQuestion
|
||||||
from django.http import HttpResponseRedirect, HttpResponseNotFound
|
from django.http import HttpResponseRedirect, HttpResponseNotFound
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
def lobby(request, join_code):
|
def lobby(request, join_code):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
quiz = get_object_or_404(QivipQuiz, pk=quiz_game.quiz_id.id)
|
||||||
context = {
|
context = {
|
||||||
@@ -22,7 +18,6 @@ def lobby(request, join_code):
|
|||||||
'quiz_game': quiz_game,
|
'quiz_game': quiz_game,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mode = request.GET.get('mode','default')
|
mode = request.GET.get('mode','default')
|
||||||
request.session['mode'] = mode
|
request.session['mode'] = mode
|
||||||
if "host_id" in request.COOKIES:
|
if "host_id" in request.COOKIES:
|
||||||
@@ -33,9 +28,6 @@ def lobby(request, join_code):
|
|||||||
elif mode=="learn":
|
elif mode=="learn":
|
||||||
return redirect('play:create_participant', join_code=join_code)
|
return redirect('play:create_participant', join_code=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)
|
||||||
|
|
||||||
@@ -55,48 +47,46 @@ def lobby(request, join_code):
|
|||||||
def select_mode(request,join_code):
|
def select_mode(request,join_code):
|
||||||
return render(request, 'play/select_mode.html', {'join_code': join_code})
|
return render(request, 'play/select_mode.html', {'join_code': join_code})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_participant(request, join_code):
|
def create_participant(request, join_code):
|
||||||
mode = request.GET.get('mode','default')
|
mode = request.GET.get('mode','default')
|
||||||
request.session['mode'] = mode
|
request.session['mode'] = mode
|
||||||
quiz_game = get_object_or_404(QuizGame, join_code=join_code)
|
quiz_game = get_object_or_404(QuizGame, join_code=join_code)
|
||||||
if mode!="learn":
|
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
|
# Prüfe ob der Teilnehmer noch existiert
|
||||||
participant_id = request.COOKIES['participant_id']
|
participant_id = request.COOKIES['participant_id']
|
||||||
try:
|
try:
|
||||||
participant = QuizGameParticipant.objects.get(participant_id=participant_id)
|
participant = QuizGameParticipant.objects.get(participant_id=participant_id)
|
||||||
if participant.quiz_game.join_code != join_code:
|
if participant.quiz_game.join_code != join_code:
|
||||||
participant.quiz_game = quiz_game
|
participant.quiz_game = quiz_game
|
||||||
participant.score = 0 # Reset score when joining new game
|
participant.score = 0 # Reset score when joining new game
|
||||||
participant.save()
|
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:
|
except QuizGameParticipant.DoesNotExist:
|
||||||
# Cookie löschen wenn Teilnehmer nicht mehr existiert
|
# Cookie löschen wenn Teilnehmer nicht mehr existiert
|
||||||
response = HttpResponseRedirect(request.path)
|
response = HttpResponseRedirect(request.path)
|
||||||
response.delete_cookie('participant_id')
|
response.delete_cookie('participant_id')
|
||||||
|
return response
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
display_name = request.POST.get('display_name')
|
||||||
|
if not display_name:
|
||||||
|
return render(request, 'play/initialize_participant.html', {
|
||||||
|
'join_code': join_code,
|
||||||
|
'error': 'Bitte geben Sie einen Namen ein'
|
||||||
|
})
|
||||||
|
|
||||||
|
participant = QuizGameParticipant()
|
||||||
|
participant.display_name = display_name
|
||||||
|
participant.quiz_game = quiz_game
|
||||||
|
participant.score = 0 # Initialize score
|
||||||
|
participant.save()
|
||||||
|
|
||||||
|
response = HttpResponseRedirect(reverse('play:lobby', kwargs={'join_code': join_code}))
|
||||||
|
response.set_cookie('participant_id', participant.participant_id, max_age=3600)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if request.method == 'POST':
|
return render(request, 'play/initialize_participant.html', {'join_code': join_code})
|
||||||
display_name = request.POST.get('display_name')
|
|
||||||
if not display_name:
|
|
||||||
return render(request, 'play/initialize_participant.html', {
|
|
||||||
'join_code': join_code,
|
|
||||||
'error': 'Bitte geben Sie einen Namen ein'
|
|
||||||
})
|
|
||||||
|
|
||||||
participant = QuizGameParticipant()
|
|
||||||
participant.display_name = display_name
|
|
||||||
participant.quiz_game = quiz_game
|
|
||||||
participant.score = 0 # Initialize score
|
|
||||||
participant.save()
|
|
||||||
|
|
||||||
response = HttpResponseRedirect(reverse('play:lobby', kwargs={'join_code': join_code}))
|
|
||||||
response.set_cookie('participant_id', participant.participant_id, max_age=3600)
|
|
||||||
return response
|
|
||||||
|
|
||||||
return render(request, 'play/initialize_participant.html', {'join_code': join_code})
|
|
||||||
else:
|
else:
|
||||||
messages.error(request, "Beitritt nicht möglich.")
|
messages.error(request, "Beitritt nicht möglich.")
|
||||||
return render(request, 'play/join_game.html')
|
return render(request, 'play/join_game.html')
|
||||||
@@ -145,8 +135,7 @@ def finished(request, join_code):
|
|||||||
context = {
|
context = {
|
||||||
'join_code': join_code,
|
'join_code': join_code,
|
||||||
'is_host': str(game.host_id) == str(request.session.get('host_id')),
|
'is_host': str(game.host_id) == str(request.session.get('host_id')),
|
||||||
'participant_id': participant_id if participant else None,
|
'participant_id': participant_id if participant else None
|
||||||
'rating_enabled': settings.QIVIP_CONFIG['ENABLE_RATING_SYSTEM']
|
|
||||||
}
|
}
|
||||||
return render(request, 'play/game/finished.html', context)
|
return render(request, 'play/game/finished.html', context)
|
||||||
except QuizGame.DoesNotExist:
|
except QuizGame.DoesNotExist:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<form action="{% url 'accounts:logout' %}" method="post">
|
<form action="{% url 'accounts:logout' %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="w-full p-3 rounded-full bg-blue-600 text-white font-black hover:scale-105 transition duration-200 cursor-pointer" type="submit">Abmelden</button>
|
<button class="bg-blue-600 text-white p-3 rounded-full font-black" type="submit">Abmelden</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<div class="items-center w-full">
|
<div class="items-center w-full">
|
||||||
<input class=" w-full p-3 rounded-full bg-gray-200 focus:scale-105 transition duration-200 font-black" type="password" name="password" id="password" required placeholder="PASSWORT">
|
<input class=" w-full p-3 rounded-full bg-gray-200 focus:scale-105 transition duration-200 font-black" type="password" name="password" id="password" required placeholder="PASSWORT">
|
||||||
</div>
|
</div>
|
||||||
<button class="w-full p-3 rounded-full bg-blue-600 text-white font-black hover:scale-105 transition duration-200 cursor-pointer" type="submit" class="login-button">Anmelden</button>
|
<button class="w-full p-3 rounded-full bg-blue-600 text-white font-black hover:scale-105 transition duration-200" type="submit" class="login-button">Anmelden</button>
|
||||||
</form>
|
</form>
|
||||||
<button class="text-center text-sm w-full mt-2 font-light text-blue-600"><a href="{% url 'accounts:register' %}" class="register_link">Noch kein Konto?</a></button>
|
<button class="text-center text-sm w-full mt-2 font-light text-blue-600"><a href="{% url 'accounts:register' %}" class="register_link">Noch kein Konto?</a></button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="{% static 'css/t-style.css' %}">
|
<link rel="stylesheet" href="{% static 'css/t-style.css' %}">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@tsparticles/confetti@3.0.3/tsparticles.confetti.bundle.min.js"></script>
|
|
||||||
<title>qivip</title>
|
<title>qivip</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -71,8 +70,5 @@
|
|||||||
localStorage.setItem("meine_seite_scroll", 0);}
|
localStorage.setItem("meine_seite_scroll", 0);}
|
||||||
</script>
|
</script>
|
||||||
{% block extra_js %}{% endblock %}
|
{% block extra_js %}{% endblock %}
|
||||||
<style>html {
|
|
||||||
overflow-y: scroll;
|
|
||||||
}</style>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -90,14 +90,6 @@
|
|||||||
<div class="flex justify-between items-center flex-wrap">
|
<div class="flex justify-between items-center flex-wrap">
|
||||||
<h2 class="text-xl font-semibold">Fragen</h2>
|
<h2 class="text-xl font-semibold">Fragen</h2>
|
||||||
<div class="flex space-x-2 flex-wrap">
|
<div class="flex space-x-2 flex-wrap">
|
||||||
{% if quiz.user_id == request.user %}
|
|
||||||
<a href="{% url 'library:new_question' %}?type=input&quiz_id={{ quiz.id }}"
|
|
||||||
class=" mt-1 bg-green-100 text-green-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
|
|
||||||
Eingabe
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
{% if quiz.user_id == request.user %}
|
{% if quiz.user_id == request.user %}
|
||||||
<a href="{% url 'library:new_question' %}?type=multiple_choice&quiz_id={{ quiz.id }}"
|
<a href="{% url 'library:new_question' %}?type=multiple_choice&quiz_id={{ quiz.id }}"
|
||||||
class=" mt-1 bg-blue-100 text-blue-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
|
class=" mt-1 bg-blue-100 text-blue-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
|
||||||
@@ -126,8 +118,8 @@
|
|||||||
<div class="flex-grow">
|
<div class="flex-grow">
|
||||||
<p class="font-medium">{{ question.data.question }}</p>
|
<p class="font-medium">{{ question.data.question }}</p>
|
||||||
<div class="mt-1">
|
<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 {% elif question.data.type == 'input' %} bg-green-100 text-green-800 {% else %}bg-purple-100 text-purple-800{% endif %}">
|
<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{% elif question.data.type == 'input' %}Eingabe{% else %}Wahr/Falsch{% endif %}
|
{% if question.data.type == 'multiple_choice' %}Multiple Choice{% else %}Wahr/Falsch{% endif %}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
@@ -151,18 +143,6 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% elif question.data.type == 'input' %}
|
|
||||||
<ul class="space-y-1 ">
|
|
||||||
{% for option in question.data.options %}
|
|
||||||
<li class="flex items-center text-sm">
|
|
||||||
<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>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for option in question.data.options %}
|
{% for option in question.data.options %}
|
||||||
{% if option.is_correct %}
|
{% if option.is_correct %}
|
||||||
@@ -213,26 +193,24 @@
|
|||||||
|
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
{% if quiz.base_quiz %}
|
{% if quiz.base_quiz %}
|
||||||
<p class="text-gray-600 mt-2 ">Bearbeitung:<span class="text-blue-600 font-bold"> <a href="{% url 'library:overview_quiz' %}?filter=1&user={{ quiz.user_id }}">{{ quiz.user_id }}</a></span></p>
|
<p class="text-gray-600 mt-2 ">Bearbeitung:<span class="font-bold"> {{ quiz.user_id}}</span></p>
|
||||||
{% else %}
|
|
||||||
<p class="text-gray-600 mt-2 ">Autor:<span class="text-blue-600 font-bold"> <a href="{% url 'library:overview_quiz' %}?filter=1&user={{ quiz.user_id }}">{{ quiz.user_id }}</a></span></p>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
{% if quiz.base_quiz %}
|
{% if quiz.base_quiz %}
|
||||||
<p class="text-gray-600 ">Kopie von: <a href="{% url 'library:detail_quiz' quiz.base_quiz.id %}"><span class="text-blue-600 font-bold">{{ quiz.base_quiz}}</span></a></p>
|
<p class="text-gray-600 ">Kopie von: <a href="{% url 'library:detail_quiz' quiz.base_quiz.id %}"><span class="font-bold">{{ quiz.base_quiz}}</span></a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
{% if quiz.base_quiz %}
|
{% if quiz.base_quiz %}
|
||||||
<p class="text-gray-600 ">Autor:<span class="text-blue-600 font-bold"> <a href="{% url 'library:overview_quiz' %}?filter=1&user={{ quiz.base_quiz.user_id }}">{{ quiz.base_quiz.user_id }}</a></span></p>
|
<p class="text-gray-600 ">Autor:<span class="font-bold"> {{ quiz.base_quiz.user_id}}</span></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
{% if quiz.credits %}
|
{% if quiz.credits %}
|
||||||
<p class="text-gray-600 mb-2">Credits:<span class="text-blue-600 font-bold"> {{ quiz.credits }}</span></p>
|
<p class="text-gray-600 mb-2">Credits:<span class="font-bold"> {{ quiz.credits }}</span></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -5,21 +5,6 @@
|
|||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
|
|
||||||
{% if form.instance.image %}
|
|
||||||
<img src="{{ form.instance.image.image.url }}" style="max-width: 100px;" alt="Bild der Frage">
|
|
||||||
<label for="reset_image">
|
|
||||||
<input type="checkbox" name="reset_image" id="reset_image">
|
|
||||||
Bild zurücksetzen
|
|
||||||
</label>
|
|
||||||
{% endif %}
|
|
||||||
<div>
|
|
||||||
<label class="font-bold" for="quiz_image">Bild:</label>
|
|
||||||
<input class="bg-blue-200 p-2 m-2 rounded-lg border-2 border-blue-400" type="file" name="quiz_image" id="quiz_image">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="flex justify-center space-x-3">
|
<div class="flex justify-center space-x-3">
|
||||||
<a href="{% if object.quiz_id %}{% url 'library:detail_quiz' object.quiz_id.id %}{% else %}{% url 'library:overview_quiz' %}{% endif %}"
|
<a href="{% if object.quiz_id %}{% url 'library:detail_quiz' object.quiz_id.id %}{% else %}{% url 'library:overview_quiz' %}{% endif %}"
|
||||||
class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
||||||
|
|||||||
@@ -51,29 +51,28 @@
|
|||||||
|
|
||||||
<div id="filterPanel" class="container mx-auto px-4">
|
<div id="filterPanel" class="container mx-auto px-4">
|
||||||
<div class="bg-white rounded-xl shadow-lg p-6 border border-gray-200">
|
<div class="bg-white rounded-xl shadow-lg p-6 border border-gray-200">
|
||||||
<form action="{% url 'library:overview_quiz' %}" method="get" class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
<form method="get" class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||||
<input type="hidden" name="filter" value="1">
|
<div class="space-y-2">
|
||||||
<div class="space-y-2">
|
<label class="block text-sm font-medium text-gray-700">minimale Anzahl an Fragen</label>
|
||||||
<label class="block text-sm font-medium text-gray-700">minimale Anzahl an Fragen</label>
|
{{ form.min_amout_questions }}
|
||||||
<input type="number" name="min_amout_questions" class="border-2 border-gray-300 rounded-lg p-2 w-full" min="1" id="id_min_amout_questions" value="{{ form.min_amout_questions.value|default_if_none:'' }}">
|
</div>
|
||||||
</div>
|
<div class="space-y-2">
|
||||||
<div class="space-y-2">
|
<label class="block text-sm font-medium text-gray-700">maximale Anzahl an Fragen</label>
|
||||||
<label class="block text-sm font-medium text-gray-700">maximale Anzahl an Fragen</label>
|
{{ form.max_amout_questions }}
|
||||||
<input type="number" name="max_amout_questions" class="border-2 border-gray-300 rounded-lg p-2 w-full" min="1" id="id_max_amout_questions" value="{{ form.max_amout_questions.value|default_if_none:'' }}">
|
</div>
|
||||||
</div>
|
<div class="space-y-2">
|
||||||
<div class="space-y-2">
|
<label class="block text-sm font-medium text-gray-700">veröffentlicht von User</label>
|
||||||
<label class="block text-sm font-medium text-gray-700">veröffentlicht von User</label>
|
{{ form.user }}
|
||||||
<input type="text" name="user" class="border-2 border-gray-300 rounded-lg p-2 w-full" id="id_user" value="{{ form.user.value|default_if_none:'' }}">
|
</div>
|
||||||
</div>
|
<div class="md:col-span-3 flex justify-end">
|
||||||
<div class="md:col-span-3 flex justify-end">
|
<button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors duration-200">
|
||||||
<button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors duration-200">
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"></path>
|
</svg>
|
||||||
</svg>
|
Filtern
|
||||||
Filtern
|
</button>
|
||||||
</button>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -97,7 +96,7 @@
|
|||||||
<div class="relative w-full h-full inset-0 bg-cover bg-center">
|
<div class="relative w-full h-full inset-0 bg-cover bg-center">
|
||||||
<!-- Hintergrundbild -->
|
<!-- Hintergrundbild -->
|
||||||
<div class="absolute inset-0 bg-cover bg-center"
|
<div class="absolute inset-0 bg-cover bg-center"
|
||||||
style="background-image: url({{ quiz.image.image.url }});">
|
style="background-image: url({{ quiz.image.url }});">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -167,7 +166,6 @@
|
|||||||
|
|
||||||
<!-- Rating -->
|
<!-- Rating -->
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
{% if quiz.rating_count > 0 %}
|
|
||||||
{% for i in '12345'|make_list %}
|
{% for i in '12345'|make_list %}
|
||||||
{% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %}
|
{% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %}
|
||||||
<span class="text-yellow-500 text-base">★</span>
|
<span class="text-yellow-500 text-base">★</span>
|
||||||
@@ -176,9 +174,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<span class="text-gray-600 text-sm">({{ quiz.rating_count }})</span>
|
<span class="text-gray-600 text-sm">({{ quiz.rating_count }})</span>
|
||||||
{% else %}
|
|
||||||
<span class="text-gray-600 text-sm">Noch keine Bewertungen</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -288,7 +283,7 @@
|
|||||||
<div class="relative w-full h-full inset-0 bg-cover bg-center">
|
<div class="relative w-full h-full inset-0 bg-cover bg-center">
|
||||||
<!-- Hintergrundbild -->
|
<!-- Hintergrundbild -->
|
||||||
<div class="absolute inset-0 bg-cover bg-center"
|
<div class="absolute inset-0 bg-cover bg-center"
|
||||||
style="background-image: url({{ quiz.image.image.url }});">
|
style="background-image: url({{ quiz.image.url }});">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -359,7 +354,6 @@
|
|||||||
|
|
||||||
<!-- Rating -->
|
<!-- Rating -->
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
{% if quiz.rating_count > 0 %}
|
|
||||||
{% for i in '12345'|make_list %}
|
{% for i in '12345'|make_list %}
|
||||||
{% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %}
|
{% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %}
|
||||||
<span class="text-yellow-500 text-base">★</span>
|
<span class="text-yellow-500 text-base">★</span>
|
||||||
@@ -367,10 +361,7 @@
|
|||||||
<span class="text-gray-300 text-base">★</span>
|
<span class="text-gray-300 text-base">★</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<span class="text-gray-600 text-sm">({{ quiz.rating_count }})</span>
|
<span class="text-gray-600 text-sm">({{ quiz.rating_count }})</span>
|
||||||
{% else %}
|
|
||||||
<span class="text-gray-600 text-sm">Noch keine Bewertungen</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -487,7 +478,7 @@
|
|||||||
<div class="relative w-full h-full inset-0 bg-cover bg-center">
|
<div class="relative w-full h-full inset-0 bg-cover bg-center">
|
||||||
<!-- Hintergrundbild -->
|
<!-- Hintergrundbild -->
|
||||||
<div class="absolute inset-0 bg-cover bg-center"
|
<div class="absolute inset-0 bg-cover bg-center"
|
||||||
style="background-image: url({{ quiz.image.image.url }});">
|
style="background-image: url({{ quiz.image.url }});">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -556,7 +547,6 @@
|
|||||||
|
|
||||||
<!-- Rating -->
|
<!-- Rating -->
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
{% if quiz.rating_count > 0 %}
|
|
||||||
{% for i in '12345'|make_list %}
|
{% for i in '12345'|make_list %}
|
||||||
{% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %}
|
{% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %}
|
||||||
<span class="text-yellow-500 text-base">★</span>
|
<span class="text-yellow-500 text-base">★</span>
|
||||||
@@ -565,9 +555,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<span class="text-gray-600 text-sm">({{ quiz.rating_count }})</span>
|
<span class="text-gray-600 text-sm">({{ quiz.rating_count }})</span>
|
||||||
{% else %}
|
|
||||||
<span class="text-gray-600 text-sm">Noch keine Bewertungen</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -646,26 +633,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
if (urlParams.get('filter') === '1') {
|
|
||||||
document.getElementById('filterPanel').classList.add('show');
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('filterButton').addEventListener('click', function() {
|
document.getElementById('filterButton').addEventListener('click', function() {
|
||||||
document.getElementById('filterPanel').classList.toggle('show');
|
document.getElementById('filterPanel').classList.toggle('show');
|
||||||
|
|
||||||
// URL beim Öffnen aktualisieren
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
|
||||||
if (document.getElementById('filterPanel').classList.contains('show')) {
|
|
||||||
params.set('filter', '1');
|
|
||||||
} else {
|
|
||||||
params.delete('filter');
|
|
||||||
}
|
|
||||||
history.replaceState(null, '', `${location.pathname}?${params}`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (window.location.pathname === "/library/") {
|
if (window.location.pathname === "/library/") {
|
||||||
window.addEventListener("beforeunload", function () {
|
window.addEventListener("beforeunload", function () {
|
||||||
localStorage.setItem("meine_seite_scroll", window.scrollY);
|
localStorage.setItem("meine_seite_scroll", window.scrollY);
|
||||||
|
|||||||
@@ -1,93 +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">{% if question %}Frage bearbeiten{% else %}Neue Eingabe Frage{% endif %}</h1>
|
|
||||||
<a href="{% url 'library:detail_quiz' quiz.id %}"
|
|
||||||
class="bg-gray-100 text-gray-700 px-4 py-2 rounded-md hover:bg-gray-200 transition-colors">
|
|
||||||
Zurück zum Quiz
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="bg-white rounded-lg shadow-md p-6 border-blue-600 border-2 rounded-xl shadow-md">
|
|
||||||
<form method="post" class="space-y-6" enctype="multipart/form-data">
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
<!-- Question Text -->
|
|
||||||
<div>
|
|
||||||
<label for="question" class="block text-sm font-medium text-gray-700">Frage</label>
|
|
||||||
<div class="mt-1">
|
|
||||||
<textarea name="question" id="question" rows="4"
|
|
||||||
class="shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md"
|
|
||||||
required>{{ question.data.question }}</textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if image %}
|
|
||||||
<img src="{{ image.image.url }}" style="max-width: 500px;" alt="Bild der Frage">
|
|
||||||
<label for="reset_image">
|
|
||||||
<input type="checkbox" name="reset_ques_image" id="reset_ques_image">
|
|
||||||
Bild zurücksetzen
|
|
||||||
</label>
|
|
||||||
{% endif %}
|
|
||||||
<div>
|
|
||||||
<label class="font-bold" for="question_image">Bild:</label>
|
|
||||||
<input class="bg-blue-200 p-2 m-2 rounded-lg border-2 border-blue-400" type="file" name="question_image" id="question_image">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Eingabe -->
|
|
||||||
{% if question and question.data.options %}
|
|
||||||
{% for option in question.data.options %}
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">Richtige Antwort</label>
|
|
||||||
<div class="flex space-x-4">
|
|
||||||
<textarea name="correct_answer" rows="2"
|
|
||||||
class="shadow-sm focus:ring-blue-500 focus:border-blue-500 flex-grow sm:text-sm border-gray-300 rounded-md"
|
|
||||||
required>{{ option.value }}</textarea>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">Richtige Antwort</label>
|
|
||||||
<div class="flex space-x-4">
|
|
||||||
<textarea name="correct_answer" rows="2"
|
|
||||||
class="shadow-sm focus:ring-blue-500 focus:border-blue-500 flex-grow sm:text-sm border-gray-300 rounded-md"
|
|
||||||
required></textarea>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
<div class="p-4">
|
|
||||||
<label class="font-bold" for="time_per_question">Zeit pro Frage:</label>
|
|
||||||
<select name="time_per_question" id="time_per_question">
|
|
||||||
<option value="10" {% if standard_time_per_question == "10" or time_per_question == "10" %}selected{% endif %}>10 Sekunden</option>
|
|
||||||
<option value="20" {% if standard_time_per_question == "20" or time_per_question == "20" %}selected{% endif %}>20 Sekunden</option>
|
|
||||||
<option value="30" {% if standard_time_per_question == "30" or time_per_question == "30" %}selected{% endif %}>30 Sekunden</option>
|
|
||||||
<option value="45" {% if standard_time_per_question == "45" or time_per_question == "45" %}selected{% endif %}>45 Sekunden</option>
|
|
||||||
<option value="60" {% if standard_time_per_question == "60" or time_per_question == "60" %}selected{% endif %}>1 Minute</option>
|
|
||||||
<option value="120" {% if standard_time_per_question == "120" or time_per_question == "120" %}selected{% endif %}>2 Minuten</option>
|
|
||||||
<option value="300" {% if standard_time_per_question == "300" or time_per_question == "300" %}selected{% endif %}>5 Minuten</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex justify-end space-x-3">
|
|
||||||
<a href="{% url 'library:detail_quiz' quiz.id %}"
|
|
||||||
class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
||||||
Abbrechen
|
|
||||||
</a>
|
|
||||||
<button type="submit"
|
|
||||||
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
||||||
{% if question %}Speichern{% else %}Erstellen{% endif %}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -25,11 +25,7 @@
|
|||||||
|
|
||||||
|
|
||||||
{% if image %}
|
{% if image %}
|
||||||
<img src="{{ image.image.url }}" style="max-width: 500px;" alt="Bild der Frage">
|
<img src="{{ image.url }}" style="max-width: 500px;" alt="Bild der Frage">
|
||||||
<label for="reset_image">
|
|
||||||
<input type="checkbox" name="reset_ques_image" id="reset_ques_image">
|
|
||||||
Bild zurücksetzen
|
|
||||||
</label>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div>
|
<div>
|
||||||
<label class="font-bold" for="question_image">Bild:</label>
|
<label class="font-bold" for="question_image">Bild:</label>
|
||||||
|
|||||||
@@ -25,11 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if image %}
|
{% if image %}
|
||||||
<img src="{{ image.image.url }}" style="max-width: 500px;" alt="Bild der Frage">
|
<img src="{{ image.url }}" style="max-width: 500px;" alt="Bild der Frage">
|
||||||
<label for="reset_image">
|
|
||||||
<input type="checkbox" name="reset_ques_image" id="reset_ques_image">
|
|
||||||
Bild zurücksetzen
|
|
||||||
</label>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div>
|
<div>
|
||||||
<label class="font-bold" for="question_image">Bild:</label>
|
<label class="font-bold" for="question_image">Bild:</label>
|
||||||
|
|||||||
@@ -1,121 +1,34 @@
|
|||||||
<nav id="main-nav" class="relative bg-blue-600 rounded-lg mt-1 m-2 shadow-md transition-all duration-300">
|
<nav class="flex justify-between items-center bg-blue-600 h-12 px-4 sm:px-6 rounded-lg mt-1 m-2 shadow-md overflow-x-auto whitespace-nowrap">
|
||||||
<!-- Desktop Navigation Bar -->
|
<div class="flex items-center flex-shrink-0 md:w-32">
|
||||||
<div class="flex justify-between items-center h-12 px-4 sm:px-6 overflow-x-auto whitespace-nowrap">
|
<h2 class="text-xl font-bold text-white hover:scale-110 transition duration-200 ">
|
||||||
<!-- Logo / Left section -->
|
<a href="{% url 'homepage:home' %}">qivip</a>
|
||||||
<div class="flex items-center flex-shrink-0 md:w-32">
|
</h2>
|
||||||
<h2 class="text-xl font-bold text-white hover:scale-110 transition duration-200">
|
|
||||||
<a href="{% url 'homepage:home' %}">qivip</a>
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Desktop Search (centered on screen) - Hidden on mobile -->
|
|
||||||
<div class="hidden md:flex justify-center items-center absolute left-1/2 transform -translate-x-1/2 min-w-40">
|
|
||||||
<form method="get" action="{% url 'library:overview_quiz' %}" class="mr-2 ml-2 flex items-center justify-center w-screen max-w-sm bg-white rounded-full px-4 py-1 shadow-md">
|
|
||||||
<input type="text" name="search" placeholder="Suche ..." value="{{ request.GET.search }}"
|
|
||||||
class="text-sm w-full px-3 py-1 text-black bg-transparent focus:outline-none lg:text-base">
|
|
||||||
<button class="py-1 text-blue-600">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5 md:size-6">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Desktop Navigation Links - Hidden on mobile -->
|
|
||||||
<div class="hidden md:flex items-center space-x-4 md:w-40">
|
|
||||||
<ul class="flex space-x-4 qp-nav-list">
|
|
||||||
{% if show_search %}
|
|
||||||
<li><a href="{% url 'library:overview_quiz' %}">Bibliothek</a></li>
|
|
||||||
{% else%}
|
|
||||||
<li><a href="{% url 'library:overview_quiz' %}">Bibliothek</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% 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>
|
|
||||||
|
|
||||||
<!-- Mobile menu button - Only visible on mobile -->
|
|
||||||
<div class="flex md:hidden items-center">
|
|
||||||
<button id="mobile-menu-button" class="text-white focus:outline-none">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Mobile Navigation Menu - Hidden by default - FULLWIDTH DROPDOWN -->
|
<div class="flex justify-center items-center min-w-40">
|
||||||
<div id="mobile-menu" class="hidden absolute w-full z-50 md:hidden opacity-0 transform -translate-y-2 transition-all duration-300">
|
<form method="get" action="{% url 'library:overview_quiz' %}" class="mr-2 ml-2 flex items-center justify-center w-screen max-w-sm bg-white rounded-full px-4 py-1 shadow-md">
|
||||||
<div class="bg-blue-500 pt-3 pb-4 rounded-b-lg shadow-inner">
|
<input type="text" name="search" placeholder="Suche ..." value="{{ request.GET.search }}"
|
||||||
<!-- Search in mobile menu -->
|
class=" text-sm w-full px-3 py-1 text-black bg-transparent focus:outline-none lg:text-base">
|
||||||
<form method="get" action="{% url 'library:overview_quiz' %}" class="px-4 mb-4">
|
<button class="py-1 text-blue-600">
|
||||||
<div class="flex items-center justify-center bg-white rounded-full px-4 py-2 shadow-md">
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5 md:size-6 ">
|
||||||
<input type="text" name="search" placeholder="Suche ..." value="{{ request.GET.search }}"
|
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
||||||
class="w-full text-sm px-2 text-black bg-transparent focus:outline-none">
|
</svg>
|
||||||
<button class="text-blue-600">
|
</button>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
</form></div>
|
||||||
stroke="currentColor" class="size-5">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round"
|
|
||||||
d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<!-- Mobile Navigation Links -->
|
|
||||||
<div class="space-y-2 px-4">
|
<div class="flex items-center space-x-4 md:w-40 ">
|
||||||
<a href="{% url 'library:overview_quiz' %}" class="block py-2 text-white font-medium rounded-lg hover:bg-blue-600 transition duration-200">
|
<ul class="flex space-x-4 qp-nav-list">
|
||||||
Bibliothek
|
{% if show_search %}
|
||||||
</a>
|
<li class="hidden md:flex"><a href="{% url 'library:overview_quiz' %}">Bibliothek</a></li>
|
||||||
{% if user.is_authenticated %}
|
{% else%}
|
||||||
<a href="{% url 'accounts:home' %}" class="block py-2 text-white font-medium rounded-lg hover:bg-blue-600 transition duration-200">
|
<li><a href="{% url 'library:overview_quiz' %}">Bibliothek</a></li>
|
||||||
Konto
|
{% endif %}
|
||||||
</a>
|
{% if user.is_authenticated %}
|
||||||
{% else %}
|
<li><a href="{% url 'accounts:home' %}">Konto</a></li>
|
||||||
<a href="{% url 'accounts:login' %}" class="block py-2 text-white font-medium rounded-lg hover:bg-blue-600 transition duration-200">
|
{% else %}
|
||||||
Anmelden
|
<li><a href="{% url 'accounts:login' %}">Anmelden</a></li>
|
||||||
</a>
|
{% endif %}
|
||||||
{% endif %}
|
</ul>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- Mobile Menu Script -->
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const mobileMenuButton = document.getElementById('mobile-menu-button');
|
|
||||||
const mobileMenu = document.getElementById('mobile-menu');
|
|
||||||
const mainNav = document.getElementById('main-nav');
|
|
||||||
|
|
||||||
mobileMenuButton.addEventListener('click', function() {
|
|
||||||
// Toggle menu visibility
|
|
||||||
if (mobileMenu.classList.contains('hidden')) {
|
|
||||||
// Show menu
|
|
||||||
mobileMenu.classList.remove('hidden');
|
|
||||||
// Entferne unten abgerundete Ecken der Navbar wenn Menü offen
|
|
||||||
mainNav.classList.remove('rounded-lg');
|
|
||||||
mainNav.classList.add('rounded-t-lg');
|
|
||||||
// Animation einfahren
|
|
||||||
setTimeout(() => {
|
|
||||||
mobileMenu.classList.remove('opacity-0', 'transform', '-translate-y-2');
|
|
||||||
mobileMenu.classList.add('opacity-100');
|
|
||||||
}, 50);
|
|
||||||
} else {
|
|
||||||
// Ausfahren Animation
|
|
||||||
mobileMenu.classList.add('opacity-0', 'transform', '-translate-y-2');
|
|
||||||
mobileMenu.classList.remove('opacity-100');
|
|
||||||
// Nach der Animation verstecken
|
|
||||||
setTimeout(() => {
|
|
||||||
mobileMenu.classList.add('hidden');
|
|
||||||
// Stelle die abgerundeten Ecken wieder her
|
|
||||||
mainNav.classList.remove('rounded-t-lg');
|
|
||||||
mainNav.classList.add('rounded-lg');
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if not is_host %}
|
{% if not is_host %}
|
||||||
{% if rating_enabled %}
|
|
||||||
<div class="bg-blue-50 rounded-lg p-6 mb-8">
|
<div class="bg-blue-50 rounded-lg p-6 mb-8">
|
||||||
<h2 class="text-2xl font-bold text-blue-800 mb-4 text-center">Wie hat dir das Quiz gefallen?</h2>
|
<h2 class="text-2xl font-bold text-blue-800 mb-4 text-center">Wie hat dir das Quiz gefallen?</h2>
|
||||||
<div class="stars flex justify-center space-x-4 mb-4">
|
<div class="stars flex justify-center space-x-4 mb-4">
|
||||||
@@ -23,9 +22,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<p id="rating-message" class="text-center text-blue-600 font-medium"></p>
|
<p id="rating-message" class="text-center text-blue-600 font-medium"></p>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
|
||||||
<p class="text-center text-blue-600 font-medium mb-8">Bewertungen sind deaktiviert</p>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
{% if question_image %}
|
{% if question_image %}
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<img class="m-4" src="{{ question_image.image.url }}" style="max-width: 500px;" alt="Bild der Frage">
|
<img class="m-4" src="{{ question_image.url }}" style="max-width: 500px;" alt="Bild der Frage">
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<p id="answer-count" class="text-6xl font-bold text-blue-700">0/0</p>
|
<p id="answer-count" class="text-6xl font-bold text-blue-700">0/0</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if question_data.type != "input" %}
|
|
||||||
<div class="grid grid-cols-2 gap-4" id="options-container">
|
<div class="grid grid-cols-2 gap-4" id="options-container">
|
||||||
{% for option in question_data.options %}
|
{% for option in question_data.options %}
|
||||||
<button
|
<button
|
||||||
@@ -48,20 +48,7 @@
|
|||||||
</button>
|
</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
|
||||||
{% if request.session.mode == "learn" %}
|
|
||||||
<input id="textanswer" type="text" placeholder="DEINE ANTWORT"
|
|
||||||
class="answer-option text-center p-2 bg-gray-100 hover:bg-blue-100 rounded-lg transition-colors duration-200 answer-option">
|
|
||||||
|
|
||||||
<button {% if request.session.mode == "learn" %}
|
|
||||||
onclick="submitAnswer( -1 );" {% endif %}
|
|
||||||
class="text-center p-2 bg-gray-100 hover:bg-blue-100 rounded-lg transition-colors duration-200 answer-option">
|
|
||||||
abschicken
|
|
||||||
</button>
|
|
||||||
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -168,9 +155,7 @@
|
|||||||
gameSocket.send(JSON.stringify({
|
gameSocket.send(JSON.stringify({
|
||||||
'type': 'update_participants'
|
'type': 'update_participants'
|
||||||
}));
|
}));
|
||||||
{% if request.session.mode != "learn" %}
|
|
||||||
updateTimer();
|
updateTimer();
|
||||||
{% endif %}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -192,20 +177,10 @@
|
|||||||
|
|
||||||
function submitAnswer(optionIndex) {
|
function submitAnswer(optionIndex) {
|
||||||
if (hasAnswered) return;
|
if (hasAnswered) return;
|
||||||
let input = ""; // Declare input here
|
|
||||||
|
|
||||||
try {
|
|
||||||
input = document.getElementById("textanswer").value;
|
|
||||||
} catch (e) {
|
|
||||||
input = "";
|
|
||||||
}
|
|
||||||
hasAnswered = true;
|
hasAnswered = true;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
let timeRemaining = Math.max(0, questionDuration - (now - questionStartTime));
|
const timeRemaining = Math.max(0, questionDuration - (now - questionStartTime));
|
||||||
{% if request.session.mode == "learn" %}
|
|
||||||
timeRemaining = questionDuration;
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
// Disable all options and highlight selected
|
// Disable all options and highlight selected
|
||||||
const options = document.getElementsByClassName('answer-option');
|
const options = document.getElementsByClassName('answer-option');
|
||||||
@@ -219,23 +194,14 @@
|
|||||||
option.classList.add('opacity-50');
|
option.classList.add('opacity-50');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(input!=""){
|
|
||||||
// Send answer to server
|
// Send answer to server
|
||||||
gameSocket.send(JSON.stringify({
|
gameSocket.send(JSON.stringify({
|
||||||
type: 'submit_answer',
|
type: 'submit_answer',
|
||||||
participant_id: participantId,
|
participant_id: participantId,
|
||||||
answer:input,
|
answer: optionIndex,
|
||||||
time_remaining: timeRemaining
|
time_remaining: timeRemaining
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
gameSocket.send(JSON.stringify({
|
|
||||||
type: 'submit_answer',
|
|
||||||
participant_id: participantId,
|
|
||||||
answer:optionIndex,
|
|
||||||
time_remaining: timeRemaining
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<p class="text-blue-600 text-xl mb-2">Verbleibende Zeit</p>
|
<p class="text-blue-600 text-xl mb-2">Verbleibende Zeit</p>
|
||||||
<p id="remaining-time" class="text-6xl font-bold text-blue-700">30</p>
|
<p id="remaining-time" class="text-6xl font-bold text-blue-700">30</p>
|
||||||
</div>
|
</div>
|
||||||
{% if question_data.type != "input" %}
|
|
||||||
<div class="grid grid-cols-2 gap-4" id="options-container">
|
<div class="grid grid-cols-2 gap-4" id="options-container">
|
||||||
{% for option in question_data.options %}
|
{% for option in question_data.options %}
|
||||||
<button
|
<button
|
||||||
@@ -26,15 +26,6 @@
|
|||||||
</button>
|
</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
|
||||||
<input id="textanswer" type="text" placeholder="DEINE ANTWORT"
|
|
||||||
class="answer-option text-center p-2 bg-gray-100 hover:bg-blue-100 rounded-lg transition-colors duration-200 answer-option">
|
|
||||||
<button
|
|
||||||
onclick="submitAnswer( -1 );"
|
|
||||||
class="text-center p-2 bg-gray-100 hover:bg-blue-100 rounded-lg transition-colors duration-200 answer-option">
|
|
||||||
abschicken
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -66,13 +57,6 @@
|
|||||||
|
|
||||||
function submitAnswer(optionIndex) {
|
function submitAnswer(optionIndex) {
|
||||||
if (hasAnswered) return;
|
if (hasAnswered) return;
|
||||||
let input = ""; // Declare input here
|
|
||||||
|
|
||||||
try {
|
|
||||||
input = document.getElementById("textanswer").value;
|
|
||||||
} catch (e) {
|
|
||||||
input = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
hasAnswered = true;
|
hasAnswered = true;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@@ -91,26 +75,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(input!=""){
|
|
||||||
// Send answer to server
|
// Send answer to server
|
||||||
gameSocket.send(JSON.stringify({
|
gameSocket.send(JSON.stringify({
|
||||||
type: 'submit_answer',
|
type: 'submit_answer',
|
||||||
participant_id: participantId,
|
participant_id: participantId,
|
||||||
answer:input,
|
answer: optionIndex,
|
||||||
time_remaining: timeRemaining
|
time_remaining: timeRemaining
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
gameSocket.send(JSON.stringify({
|
|
||||||
type: 'submit_answer',
|
|
||||||
participant_id: participantId,
|
|
||||||
answer:optionIndex,
|
|
||||||
time_remaining: timeRemaining
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Timer
|
// Timer
|
||||||
function updateTimer() {
|
function updateTimer() {
|
||||||
|
|||||||
@@ -17,109 +17,52 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if request.session.mode != "learn" %}
|
||||||
|
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<h2 class="text-xl font-bold mb-4">Punktestand</h2>
|
<h2 class="text-xl font-bold mb-4">Punktestand</h2>
|
||||||
<div id="scoreboard" class="space-y-2">
|
<div class="space-y-2">
|
||||||
{% for participant in participants %}
|
{% for participant in participants %}
|
||||||
{% if participant == my_participant or is_host %}
|
{% if participant == my_participant or is_host %}
|
||||||
<div class="p-4 bg-gray-100 rounded-lg flex justify-between items-center border {% if forloop.counter <= 3 %}border-yellow-500{% else %}border-transparent{% endif %}">
|
|
||||||
<div>
|
<div class="p-4 {% if forloop.first %}bg-yellow-100 border-2 border-yellow-500{% else %}bg-gray-100{% endif %} rounded-lg flex justify-between items-center">
|
||||||
<p class="text-lg font-bold">
|
<div>
|
||||||
{% if forloop.counter == 1 %}
|
<p class="text-lg font-bold">{{ participant.display_name }}</p>
|
||||||
🥇
|
<p class="text-gray-600">{{ participant.score }} Punkte</p>
|
||||||
{% elif forloop.counter == 2 %}
|
|
||||||
🥈
|
|
||||||
{% elif forloop.counter == 3 %}
|
|
||||||
🥉
|
|
||||||
{% endif %}
|
|
||||||
{{ participant.display_name }}
|
|
||||||
</p>
|
|
||||||
<p class="text-gray-600">{{ participant.score }} Punkte</p>
|
|
||||||
</div>
|
|
||||||
{% if participant.last_answer_correct %}
|
|
||||||
<span class="text-green-500">✓</span>
|
|
||||||
{% elif participant.last_answer_correct == False %}
|
|
||||||
<span class="text-red-500">✗</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
{% if participant.last_answer_correct %}
|
||||||
|
<span class="text-green-500">✓</span>
|
||||||
|
{% elif participant.last_answer_correct == False %}
|
||||||
|
<span class="text-red-500">✗</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if is_host %}
|
|
||||||
{% if is_last_question %}
|
|
||||||
<button id="finish-button" class="w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
|
|
||||||
Quiz beenden
|
|
||||||
</button>
|
|
||||||
{% else %}
|
|
||||||
<button id="next-button" class="w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
|
|
||||||
Nächste Frage
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% if is_host %}
|
||||||
|
{% if is_last_question %}
|
||||||
|
<button id="finish-button" class="w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
|
||||||
|
Quiz beenden
|
||||||
|
</button>
|
||||||
|
{% else %}
|
||||||
|
<button id="next-button" class="w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
|
||||||
|
Nächste Frage
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
{% if is_last_question %}
|
|
||||||
<script>
|
|
||||||
// Hilfsfunktion für Pausen
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async function() {
|
|
||||||
const items = document.querySelectorAll('#scoreboard div');
|
|
||||||
const top3 = Array.from(items).slice(0, 3); // Nur die ersten 3 animieren
|
|
||||||
|
|
||||||
// Sofort Startzustände für Top3 setzen, die anderen sofort sichtbar
|
|
||||||
items.forEach((el, index) => {
|
|
||||||
if (index >= 3) {
|
|
||||||
el.style.opacity = '1';
|
|
||||||
el.style.transform = 'translateY(0)';
|
|
||||||
} else {
|
|
||||||
el.style.opacity = '0';
|
|
||||||
el.style.transform = 'translateY(20px)';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Warten bevor Animation startet
|
|
||||||
await sleep(1500); // <<< hier die 5 Sekunden Pause
|
|
||||||
|
|
||||||
// Transition-Eigenschaft setzen nach Render-Zyklus
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
top3.forEach(el => {
|
|
||||||
el.style.transition = 'all 0.8s ease';
|
|
||||||
});
|
|
||||||
|
|
||||||
// Animation für Top 3 starten – von Platz 3 zu 1
|
|
||||||
top3.reverse().forEach((el, index) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
el.style.opacity = '1';
|
|
||||||
el.style.transform = 'translateY(0)';
|
|
||||||
|
|
||||||
if (index === top3.length - 1) {
|
|
||||||
triggerConfetti();
|
|
||||||
}
|
|
||||||
}, index * 1500); // Zeitversetzt aufdecken
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function triggerConfetti() {
|
|
||||||
const end = Date.now() + 15 * 1000;
|
|
||||||
(function frame() {
|
|
||||||
confetti({ particleCount: 2, angle: 60, spread: 55, origin: { x: 0 } });
|
|
||||||
confetti({ particleCount: 2, angle: 120, spread: 55, origin: { x: 1 } });
|
|
||||||
if (Date.now() < end) requestAnimationFrame(frame);
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{% include 'play/game/common_scripts.html' %}
|
{% include 'play/game/common_scripts.html' %}
|
||||||
<script>
|
<script>
|
||||||
const joinCode = '{{ quiz_game.join_code }}';
|
const joinCode = '{{ quiz_game.join_code }}';
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
required
|
required
|
||||||
maxlength="20"
|
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"
|
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>
|
<p class="text-xs text-gray-500 mt-2">Maximal 20 Zeichen</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<span class="w-2 h-2 bg-green-500 rounded-full mr-2"></span>
|
<span class="w-2 h-2 bg-green-500 rounded-full mr-2"></span>
|
||||||
<span>Angemeldet als <b>{{ participant.display_name }}</b></span>
|
<span>Angemeldet als <b>{{ participant.display_name }}</b></span>
|
||||||
</div>
|
</div>
|
||||||
|
<a href="{% url 'play:create_participant' quiz_game.join_code %}">Auftreten ändern...</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
Teilnehmer
|
Teilnehmer
|
||||||
</h3>
|
</h3>
|
||||||
<ul id="participants-list" class="space-y-2 max-h-60">
|
<ul id="participants-list" class="space-y-2 max-h-60 overflow-y-auto">
|
||||||
<li class="text-gray-500 p-3 bg-gray-50 rounded-lg text-center">Warte auf Teilnehmer...</li>
|
<li class="text-gray-500 p-3 bg-gray-50 rounded-lg text-center">Warte auf Teilnehmer...</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,3 @@ daphne~=4.1.2 # ASGI server
|
|||||||
pillow~=11.1.0 # Image handling
|
pillow~=11.1.0 # Image handling
|
||||||
whitenoise~=6.6.0 # Static file serving
|
whitenoise~=6.6.0 # Static file serving
|
||||||
django-cleanup
|
django-cleanup
|
||||||
redis
|
|
||||||
channels_redis
|
|
||||||
djangorestframework #React integration
|
|
||||||
django-cors-headers #React integration
|
|
||||||
Reference in New Issue
Block a user