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
915f2261
Commit
915f2261
authored
Sep 20, 2015
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add management command to set status
parent
66eedd50
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
161 additions
and
0 deletions
+161
-0
edx_proctoring/management/__init__.py
+3
-0
edx_proctoring/management/commands/__init__.py
+3
-0
edx_proctoring/management/commands/set_attempt_status.py
+64
-0
edx_proctoring/management/commands/tests/__init__.py
+3
-0
edx_proctoring/management/commands/tests/test_set_attempt_status.py
+81
-0
edx_proctoring/models.py
+7
-0
No files found.
edx_proctoring/management/__init__.py
0 → 100644
View file @
915f2261
"""
This is a python module
"""
edx_proctoring/management/commands/__init__.py
0 → 100644
View file @
915f2261
"""
This is a python module
"""
edx_proctoring/management/commands/set_attempt_status.py
0 → 100644
View file @
915f2261
"""
Django management command to manually set the attempt status for a user in a proctored exam
"""
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
from
edx_proctoring.api
import
(
update_attempt_status
,
get_exam_by_id
)
from
edx_proctoring.models
import
ProctoredExamStudentAttemptStatus
class
Command
(
BaseCommand
):
"""
Django Management command to force a background check of all possible notifications
"""
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'-e'
,
'--exam'
,
metavar
=
'EXAM_ID'
,
dest
=
'exam_id'
,
help
=
'exam_id to change'
),
make_option
(
'-u'
,
'--user'
,
metavar
=
'USER'
,
dest
=
'user'
,
help
=
"user_id of user to affect"
),
make_option
(
'-t'
,
'--to'
,
metavar
=
'TO_STATUS'
,
dest
=
'to_status'
,
help
=
'the status to set'
),
)
def
handle
(
self
,
*
args
,
**
options
):
"""
Management command entry point, simply call into the signal firiing
"""
exam_id
=
options
[
'exam_id'
]
user_id
=
options
[
'user_id'
]
to_status
=
options
[
'to_status'
]
msg
=
(
'Running management command to update user {user_id} '
'attempt status on exam_id {exam_id} to {to_status}'
.
format
(
user_id
=
user_id
,
exam_id
=
exam_id
,
to_status
=
to_status
)
)
print
msg
if
not
ProctoredExamStudentAttemptStatus
.
is_valid_status
(
to_status
):
raise
Exception
(
'{to_status} is not a valid attempt status!'
.
format
(
to_status
=
to_status
))
# get exam, this will throw exception if does not exist, so let it bomb out
get_exam_by_id
(
exam_id
)
update_attempt_status
(
exam_id
,
user_id
,
to_status
)
print
'Completed!'
edx_proctoring/management/commands/tests/__init__.py
0 → 100644
View file @
915f2261
"""
This is a python module
"""
edx_proctoring/management/commands/tests/test_set_attempt_status.py
0 → 100644
View file @
915f2261
"""
Tests for the set_attempt_status management command
"""
from
datetime
import
datetime
import
pytz
from
edx_proctoring.tests.utils
import
LoggedInTestCase
from
edx_proctoring.api
import
create_exam
,
get_exam_attempt
from
edx_proctoring.management.commands
import
set_attempt_status
from
edx_proctoring.models
import
ProctoredExamStudentAttemptStatus
,
ProctoredExamStudentAttempt
from
edx_proctoring.tests.test_services
import
(
MockCreditService
,
)
from
edx_proctoring.runtime
import
set_runtime_service
class
SetAttemptStatusTests
(
LoggedInTestCase
):
"""
Coverage of the set_attempt_status.py file
"""
def
setUp
(
self
):
"""
Build up test data
"""
super
(
SetAttemptStatusTests
,
self
)
.
setUp
()
set_runtime_service
(
'credit'
,
MockCreditService
())
self
.
exam_id
=
create_exam
(
course_id
=
'foo'
,
content_id
=
'bar'
,
exam_name
=
'Test Exam'
,
time_limit_mins
=
90
)
ProctoredExamStudentAttempt
.
objects
.
create
(
proctored_exam_id
=
self
.
exam_id
,
user_id
=
self
.
user
.
id
,
external_id
=
'foo'
,
started_at
=
datetime
.
now
(
pytz
.
UTC
),
status
=
ProctoredExamStudentAttemptStatus
.
started
,
allowed_time_limit_mins
=
10
,
taking_as_proctored
=
True
,
is_sample_attempt
=
False
)
def
test_run_comand
(
self
):
"""
Run the management command
"""
set_attempt_status
.
Command
()
.
handle
(
exam_id
=
self
.
exam_id
,
user_id
=
self
.
user
.
id
,
to_status
=
ProctoredExamStudentAttemptStatus
.
rejected
)
attempt
=
get_exam_attempt
(
self
.
exam_id
,
self
.
user
.
id
)
self
.
assertEqual
(
attempt
[
'status'
],
ProctoredExamStudentAttemptStatus
.
rejected
)
set_attempt_status
.
Command
()
.
handle
(
exam_id
=
self
.
exam_id
,
user_id
=
self
.
user
.
id
,
to_status
=
ProctoredExamStudentAttemptStatus
.
verified
)
attempt
=
get_exam_attempt
(
self
.
exam_id
,
self
.
user
.
id
)
self
.
assertEqual
(
attempt
[
'status'
],
ProctoredExamStudentAttemptStatus
.
verified
)
def
test_bad_status
(
self
):
"""
Try passing a bad status
"""
with
self
.
assertRaises
(
Exception
):
set_attempt_status
.
Command
()
.
handle
(
exam_id
=
self
.
exam_id
,
user_id
=
self
.
user
.
id
,
to_status
=
'bad'
)
edx_proctoring/models.py
View file @
915f2261
...
...
@@ -200,6 +200,13 @@ class ProctoredExamStudentAttemptStatus(object):
return
cls
.
status_alias_mapping
.
get
(
status
,
''
)
@classmethod
def
is_valid_status
(
cls
,
status
):
"""
Makes sure that passed in status string is valid
"""
return
cls
.
is_completed_status
(
status
)
or
cls
.
is_incomplete_status
(
status
)
class
ProctoredExamStudentAttemptManager
(
models
.
Manager
):
"""
...
...
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