Skip to content

Commit

Permalink
MCKIN-12693 Fix problem report generation when a choice has been remo…
Browse files Browse the repository at this point in the history
…ved (#70)

In case a choice has been removed from the list of options, problem report generation can fail if there are students that chose that option. This commit fixes that issue by adding a fallback for those cases.
  • Loading branch information
xitij2000 authored Jan 8, 2020
2 parents 3c7dcaf + 81344bc commit 5534f44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions poll/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ def generate_report_data(self, user_state_iterator, limit_responses=None):
continue
report = {
self.ugettext('Question'): self.question,
self.ugettext('Answer'): answers_dict[choice]['label'],
self.ugettext('Answer'): answers_dict.get(choice, {}).get('label',
"[Removed Poll Option {}]".format(choice)),
self.ugettext('Submissions count'): user_state.state['submissions_count']
}
count += 1
Expand Down Expand Up @@ -1329,8 +1330,9 @@ def generate_report_data(self, user_state_iterator, limit_responses=None):
# End the iterator here
return

question = questions_dict[question_id]['label']
answer = answers_dict[answer_id]
question = questions_dict.get(question_id, {}).get('label',
"[Removed Survey Question {}]".format(question_id))
answer = answers_dict.get(answer_id) or "[Removed Survey Option {}]".format(answer_id)
report = {
self.ugettext('Question'): question,
self.ugettext('Answer'): answer,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def package_data(pkg, roots):

setup(
name='xblock-poll',
version='1.9.0',
version='1.9.2',
description='An XBlock for polling users.',
packages=[
'poll',
Expand Down

0 comments on commit 5534f44

Please sign in to comment.