Bilder für Fragen
This commit is contained in:
@@ -348,6 +348,7 @@ def new_question(request):
|
||||
|
||||
if request.method == 'POST':
|
||||
question_text = request.POST.get('question', '')
|
||||
question_image = request.FILES['question_image']
|
||||
|
||||
# Handle different question types
|
||||
if question_type == 'true_false':
|
||||
@@ -387,6 +388,7 @@ def new_question(request):
|
||||
question = QivipQuestion()
|
||||
question.data = json.dumps(json_data)
|
||||
question.quiz_id = quiz
|
||||
question.image = question_image
|
||||
question.time_per_question = request.POST.get('time_per_question', '30')
|
||||
question.save()
|
||||
#return modified(request, pk=quiz.pk)
|
||||
@@ -435,6 +437,7 @@ def edit_question(request, pk):
|
||||
try:
|
||||
question_data = json.loads(question.data) if question.data else {}
|
||||
question_type = question_data.get('type', 'multiple_choice')
|
||||
question_image = question.image
|
||||
|
||||
# For true/false questions, get the correct answer from the options
|
||||
if question_type == 'true_false':
|
||||
@@ -479,7 +482,11 @@ def edit_question(request, pk):
|
||||
|
||||
if request.method == 'POST':
|
||||
question_text = request.POST.get('question', '')
|
||||
|
||||
try:
|
||||
question_image = request.FILES['question_image']
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Handle different question types
|
||||
if question_type == 'true_false':
|
||||
correct_answer = request.POST.get('correct_answer') == 'true'
|
||||
@@ -521,6 +528,7 @@ def edit_question(request, pk):
|
||||
|
||||
question.data = json.dumps(json_data)
|
||||
question.time_per_question = request.POST.get('time_per_question', '30')
|
||||
question.image = question_image
|
||||
question.save()
|
||||
#return modified(request, question.quiz_id.pk)
|
||||
return redirect('library:detail_quiz', pk=question.quiz_id.pk)
|
||||
@@ -532,6 +540,7 @@ def edit_question(request, pk):
|
||||
'quiz_id': question.quiz_id.pk,
|
||||
'quiz': question.quiz_id,
|
||||
'time_per_question': question.time_per_question,
|
||||
'image': question_image,
|
||||
}
|
||||
|
||||
return render(request, template_name, context)
|
||||
|
||||
Reference in New Issue
Block a user