Skip to content

Commit

Permalink
Fix edge case for logging on student submission
Browse files Browse the repository at this point in the history
This handles the case where there is no correct answer.
  • Loading branch information
jleong-openedx committed Jul 27, 2017
1 parent 76d8ae8 commit 0e5b06a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ubcpi/ubcpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,18 @@ def record_response(self, answer, rationale, status):
answers = self.get_answers_for_student()
stats = self.get_current_stats()
truncated_rationle, was_truncated = truncate_rationale(rationale)
corr_ans_text = ''
if self.correct_answer == 3: # handle scenario with no correct answer
corr_ans_text = 'n/a'
else:
corr_ans_text = self.options[self.correct_answer].get('text'),
event_dict = {
'answer': answer,
'answer_text': self.options[answer].get('text'),
'rationale': truncated_rationle,
'correct_answer': self.correct_answer,
'correct_answer_text': corr_ans_text,
'correct_rationale': self.correct_rationale,
'truncated': was_truncated
}
if not answers.has_revision(0) and status == STATUS_NEW:
Expand Down

0 comments on commit 0e5b06a

Please sign in to comment.