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
a4f53d4b
Commit
a4f53d4b
authored
Aug 03, 2015
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests
parent
b009e73c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
edx_proctoring/api.py
+8
-6
edx_proctoring/tests/test_api.py
+27
-0
No files found.
edx_proctoring/api.py
View file @
a4f53d4b
...
@@ -168,7 +168,7 @@ def remove_allowance_for_user(exam_id, user_id, key):
...
@@ -168,7 +168,7 @@ def remove_allowance_for_user(exam_id, user_id, key):
student_allowance
.
delete
()
student_allowance
.
delete
()
def
_
update_exam_attempt_status
(
attempt
):
def
_
check_for_attempt_timeout
(
attempt
):
"""
"""
Helper method to see if the status of an
Helper method to see if the status of an
exam needs to be updated, e.g. timeout
exam needs to be updated, e.g. timeout
...
@@ -190,10 +190,12 @@ def _update_exam_attempt_status(attempt):
...
@@ -190,10 +190,12 @@ def _update_exam_attempt_status(attempt):
has_time_expired
=
now_utc
>
expires_at
has_time_expired
=
now_utc
>
expires_at
if
has_time_expired
:
if
has_time_expired
:
exam_attempt_obj
=
ProctoredExamStudentAttempt
.
objects
.
get_exam_attempt_by_id
(
attempt
[
'id'
])
update_attempt_status
(
exam_attempt_obj
.
status
=
ProctoredExamStudentAttemptStatus
.
timed_out
attempt
[
'proctored_exam'
][
'id'
],
exam_attempt_obj
.
save
()
attempt
[
'user'
][
'id'
],
attempt
=
ProctoredExamStudentAttemptSerializer
(
exam_attempt_obj
)
.
data
ProctoredExamStudentAttemptStatus
.
timed_out
)
attempt
=
get_exam_attempt_by_id
(
attempt
[
'id'
])
return
attempt
return
attempt
...
@@ -204,7 +206,7 @@ def _get_exam_attempt(exam_attempt_obj):
...
@@ -204,7 +206,7 @@ def _get_exam_attempt(exam_attempt_obj):
"""
"""
serialized_attempt_obj
=
ProctoredExamStudentAttemptSerializer
(
exam_attempt_obj
)
serialized_attempt_obj
=
ProctoredExamStudentAttemptSerializer
(
exam_attempt_obj
)
attempt
=
serialized_attempt_obj
.
data
if
exam_attempt_obj
else
None
attempt
=
serialized_attempt_obj
.
data
if
exam_attempt_obj
else
None
attempt
=
_
update_exam_attempt_status
(
attempt
)
attempt
=
_
check_for_attempt_timeout
(
attempt
)
return
attempt
return
attempt
...
...
edx_proctoring/tests/test_api.py
View file @
a4f53d4b
...
@@ -31,6 +31,7 @@ from edx_proctoring.api import (
...
@@ -31,6 +31,7 @@ from edx_proctoring.api import (
is_feature_enabled
,
is_feature_enabled
,
mark_exam_attempt_timeout
,
mark_exam_attempt_timeout
,
mark_exam_attempt_as_ready
,
mark_exam_attempt_as_ready
,
update_attempt_status
,
)
)
from
edx_proctoring.exceptions
import
(
from
edx_proctoring.exceptions
import
(
ProctoredExamAlreadyExists
,
ProctoredExamAlreadyExists
,
...
@@ -51,6 +52,9 @@ from .utils import (
...
@@ -51,6 +52,9 @@ from .utils import (
LoggedInTestCase
,
LoggedInTestCase
,
)
)
from
edx_proctoring.tests.test_services
import
MockCreditService
from
edx_proctoring.runtime
import
set_runtime_service
,
get_runtime_service
class
ProctoredExamApiTests
(
LoggedInTestCase
):
class
ProctoredExamApiTests
(
LoggedInTestCase
):
"""
"""
...
@@ -92,6 +96,8 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -92,6 +96,8 @@ class ProctoredExamApiTests(LoggedInTestCase):
self
.
start_a_practice_exam_msg
=
'Would you like to take
%
s as a practice proctored exam?'
self
.
start_a_practice_exam_msg
=
'Would you like to take
%
s as a practice proctored exam?'
self
.
practice_exam_submitted_msg
=
'You have submitted this practice proctored exam'
self
.
practice_exam_submitted_msg
=
'You have submitted this practice proctored exam'
set_runtime_service
(
'credit'
,
MockCreditService
())
def
_create_proctored_exam
(
self
):
def
_create_proctored_exam
(
self
):
"""
"""
Calls the api's create_exam to create an exam object.
Calls the api's create_exam to create an exam object.
...
@@ -1030,3 +1036,24 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -1030,3 +1036,24 @@ class ProctoredExamApiTests(LoggedInTestCase):
}
}
)
)
self
.
assertIn
(
self
.
timed_exam_completed_msg
,
rendered_response
)
self
.
assertIn
(
self
.
timed_exam_completed_msg
,
rendered_response
)
def
test_submitted_credit_state
(
self
):
"""
Verify that putting an attempt into the submitted state will also mark
the credit requirement as submitted
"""
exam_attempt
=
self
.
_create_started_exam_attempt
()
update_attempt_status
(
exam_attempt
.
proctored_exam_id
,
self
.
user
.
id
,
ProctoredExamStudentAttemptStatus
.
submitted
)
credit_service
=
get_runtime_service
(
'credit'
)
credit_status
=
credit_service
.
get_credit_state
(
self
.
user
.
id
,
exam_attempt
.
proctored_exam
.
course_id
)
self
.
assertEqual
(
len
(
credit_status
[
'credit_requirement_status'
]),
1
)
self
.
assertEqual
(
credit_status
[
'credit_requirement_status'
][
0
][
'status'
],
'submitted'
)
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