Commit f611571d by chrisndodge

Merge pull request #72 from edx/cdodge/always-return-status-summary

all students should be able to get practice exam status summary
parents 06eae925 19240462
...@@ -829,13 +829,6 @@ def get_attempt_status_summary(user_id, course_id, content_id): ...@@ -829,13 +829,6 @@ def get_attempt_status_summary(user_id, course_id, content_id):
} }
""" """
# as a quick exit, let's check credit eligibility
credit_service = get_runtime_service('credit')
if credit_service:
credit_state = credit_service.get_credit_state(user_id, unicode(course_id))
if not _check_credit_eligibility(credit_state):
return None
try: try:
exam = get_exam_by_content_id(course_id, content_id) exam = get_exam_by_content_id(course_id, content_id)
except ProctoredExamNotFoundException, ex: except ProctoredExamNotFoundException, ex:
...@@ -843,6 +836,15 @@ def get_attempt_status_summary(user_id, course_id, content_id): ...@@ -843,6 +836,15 @@ def get_attempt_status_summary(user_id, course_id, content_id):
log.exception(ex) log.exception(ex)
return None return None
# let's check credit eligibility
credit_service = get_runtime_service('credit')
# 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))
if not _check_credit_eligibility(credit_state):
return None
attempt = get_exam_attempt(exam['id'], user_id) attempt = get_exam_attempt(exam['id'], user_id)
status = attempt['status'] if attempt else ProctoredExamStudentAttemptStatus.eligible status = attempt['status'] if attempt else ProctoredExamStudentAttemptStatus.eligible
......
...@@ -1333,6 +1333,58 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -1333,6 +1333,58 @@ class ProctoredExamApiTests(LoggedInTestCase):
self.assertIn(summary, [expected]) self.assertIn(summary, [expected])
@ddt.data( @ddt.data(
(
ProctoredExamStudentAttemptStatus.eligible, {
'status': ProctoredExamStudentAttemptStatus.eligible,
'short_description': 'Ungraded Practice Exam',
'suggested_icon': 'fa-lock',
'in_completed_state': False
}
),
(
ProctoredExamStudentAttemptStatus.submitted, {
'status': ProctoredExamStudentAttemptStatus.submitted,
'short_description': 'Practice Exam Completed',
'suggested_icon': 'fa-check',
'in_completed_state': True
}
),
(
ProctoredExamStudentAttemptStatus.error, {
'status': ProctoredExamStudentAttemptStatus.error,
'short_description': 'Practice Exam Failed',
'suggested_icon': 'fa-exclamation-triangle',
'in_completed_state': True
}
)
)
@ddt.unpack
def test_practice_status_honor(self, status, expected):
"""
Assert that we get the expected status summaries
"""
set_runtime_service('credit', MockCreditService(enrollment_mode='honor'))
exam_attempt = self._create_started_exam_attempt(is_sample_attempt=True)
exam_attempt.proctored_exam.is_practice_exam = True
exam_attempt.proctored_exam.save()
update_attempt_status(
exam_attempt.proctored_exam_id,
self.user.id,
status
)
summary = get_attempt_status_summary(
self.user.id,
exam_attempt.proctored_exam.course_id,
exam_attempt.proctored_exam.content_id
)
self.assertIn(summary, [expected])
@ddt.data(
'honor', 'staff' 'honor', 'staff'
) )
def test_status_summary_honor(self, enrollment_mode): def test_status_summary_honor(self, enrollment_mode):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment