Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-proctoring
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-proctoring
Commits
a3415c8b
Commit
a3415c8b
authored
Feb 15, 2017
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use expire time for timeouts instead of now.
parent
9d5acea4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
6 deletions
+43
-6
edx_proctoring/api.py
+8
-4
edx_proctoring/tests/test_api.py
+35
-2
No files found.
edx_proctoring/api.py
View file @
a3415c8b
...
...
@@ -391,7 +391,8 @@ def _check_for_attempt_timeout(attempt):
update_attempt_status
(
attempt
[
'proctored_exam'
][
'id'
],
attempt
[
'user'
][
'id'
],
ProctoredExamStudentAttemptStatus
.
timed_out
ProctoredExamStudentAttemptStatus
.
timed_out
,
timeout_timestamp
=
expires_at
)
attempt
=
get_exam_attempt_by_id
(
attempt
[
'id'
])
...
...
@@ -715,7 +716,8 @@ def mark_exam_attempt_as_ready(exam_id, user_id):
return
update_attempt_status
(
exam_id
,
user_id
,
ProctoredExamStudentAttemptStatus
.
ready_to_start
)
def
update_attempt_status
(
exam_id
,
user_id
,
to_status
,
raise_if_not_found
=
True
,
cascade_effects
=
True
):
def
update_attempt_status
(
exam_id
,
user_id
,
to_status
,
raise_if_not_found
=
True
,
cascade_effects
=
True
,
timeout_timestamp
=
None
):
"""
Internal helper to handle state transitions of attempt status
"""
...
...
@@ -730,11 +732,11 @@ def update_attempt_status(exam_id, user_id, to_status, raise_if_not_found=True,
# In some configuration we may treat timeouts the same
# as the user saying he/she wises to submit the exam
alias_timeout
=
(
treat_timeout_as_submitted
=
(
to_status
==
ProctoredExamStudentAttemptStatus
.
timed_out
and
not
settings
.
PROCTORING_SETTINGS
.
get
(
'ALLOW_TIMED_OUT_STATE'
,
False
)
)
if
alias_timeout
:
if
treat_timeout_as_submitted
:
to_status
=
ProctoredExamStudentAttemptStatus
.
submitted
exam_attempt_obj
=
ProctoredExamStudentAttempt
.
objects
.
get_exam_attempt
(
exam_id
,
user_id
)
...
...
@@ -792,6 +794,8 @@ def update_attempt_status(exam_id, user_id, to_status, raise_if_not_found=True,
)
if
add_start_time
:
exam_attempt_obj
.
started_at
=
datetime
.
now
(
pytz
.
UTC
)
elif
treat_timeout_as_submitted
:
exam_attempt_obj
.
completed_at
=
timeout_timestamp
elif
to_status
==
ProctoredExamStudentAttemptStatus
.
submitted
:
# likewise, when we transition to submitted mark
# when the exam has been completed
...
...
edx_proctoring/tests/test_api.py
View file @
a3415c8b
...
...
@@ -943,17 +943,19 @@ class ProctoredExamApiTests(ProctoredExamTestCase):
to_status
)
def
test_
alias_timed_out
(
self
):
def
test_
time_out_as_submitted
(
self
):
"""
Verified that timed_out will automatically state transition
to submitted
"""
exam_attempt
=
self
.
_create_started_exam_attempt
()
random_timestamp
=
datetime
.
now
(
pytz
.
UTC
)
-
timedelta
(
hours
=
4
)
update_attempt_status
(
exam_attempt
.
proctored_exam_id
,
self
.
user
.
id
,
ProctoredExamStudentAttemptStatus
.
timed_out
ProctoredExamStudentAttemptStatus
.
timed_out
,
timeout_timestamp
=
random_timestamp
)
exam_attempt
=
get_exam_attempt_by_id
(
exam_attempt
.
id
)
...
...
@@ -963,6 +965,37 @@ class ProctoredExamApiTests(ProctoredExamTestCase):
ProctoredExamStudentAttemptStatus
.
submitted
)
self
.
assertEqual
(
exam_attempt
[
'completed_at'
],
random_timestamp
)
@patch.dict
(
'django.conf.settings.PROCTORING_SETTINGS'
,
{
'ALLOW_TIMED_OUT_STATE'
:
True
})
def
test_timeout_not_submitted
(
self
):
"""
Test that when the setting is disabled, the status remains timed_out
"""
exam_attempt
=
self
.
_create_started_exam_attempt
()
random_timestamp
=
datetime
.
now
(
pytz
.
UTC
)
-
timedelta
(
hours
=
4
)
update_attempt_status
(
exam_attempt
.
proctored_exam_id
,
self
.
user
.
id
,
ProctoredExamStudentAttemptStatus
.
timed_out
,
timeout_timestamp
=
random_timestamp
)
exam_attempt
=
get_exam_attempt_by_id
(
exam_attempt
.
id
)
self
.
assertEqual
(
exam_attempt
[
'status'
],
ProctoredExamStudentAttemptStatus
.
timed_out
)
self
.
assertNotEqual
(
exam_attempt
[
'completed_at'
],
random_timestamp
)
def
test_update_unexisting_attempt
(
self
):
"""
Tests updating an non-existing attempt
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment