diff --git a/django/library/forms.py b/django/library/forms.py index 1a5ad63..b0a75de 100644 --- a/django/library/forms.py +++ b/django/library/forms.py @@ -4,7 +4,7 @@ from .models import QivipQuiz, QivipQuestion class QuizForm(forms.ModelForm): class Meta: model = QivipQuiz - fields = ['name', 'description','image', 'status', 'category', 'tags',"difficulty","credits"] + fields = ['name', 'description','image', 'status', 'category', 'tags','difficulty','credits'] class QuestionForm(forms.ModelForm): class Meta: diff --git a/django/library/models.py b/django/library/models.py index db3acba..8f0c8eb 100644 --- a/django/library/models.py +++ b/django/library/models.py @@ -66,7 +66,7 @@ class QivipQuestion(models.Model): 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") + 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/library/views.py b/django/library/views.py index 5f16d54..83c209f 100644 --- a/django/library/views.py +++ b/django/library/views.py @@ -283,6 +283,7 @@ def new_question(request): question = QivipQuestion() question.data = json.dumps(json_data) question.quiz_id = quiz + question.time_per_question = request.POST.get('time_per_question', '30') question.save() #return modified(request, pk=quiz.pk) return redirect('library:detail_quiz', pk=quiz.pk) @@ -297,6 +298,7 @@ def new_question(request): {'value': 'Falsch', 'is_correct': False} ] } + standard_time_per_question = 30 elif question_type == 'multiple_choice': question_data = { 'type': question_type, @@ -306,12 +308,14 @@ def new_question(request): {'value': '', 'is_correct': False} ] } + standard_time_per_question = 30 template_name = f'library/question/question_{question_type}.html' context = { 'question': question_data, 'quiz_id': quiz_id, - 'quiz': quiz + 'quiz': quiz, + 'standard_time_per_question': standard_time_per_question, } return render(request, template_name, context) @@ -412,6 +416,7 @@ def edit_question(request, pk): } question.data = json.dumps(json_data) + question.time_per_question = request.POST.get('time_per_question', '30') question.save() #return modified(request, question.quiz_id.pk) return redirect('library:detail_quiz', pk=question.quiz_id.pk) @@ -421,7 +426,8 @@ def edit_question(request, pk): context = { 'question': {'data': question_data}, # Wrap in data structure expected by template 'quiz_id': question.quiz_id.pk, - 'quiz': question.quiz_id + 'quiz': question.quiz_id, + 'time_per_question': question.time_per_question, } return render(request, template_name, context) diff --git a/django/templates/library/question/question_multiple_choice.html b/django/templates/library/question/question_multiple_choice.html index 4b0587c..7a9c0d4 100644 --- a/django/templates/library/question/question_multiple_choice.html +++ b/django/templates/library/question/question_multiple_choice.html @@ -91,6 +91,19 @@ +
+ + +
+
diff --git a/django/templates/library/question/question_true_false.html b/django/templates/library/question/question_true_false.html index d5ce70d..8c8bd84 100644 --- a/django/templates/library/question/question_true_false.html +++ b/django/templates/library/question/question_true_false.html @@ -43,6 +43,19 @@
+
+ + +
+