Skip to content

Commit

Permalink
Handle another test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave St.Germain committed Nov 30, 2018
1 parent a45457b commit 524d0ad
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
17 changes: 17 additions & 0 deletions edx_proctoring/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2570,6 +2570,23 @@ def test_error_with_no_exams(self):
)
self.assertEqual(response.status_code, 404)

# test the case of no PROCTORED exams
ProctoredExam.objects.create(
course_id=course_id,
content_id='test_content',
exam_name='Timed Exam',
external_id='123aXqe3',
time_limit_mins=90,
is_active=True,
is_proctored=False,
backend='software_secure',
)
response = self.client.get(
reverse('edx_proctoring.instructor_dashboard_course',
kwargs={'course_id': course_id})
)
self.assertEqual(response.status_code, 404)

def test_error_with_no_dashboard(self):
course_id = 'a/b/d'

Expand Down
29 changes: 17 additions & 12 deletions edx_proctoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,16 +978,21 @@ def get(self, request, course_id, exam_id=None):
else:
found_backend = exam_backend
if exam is None:
return Response(data='No exam found for course %r.' % course_id, status=404)
backend = get_backend_provider(exam)
user = {
'id': request.user.id,
'full_name': request.user.get_full_name(),
'email': request.user.email
}
url = backend.get_instructor_url(exam['course_id'], user, exam_id=exam_id)
if url:
resp = redirect(url)
error = _('No exams in course {course_id}.').format(course_id=course_id)
else:
resp = Response(data='No instructor dashboard for %s' % backend.verbose_name, status=404)
return resp
backend = get_backend_provider(exam)
if backend:
user = {
'id': request.user.id,
'full_name': request.user.get_full_name(),
'email': request.user.email
}
url = backend.get_instructor_url(exam['course_id'], user, exam_id=exam_id)
if url:
return redirect(url)
else:
error = _('No instructor dashboard for {proctor_service}').format(
proctor_service=backend.verbose_name)
else:
error = _('No proctored exams in course {course_id}').format(course_id=course_id)
return Response(data=error, status=404, headers={'X-Frame-Options': 'sameorigin'})

0 comments on commit 524d0ad

Please sign in to comment.