Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
0a293731
Commit
0a293731
authored
11 years ago
by
Chris Dodge
Browse files
Options
Downloads
Patches
Plain Diff
remove commented out code. Also fix up indents and other violations
parent
d9fa723e
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
+46
-58
46 additions, 58 deletions
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
with
46 additions
and
58 deletions
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
+
46
−
58
View file @
0a293731
import
logging
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.inheritance
import
own_metadata
from
fs.osfs
import
OSFS
from
json
import
dumps
def
export_to_xml
(
modulestore
,
contentstore
,
course_location
,
root_dir
,
course_dir
,
draft_modulestore
=
None
):
def
export_to_xml
(
modulestore
,
contentstore
,
course_location
,
root_dir
,
course_dir
,
draft_modulestore
=
None
):
course
=
modulestore
.
get_item
(
course_location
)
course
=
modulestore
.
get_item
(
course_location
)
fs
=
OSFS
(
root_dir
)
export_fs
=
fs
.
makeopendir
(
course_dir
)
fs
=
OSFS
(
root_dir
)
export_fs
=
fs
.
makeopendir
(
course_dir
)
xml
=
course
.
export_to_xml
(
export_fs
)
with
export_fs
.
open
(
'
course.xml
'
,
'
w
'
)
as
course_xml
:
course_xml
.
write
(
xml
)
# export the static assets
contentstore
.
export_all_for_course
(
course_location
,
root_dir
+
'
/
'
+
course_dir
+
'
/static/
'
)
# export the static tabs
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
'
static_tab
'
,
'
tabs
'
,
'
.html
'
)
# export the custom tags
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
'
custom_tag_template
'
,
'
custom_tags
'
)
# export the course updates
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
'
course_info
'
,
'
info
'
,
'
.html
'
)
# export the grading policy
policies_dir
=
export_fs
.
makeopendir
(
'
policies
'
)
course_run_policy_dir
=
policies_dir
.
makeopendir
(
course
.
location
.
name
)
with
course_run_policy_dir
.
open
(
'
grading_policy.json
'
,
'
w
'
)
as
grading_policy
:
grading_policy
.
write
(
dumps
(
course
.
grading_policy
))
# export all of the course metadata in policy.json
with
course_run_policy_dir
.
open
(
'
policy.json
'
,
'
w
'
)
as
course_policy
:
policy
=
{
'
course/
'
+
course
.
location
.
name
:
own_metadata
(
course
)}
course_policy
.
write
(
dumps
(
policy
))
# export everything from the draft store, unfortunately this will create lots of duplicates
'''
if draft_modulestore is not None:
draft_course = draft_modulestore.get_item(course_location)
xml = draft_course.export_to_xml(draft_course_dir)
with draft_course_dir.open(
'
course.xml
'
,
'
w
'
) as course_xml:
xml
=
course
.
export_to_xml
(
export_fs
)
with
export_fs
.
open
(
'
course.xml
'
,
'
w
'
)
as
course_xml
:
course_xml
.
write
(
xml
)
'''
# export draft content
# NOTE: this code assumes that verticals are the top most draftable container
# should we change the application, then this assumption will no longer
# be valid
if
draft_modulestore
is
not
None
:
draft_verticals
=
draft_modulestore
.
get_items
([
None
,
course_location
.
org
,
course_location
.
course
,
'
vertical
'
,
None
,
'
draft
'
])
if
len
(
draft_verticals
)
>
0
:
draft_course_dir
=
export_fs
.
makeopendir
(
'
drafts
'
)
for
draft_vertical
in
draft_verticals
:
parent_locs
=
draft_modulestore
.
get_parent_locations
(
draft_vertical
.
location
,
course
.
location
.
course_id
)
logging
.
debug
(
'
parent_locs = {0}
'
.
format
(
parent_locs
))
draft_vertical
.
xml_attributes
[
'
parent_sequential_url
'
]
=
Location
(
parent_locs
[
0
]).
url
()
sequential
=
modulestore
.
get_item
(
Location
(
parent_locs
[
0
]))
index
=
sequential
.
children
.
index
(
draft_vertical
.
location
.
url
())
draft_vertical
.
xml_attributes
[
'
index_in_children_list
'
]
=
str
(
index
)
draft_vertical
.
export_to_xml
(
draft_course_dir
)
# export the static assets
contentstore
.
export_all_for_course
(
course_location
,
root_dir
+
'
/
'
+
course_dir
+
'
/static/
'
)
# export the static tabs
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
'
static_tab
'
,
'
tabs
'
,
'
.html
'
)
# export the custom tags
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
'
custom_tag_template
'
,
'
custom_tags
'
)
# export the course updates
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
'
course_info
'
,
'
info
'
,
'
.html
'
)
# export the grading policy
policies_dir
=
export_fs
.
makeopendir
(
'
policies
'
)
course_run_policy_dir
=
policies_dir
.
makeopendir
(
course
.
location
.
name
)
with
course_run_policy_dir
.
open
(
'
grading_policy.json
'
,
'
w
'
)
as
grading_policy
:
grading_policy
.
write
(
dumps
(
course
.
grading_policy
))
# export all of the course metadata in policy.json
with
course_run_policy_dir
.
open
(
'
policy.json
'
,
'
w
'
)
as
course_policy
:
policy
=
{
'
course/
'
+
course
.
location
.
name
:
own_metadata
(
course
)}
course_policy
.
write
(
dumps
(
policy
))
# export draft content
# NOTE: this code assumes that verticals are the top most draftable container
# should we change the application, then this assumption will no longer
# be valid
if
draft_modulestore
is
not
None
:
draft_verticals
=
draft_modulestore
.
get_items
([
None
,
course_location
.
org
,
course_location
.
course
,
'
vertical
'
,
None
,
'
draft
'
])
if
len
(
draft_verticals
)
>
0
:
draft_course_dir
=
export_fs
.
makeopendir
(
'
drafts
'
)
for
draft_vertical
in
draft_verticals
:
parent_locs
=
draft_modulestore
.
get_parent_locations
(
draft_vertical
.
location
,
course
.
location
.
course_id
)
logging
.
debug
(
'
parent_locs = {0}
'
.
format
(
parent_locs
))
draft_vertical
.
xml_attributes
[
'
parent_sequential_url
'
]
=
Location
(
parent_locs
[
0
]).
url
()
sequential
=
modulestore
.
get_item
(
Location
(
parent_locs
[
0
]))
index
=
sequential
.
children
.
index
(
draft_vertical
.
location
.
url
())
draft_vertical
.
xml_attributes
[
'
index_in_children_list
'
]
=
str
(
index
)
draft_vertical
.
export_to_xml
(
draft_course_dir
)
def
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
category_type
,
dirname
,
file_suffix
=
''
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment