Skip to content

Commit

Permalink
fix the bug where 'Proctored Option available' appears on the left pa…
Browse files Browse the repository at this point in the history
…ne for a proctored exam in an expired instructor paced course
  • Loading branch information
ibrahimahmed443 authored and Douglas Hall committed Mar 21, 2016
1 parent eaf8a89 commit a2f9f85
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
14 changes: 12 additions & 2 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,11 @@ def _resolve_prerequisite_links(exam, prerequisites):
'short_description': _('Failed Proctoring'),
'suggested_icon': 'fa-exclamation-triangle',
'in_completed_state': True
},
ProctoredExamStudentAttemptStatus.expired: {
'short_description': _('Proctored Option No Longer Available'),
'suggested_icon': 'fa-times-circle',
'in_completed_state': False
}
}

Expand Down Expand Up @@ -1375,12 +1380,17 @@ def get_attempt_status_summary(user_id, course_id, content_id):
# practice exams always has an attempt status regardless of
# eligibility
if credit_service and not exam['is_practice_exam']:
credit_state = credit_service.get_credit_state(user_id, unicode(course_id))
credit_state = credit_service.get_credit_state(user_id, unicode(course_id), return_course_info=True)
if not _check_eligibility_of_enrollment_mode(credit_state):
return None

attempt = get_exam_attempt(exam['id'], user_id)
status = attempt['status'] if attempt else ProctoredExamStudentAttemptStatus.eligible
if attempt:
status = attempt['status']
elif not exam['is_practice_exam'] and has_due_date_passed(credit_state.get('course_end_date', None)):
status = ProctoredExamStudentAttemptStatus.expired
else:
status = ProctoredExamStudentAttemptStatus.eligible

status_map = STATUS_SUMMARY_MAP if not exam['is_practice_exam'] else PRACTICE_STATUS_SUMMARY_MAP

Expand Down
3 changes: 3 additions & 0 deletions edx_proctoring/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ class ProctoredExamStudentAttemptStatus(object):
# the exam is believed to be in error
error = 'error'

# the course end date has passed
expired = 'expired'

# status alias for sending email
status_alias_mapping = {
submitted: _('pending'),
Expand Down
26 changes: 26 additions & 0 deletions edx_proctoring/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,24 @@ def test_proctored_exam_passed_end_date(self):
)
self.assertIsNone(rendered_response)

def test_proctored_status_summary_passed_end_date(self):
"""
Assert that we get the expected status summaries
"""

set_runtime_service('credit', MockCreditServiceWithCourseEndDate())

exam = get_exam_by_id(self.proctored_exam_id)
summary = get_attempt_status_summary(self.user.id, exam['course_id'], exam['content_id'])

expected = {
'status': ProctoredExamStudentAttemptStatus.expired,
'short_description': 'Proctored Option No Longer Available',
'suggested_icon': 'fa-times-circle',
'in_completed_state': False
}
self.assertIn(summary, [expected])

def test_practice_exam_passed_end_date(self):
"""
Verify that we get a None back on a practice exam
Expand Down Expand Up @@ -2331,6 +2349,14 @@ def test_update_unexisting_attempt(self):
'suggested_icon': 'fa-pencil-square-o',
'in_completed_state': False
}
),
(
ProctoredExamStudentAttemptStatus.expired, {
'status': ProctoredExamStudentAttemptStatus.expired,
'short_description': 'Proctored Option No Longer Available',
'suggested_icon': 'fa-times-circle',
'in_completed_state': False
}
)
)
@ddt.unpack
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def load_requirements(*requirements_paths):

setup(
name='edx-proctoring',
version='0.12.14',
version='0.12.15',
description='Proctoring subsystem for Open edX',
long_description=open('README.md').read(),
author='edX',
Expand Down

0 comments on commit a2f9f85

Please sign in to comment.