Commit a9a7ae06 by Ibrahim

fix the bug where the learner gets full time even after due date is passed

parent f2cc8597
......@@ -905,6 +905,33 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
response_data = json.loads(response.content)
self.assertEqual(response_data['status'], 'submitted')
def test_attempt_with_duedate_expired(self):
"""
Tests that an exam with duedate passed cannot be accessed
"""
# create an exam with duedate passed
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,
due_date=datetime.now(pytz.UTC) - timedelta(minutes=10),
)
attempt_data = {
'exam_id': proctored_exam.id,
'external_id': proctored_exam.external_id,
'start_clock': True,
}
# Starting exam attempt
response = self.client.post(
reverse('edx_proctoring.proctored_exam.attempt.collection'),
attempt_data
)
self.assertEqual(response.status_code, 400)
self.assertRaises(ProctoredExamPermissionDenied)
def test_remove_attempt(self):
"""
Confirms that an attempt can be removed
......
......@@ -595,14 +595,16 @@ class StudentProctoredExamAttemptCollection(AuthenticatedAPIView):
exam_id = request.data.get('exam_id', None)
attempt_proctored = request.data.get('attempt_proctored', 'false').lower() == 'true'
try:
exam = get_exam_by_id(exam_id)
if exam['due_date'] and exam['due_date'] <= datetime.now(pytz.UTC):
raise ProctoredExamPermissionDenied('Attempted to access expired exam')
exam_attempt_id = create_exam_attempt(
exam_id=exam_id,
user_id=request.user.id,
taking_as_proctored=attempt_proctored
)
exam = get_exam_by_id(exam_id)
# if use elected not to take as proctored exam, then
# use must take as open book, and loose credit eligibility
if exam['is_proctored'] and not attempt_proctored:
......
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