From 3504e79fe724bd6039548cf8bacae2dc7a4ff584 Mon Sep 17 00:00:00 2001 From: attiyaishaque Date: Wed, 16 Aug 2017 12:11:20 +0500 Subject: [PATCH] EDUCATOR-1104 Fix 500 error in course page. --- edx_proctoring/api.py | 2 +- edx_proctoring/tests/test_api.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/edx_proctoring/api.py b/edx_proctoring/api.py index fcade4aef6f..c9e51663074 100644 --- a/edx_proctoring/api.py +++ b/edx_proctoring/api.py @@ -1235,7 +1235,7 @@ def _check_eligibility_of_enrollment_mode(credit_state): # Also make an exception for the honor students to take the "practice exam" as a proctored exam. # For the rest of the enrollment modes, None is returned which shows the exam content # to the student rather than the proctoring prompt. - return credit_state['enrollment_mode'] == 'verified' + return credit_state and credit_state['enrollment_mode'] == 'verified' def _get_ordered_prerequisites(prerequisites_statuses, filter_out_namespaces=None): diff --git a/edx_proctoring/tests/test_api.py b/edx_proctoring/tests/test_api.py index 0aaf01cff14..97bd87f0377 100644 --- a/edx_proctoring/tests/test_api.py +++ b/edx_proctoring/tests/test_api.py @@ -1648,3 +1648,18 @@ def test_declined_prerequisites(self, content_id, self.assertEqual(len(results['failed_prerequisites']), expected_len_failed_prerequisites) self.assertEqual(len(results['pending_prerequisites']), expected_len_pending_prerequisites) self.assertEqual(len(results['declined_prerequisites']), expected_len_declined_prerequisites) + + def test_summary_without_credit_state(self): + """ + Test that attempt status summary is None for users who are not enrolled. + """ + exam_id = self._create_exam_with_due_time() + set_runtime_service('credit', MockCreditServiceNone()) + + timed_exam = get_exam_by_id(exam_id) + summary = get_attempt_status_summary( + self.user.id, + timed_exam['course_id'], + timed_exam['content_id'] + ) + self.assertIsNone(summary)