[FIX] survey: preserve the multiple choices question answers order
When configuring a survey with a Multiple choice: only one answer question, the answers shown in the result may be in the wrong order because of the use of a simple `Dict` instead of an `OrderedDict`. The behavior was increased when using Python 3.5, as it randomizes on purpose dictionnaries. opw-1818797
This commit is contained in:
@@ -227,9 +227,8 @@ class Survey(models.Model):
|
||||
|
||||
# Calculate and return statistics for choice
|
||||
if question.type in ['simple_choice', 'multiple_choice']:
|
||||
answers = {}
|
||||
comments = []
|
||||
[answers.update({label.id: {'text': label.value, 'count': 0, 'answer_id': label.id}}) for label in question.labels_ids]
|
||||
answers = OrderedDict((label.id, {'text': label.value, 'count': 0, 'answer_id': label.id}) for label in question.labels_ids)
|
||||
for input_line in question.user_input_line_ids:
|
||||
if input_line.answer_type == 'suggestion' and answers.get(input_line.value_suggested.id) and (not(current_filters) or input_line.user_input_id.id in current_filters):
|
||||
answers[input_line.value_suggested.id]['count'] += 1
|
||||
|
||||
Reference in New Issue
Block a user