Reihenfolge_Fragetyp(und Lizenzenz_Dateien)
This commit is contained in:
@@ -20,7 +20,7 @@ urlpatterns = [
|
||||
path('detail/copy/<int:pk>/', views.copy_quiz, name='copy_quiz'),
|
||||
path('favorite_quiz/<int:pk>/', views.favorite_quiz, name='favorite_quiz'),
|
||||
path("quiz-names-json/", views.quiz_names_json, name="quiz_names_json"),
|
||||
path('quiz/<int:pk>/pdf/', views.pdf_solution, name='quiz_solution'),
|
||||
path('quiz/<int:pk>/pdf/task', views.pdf_task, name='quiz_task'),
|
||||
#path('quiz/<int:pk>/pdf/', views.pdf_solution, name='quiz_solution'),
|
||||
#path('quiz/<int:pk>/pdf/task', views.pdf_task, name='quiz_task'),
|
||||
|
||||
]
|
||||
|
||||
@@ -40,7 +40,7 @@ from PIL import Image as PILImage, ImageOps
|
||||
from django.conf import settings
|
||||
import os
|
||||
from django.utils.html import escape
|
||||
|
||||
"""
|
||||
def pdf_solution(request, pk):
|
||||
quiz = get_object_or_404(QivipQuiz, pk=pk)
|
||||
|
||||
@@ -337,7 +337,7 @@ def pdf_task(request, pk):
|
||||
story.append(Paragraph(link_html, styles['Normal']))
|
||||
doc.build(story)
|
||||
return response
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -860,7 +860,7 @@ def new_question(request):
|
||||
messages.error(request, 'Quiz nicht gefunden oder keine Berechtigung.')
|
||||
return redirect('library:overview_quiz')
|
||||
|
||||
if question_type not in ['multiple_choice', 'true_false','input']:
|
||||
if question_type not in ['multiple_choice', 'true_false','input','order']:
|
||||
base_url = reverse('library:new_question')
|
||||
return redirect(f'{base_url}?type=multiple_choice&quiz_id={quiz_id}')
|
||||
|
||||
@@ -889,7 +889,7 @@ def new_question(request):
|
||||
|
||||
]
|
||||
}
|
||||
elif question_type == 'multiple_choice':
|
||||
elif question_type == 'multiple_choice' :
|
||||
options = []
|
||||
i = 1
|
||||
# Limit to maximum 6 options
|
||||
@@ -912,7 +912,35 @@ def new_question(request):
|
||||
'question': question_text,
|
||||
'options': options
|
||||
}
|
||||
|
||||
elif question_type == 'order' :
|
||||
options = []
|
||||
i = 1
|
||||
# Limit to maximum 6 options
|
||||
while request.POST.get(f'option_{i}') and i <= 6:
|
||||
is_correct = request.POST.get(f'correct_{i}') == '1'
|
||||
options.append({
|
||||
'order': i,
|
||||
'value': request.POST.get(f'option_{i}'),
|
||||
|
||||
})
|
||||
i += 1
|
||||
|
||||
|
||||
# Validate minimum 2 options
|
||||
if len(options) < 2:
|
||||
messages.error(request, 'Mindestens zwei Optionen müssen angegeben werden.')
|
||||
return redirect(request.get_full_path())
|
||||
|
||||
json_data = {
|
||||
'type': question_type,
|
||||
'question': question_text,
|
||||
'options': options
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
question = QivipQuestion()
|
||||
question.data = json.dumps(json_data)
|
||||
question.quiz_id = quiz
|
||||
@@ -966,6 +994,17 @@ def new_question(request):
|
||||
]
|
||||
}
|
||||
standard_time_per_question = 30
|
||||
|
||||
elif question_type == 'order':
|
||||
question_data = {
|
||||
'type': question_type,
|
||||
'question': '',
|
||||
'options': [
|
||||
{'value': ''},
|
||||
{'value': ''}
|
||||
]
|
||||
}
|
||||
standard_time_per_question = 30
|
||||
|
||||
template_name = f'library/question/question_{question_type}.html'
|
||||
context = {
|
||||
@@ -1092,6 +1131,32 @@ def edit_question(request, pk):
|
||||
'options': options
|
||||
}
|
||||
|
||||
elif question_type == 'order':
|
||||
options = []
|
||||
i = 1
|
||||
# Limit to maximum 6 options
|
||||
while request.POST.get(f'option_{i}') and i <= 6:
|
||||
options.append({
|
||||
'order': i,
|
||||
'value': request.POST.get(f'option_{i}')
|
||||
})
|
||||
i += 1
|
||||
|
||||
# Validate minimum 2 options
|
||||
if len(options) < 2:
|
||||
messages.error(request, 'Mindestens zwei Optionen müssen angegeben werden.')
|
||||
return redirect(request.get_full_path())
|
||||
|
||||
# Validate maximum 6 options
|
||||
if len(options) > 6:
|
||||
messages.error(request, 'Maximal 6 Optionen sind erlaubt.')
|
||||
return redirect(request.get_full_path())
|
||||
|
||||
json_data = {
|
||||
'type': question_type,
|
||||
'question': question_text,
|
||||
'options': options
|
||||
}
|
||||
question.data = json.dumps(json_data)
|
||||
question.time_per_question = request.POST.get('time_per_question', '30')
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user