Compare commits
26 Commits
51-im-impr
...
testbranhc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e135ff945f | ||
|
|
fbb0787aa9 | ||
|
|
16fcaf6346 | ||
|
|
8a6d337392 | ||
|
|
5f4fd4345e | ||
|
|
7e93165c58 | ||
|
|
419160d144 | ||
|
|
0c6580e732 | ||
|
|
8f4b5d581d | ||
|
|
809d857e94 | ||
|
|
98142c91f3 | ||
|
|
93b2675b9e | ||
|
|
157daae740 | ||
|
|
f6459965e0 | ||
|
|
a3331543f2 | ||
|
|
9d71f2bbf3 | ||
|
|
8cceecf1bd | ||
|
|
c330c4bc70 | ||
|
|
26bf2a2c55 | ||
|
|
86958c6d16 | ||
|
|
83a3d1584a | ||
|
|
a07c66ad1a | ||
|
|
956e69b56f | ||
|
|
526e486fd3 | ||
|
|
b149cbcfee | ||
|
|
12c5cec7a1 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ db.sqlite3
|
||||
tailwindcss.exe
|
||||
t-style.css
|
||||
dump.rdb
|
||||
media
|
||||
node_modules
|
||||
@@ -100,10 +100,10 @@ npx @tailwindcss/cli -i <INPUT-DATEI> -o <OUTPUT-DATEI> --watch --minify
|
||||
|
||||
```sh
|
||||
# unter Linux mit Tailwind Binärdatei:
|
||||
tailwindcss -i core/static/homepage/t-input.css -o core/static/homepage/t-style.css --watch --minify
|
||||
tailwindcss -i static/css/t-input.css -o static/css/t-style.css --watch --minify
|
||||
|
||||
# unter Windows mit NPM:
|
||||
npx @tailwindcss/cli -i .\core\static\homepage\t-input.css -o .\core\static\homepage\t-style.css --watch --minify
|
||||
# unter Windows mit NPM (in bash mit '/' statt '\'):
|
||||
npx @tailwindcss/cli -i .\static\css\t-input.css -o .\static\css\t-style.css --watch --minify
|
||||
```
|
||||
|
||||
## Issue - Merge Request - Merge
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth import login, authenticate
|
||||
from .forms import RegisterForm
|
||||
|
||||
# Create your views here.
|
||||
@@ -11,8 +12,9 @@ def register(response):
|
||||
if response.method == "POST":
|
||||
form = RegisterForm(response.POST)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect("home")
|
||||
user=form.save()
|
||||
login(response, user) #automatischer Login nach Registrierung
|
||||
return redirect("accounts:home")
|
||||
else:
|
||||
form = RegisterForm()
|
||||
|
||||
|
||||
@@ -129,3 +129,7 @@ STATICFILES_DIRS = [BASE_DIR / 'static']
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
LOGIN_URL = '/account/login/'
|
||||
import os
|
||||
|
||||
MEDIA_URL = '/media/' # URL, um auf Medien-Dateien zuzugreifen
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') # Speicherort für hochgeladene Dateien
|
||||
|
||||
@@ -23,4 +23,5 @@ urlpatterns = [
|
||||
path('', include('homepage.urls')),
|
||||
path('play/', include('play.urls')),
|
||||
path('library/', include('library.urls')),
|
||||
path('components/', include('components.urls'))
|
||||
]
|
||||
|
||||
@@ -6,7 +6,6 @@ class QivipQuizAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'user_id', 'status', 'category', 'creation_date', 'update_date') # Welche Felder sollen in der Übersicht angezeigt werden
|
||||
search_fields = ('name', 'user_id__username', 'category__name') # Suchfelder
|
||||
list_filter = ('status', 'category') # Filteroptionen
|
||||
|
||||
# Für das QivipQuestion Modell
|
||||
class QivipQuestionAdmin(admin.ModelAdmin):
|
||||
list_display = ('quiz_id', 'data', 'creation_date', 'update_date')
|
||||
|
||||
@@ -4,9 +4,28 @@ from .models import QivipQuiz, QivipQuestion
|
||||
class QuizForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = QivipQuiz
|
||||
fields = ['name', 'description', 'status', 'category', 'tags',"difficulty"]
|
||||
fields = ['name', 'description','image', 'status', 'category', 'tags',"difficulty","credits"]
|
||||
|
||||
class QuestionForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = QivipQuestion
|
||||
fields = ['quiz_id', 'data']
|
||||
|
||||
from django import forms
|
||||
|
||||
class QuizFilterForm(forms.Form):
|
||||
search = forms.CharField(required=False, label="Suche", widget=forms.TextInput(attrs={
|
||||
'class': 'flex flex-grow rounded-lg p-2' ,'placeholder': 'Suche ...',
|
||||
}))
|
||||
|
||||
|
||||
min_amout_questions = forms.IntegerField(required=False, min_value=1, label="Minimale Anzahl an Fragen", widget=forms.NumberInput(attrs={
|
||||
'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
|
||||
}))
|
||||
|
||||
max_amout_questions = forms.IntegerField(required=False, min_value=1, label="Maximale Anzahl an Fragen", widget=forms.NumberInput(attrs={
|
||||
'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
|
||||
}))
|
||||
user = forms.CharField(required=False, label="von User", widget=forms.TextInput(attrs={
|
||||
'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
|
||||
}))
|
||||
|
||||
18
django/library/migrations/0023_qivipquiz_image.py
Normal file
18
django/library/migrations/0023_qivipquiz_image.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.7 on 2025-03-21 17:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0022_alter_qivipquiz_description_alter_qivipquiz_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='qivipquiz',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='quiz_images/'),
|
||||
),
|
||||
]
|
||||
18
django/library/migrations/0024_alter_qivipquiz_image.py
Normal file
18
django/library/migrations/0024_alter_qivipquiz_image.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.7 on 2025-03-22 10:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0023_qivipquiz_image'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='qivipquiz',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, max_length=256, null=True, upload_to='quiz_images/'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.7 on 2025-04-03 16:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0024_alter_qivipquiz_image'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='qivipquiz',
|
||||
name='modified_description',
|
||||
field=models.TextField(blank=True, default='Das Quiz wurde modifiziert von:', editable=False),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.7 on 2025-04-04 13:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0025_qivipquiz_modified_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='qivipquiz',
|
||||
name='modified_description',
|
||||
field=models.TextField(blank=True, editable=False),
|
||||
),
|
||||
]
|
||||
21
django/library/migrations/0027_qivipquiz_creator.py
Normal file
21
django/library/migrations/0027_qivipquiz_creator.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.1.7 on 2025-04-04 13:37
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0026_alter_qivipquiz_modified_description'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='qivipquiz',
|
||||
name='creator',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='creator_quiz', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
||||
21
django/library/migrations/0028_alter_qivipquiz_creator.py
Normal file
21
django/library/migrations/0028_alter_qivipquiz_creator.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.1.7 on 2025-04-04 13:57
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0027_qivipquiz_creator'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='qivipquiz',
|
||||
name='creator',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='creator_quiz', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
||||
18
django/library/migrations/0029_qivipquiz_credits.py
Normal file
18
django/library/migrations/0029_qivipquiz_credits.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.7 on 2025-04-04 16:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0028_alter_qivipquiz_creator'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='qivipquiz',
|
||||
name='credits',
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 5.1.7 on 2025-04-05 09:39
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('library', '0029_qivipquiz_credits'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='qivipquiz',
|
||||
name='creator',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='qivipquiz',
|
||||
name='modified_description',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='qivipquiz',
|
||||
name='base_quiz',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='child_quizzes', to='library.qivipquiz'),
|
||||
),
|
||||
]
|
||||
@@ -24,9 +24,11 @@ class QivipQuiz(models.Model):
|
||||
if value.strip() == "In dem Quiz geht es um ...":
|
||||
raise ValidationError("Bitte gib eine aussagekräftige Beschreibung ein.")
|
||||
|
||||
|
||||
image = models.ImageField(max_length=256, upload_to='quiz_images/', blank=True, null=True) # Bild speichern in media/quiz_images/
|
||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||
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')
|
||||
base_quiz = models.ForeignKey('self', on_delete=models.SET_NULL,blank=True, null=True, related_name='child_quizzes')
|
||||
creation_date = models.DateTimeField(auto_now_add=True)
|
||||
update_date = models.DateTimeField(auto_now=True)
|
||||
status = models.CharField(max_length=10, choices=list(STATUS_VALUES.items()), default="öffentlich")
|
||||
@@ -35,11 +37,13 @@ class QivipQuiz(models.Model):
|
||||
name = models.CharField(max_length=75)
|
||||
description = models.TextField(validators=[validate_description],max_length=200,blank=False, default="In dem Quiz geht es um ...")
|
||||
difficulty= models.CharField(max_length=13, choices=list(DIFFICULTY_VALUES.items()), default="nicht gesetzt", help_text="1: niedrigste Schwierigkeit und 5: höchste Schwierigkeit")
|
||||
|
||||
credits=models.TextField(blank=True, editable=True)
|
||||
def __str__(self):
|
||||
|
||||
return self.name
|
||||
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class QivipQuestion(models.Model):
|
||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
from django.conf import settings
|
||||
from . import views
|
||||
from django.conf.urls.static import static
|
||||
app_name = 'library'
|
||||
|
||||
urlpatterns = [
|
||||
@@ -12,4 +14,8 @@ urlpatterns = [
|
||||
path('question/new/', views.new_question, name='new_question'),
|
||||
path('question/edit/<int:pk>/', views.edit_question, name='edit_question'),
|
||||
path('question/delete/<int:pk>/', views.delete_question, name='delete_question'),
|
||||
]
|
||||
path('detail/copy/<int:pk>/', views.copy_quiz, name='copy_quiz'),
|
||||
|
||||
]# Nur für die Entwicklungsumgebung
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import uuid
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
@@ -7,29 +8,95 @@ from .models import QivipQuiz, QivipQuestion
|
||||
from .forms import QuizForm, QuestionForm
|
||||
import json
|
||||
from django.core.paginator import Paginator
|
||||
from .models import QivipQuiz
|
||||
from .forms import QuizFilterForm
|
||||
from django.db.models import Count
|
||||
from django.contrib.auth.models import User
|
||||
# Übersicht aller Quizze
|
||||
|
||||
def overview_quiz(request):
|
||||
try:
|
||||
quizzes = QivipQuiz.objects.filter(user_id=request.user)
|
||||
all_quizzes = QivipQuiz.objects.filter(status='öffentlich').exclude(user_id=request.user).filter(question__isnull=False).distinct()
|
||||
return render(request, 'library/overview_quiz.html', {'quizzes': quizzes, 'all_quizzes': all_quizzes})
|
||||
|
||||
#Filter
|
||||
form = QuizFilterForm(request.GET)
|
||||
|
||||
|
||||
try:
|
||||
|
||||
filter_my_quizzes = QivipQuiz.objects.filter(user_id=request.user).annotate(max_amout_questions=Count('question'))
|
||||
except:
|
||||
all_quizzes = QivipQuiz.objects.filter(status='öffentlich').filter(question__isnull=False).distinct()
|
||||
return render(request, 'library/overview_quiz.html', {'quizzes': None, 'all_quizzes': all_quizzes})
|
||||
filter_my_quizzes = QivipQuiz.objects.none()
|
||||
|
||||
filter_other_quizzes = QivipQuiz.objects.annotate(max_amout_questions=Count('question'))
|
||||
|
||||
|
||||
|
||||
if form.is_valid():
|
||||
search = form.cleaned_data.get('search')
|
||||
username= form.cleaned_data.get('user')
|
||||
max_amout_questions= form.cleaned_data.get('max_amout_questions')
|
||||
min_amout_questions= form.cleaned_data.get('min_amout_questions')
|
||||
if search: # Suche nach Namen
|
||||
filter_other_quizzes = filter_other_quizzes.filter(name__icontains=search)
|
||||
filter_my_quizzes = filter_my_quizzes.filter(name__icontains=search)
|
||||
|
||||
if min_amout_questions:
|
||||
filter_other_quizzes = filter_other_quizzes.filter(max_amout_questions__gte=min_amout_questions)
|
||||
try:
|
||||
filter_my_quizzes =filter_my_quizzes.filter(max_amout_questions__gte=min_amout_questions)
|
||||
except:
|
||||
filter_my_quizzes = QivipQuiz.objects.none()
|
||||
|
||||
if max_amout_questions:
|
||||
filter_other_quizzes = filter_other_quizzes.filter(max_amout_questions__lte=max_amout_questions)
|
||||
try:
|
||||
filter_my_quizzes =filter_my_quizzes.filter(max_amout_questions__lte=max_amout_questions)
|
||||
except:
|
||||
filter_my_quizzes = QivipQuiz.objects.none()
|
||||
|
||||
if username:
|
||||
try:
|
||||
user = User.objects.get(username=username) # Benutzer anhand des Namens holen
|
||||
filter_other_quizzes = filter_other_quizzes.filter(user_id=user.id)
|
||||
filter_my_quizzes = filter_my_quizzes.filter(user_id=user.id) # Nach der user_id filtern
|
||||
except User.DoesNotExist:
|
||||
filter_other_quizzes = QivipQuiz.objects.none() # Falls User nicht existiert, leere Query zurückgeben
|
||||
filter_my_quizzes = QivipQuiz.objects.none()
|
||||
|
||||
try:
|
||||
filter_other_quizzes=filter_other_quizzes.exclude(user_id=request.user)
|
||||
except:
|
||||
filter_other_quizzes=filter_other_quizzes
|
||||
|
||||
|
||||
|
||||
filter_other_quizzes = filter_other_quizzes.filter(max_amout_questions__gte=1).filter(status='öffentlich')
|
||||
|
||||
context = {
|
||||
'show_search': True,
|
||||
'filter_my_quizzes': filter_my_quizzes.order_by('-creation_date'),
|
||||
'filter_other_quizzes': filter_other_quizzes.order_by('-creation_date'),
|
||||
'form': form,
|
||||
}
|
||||
|
||||
|
||||
return render(request, 'library/overview_quiz.html', context)
|
||||
|
||||
|
||||
|
||||
|
||||
# Neues Quiz erstellen
|
||||
@login_required
|
||||
def new_quiz(request):
|
||||
if request.method == 'POST':
|
||||
form = QuizForm(request.POST)
|
||||
form = QuizForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
quiz = form.save(commit=False)
|
||||
quiz.user_id = request.user
|
||||
quiz.creator = request.user
|
||||
quiz.save()
|
||||
form.save_m2m() # Speichert die Many-to-Many Beziehungen (Tags)
|
||||
return redirect('library:edit_quiz', pk=quiz.pk)
|
||||
return redirect('library:detail_quiz', pk=quiz.pk)
|
||||
|
||||
else:
|
||||
form = QuizForm()
|
||||
return render(request, 'library/form.html', {'form': form})
|
||||
@@ -39,10 +106,13 @@ def new_quiz(request):
|
||||
def edit_quiz(request, pk):
|
||||
quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
||||
if request.method == 'POST':
|
||||
form = QuizForm(request.POST, instance=quiz)
|
||||
form = QuizForm(request.POST, instance=quiz, files=request.FILES)
|
||||
if form.is_valid():
|
||||
|
||||
form.save()
|
||||
return redirect('library:overview_quiz')
|
||||
return redirect('library:detail_quiz', pk=pk)
|
||||
#return modified(request, pk)
|
||||
|
||||
else:
|
||||
form = QuizForm(instance=quiz)
|
||||
return render(request, 'library/form.html', {'form': form})
|
||||
@@ -57,9 +127,9 @@ def delete_quiz(request, pk):
|
||||
return render(request, 'library/delete_confirmation.html', {'object': quiz})
|
||||
|
||||
# Quiz anzeigen
|
||||
@login_required
|
||||
def detail_quiz(request, pk):
|
||||
quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
||||
#quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
|
||||
quiz = get_object_or_404(QivipQuiz, pk=pk)
|
||||
questions = QivipQuestion.objects.filter(quiz_id=quiz)
|
||||
|
||||
# Parse JSON data for each question
|
||||
@@ -72,6 +142,63 @@ def detail_quiz(request, pk):
|
||||
'questions': questions
|
||||
}
|
||||
return render(request, 'library/detail_quiz.html', context)
|
||||
"""
|
||||
def modified(request, pk):
|
||||
|
||||
original_quiz = get_object_or_404(QivipQuiz, pk=pk)
|
||||
words=original_quiz.modified_description.split()
|
||||
word_exist=0
|
||||
print(original_quiz.creator.username)
|
||||
print(request.user.username)
|
||||
|
||||
for word in words:
|
||||
|
||||
if word==request.user.username or word+","==request.user.username:
|
||||
word_exist=1
|
||||
|
||||
|
||||
if word_exist==0 and len(words)!=0 and request.user.username!=original_quiz.creator.username:
|
||||
original_quiz.modified_description +=", "+ request.user.username
|
||||
|
||||
|
||||
elif word_exist==0 and request.user.username!=original_quiz.creator.username:
|
||||
original_quiz.modified_description +=" "+ request.user.username
|
||||
|
||||
original_quiz.save()
|
||||
|
||||
return redirect('library:detail_quiz', pk=pk)
|
||||
|
||||
"""
|
||||
|
||||
@login_required
|
||||
def copy_quiz(request, 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)
|
||||
|
||||
new_quiz = original_quiz # Kopie erstellen (aber Achtung: Noch gleiche Referenz!)
|
||||
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.user_id = request.user # Neuer Besitzer ist der aktuelle User
|
||||
new_quiz.name += " - Kopie" # Optional: Name anpassen
|
||||
new_quiz.base_quiz_id = pk
|
||||
#new_quiz.creator = original_quiz.creator or request.user
|
||||
new_quiz.save() # Speichern als neues Objekt
|
||||
# Optional: Beschreibung anpassen
|
||||
# Alle zugehörigen Fragen kopieren
|
||||
questions = QivipQuestion.objects.filter(quiz_id=pk)
|
||||
for question in questions:
|
||||
question.uuid = uuid.uuid4()
|
||||
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.data = question.data # `data`-Feld wird explizit übernommen # Verknüpfe mit dem neuen Quiz
|
||||
question.save()
|
||||
|
||||
return redirect('library:detail_quiz', pk=new_quiz.pk)
|
||||
|
||||
|
||||
# Übersicht aller Fragen
|
||||
@login_required
|
||||
@@ -147,6 +274,7 @@ def new_question(request):
|
||||
question.data = json.dumps(json_data)
|
||||
question.quiz_id = quiz
|
||||
question.save()
|
||||
#return modified(request, pk=quiz.pk)
|
||||
return redirect('library:detail_quiz', pk=quiz.pk)
|
||||
else:
|
||||
# Initialize empty question data for new questions
|
||||
@@ -275,7 +403,9 @@ def edit_question(request, pk):
|
||||
|
||||
question.data = json.dumps(json_data)
|
||||
question.save()
|
||||
#return modified(request, question.quiz_id.pk)
|
||||
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
||||
|
||||
else:
|
||||
template_name = f'library/question/question_{question_type}.html'
|
||||
context = {
|
||||
@@ -286,6 +416,7 @@ def edit_question(request, pk):
|
||||
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
# Frage löschen
|
||||
@login_required
|
||||
def delete_question(request, pk):
|
||||
|
||||
35
django/package-lock.json
generated
Normal file
35
django/package-lock.json
generated
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "django",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "django",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"swiper": "^11.2.6"
|
||||
}
|
||||
},
|
||||
"node_modules/swiper": {
|
||||
"version": "11.2.6",
|
||||
"resolved": "https://registry.npmjs.org/swiper/-/swiper-11.2.6.tgz",
|
||||
"integrity": "sha512-8aXpYKtjy3DjcbzZfz+/OX/GhcU5h+looA6PbAzHMZT6ESSycSp9nAjPCenczgJyslV+rUGse64LMGpWE3PX9Q==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/swiperjs"
|
||||
},
|
||||
{
|
||||
"type": "open_collective",
|
||||
"url": "http://opencollective.com/swiper"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
django/package.json
Normal file
15
django/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "django",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"swiper": "^11.2.6"
|
||||
}
|
||||
}
|
||||
13
django/static/swiper/swiper-bundle.min.css
vendored
Normal file
13
django/static/swiper/swiper-bundle.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
14
django/static/swiper/swiper-bundle.min.js
vendored
Normal file
14
django/static/swiper/swiper-bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@
|
||||
{% load static %}
|
||||
{% block title %}Antwort{% endblock %}
|
||||
{% block content %}
|
||||
<link rel="stylesheet" href="{% static 'homepage/t-style.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'css/t-style.css' %}">
|
||||
|
||||
<!-- TODO Bedingung festlegen: Quiztyp unterscheiden % if <Bedingung> % -->
|
||||
{% if user.is_authenticated %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% load static %}
|
||||
<link rel="stylesheet" href="{% static 'homepage/t-style.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'css/t-style.css' %}">
|
||||
<!doctype html>
|
||||
<html class="h-full">
|
||||
<head>
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<div class="grid place-content-center md:h-screen h-150 w-full -z-50 top-0 p-4">
|
||||
<div class="text-center">
|
||||
<h2 class="font-bold md:text-8xl text-6xl md:mb-8 text-blue-600">qivip</h2>
|
||||
<h3 class="italic font-extralight sm:text-2xl text-md">Interaktives Lernen neu definiert.</h3>
|
||||
<h3 class="mt-4 italic font-extralight sm:text-2xl text-md">Interaktives Lernen neu definiert.</h3>
|
||||
</div>
|
||||
<div class="grid sm:grid-cols-3 place-items-stretch text-center mt-8 gap-4 p-4 border-3 bg-blue-100 border-blue-100 rounded-md">
|
||||
<a class="qp-a-button bg-green-500 text-white" href="{% url 'play:join_game' %}">Teilnehmen</a>
|
||||
<a class="qp-a-button bg-indigo-500 text-white" href="#">Moderieren</a>
|
||||
<a class="qp-a-button bg-indigo-500 text-white" href="{% url 'library:overview_quiz' %}">Moderieren</a>
|
||||
<a class="qp-a-button bg-purple-500 text-white" href="{% url 'library:new_quiz' %}">Erstellen</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="input-group p-4 m-2 border-blue-600 border-2 rounded-xl shadow-md">
|
||||
<div class="grid place-content-center h-120">
|
||||
|
||||
<h1 class="text-center m-4 text-3xl lg:text-6xl">Datenschutzerklärung</b></h1>
|
||||
<h1 class="text-center m-4 text-3xl lg:text-6xl">Datenschutz-</br>erklärung</h1>
|
||||
Hier muss die Datenschutzerklärung stehen! <br>
|
||||
<br>
|
||||
|
||||
|
||||
@@ -1,32 +1,53 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<div class="container mx-auto px-4">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h1 class="text-2xl font-bold">{{ quiz.name }}</h1>
|
||||
<div class="flex space-x-2">
|
||||
<a href="{% url 'library:edit_quiz' quiz.id %}" class=" text-white px-4 py-2 rounded-md text-sm lg:text-lg hover:scale-110 transition-colors">✏</a>
|
||||
<a href="{% url 'library:delete_quiz' quiz.id %}" class=" text-white px-4 py-2 rounded-md text-sm lg:text-lg hover:scale-110 transition-colors">🗑</a>
|
||||
{% if quiz.user_id == request.user %}
|
||||
<a href="{% url 'library:edit_quiz' quiz.id %}" class=" text-white px-4 py-2 rounded-md text-sm lg:text-lg hover:scale-110 transition-colors">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7 text-gray-600">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
|
||||
</svg>
|
||||
|
||||
</a>
|
||||
<a href="{% url 'library:delete_quiz' quiz.id %}" class=" text-white px-4 py-2 rounded-md text-sm lg:text-lg hover:scale-110 transition-colors">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7 text-gray-600">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
||||
</svg>
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'library:copy_quiz' quiz.id %}" class="flex items-center qp-a-button-small border-2 border-blue-600 text-gray-600 font-bold drop-shadow-lg custom-outline">Quiz kopieren</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if quiz.description %}
|
||||
<p class="text-gray-600 mb-8">{{ quiz.description }}</p>
|
||||
<p class="text-gray-600 mb-4">{{ quiz.description }}</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md border-blue-600 border-2 rounded-xl shadow-md">
|
||||
<div class="border-b border-gray-200 p-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<h2 class="text-xl font-semibold">Fragen</h2>
|
||||
<div class="flex space-x-2">
|
||||
{% if quiz.user_id == request.user %}
|
||||
<a href="{% url 'library:new_question' %}?type=multiple_choice&quiz_id={{ quiz.id }}"
|
||||
class="bg-blue-100 text-blue-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
|
||||
Multiple Choice
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if quiz.user_id == request.user %}
|
||||
<a href="{% url 'library:new_question' %}?type=true_false&quiz_id={{ quiz.id }}"
|
||||
class="bg-purple-100 text-purple-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
|
||||
Wahr/Falsch
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,7 +58,7 @@
|
||||
{% for question in questions %}
|
||||
|
||||
<div class="w-full rounded-xl p-4 hover:bg-gray-50">
|
||||
<a class="block flex h-full w-full" href="{% url 'library:edit_question' question.id %}" >
|
||||
{% if quiz.user_id == request.user %} <a class="block flex h-full w-full" href="{% url 'library:edit_question' question.id %}" > {% endif %}
|
||||
<div class="flex justify-between items-start">
|
||||
|
||||
<div class="flex-grow">
|
||||
@@ -80,16 +101,14 @@
|
||||
</div>
|
||||
|
||||
<div class="flex h-full space-x-2 ml-4 items-center">
|
||||
<!--
|
||||
<a href="{% url 'library:edit_question' question.id %}"
|
||||
class="bg-gray-100 text-gray-700 px-3 py-1 rounded hover:bg-gray-200 transition-colors">
|
||||
Bearbeiten
|
||||
</a>
|
||||
-->
|
||||
|
||||
<a href=" {% url 'library:delete_question' question.id %}"
|
||||
class=" text-red-700 px-4 py-1 rounded hover:scale-110 ">
|
||||
🗑
|
||||
{% if quiz.user_id == request.user %}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7 text-gray-600">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
||||
</svg>
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
</div>
|
||||
@@ -110,5 +129,23 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
{% if quiz.base_quiz %}
|
||||
<p class="text-gray-600 mt-2 ">Kopie von: <a href="{% url 'library:detail_quiz' quiz.base_quiz.id %}"><span class="font-bold">{{ quiz.base_quiz}}</span></a></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
{% if quiz.base_quiz %}
|
||||
<p class="text-gray-600 mb-2">Autor:<span class="font-bold"> {{ quiz.base_quiz.user_id}}</span></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
{% if quiz.credits %}
|
||||
<p class="text-gray-600 mb-2">Credits:<span class="font-bold"> {{ quiz.credits }}</span></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="input-group border-blue-600 border-2 rounded-xl shadow-md mt-12">
|
||||
<form method="post">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">Speichern</button>
|
||||
|
||||
@@ -1,61 +1,226 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% load static %}
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="{% static 'swiper/swiper-bundle.min.css' %}">
|
||||
<style>
|
||||
|
||||
|
||||
|
||||
|
||||
.swiper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.swiper-slide {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<div class="flex justify-end mr-2">
|
||||
<a href="{% url 'library:new_quiz' %}" class="mt-2 p-2 shadow-md border-blue-600 border-2 rounded-md text-black mb-12">Neues Quiz erstellen</a>
|
||||
<a href="{% url 'library:new_quiz' %}" class="mt-2 p-2 shadow-md border-blue-600 border-2 rounded-md text-black ">Neues Quiz erstellen</a>
|
||||
</div>
|
||||
{% if quizzes %}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 px-4 place-items-center">
|
||||
<h1 class="font-bold mb-4 px-4 bg-blue-100">meine eigenen Quiz</h1></div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 px-4 place-items-center">
|
||||
{% for quiz in quizzes %}
|
||||
<div class="bg-white w-full max-w-md rounded-lg p-4 shadow-md border-blue-600 border-2 rounded-xl h-80 ">
|
||||
<h2 class="text-lg font-bold break-words truncate"><a href="{% url 'library:edit_quiz' quiz.id %}">{{ quiz.name }}</a></h2>
|
||||
<p class="text-sm text-gray-600 pt-11 h-54"><span class="break-words line-clamp-2">{{ quiz.description }} </span><br> Status: <span class="font-bold">{{ quiz.status }}</span>
|
||||
<br> Schwierigkeit:<span class="font-bold"> {{ quiz.difficulty }}</span>
|
||||
<br> Anzahl der Fragen:<span class="font-bold"> {{ quiz.question.count }}</span> </p>
|
||||
<div class="flex justify-end mr-2">
|
||||
<a href="{% url 'library:overview_quiz' %}" class="mt-2 p-2 shadow-md border-blue-600 border-2 rounded-md text-black ">Suche und Filter zurücksetzen</a>
|
||||
</div>
|
||||
|
||||
<div class="w-screen flex justify-center items-center">
|
||||
<div class="w-full m-4 border-blue-600 border-2 rounded-xl shadow-md p-6 lg:w-1/4">
|
||||
<form method="get" class="flex flex-col space-y-4">
|
||||
<h1 class="text-xl font-bold">Filter</h1>
|
||||
Minimale Anzahl an Fragen {{ form.min_amout_questions }}
|
||||
Maximale Anzahl an Fragen {{ form.max_amout_questions }}
|
||||
von User {{ form.user }}
|
||||
<!-- Rendert die Form-Felder -->
|
||||
<button type="submit" class="qp-a-button-small border-2 border-blue-600 text-black">Filtern</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Swiper Container für eigene Quiz -->
|
||||
{% if filter_my_quizzes %}
|
||||
<div class="text-center m-8 bg-blue-600 grid mx-8 h-8 place-items-center rounded-xl shadow-md ">
|
||||
<h1 id="my-quizzes" class="flex px-4 font-bold text-white">Eigene Quiz</h1>
|
||||
</div>
|
||||
|
||||
<div class="swiper mySwiper">
|
||||
<div class="swiper-wrapper">
|
||||
{% for quiz in filter_my_quizzes %}
|
||||
<div class="swiper-slide">
|
||||
<div class="relative h-80 bg-white bg-cover text-white w-full max-w-md rounded-lg p-4 shadow-md border-blue-600 border-2 rounded-xl flex flex-col justify-between"
|
||||
{% if quiz.image %} style="background-image: url('http://127.0.0.1:8000/library{{ quiz.image.url }}');" {% endif %}>
|
||||
<div class="absolute inset-0 bg-gray-900/60 bg-opacity-50 rounded-lg"></div>
|
||||
|
||||
<h2 class=" break-words truncate text-white drop-shadow-lg custom-outline"> <a href="{% url 'library:detail_quiz' quiz.id %}">{{ quiz.name }}</a></h2>
|
||||
|
||||
<p class="text-white font-bold text-white drop-shadow-lg custom-outline">
|
||||
<span class="break-words line-clamp-2 ">{{ quiz.description }}</span><br>
|
||||
Schwierigkeit: <span class="font-bold">{{ quiz.difficulty }}</span><br>
|
||||
Anzahl der Fragen: <span class="font-bold ">{{ quiz.question.count }}</span><br>
|
||||
Status: <span class="font-bold ">{{ quiz.status }}</span>
|
||||
|
||||
|
||||
<div>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<a href="#" class="qp-a-button-small border-2 border-blue-600 text-black">Spiel starten</a>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<a href="{% url 'library:detail_quiz' quiz.id %}" class="qp-a-button-small border-2 border-blue-600 text-white">✏</a>
|
||||
<a href="{% url 'library:delete_quiz' quiz.id %}" class="qp-a-button-small border-2 border-blue-600 text-white">🗑</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class=" font-bold break-words truncate text-white drop-shadow-lg custom-outline">
|
||||
{% if quiz.authors.all %}
|
||||
Autor(en):
|
||||
{% for author in quiz.authors.all %}
|
||||
|
||||
{{ author.username }}{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</p>
|
||||
|
||||
<!-- Buttons bleiben am unteren Rand -->
|
||||
<div class="flex justify-between items-center gap-2 ">
|
||||
<a href="#" class="qp-a-button-small border-2 border-blue-600 text-white font-bold text-white drop-shadow-lg custom-outline">Spiel starten</a>
|
||||
<div class="flex gap-2">
|
||||
<a href="{% url 'library:detail_quiz' quiz.id %}" class="qp-a-button-small border-2 border-blue-600 text-white font-bold drop-shadow-lg custom-outline">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
|
||||
</svg>
|
||||
</a>
|
||||
<a href="{% url 'library:delete_quiz' quiz.id %}" class="qp-a-button-small border-2 border-blue-600 text-white text-white font-bold text-white drop-shadow-lg custom-outline">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
||||
</svg>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
||||
{% if filter_my_quizzes|length > 1 %}
|
||||
<div class="swiper-button-next"></div>
|
||||
<div class="swiper-button-prev"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 px-4 place-items-center">
|
||||
<h1 class="font-bold px-4 bg-blue-100 mt-8 mb-4">Quiz von anderen Nutzern</h1></div>
|
||||
<!-- Swiper Container für Quiz von anderen Nutzern -->
|
||||
{% if filter_other_quizzes %}
|
||||
<div class="text-center m-8 bg-blue-600 grid mx-8 h-8 place-items-center rounded-xl shadow-md">
|
||||
<h1 id="other-quizzes" class="flex px-4 font-bold text-white">Quiz von anderen Nutzern</h1>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 px-4 place-items-center">
|
||||
{% for quiz in all_quizzes %}
|
||||
<div class="swiper mySwiper">
|
||||
<div class="swiper-wrapper">
|
||||
|
||||
<div class="h-80 bg-white w-full max-w-md rounded-lg p-4 shadow-md border-blue-600 border-2 rounded-xl ">
|
||||
<h2 class="text-lg font-bold break-words truncate">{{ quiz.name }}</h2>
|
||||
<p class="text-sm text-gray-600 pt-11 h-54"><span class="break-words line-clamp-2">{{ quiz.description }} </span> <br> Schwierigkeit:<span class="font-bold ">
|
||||
{{ quiz.difficulty }}</span><br> Anzahl der Fragen:<span class="font-bold"> {{ quiz.question.count }}</span>
|
||||
<br>Erstmalig erstellt am:<span class="font-bold"> {{ quiz.creation_date }}</span>
|
||||
|
||||
{% for quiz in filter_other_quizzes %}
|
||||
<div class="swiper-slide">
|
||||
<div class="relative h-80 bg-white bg-cover text-white w-full max-w-md rounded-lg p-4 shadow-md border-blue-600 border-2 rounded-xl flex flex-col justify-between"
|
||||
{% if quiz.image %} style="background-image: url('http://127.0.0.1:8000/library{{ quiz.image.url }}');" {% endif %}>
|
||||
<div class="absolute inset-0 bg-gray-900/60 bg-opacity-50 rounded-lg"></div>
|
||||
|
||||
<h2 class="break-words truncate text-white drop-shadow-lg custom-outline"> <a href="{% url 'library:detail_quiz' quiz.id %}">{{ quiz.name }}</a></h2>
|
||||
|
||||
<p class="text-white font-bold text-white drop-shadow-lg custom-outline">
|
||||
<span class="break-words line-clamp-2 ">{{ quiz.description }}</span><br>
|
||||
Schwierigkeit: <span class="font-bold">{{ quiz.difficulty }}</span><br>
|
||||
Anzahl der Fragen: <span class="font-bold ">{{ quiz.question.count }}</span><br>
|
||||
Erstellt am: <span class="font-bold ">{{ quiz.creation_date }}</span>
|
||||
</p>
|
||||
<div>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<a href="#" class="qp-a-button-small border-2 border-blue-600 text-black">Spiel starten</a>
|
||||
{% if quiz.original_creator %}
|
||||
<p class=" font-bold break-words truncate text-white drop-shadow-lg custom-outline">Ursprünglich erstellt von: {{ quiz.original_creator }}</p>
|
||||
{% endif %}
|
||||
|
||||
<!-- Buttons bleiben am unteren Rand -->
|
||||
<div class="flex justify-between items-center gap-2 ">
|
||||
<a href="#" class="qp-a-button-small border-2 border-blue-600 text-white font-bold text-white drop-shadow-lg custom-outline">Spiel starten</a>
|
||||
<a href="{% url 'library:detail_quiz' quiz.id %}" class="qp-a-button-small border-2 border-blue-600 text-white text-white font-bold text-white drop-shadow-lg custom-outline">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
|
||||
</svg>
|
||||
|
||||
</a>
|
||||
<div class="flex gap-2">
|
||||
<a href="{% url 'library:overview_quiz' %}?user={{ quiz.user_id }}" class="qp-a-button-small border-2 border-blue-600 text-white font-bold drop-shadow-lg custom-outline">
|
||||
|
||||
<div class="qp-a-button-small text-gray-600 text-sm "> Quiz von {{ quiz.user_id }}</div>
|
||||
<button type="submit" class=" text-sm py-1 text-white font-bold drop-shadow-lg custom-outline"> veröffentlicht von {{ quiz.user_id }}</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% if filter_other_quizzes|length > 1 %}
|
||||
<div class="swiper-button-next"></div>
|
||||
<div class="swiper-button-prev"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not filter_other_quizzes and not filter_my_quizzes %}
|
||||
<div class="grid text-center font-bold items-center">Es wurde kein Quiz passendes gefunden!</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
<!-- Swiper.js -->
|
||||
<script src="{% static 'swiper/swiper-bundle.min.js' %}"></script>
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
var swiper = new Swiper('.swiper', {
|
||||
slidesPerView: getSlidesPerView(),
|
||||
direction: getDirection(),
|
||||
navigation: {
|
||||
nextEl: '.swiper-button-next',
|
||||
prevEl: '.swiper-button-prev',
|
||||
},
|
||||
on: {
|
||||
resize: function () {
|
||||
swiper.changeDirection(getDirection());
|
||||
swiper.params.slidesPerView = getSlidesPerView();
|
||||
swiper.update();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function getDirection() {
|
||||
return window.innerWidth <= 0? 'vertical' : 'horizontal';
|
||||
}
|
||||
|
||||
function getSlidesPerView() {
|
||||
if (window.innerWidth <= 840) {
|
||||
return 1; // Smartphones
|
||||
} else if (window.innerWidth <= 1024) {
|
||||
return 2; // Tablets
|
||||
} else {
|
||||
return 3; // Desktops
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.custom-outline {
|
||||
-webkit-text-stroke: 0.2px rgb(0, 0, 0); /* Schwarze Umrandung */
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,10 +1,29 @@
|
||||
<nav class="flex justify-between bg-blue-600 h-12 px-4 sm:px-6 lg:px-8 rounded-lg m-2 shadow-md">
|
||||
<div class="flex items-center">
|
||||
<h2 class="text-xl font-bold text-white hover:scale-110 transition duration-200"><a href="{% url 'homepage:home' %}">qivip</a></h2>
|
||||
<nav class="flex justify-between items-center bg-blue-600 h-12 px-4 sm:px-6 lg:px-8 rounded-lg m-2 shadow-md overflow-x-auto whitespace-nowrap">
|
||||
<div class="flex items-center flex-shrink-0">
|
||||
<h2 class="text-xl font-bold text-white hover:scale-110 transition duration-200">
|
||||
<a href="{% url 'homepage:home' %}">qivip</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
|
||||
{% if show_search %}
|
||||
<form method="get" class="mr-2 ml-2 flex items-center w-full 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="w-full px-3 py-1 text-black bg-transparent focus:outline-none">
|
||||
<button type="submit" 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-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>
|
||||
{% endif %}
|
||||
|
||||
<div class="flex items-center space-x-4">
|
||||
<ul class="flex space-x-4 qp-nav-list">
|
||||
{% if show_search %}
|
||||
<li class="hidden md:flex"><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 %}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
django~=5.1.4
|
||||
channels~=4.2.0
|
||||
daphne~=4.1.2
|
||||
pillow~=11.1.0
|
||||
Reference in New Issue
Block a user