Commit 42894358 by chrisndodge

Merge pull request #135 from edx/muhhshoaib/SOL-1168-getattempt-status-summary-for-timed-exams

SOL-1168 added the check and the test case
parents cb2a6171 bd19cd65
...@@ -950,12 +950,23 @@ PRACTICE_STATUS_SUMMARY_MAP = { ...@@ -950,12 +950,23 @@ PRACTICE_STATUS_SUMMARY_MAP = {
} }
} }
TIMED_EXAM_STATUS_SUMMARY_MAP = {
'_default': {
'short_description': _('Timed Exam'),
'suggested_icon': 'fa-clock-o',
'in_completed_state': False
}
}
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
in the course_id and content_id in the course_id and content_id
If the exam is timed exam only then we simply
return the dictionary with timed exam default summary
Return will be: Return will be:
None: Not applicable None: Not applicable
- or - - or -
...@@ -974,6 +985,10 @@ def get_attempt_status_summary(user_id, course_id, content_id): ...@@ -974,6 +985,10 @@ def get_attempt_status_summary(user_id, course_id, content_id):
log.exception(ex) log.exception(ex)
return None return None
# check if the exam is not proctored
if not exam['is_proctored']:
return TIMED_EXAM_STATUS_SUMMARY_MAP['_default']
# let's check credit eligibility # let's check credit eligibility
credit_service = get_runtime_service('credit') credit_service = get_runtime_service('credit')
# practice exams always has an attempt status regardless of # practice exams always has an attempt status regardless of
......
...@@ -148,7 +148,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -148,7 +148,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
exam_name=self.exam_name, exam_name=self.exam_name,
time_limit_mins=self.default_time_limit, time_limit_mins=self.default_time_limit,
is_practice_exam=True, is_practice_exam=True,
is_proctored=False is_proctored=True
) )
def _create_disabled_exam(self): def _create_disabled_exam(self):
...@@ -1462,6 +1462,30 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -1462,6 +1462,30 @@ class ProctoredExamApiTests(LoggedInTestCase):
@ddt.data( @ddt.data(
( (
{
'short_description': 'Timed Exam',
'suggested_icon': 'fa-clock-o',
'in_completed_state': False
},
)
)
@ddt.unpack
def test_timed_exam_status_summary(self, expected):
"""
Assert that we get the expected status summaries
for the timed exams.
"""
timed_exam = get_exam_by_id(self.timed_exam)
summary = get_attempt_status_summary(
self.user.id,
timed_exam['course_id'],
timed_exam['content_id']
)
self.assertIn(summary, [expected])
@ddt.data(
(
ProctoredExamStudentAttemptStatus.eligible, { ProctoredExamStudentAttemptStatus.eligible, {
'status': ProctoredExamStudentAttemptStatus.eligible, 'status': ProctoredExamStudentAttemptStatus.eligible,
'short_description': 'Ungraded Practice Exam', 'short_description': 'Ungraded Practice Exam',
......
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