Schätzfunktion( (mit Schieberegler) #148
This commit is contained in:
@@ -849,6 +849,7 @@ def question_list(request):
|
||||
def new_question(request):
|
||||
question_type = request.GET.get('type')
|
||||
quiz_id = request.GET.get('quiz_id')
|
||||
question_data = None
|
||||
|
||||
if not quiz_id:
|
||||
messages.error(request, 'Quiz ID muss angegeben werden.')
|
||||
@@ -860,7 +861,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','order']:
|
||||
if question_type not in ['multiple_choice', 'true_false','input','order','guess']:
|
||||
base_url = reverse('library:new_question')
|
||||
return redirect(f'{base_url}?type=multiple_choice&quiz_id={quiz_id}')
|
||||
|
||||
@@ -937,6 +938,24 @@ def new_question(request):
|
||||
'question': question_text,
|
||||
'options': options
|
||||
}
|
||||
|
||||
|
||||
elif question_type == 'guess':
|
||||
correct_answer = request.POST.get('correct_answer')
|
||||
min_value = request.POST.get('min')
|
||||
max_value = request.POST.get('max')
|
||||
tolerance = request.POST.get('tolerance')
|
||||
json_data = {
|
||||
'type': question_type,
|
||||
'question': question_text,
|
||||
'correct_answer': correct_answer,
|
||||
'min': min_value,
|
||||
'max': max_value,
|
||||
'tolerance': tolerance,
|
||||
'options': [
|
||||
{'value': correct_answer, 'is_correct': True}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1005,6 +1024,24 @@ def new_question(request):
|
||||
]
|
||||
}
|
||||
standard_time_per_question = 30
|
||||
elif question_type == 'guess':
|
||||
correct_answer = request.POST.get('correct_answer')
|
||||
min_value = request.POST.get('min')
|
||||
max_value = request.POST.get('max')
|
||||
tolerance = request.POST.get('tolerance')
|
||||
json_data = {
|
||||
'type': question_type,
|
||||
'question': '',
|
||||
'correct_answer': correct_answer,
|
||||
'min': min_value,
|
||||
'max': max_value,
|
||||
'tolerance': tolerance,
|
||||
'options': [
|
||||
{'value': correct_answer, 'is_correct': True}
|
||||
]
|
||||
}
|
||||
standard_time_per_question = 30
|
||||
|
||||
|
||||
template_name = f'library/question/question_{question_type}.html'
|
||||
context = {
|
||||
@@ -1157,6 +1194,23 @@ def edit_question(request, pk):
|
||||
'question': question_text,
|
||||
'options': options
|
||||
}
|
||||
elif question_type == 'guess':
|
||||
correct_answer = request.POST.get('correct_answer')
|
||||
min_value = request.POST.get('min')
|
||||
max_value = request.POST.get('max')
|
||||
tolerance = request.POST.get('tolerance')
|
||||
json_data = {
|
||||
'type': question_type,
|
||||
'question': question_text,
|
||||
'correct_answer': correct_answer,
|
||||
'min': min_value,
|
||||
'max': max_value,
|
||||
'tolerance': tolerance,
|
||||
'options': [
|
||||
{'value': correct_answer, 'is_correct': True}
|
||||
]
|
||||
}
|
||||
|
||||
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