Skip to content

Commit

Permalink
Merge pull request #375 from edx/attiya/EDUCATOR-1256
Browse files Browse the repository at this point in the history
EDUCATOR-1256 Fix 500 error when user is not enrolled.
  • Loading branch information
attiyaIshaque authored Aug 31, 2017
2 parents 47ce286 + e3080a5 commit c1f371b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ def get_student_view(user_id, course_id, content_id,

# call service to get course end date.
credit_state = credit_service.get_credit_state(user_id, course_id, return_course_info=True)
course_end_date = credit_state.get('course_end_date', None)
course_end_date = credit_state.get('course_end_date') if credit_state else None

exam_id = None
try:
Expand Down
20 changes: 19 additions & 1 deletion edx_proctoring/tests/test_student_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)
from edx_proctoring.runtime import set_runtime_service

from .test_services import MockCreditServiceWithCourseEndDate
from .test_services import MockCreditServiceWithCourseEndDate, MockCreditServiceNone
from .utils import ProctoredExamTestCase


Expand Down Expand Up @@ -388,6 +388,24 @@ def test_get_disabled_student_view(self):
)
)

def test_student_response_without_credit_state(self):
"""
Test that response is not None for users who are not enrolled.
"""
set_runtime_service('credit', MockCreditServiceNone())
rendered_response = get_student_view(
user_id=self.user_id,
course_id=self.course_id,
content_id=self.content_id,
context={
'is_proctored': True,
'display_name': self.exam_name,
'default_time_limit_mins': 90
},
user_role='student'
)
self.assertIsNotNone(rendered_response)

@ddt.data(False, True)
def test_get_studentview_unstarted_exam(self, allow_proctoring_opt_out):
"""
Expand Down

0 comments on commit c1f371b

Please sign in to comment.