Commit 9f46dc33 by Chris Dodge

tweeks

parent 29219937
...@@ -374,7 +374,7 @@ def _start_exam_attempt(existing_attempt): ...@@ -374,7 +374,7 @@ def _start_exam_attempt(existing_attempt):
Helper method Helper method
""" """
if existing_attempt.started_at: if existing_attempt.started_at and existing_attempt.status == ProctoredExamStudentAttemptStatus.started:
# cannot restart an attempt # cannot restart an attempt
err_msg = ( err_msg = (
'Cannot start exam attempt for exam_id = {exam_id} ' 'Cannot start exam attempt for exam_id = {exam_id} '
...@@ -488,7 +488,13 @@ def update_attempt_status(exam_id, user_id, to_status): ...@@ -488,7 +488,13 @@ def update_attempt_status(exam_id, user_id, to_status):
exam_attempt_obj.completed_at = datetime.now(pytz.UTC) exam_attempt_obj.completed_at = datetime.now(pytz.UTC)
exam_attempt_obj.save() exam_attempt_obj.save()
if to_status == ProctoredExamStudentAttemptStatus.started: # if we have transitioned to started and haven't set our
# started_at timestamp, do so now
add_start_time = (
to_status == ProctoredExamStudentAttemptStatus.started and
not exam_attempt_obj.started_at
)
if add_start_time:
exam_attempt_obj.started_at = datetime.now(pytz.UTC) exam_attempt_obj.started_at = datetime.now(pytz.UTC)
exam_attempt_obj.save() exam_attempt_obj.save()
...@@ -692,10 +698,11 @@ def get_student_view(user_id, course_id, content_id, ...@@ -692,10 +698,11 @@ def get_student_view(user_id, course_id, content_id,
if attempt and attempt['status'] == ProctoredExamStudentAttemptStatus.declined: if attempt and attempt['status'] == ProctoredExamStudentAttemptStatus.declined:
return None return None
does_time_remain = False
has_started_exam = attempt and attempt.get('started_at') has_started_exam = attempt and attempt.get('started_at')
if has_started_exam: if has_started_exam:
if attempt.get('status') == 'error': expires_at = attempt['started_at'] + timedelta(minutes=attempt['allowed_time_limit_mins'])
student_view_template = 'proctoring/seq_proctored_exam_error.html' does_time_remain = datetime.now(pytz.UTC) < expires_at
if not has_started_exam: if not has_started_exam:
# determine whether to show a timed exam only entrance screen # determine whether to show a timed exam only entrance screen
...@@ -716,6 +723,8 @@ def get_student_view(user_id, course_id, content_id, ...@@ -716,6 +723,8 @@ def get_student_view(user_id, course_id, content_id,
}) })
else: else:
student_view_template = 'proctoring/seq_timed_exam_entrance.html' student_view_template = 'proctoring/seq_timed_exam_entrance.html'
elif attempt['status'] == ProctoredExamStudentAttemptStatus.error:
student_view_template = 'proctoring/seq_proctored_exam_error.html'
elif attempt['status'] == ProctoredExamStudentAttemptStatus.timed_out: elif attempt['status'] == ProctoredExamStudentAttemptStatus.timed_out:
student_view_template = 'proctoring/seq_timed_exam_expired.html' student_view_template = 'proctoring/seq_timed_exam_expired.html'
elif attempt['status'] == ProctoredExamStudentAttemptStatus.submitted: elif attempt['status'] == ProctoredExamStudentAttemptStatus.submitted:
...@@ -752,11 +761,16 @@ def get_student_view(user_id, course_id, content_id, ...@@ -752,11 +761,16 @@ def get_student_view(user_id, course_id, content_id,
'exam_id': exam_id, 'exam_id': exam_id,
'progress_page_url': progress_page_url, 'progress_page_url': progress_page_url,
'is_sample_attempt': attempt['is_sample_attempt'] if attempt else False, 'is_sample_attempt': attempt['is_sample_attempt'] if attempt else False,
'does_time_remain': does_time_remain,
'enter_exam_endpoint': reverse('edx_proctoring.proctored_exam.attempt.collection'), 'enter_exam_endpoint': reverse('edx_proctoring.proctored_exam.attempt.collection'),
'exam_started_poll_url': reverse( 'exam_started_poll_url': reverse(
'edx_proctoring.proctored_exam.attempt', 'edx_proctoring.proctored_exam.attempt',
args=[attempt['id']] args=[attempt['id']]
) if attempt else '' ) if attempt else '',
'change_state_url': reverse(
'edx_proctoring.proctored_exam.attempt',
args=[attempt['id']]
) if attempt else '',
}) })
return template.render(django_context) return template.render(django_context)
......
...@@ -11,17 +11,21 @@ ...@@ -11,17 +11,21 @@
Your worked will then be graded and your proctored session will be reviewed separately. Your worked will then be graded and your proctored session will be reviewed separately.
{% endblocktrans %} {% endblocktrans %}
</p> </p>
<button type="button" name="submit-proctored-exam" class="exam-action-button" data-action="submit" data-exam-id="{{exam_id}}" data-change-state-url="{{data-change-state-url}}"> <div>
{% blocktrans %} <button type="button" name="submit-proctored-exam" class="exam-action-button" data-action="submit" data-exam-id="{{exam_id}}" data-change-state-url="{{change_state_url}}">
I'm ready! Submit my answers and end my proctored exam.
{% endblocktrans %}
</button>
{% if does_time_remain %}
<button type="button" name="goback-proctored-exam" class="exam-action-button" data-action="start" data-exam-id="{{exam_id}}" data-change-state-url="{{data-change-state-url}}">
{% blocktrans %} {% blocktrans %}
No, I am not ready! I'd like to continue my work. I'm ready! Submit my answers and end my proctored exam.
{% endblocktrans %} {% endblocktrans %}
</button> </button>
</div>
{% if does_time_remain %}
<div>
<button type="button" name="goback-proctored-exam" class="exam-action-button" data-action="start" data-exam-id="{{exam_id}}" data-change-state-url="{{change_state_url}}">
{% blocktrans %}
No, I am not ready! I'd like to continue my work.
{% endblocktrans %}
</button>
</div>
{% endif %} {% endif %}
</div> </div>
<div class="footer-sequence border-b-0 padding-b-0"> <div class="footer-sequence border-b-0 padding-b-0">
...@@ -37,13 +41,13 @@ ...@@ -37,13 +41,13 @@
<script type="text/javascript"> <script type="text/javascript">
$('.exam-action-button').click( $('.exam-action-button').click(
function(event) { function(event) {
var action_url = $(this).data('data-change-state-url'); var action_url = $(this).data('change-state-url');
var exam_id = $(this).data('exam-id'); var exam_id = $(this).data('exam-id');
var action = $(this).data('data-action') var action = $(this).data('action')
// Update the state of the attempt // Update the state of the attempt
$.ajax({ $.ajax({
url: url, url: action_url,
type: 'PUT', type: 'PUT',
data: { data: {
action: action action: action
......
...@@ -346,6 +346,7 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView): ...@@ -346,6 +346,7 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
return Response({"exam_attempt_id": exam_attempt_id}) return Response({"exam_attempt_id": exam_attempt_id})
except ProctoredBaseException, ex: except ProctoredBaseException, ex:
LOG.exception(ex)
return Response( return Response(
status=status.HTTP_400_BAD_REQUEST, status=status.HTTP_400_BAD_REQUEST,
data={"detail": str(ex)} data={"detail": str(ex)}
......
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