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
OpenEdx
edx-proctoring
Commits
4362252e
Commit
4362252e
authored
Jan 11, 2016
by
Douglas Hall
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #258 from edx/hotfix/PHX-242/2016-01-11
Hotfix PHX-242
parents
9ff6ec51
1b27fcc6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
38 deletions
+71
-38
edx_proctoring/callbacks.py
+6
-5
edx_proctoring/tests/test_views.py
+65
-33
No files found.
edx_proctoring/callbacks.py
View file @
4362252e
...
...
@@ -18,11 +18,11 @@ from rest_framework.negotiation import BaseContentNegotiation
from
edx_proctoring.api
import
(
get_exam_attempt_by_code
,
mark_exam_attempt_as_ready
,
update_exam_attempt
)
from
edx_proctoring.exceptions
import
ProctoredBaseException
update_exam_attempt
)
from
edx_proctoring.backends
import
get_backend_provider
from
edx_proctoring.exceptions
import
ProctoredBaseException
from
edx_proctoring.models
import
ProctoredExamStudentAttemptStatus
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -48,7 +48,8 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume
status
=
404
)
if
attempt
[
'status'
]
==
"created"
:
if
attempt
[
'status'
]
in
[
ProctoredExamStudentAttemptStatus
.
created
,
ProctoredExamStudentAttemptStatus
.
download_software_clicked
]:
mark_exam_attempt_as_ready
(
attempt
[
'proctored_exam'
][
'id'
],
attempt
[
'user'
][
'id'
])
template
=
loader
.
get_template
(
'proctored_exam/proctoring_launch_callback.html'
)
...
...
edx_proctoring/tests/test_views.py
View file @
4362252e
...
...
@@ -441,6 +441,56 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
return
ProctoredExamStudentAttempt
.
objects
.
get_exam_attempt
(
proctored_exam
.
id
,
self
.
user
.
id
)
def
_test_exam_attempt_creation
(
self
):
"""
Create proctored exam and exam attempt and verify the status of the attempt is "created"
"""
# Create an exam.
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
,
is_proctored
=
True
)
attempt_id
=
create_exam_attempt
(
proctored_exam
.
id
,
self
.
user
.
id
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"created"
)
return
attempt
def
_test_repeated_start_exam_callbacks
(
self
,
attempt
):
"""
Given an exam attempt, call the start exam callback twice to verify
that the status in not incorrectly reverted
"""
# hit callback and verify that exam status is 'ready to start'
attempt_id
=
attempt
[
'id'
]
code
=
attempt
[
'attempt_code'
]
self
.
client
.
get
(
reverse
(
'edx_proctoring.anonymous.proctoring_launch_callback.start_exam'
,
kwargs
=
{
'attempt_code'
:
code
})
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"ready_to_start"
)
# update exam status to 'started'
exam_id
=
attempt
[
'proctored_exam'
][
'id'
]
user_id
=
attempt
[
'user'
][
'id'
]
update_attempt_status
(
exam_id
,
user_id
,
ProctoredExamStudentAttemptStatus
.
started
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"started"
)
# hit callback again and verify that status is still 'started' and not 'ready to start'
self
.
client
.
get
(
reverse
(
'edx_proctoring.anonymous.proctoring_launch_callback.start_exam'
,
kwargs
=
{
'attempt_code'
:
code
})
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"started"
)
self
.
assertFalse
(
attempt
[
'status'
]
==
"ready_to_start"
)
def
test_start_exam_create
(
self
):
"""
Start an exam (create an exam attempt)
...
...
@@ -515,46 +565,28 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt
=
get_exam_attempt_by_id
(
old_attempt_id
)
self
.
assertIsNotNone
(
attempt
[
'started_at'
])
def
test_start_exam_callback
(
self
):
def
test_start_exam_callback
_when_created
(
self
):
"""
Test that hitting software secure callback URL twice
does not change the state
from 'started' back to 'ready to start'
Test that hitting software secure callback URL twice
when the attempt state begins at
'created' does not change the state
from 'started' back to 'ready to start'
"""
# Create an exam.
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
,
is_proctored
=
True
)
attempt_id
=
create_exam_attempt
(
proctored_exam
.
id
,
self
.
user
.
id
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"created"
)
attempt
=
self
.
_test_exam_attempt_creation
()
self
.
_test_repeated_start_exam_callbacks
(
attempt
)
# hit callback and verify that exam status is 'ready to start'
code
=
attempt
[
'attempt_code'
]
self
.
client
.
get
(
reverse
(
'edx_proctoring.anonymous.proctoring_launch_callback.start_exam'
,
kwargs
=
{
'attempt_code'
:
code
})
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"ready_to_start"
)
def
test_start_exam_callback_when_download_software_clicked
(
self
):
"""
Test that hitting software secure callback URL twice when the attempt state begins at
'download_software_clicked' does not change the state from 'started' back to 'ready to start'
"""
# Create an exam.
attempt
=
self
.
_test_exam_attempt_creation
(
)
#
update exam status to 'start
ed'
#
Update attempt status to 'download_software_click
ed'
exam_id
=
attempt
[
'proctored_exam'
][
'id'
]
user_id
=
attempt
[
'user'
][
'id'
]
update_attempt_status
(
exam_id
,
user_id
,
ProctoredExamStudentAttemptStatus
.
started
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"started"
)
update_attempt_status
(
exam_id
,
user_id
,
ProctoredExamStudentAttemptStatus
.
download_software_clicked
)
# hit callback again and verify that status is still 'started' and not 'ready to start'
self
.
client
.
get
(
reverse
(
'edx_proctoring.anonymous.proctoring_launch_callback.start_exam'
,
kwargs
=
{
'attempt_code'
:
code
})
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertEqual
(
attempt
[
'status'
],
"started"
)
self
.
assertFalse
(
attempt
[
'status'
]
==
"ready_to_start"
)
self
.
_test_repeated_start_exam_callbacks
(
attempt
)
def
test_attempt_readback
(
self
):
"""
...
...
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