Skip to content

Commit

Permalink
Fix pgreport about missing student_answers openedx#435
Browse files Browse the repository at this point in the history
  • Loading branch information
hachiyanagi-ks committed Oct 20, 2015
1 parent 5fe7fa6 commit b415802
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lms/djangoapps/pgreport/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,20 @@ def test_get_correctmap_data(self):

def test_get_student_answers_data(self):
sum_answers = {}

# Invalid answers
# None, empty
student_answers = None
return_answers = self.pgreport._get_student_answers_data(
sum_answers, student_answers)
self.assertEquals(return_answers, {})

student_answers = {}
return_answers = self.pgreport._get_student_answers_data(
sum_answers, student_answers)
self.assertEquals(return_answers, {})

# Valid answers
student_answers = {'1_2_1': 'abcd', '1_2_2': 'abcd', '1_2_3': 'xyz'}
return_answers = self.pgreport._get_student_answers_data(
sum_answers, student_answers)
Expand Down
3 changes: 3 additions & 0 deletions lms/djangoapps/pgreport/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ def _get_correctmap_data(self, sum_correct_map, correct_map):

def _get_student_answers_data(self, sum_student_answers, student_answers):

if not student_answers:
return sum_student_answers

for key, answers in student_answers.items():
answers_data = {}
if isinstance(answers, list):
Expand Down

0 comments on commit b415802

Please sign in to comment.