Skip to content

Commit

Permalink
Fix handling of empty answers in quizzes
Browse files Browse the repository at this point in the history
Change-Id: Iebdace589553105383686a5b531c2968870932df
  • Loading branch information
DietPawel committed Aug 17, 2023
1 parent e0b63eb commit 6a07ee4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions oioioi/quizzes/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ def _submit_answers(self, selected_answers, question, submission):
sub.save()

def _get_selected_answers(self, form_data, field_id, question):
field_value = form_data.get(field_id)
field_value = form_data.get(field_id, '')
if question.is_text_input:
if isinstance(field_value, list):
return field_value[:1]
return [field_value]
elif question.is_multiple_choice:
return [int(a) for a in field_value]
return [int(a) for a in filter(bool,field_value)]
else:
return [int(field_value)]
return [] if not field_value else [int(field_value)]

def is_quiz_question_answer_case_ignored(self, question):
return True
Expand Down

0 comments on commit 6a07ee4

Please sign in to comment.