Bugfix: adding zero counts that were skipped

This commit is contained in:
Vivek Santayana 2022-09-01 11:56:15 +01:00
parent b2df303632
commit 0c49d22865

View File

@ -37,16 +37,15 @@ def _playbooks():
@views.route('/answers/')
def _answers():
answers = {}
answers = { }
for index, question in enumerate(render_questions()):
answers[index] = { }
for _index, answer in enumerate(question['answers']): answers[index][_index] = 0
for entry in Entry.query.all():
for index, answer in enumerate(entry.answers):
if index not in answers: answers[index] = { }
if type(answer) is list:
for option in answer:
if option not in answers[index]: answers[index][option] = 0
answers[index][option] += 1
for option in answer: answers[index][option] += 1
else:
if answer not in answers[index]: answers[index][answer] = 0
answers[index][answer] += 1
return list(answers.values())