Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
7ff13786
Commit
7ff13786
authored
Jan 15, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2180 from edx/usman/openended_post_hostname_argument
Added hostname argument to openended_post command.
parents
a3211a74
45401f5a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
lms/djangoapps/instructor/management/commands/openended_post.py
+30
-5
lms/djangoapps/instructor/utils.py
+2
-1
No files found.
lms/djangoapps/instructor/management/commands/openended_post.py
View file @
7ff13786
...
...
@@ -19,7 +19,7 @@ class Command(BaseCommand):
Command to manually re-post open ended submissions to the grader.
"""
help
=
(
"Usage: openended_post <course_id> <problem_location> <student_ids.txt> --dry-run --task-number=<task_number>
\n
"
help
=
(
"Usage: openended_post <course_id> <problem_location> <student_ids.txt>
<hostname>
--dry-run --task-number=<task_number>
\n
"
"The text file should contain a User.id in each line."
)
option_list
=
BaseCommand
.
option_list
+
(
...
...
@@ -36,10 +36,11 @@ class Command(BaseCommand):
dry_run
=
options
[
'dry_run'
]
task_number
=
options
[
'task_number'
]
if
len
(
args
)
==
3
:
if
len
(
args
)
==
4
:
course_id
=
args
[
0
]
location
=
args
[
1
]
students_ids
=
[
line
.
strip
()
for
line
in
open
(
args
[
2
])]
hostname
=
args
[
3
]
else
:
print
self
.
help
return
...
...
@@ -62,15 +63,20 @@ class Command(BaseCommand):
print
"Number of students: {0}"
.
format
(
students
.
count
())
for
student
in
students
:
post_submission_for_student
(
student
,
course
,
location
,
task_number
,
dry_run
=
dry_run
)
post_submission_for_student
(
student
,
course
,
location
,
task_number
,
dry_run
=
dry_run
,
hostname
=
hostname
)
def
post_submission_for_student
(
student
,
course
,
location
,
task_number
,
dry_run
=
True
):
def
post_submission_for_student
(
student
,
course
,
location
,
task_number
,
dry_run
=
True
,
hostname
=
None
):
"""If the student's task child_state is ASSESSING post submission to grader."""
print
"{0}:{1}"
.
format
(
student
.
id
,
student
.
username
)
request
=
DummyRequest
()
request
.
user
=
student
request
.
host
=
hostname
try
:
module
=
get_module_for_student
(
student
,
course
,
location
)
module
=
get_module_for_student
(
student
,
course
,
location
,
request
=
request
)
if
module
is
None
:
print
" WARNING: No state found."
return
False
...
...
@@ -104,3 +110,22 @@ def post_submission_for_student(student, course, location, task_number, dry_run=
print
err
return
False
class
DummyRequest
(
object
):
"""Dummy request"""
META
=
{}
def
__init__
(
self
):
self
.
session
=
{}
self
.
user
=
None
self
.
host
=
None
self
.
secure
=
True
def
get_host
(
self
):
"""Return a default host."""
return
self
.
host
def
is_secure
(
self
):
"""Always secure."""
return
self
.
secure
lms/djangoapps/instructor/utils.py
View file @
7ff13786
...
...
@@ -27,8 +27,9 @@ class DummyRequest(object):
return
False
def
get_module_for_student
(
student
,
course
,
location
):
def
get_module_for_student
(
student
,
course
,
location
,
request
=
None
):
"""Return the module for the (student, location) using a DummyRequest."""
if
request
is
None
:
request
=
DummyRequest
()
request
.
user
=
student
...
...
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