Commit cb5bc624 by Hasnain

adding practice exam in context

parent 67516498
......@@ -1877,6 +1877,43 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
self.assertEqual(response.status_code, 405)
@ddt.data(
(True, True, 'practice'),
(True, False, 'proctored'),
(False, False, 'timed')
)
@ddt.unpack
def test_exam_type(self, is_proctored, is_practice, expected_exam_type):
"""
Testing the exam type
"""
proctored_exam = ProctoredExam.objects.create(
course_id='a/b/c',
content_id='test_content',
exam_name='Test Exam',
external_id='123aXqe3',
time_limit_mins=90,
is_proctored=is_proctored,
is_practice_exam=is_practice
)
ProctoredExamStudentAttempt.objects.create(
proctored_exam=proctored_exam,
user=self.user,
allowed_time_limit_mins=90,
taking_as_proctored=is_proctored,
is_sample_attempt=is_practice,
external_id=proctored_exam.external_id,
status=ProctoredExamStudentAttemptStatus.started
)
response = self.client.get(
reverse('edx_proctoring.proctored_exam.attempt.collection')
)
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertEqual(data['exam_type'], expected_exam_type)
class TestExamAllowanceView(LoggedInTestCase):
"""
......
......@@ -559,7 +559,10 @@ class StudentProctoredExamAttemptCollection(AuthenticatedAPIView):
response_dict = {
'in_timed_exam': True,
'taking_as_proctored': attempt['taking_as_proctored'],
'exam_type': _('proctored') if attempt['taking_as_proctored'] else _('timed'),
'exam_type': (
_('timed') if not attempt['taking_as_proctored'] else
(_('practice') if attempt['is_sample_attempt'] else _('proctored'))
),
'exam_display_name': exam['exam_name'],
'exam_url_path': exam_url_path,
'time_remaining_seconds': time_remaining_seconds,
......
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