Commit 9eb5619f by chrisndodge

Merge pull request #66 from edx/cdodge/practice_exam_status_indicators

set status indicators for practice exams
parents dca995b3 b34543ba
...@@ -782,6 +782,25 @@ STATUS_SUMMARY_MAP = { ...@@ -782,6 +782,25 @@ STATUS_SUMMARY_MAP = {
} }
PRACTICE_STATUS_SUMMARY_MAP = {
'_default': {
'short_description': _('Ungraded Practice Exam'),
'suggested_icon': 'fa-lock',
'in_completed_state': False
},
ProctoredExamStudentAttemptStatus.submitted: {
'short_description': _('Practice Exam Completed'),
'suggested_icon': 'fa-check',
'in_completed_state': True
},
ProctoredExamStudentAttemptStatus.error: {
'short_description': _('Practice Exam Failed'),
'suggested_icon': 'fa-exclamation-triangle',
'in_completed_state': True
}
}
def get_attempt_status_summary(user_id, course_id, content_id): def get_attempt_status_summary(user_id, course_id, content_id):
""" """
Returns a summary about the status of the attempt for the user Returns a summary about the status of the attempt for the user
...@@ -815,11 +834,13 @@ def get_attempt_status_summary(user_id, course_id, content_id): ...@@ -815,11 +834,13 @@ def get_attempt_status_summary(user_id, course_id, content_id):
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
status_map = STATUS_SUMMARY_MAP if not attempt['is_sample_attempt'] else PRACTICE_STATUS_SUMMARY_MAP
summary = None summary = None
if status in STATUS_SUMMARY_MAP: if status in status_map:
summary = STATUS_SUMMARY_MAP[status] summary = status_map[status]
else: else:
summary = STATUS_SUMMARY_MAP['_default'] summary = status_map['_default']
summary.update({"status": status}) summary.update({"status": status})
......
...@@ -169,7 +169,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -169,7 +169,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
status='created' status='created'
) )
def _create_started_exam_attempt(self, started_at=None, is_proctored=True): def _create_started_exam_attempt(self, started_at=None, is_proctored=True, is_sample_attempt=False):
""" """
Creates the ProctoredExamStudentAttempt object. Creates the ProctoredExamStudentAttempt object.
""" """
...@@ -179,7 +179,8 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -179,7 +179,8 @@ class ProctoredExamApiTests(LoggedInTestCase):
external_id=self.external_id, external_id=self.external_id,
started_at=started_at if started_at else datetime.now(pytz.UTC), started_at=started_at if started_at else datetime.now(pytz.UTC),
status=ProctoredExamStudentAttemptStatus.started, status=ProctoredExamStudentAttemptStatus.started,
allowed_time_limit_mins=10 allowed_time_limit_mins=10,
is_sample_attempt=is_sample_attempt
) )
def _create_started_practice_exam_attempt(self, started_at=None): # pylint: disable=invalid-name def _create_started_practice_exam_attempt(self, started_at=None): # pylint: disable=invalid-name
...@@ -1268,6 +1269,53 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -1268,6 +1269,53 @@ 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_summary(self, status, expected):
"""
Assert that we get the expected status summaries
"""
exam_attempt = self._create_started_exam_attempt(is_sample_attempt=True)
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