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
03b0bf22
Commit
03b0bf22
authored
Oct 07, 2014
by
Justin Riley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add --dry-run option to reapply_extensions command
parent
571527f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
lms/djangoapps/instructor/management/commands/reapply_extensions.py
+10
-2
lms/djangoapps/instructor/views/tools.py
+13
-4
No files found.
lms/djangoapps/instructor/management/commands/reapply_extensions.py
View file @
03b0bf22
#!/usr/bin/python
#!/usr/bin/python
from
django.http
import
Http404
from
django.http
import
Http404
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
BaseCommand
,
CommandError
,
make_option
from
courseware.courses
import
get_course_by_id
from
courseware.courses
import
get_course_by_id
from
instructor.views.tools
import
reapply_all_extensions
from
instructor.views.tools
import
reapply_all_extensions
...
@@ -9,12 +9,20 @@ from instructor.views.tools import reapply_all_extensions
...
@@ -9,12 +9,20 @@ from instructor.views.tools import reapply_all_extensions
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
args
=
"<course_id>"
args
=
"<course_id>"
help
=
"Reapply all extensions (fixes extensions for newly added problems)"
help
=
"Reapply all extensions (fixes extensions for newly added problems)"
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--dry-run'
,
dest
=
'dry_run'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Show what would be done without actually doing '
'anything'
),
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
if
len
(
args
)
!=
1
:
if
len
(
args
)
!=
1
:
raise
CommandError
(
"insufficient arguments"
)
raise
CommandError
(
"insufficient arguments"
)
try
:
try
:
course
=
get_course_by_id
(
args
[
0
])
course
=
get_course_by_id
(
args
[
0
])
reapply_all_extensions
(
course
)
reapply_all_extensions
(
course
,
dry_run
=
options
[
'dry_run'
]
)
except
(
ValueError
,
Http404
)
as
e
:
except
(
ValueError
,
Http404
)
as
e
:
raise
CommandError
(
e
)
raise
CommandError
(
e
)
lms/djangoapps/instructor/views/tools.py
View file @
03b0bf22
...
@@ -254,7 +254,12 @@ def dump_student_extensions(course, student):
...
@@ -254,7 +254,12 @@ def dump_student_extensions(course, student):
"data"
:
data
}
"data"
:
data
}
def
reapply_all_extensions
(
course
):
def
reapply_all_extensions
(
course
,
dry_run
=
False
):
"""
Recursively reapply all extensions to each extended unit in course. This
fixes an issue where new xmodule children (ie new <problem> children) don't
inherit the same 'extended_due' as their parent.
"""
units
=
get_units_with_due_date
(
course
)
units
=
get_units_with_due_date
(
course
)
units
=
dict
([(
u
.
location
.
url
(),
u
)
for
u
in
units
])
units
=
dict
([(
u
.
location
.
url
(),
u
)
for
u
in
units
])
msks
=
units
.
keys
()
msks
=
units
.
keys
()
...
@@ -272,9 +277,13 @@ def reapply_all_extensions(course):
...
@@ -272,9 +277,13 @@ def reapply_all_extensions(course):
if
not
edue
:
if
not
edue
:
continue
continue
unit
=
units
.
get
(
module
.
module_state_key
)
unit
=
units
.
get
(
module
.
module_state_key
)
print
(
'reapplying extension
%
s to
%
s for user
%
s'
%
if
dry_run
:
(
edue
,
unit
.
location
.
url
(),
student
.
username
))
print
(
'would reapply extension
%
s to
%
s for user
%
s'
%
set_due_date_extension
(
course
,
unit
,
student
,
edue
)
(
edue
,
unit
.
location
.
url
(),
student
.
username
))
else
:
print
(
'reapplying extension
%
s to
%
s for user
%
s'
%
(
edue
,
unit
.
location
.
url
(),
student
.
username
))
set_due_date_extension
(
course
,
unit
,
student
,
edue
)
r
=
reapplied
.
get
(
student
.
username
,
[])
r
=
reapplied
.
get
(
student
.
username
,
[])
r
.
append
(
unit
.
location
.
url
())
r
.
append
(
unit
.
location
.
url
())
reapplied
[
student
.
username
]
=
r
reapplied
[
student
.
username
]
=
r
...
...
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