Commit 0302fe99 by Afzal Wali

Removed the changes for create exam attempt for practice exams.

parent 795d41b9
......@@ -210,25 +210,19 @@ def get_exam_attempt_by_code(attempt_code):
def create_exam_attempt(exam_id, user_id, taking_as_proctored=False):
"""
Creates an exam attempt for user_id against exam_id. There should only be
one exam_attempt per user per exam except for the practice exams where multiple
attempts are allowed. Multiple attempts by user will be archived
one exam_attempt per user per exam. Multiple attempts by user will be archived
in a separate table
"""
if ProctoredExamStudentAttempt.objects.get_exam_attempt(exam_id, user_id):
err_msg = (
'Cannot create new exam attempt for exam_id = {exam_id} and '
'user_id = {user_id} because it already exists!'
).format(exam_id=exam_id, user_id=user_id)
exam = get_exam_by_id(exam_id)
existing_attempt = ProctoredExamStudentAttempt.objects.get_exam_attempt(exam_id, user_id)
if existing_attempt:
if exam['is_practice_exam']:
# Archive the existing attempt by deleting it.
existing_attempt.delete_exam_attempt()
else:
err_msg = (
'Cannot create new exam attempt for exam_id = {exam_id} and '
'user_id = {user_id} because it already exists!'
).format(exam_id=exam_id, user_id=user_id)
raise StudentExamAttemptAlreadyExistsException(err_msg)
raise StudentExamAttemptAlreadyExistsException(err_msg)
# for now the student is allowed the exam default
exam = get_exam_by_id(exam_id)
allowed_time_limit_mins = exam['time_limit_mins']
# add in the allowed additional time
......
......@@ -368,14 +368,6 @@ class ProctoredExamApiTests(LoggedInTestCase):
with self.assertRaises(StudentExamAttemptAlreadyExistsException):
create_exam_attempt(proctored_exam_student_attempt.proctored_exam.id, self.user_id)
def test_recreate_a_practice_exam_attempt(self): # pylint: disable=invalid-name
"""
Taking the practice exam several times should not cause an exception.
"""
practice_exam_student_attempt = self._create_started_practice_exam_attempt()
new_attempt_id = create_exam_attempt(practice_exam_student_attempt.proctored_exam.id, self.user_id)
self.assertGreater(practice_exam_student_attempt, new_attempt_id, "New attempt not created.")
def test_get_exam_attempt(self):
"""
Test to get the existing exam attempt.
......
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