From f405016f9670c51194673f7c627a5353eeb66e9d Mon Sep 17 00:00:00 2001 From: nik8 Date: Wed, 9 Apr 2025 14:22:46 +0200 Subject: [PATCH] zwischenstand --- django/library/forms.py | 2 +- .../0033_qivipquestion_time_per_question.py | 18 ++++++++++++++++++ ...34_alter_qivipquestion_time_per_question.py | 18 ++++++++++++++++++ ...35_alter_qivipquestion_time_per_question.py | 18 ++++++++++++++++++ django/library/models.py | 15 ++++++++++++++- .../question/question_multiple_choice.html | 1 - 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 django/library/migrations/0033_qivipquestion_time_per_question.py create mode 100644 django/library/migrations/0034_alter_qivipquestion_time_per_question.py create mode 100644 django/library/migrations/0035_alter_qivipquestion_time_per_question.py diff --git a/django/library/forms.py b/django/library/forms.py index c454b71..b5ab887 100644 --- a/django/library/forms.py +++ b/django/library/forms.py @@ -9,7 +9,7 @@ class QuizForm(forms.ModelForm): class QuestionForm(forms.ModelForm): class Meta: model = QivipQuestion - fields = ['quiz_id', 'data'] + fields = ['quiz_id', 'data', 'time_per_question'] from django import forms diff --git a/django/library/migrations/0033_qivipquestion_time_per_question.py b/django/library/migrations/0033_qivipquestion_time_per_question.py new file mode 100644 index 0000000..fd5a7a1 --- /dev/null +++ b/django/library/migrations/0033_qivipquestion_time_per_question.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.7 on 2025-04-08 14:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('library', '0032_qivipquiz_average_rating_qivipquiz_rating_count_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='qivipquestion', + name='time_per_question', + field=models.CharField(choices=[('10', 10), ('15', 15), ('30', 30), ('60', 60), ('90', 90), ('120', 120), ('180', 180), ('nicht gesetzt', 'nicht gesetzt')], default=30, help_text='Zeit pro Frage in Sekunden', max_length=13), + ), + ] diff --git a/django/library/migrations/0034_alter_qivipquestion_time_per_question.py b/django/library/migrations/0034_alter_qivipquestion_time_per_question.py new file mode 100644 index 0000000..3c50abb --- /dev/null +++ b/django/library/migrations/0034_alter_qivipquestion_time_per_question.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.7 on 2025-04-08 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('library', '0033_qivipquestion_time_per_question'), + ] + + operations = [ + migrations.AlterField( + model_name='qivipquestion', + name='time_per_question', + field=models.CharField(choices=[('10', 10), ('15', 15), ('30', 30), ('60', 60), ('90', 90), ('120', 120), ('180', 180)], default=30, help_text='Zeit pro Frage in Sekunden', max_length=13), + ), + ] diff --git a/django/library/migrations/0035_alter_qivipquestion_time_per_question.py b/django/library/migrations/0035_alter_qivipquestion_time_per_question.py new file mode 100644 index 0000000..b8825eb --- /dev/null +++ b/django/library/migrations/0035_alter_qivipquestion_time_per_question.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.7 on 2025-04-08 14:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('library', '0034_alter_qivipquestion_time_per_question'), + ] + + operations = [ + migrations.AlterField( + model_name='qivipquestion', + name='time_per_question', + field=models.CharField(choices=[('10', 10), ('15', 15), ('30', 30), ('60', 60), ('90', 90), ('120', 120), ('180', 180)], default=30, help_text='Zeit pro Frage in Sekunden', max_length=3), + ), + ] diff --git a/django/library/models.py b/django/library/models.py index ceb2eb5..db3acba 100644 --- a/django/library/models.py +++ b/django/library/models.py @@ -19,6 +19,9 @@ class QivipQuiz(models.Model): "nicht gesetzt":"nicht gesetzt", } + + + def validate_description(value): if value.strip() == "In dem Quiz geht es um ...": @@ -48,12 +51,22 @@ class QivipQuiz(models.Model): # Create your models here. class QivipQuestion(models.Model): + + TIME_VALUES = { + "10": 10, + "15": 15, + "30": 30, + "60": 60, + "90": 90, + "120": 120, + "180": 180, + } uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) quiz_id = models.ForeignKey(QivipQuiz, on_delete=models.CASCADE, related_name='questions') creation_date = models.DateTimeField(auto_now_add=True) update_date = models.DateTimeField(auto_now=True) 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") def __str__(self): return self.data[:50] diff --git a/django/templates/library/question/question_multiple_choice.html b/django/templates/library/question/question_multiple_choice.html index 40eb00a..4b0587c 100644 --- a/django/templates/library/question/question_multiple_choice.html +++ b/django/templates/library/question/question_multiple_choice.html @@ -9,7 +9,6 @@ Zurück zum Quiz -
{% csrf_token %}