def _create_exam_attempt(self, exam_id, status=ProctoredExamStudentAttemptStatus.created, is_practice_exam=False, time_remaining_seconds=None): """ Creates the ProctoredExamStudentAttempt object. """ attempt = ProctoredExamStudentAttempt( proctored_exam_id=exam_id, user_id=self.user_id, external_id=self.external_id, status=status, allowed_time_limit_mins=10, taking_as_proctored=True, is_sample_attempt=is_practice_exam, time_remaining_seconds=time_remaining_seconds, ) if status in (ProctoredExamStudentAttemptStatus.started, ProctoredExamStudentAttemptStatus.ready_to_submit, ProctoredExamStudentAttemptStatus.submitted): attempt.started_at = datetime.now(pytz.UTC) if ProctoredExamStudentAttemptStatus.is_completed_status(status): attempt.completed_at = datetime.now(pytz.UTC) if status == ProctoredExamStudentAttemptStatus.error: attempt.is_resumable = True attempt.save() return attempt
def _create_exam_attempt(self, exam_id, status=ProctoredExamStudentAttemptStatus.created): """ Creates the ProctoredExamStudentAttempt object. """ attempt = ProctoredExamStudentAttempt( proctored_exam_id=exam_id, user_id=self.user_id, external_id=self.external_id, status=status, allowed_time_limit_mins=10, taking_as_proctored=True, ) if status in (ProctoredExamStudentAttemptStatus.started, ProctoredExamStudentAttemptStatus.ready_to_submit, ProctoredExamStudentAttemptStatus.submitted): attempt.started_at = datetime.now(pytz.UTC) if ProctoredExamStudentAttemptStatus.is_completed_status(status): attempt.completed_at = datetime.now(pytz.UTC) attempt.save() return attempt
def _create_exam_attempt(self, exam_id, status='created'): """ Creates the ProctoredExamStudentAttempt object. """ attempt = ProctoredExamStudentAttempt( proctored_exam_id=exam_id, user_id=self.user_id, external_id=self.external_id, allowed_time_limit_mins=10, status=status ) if status in (ProctoredExamStudentAttemptStatus.started, ProctoredExamStudentAttemptStatus.ready_to_submit, ProctoredExamStudentAttemptStatus.submitted): attempt.started_at = datetime.now(pytz.UTC) if ProctoredExamStudentAttemptStatus.is_completed_status(status): attempt.completed_at = datetime.now(pytz.UTC) attempt.save() return attempt