diff --git a/django/library/admin.py b/django/library/admin.py index 700000b..663fdf7 100644 --- a/django/library/admin.py +++ b/django/library/admin.py @@ -8,7 +8,7 @@ class QivipQuizAdmin(admin.ModelAdmin): list_filter = ('status', 'category') # Filteroptionen # Für das QivipQuestion Modell class QivipQuestionAdmin(admin.ModelAdmin): - list_display = ('id', 'quiz_id', 'data', 'creation_date', 'update_date') + list_display = ('id', 'quiz_id', 'data', 'creation_date', 'update_date', 'credits') search_fields = ('data',) list_filter = ('quiz_id',) diff --git a/django/library/migrations/0054_qivipquestion_credits.py b/django/library/migrations/0054_qivipquestion_credits.py new file mode 100644 index 0000000..8e39735 --- /dev/null +++ b/django/library/migrations/0054_qivipquestion_credits.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.7 on 2025-06-13 16:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('library', '0053_questionimage_quizimage_alter_qivipquestion_image_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='qivipquestion', + name='credits', + field=models.TextField(blank=True), + ), + ] diff --git a/django/library/models.py b/django/library/models.py index 9b17d6f..eb1b3de 100644 --- a/django/library/models.py +++ b/django/library/models.py @@ -98,6 +98,7 @@ class QivipQuestion(models.Model): on_delete=models.PROTECT, related_name="questions" ) + credits=models.TextField(blank=True, editable=True) def __str__(self): return self.data[:50] diff --git a/django/library/views.py b/django/library/views.py index 26757f7..c114a74 100644 --- a/django/library/views.py +++ b/django/library/views.py @@ -417,6 +417,10 @@ def new_question(request): question.time_per_question = request.POST.get('time_per_question', '30') + try: + question.credits=request.POST.get('credits',"") + except: + question.credits="" question.save() #return modified(request, pk=quiz.pk) return redirect('library:detail_quiz', pk=quiz.pk) @@ -454,7 +458,7 @@ def new_question(request): ] } standard_time_per_question = 30 - + template_name = f'library/question/question_{question_type}.html' context = { 'question': question_data, @@ -582,8 +586,11 @@ def edit_question(request, pk): question.data = json.dumps(json_data) question.time_per_question = request.POST.get('time_per_question', '30') - - + try: + question.credits=request.POST.get('credits',"") + except: + question.credits="" + question.save() for img in QuestionImage.objects.all(): try: @@ -597,6 +604,7 @@ def edit_question(request, pk): else: template_name = f'library/question/question_{question_type}.html' context = { + 'credits':question.credits, 'question': {'data': question_data}, # Wrap in data structure expected by template 'quiz_id': question.quiz_id.pk, 'quiz': question.quiz_id, diff --git a/django/templates/library/detail_quiz.html b/django/templates/library/detail_quiz.html index 21cd02c..567707b 100644 --- a/django/templates/library/detail_quiz.html +++ b/django/templates/library/detail_quiz.html @@ -253,13 +253,29 @@ {% endif %} -
+
{% if quiz.credits %} -

Credits: {{ quiz.credits }}

+

Credits (Quiz): {{ quiz.credits }}

+ {% endif %} + +
+
+ +
{% endblock %} diff --git a/django/templates/library/question/question_input.html b/django/templates/library/question/question_input.html index 79c7dad..ebf7579 100644 --- a/django/templates/library/question/question_input.html +++ b/django/templates/library/question/question_input.html @@ -76,6 +76,12 @@ + +
+ +
5 Minuten
+ +
+ +
5 Minuten
+ +
+ +
+