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
38ee5d8f
Commit
38ee5d8f
authored
Aug 03, 2015
by
chrisndodge
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #56 from edx/cdodge/add-submitted-status
Cdodge/add submitted status
parents
f22b9b30
a4f53d4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
9 deletions
+43
-9
edx_proctoring/api.py
+16
-9
edx_proctoring/tests/test_api.py
+27
-0
No files found.
edx_proctoring/api.py
View file @
38ee5d8f
...
...
@@ -168,7 +168,7 @@ def remove_allowance_for_user(exam_id, user_id, key):
student_allowance
.
delete
()
def
_
update_exam_attempt_status
(
attempt
):
def
_
check_for_attempt_timeout
(
attempt
):
"""
Helper method to see if the status of an
exam needs to be updated, e.g. timeout
...
...
@@ -190,10 +190,12 @@ def _update_exam_attempt_status(attempt):
has_time_expired
=
now_utc
>
expires_at
if
has_time_expired
:
exam_attempt_obj
=
ProctoredExamStudentAttempt
.
objects
.
get_exam_attempt_by_id
(
attempt
[
'id'
])
exam_attempt_obj
.
status
=
ProctoredExamStudentAttemptStatus
.
timed_out
exam_attempt_obj
.
save
()
attempt
=
ProctoredExamStudentAttemptSerializer
(
exam_attempt_obj
)
.
data
update_attempt_status
(
attempt
[
'proctored_exam'
][
'id'
],
attempt
[
'user'
][
'id'
],
ProctoredExamStudentAttemptStatus
.
timed_out
)
attempt
=
get_exam_attempt_by_id
(
attempt
[
'id'
])
return
attempt
...
...
@@ -204,7 +206,7 @@ def _get_exam_attempt(exam_attempt_obj):
"""
serialized_attempt_obj
=
ProctoredExamStudentAttemptSerializer
(
exam_attempt_obj
)
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
...
...
@@ -424,13 +426,18 @@ def update_attempt_status(exam_id, user_id, to_status):
# see if the status transition this changes credit requirement status
update_credit
=
to_status
in
[
ProctoredExamStudentAttemptStatus
.
verified
,
ProctoredExamStudentAttemptStatus
.
rejected
,
ProctoredExamStudentAttemptStatus
.
declined
,
ProctoredExamStudentAttemptStatus
.
not_reviewed
ProctoredExamStudentAttemptStatus
.
declined
,
ProctoredExamStudentAttemptStatus
.
not_reviewed
,
ProctoredExamStudentAttemptStatus
.
submitted
]
if
update_credit
:
exam
=
get_exam_by_id
(
exam_id
)
verification
=
'satisfied'
if
to_status
==
ProctoredExamStudentAttemptStatus
.
verified
\
else
'failed'
if
to_status
==
ProctoredExamStudentAttemptStatus
.
verified
:
verification
=
'satisfied'
elif
to_status
==
ProctoredExamStudentAttemptStatus
.
submitted
:
verification
=
'submitted'
else
:
verification
=
'failed'
credit_service
.
set_credit_requirement_status
(
user_id
=
exam_attempt_obj
.
user_id
,
course_key_or_id
=
exam
[
'course_id'
],
...
...
edx_proctoring/tests/test_api.py
View file @
38ee5d8f
...
...
@@ -31,6 +31,7 @@ from edx_proctoring.api import (
is_feature_enabled
,
mark_exam_attempt_timeout
,
mark_exam_attempt_as_ready
,
update_attempt_status
,
)
from
edx_proctoring.exceptions
import
(
ProctoredExamAlreadyExists
,
...
...
@@ -51,6 +52,9 @@ from .utils import (
LoggedInTestCase
,
)
from
edx_proctoring.tests.test_services
import
MockCreditService
from
edx_proctoring.runtime
import
set_runtime_service
,
get_runtime_service
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
.
practice_exam_submitted_msg
=
'You have submitted this practice proctored exam'
set_runtime_service
(
'credit'
,
MockCreditService
())
def
_create_proctored_exam
(
self
):
"""
Calls the api's create_exam to create an exam object.
...
...
@@ -1030,3 +1036,24 @@ class ProctoredExamApiTests(LoggedInTestCase):
}
)
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