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
15852cd8
Commit
15852cd8
authored
Aug 12, 2013
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify export_to_xml to take an optional contentstore and work with xml courses
parent
55925110
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
8 deletions
+55
-8
cms/djangoapps/contentstore/tests/test_contentstore.py
+41
-0
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
+14
-8
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
15852cd8
...
...
@@ -1273,6 +1273,47 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
# export out to a tempdir
export_to_xml
(
module_store
,
content_store
,
location
,
root_dir
,
'test_export'
)
def
test_export_course_without_content_store
(
self
):
module_store
=
modulestore
(
'direct'
)
content_store
=
contentstore
()
# Create toy course
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'toy'
])
location
=
CourseDescriptor
.
id_to_location
(
'edX/toy/2012_Fall'
)
# Add a sequence
stub_location
=
Location
([
'i4x'
,
'edX'
,
'toy'
,
'sequential'
,
'vertical_sequential'
])
sequential
=
module_store
.
get_item
(
stub_location
)
module_store
.
update_children
(
sequential
.
location
,
sequential
.
children
)
# Get course and export it without a content_store
course
=
module_store
.
get_item
(
location
)
course
.
save
()
root_dir
=
path
(
mkdtemp_clean
())
print
'Exporting to tempdir = {0}'
.
format
(
root_dir
)
export_to_xml
(
module_store
,
None
,
location
,
root_dir
,
'test_export_no_content_store'
)
# Delete the course from module store and reimport it
delete_course
(
module_store
,
content_store
,
location
,
commit
=
True
)
import_from_xml
(
module_store
,
root_dir
,
[
'test_export_no_content_store'
],
draft_store
=
None
,
static_content_store
=
None
,
target_location_namespace
=
course
.
location
)
# Verify reimported course
items
=
module_store
.
get_items
(
stub_location
)
self
.
assertEqual
(
len
(
items
),
1
)
@override_settings
(
CONTENTSTORE
=
TEST_DATA_CONTENTSTORE
,
MODULESTORE
=
TEST_MODULESTORE
)
class
ContentStoreTest
(
ModuleStoreTestCase
):
...
...
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
View file @
15852cd8
...
...
@@ -38,7 +38,7 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
Export all modules from `modulestore` and content from `contentstore` as xml to `root_dir`.
`modulestore`: A `ModuleStore` object that is the source of the modules to export
`contentstore`: A `ContentStore` object that is the source of the content to export
`contentstore`: A `ContentStore` object that is the source of the content to export
, can be None
`course_location`: The `Location` of the `CourseModuleDescriptor` to export
`root_dir`: The directory to write the exported xml to
`course_dir`: The name of the directory inside `root_dir` to write the course content to
...
...
@@ -46,7 +46,12 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
alongside the public content in the course.
"""
course
=
modulestore
.
get_item
(
course_location
)
# we use get_instance instead of get_item to support modulestores
# that can't guarantee that definitions are unique
course
=
modulestore
.
get_instance
(
course_location
.
course_id
,
course_location
)
fs
=
OSFS
(
root_dir
)
export_fs
=
fs
.
makeopendir
(
course_dir
)
...
...
@@ -55,13 +60,14 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
with
export_fs
.
open
(
'course.xml'
,
'w'
)
as
course_xml
:
course_xml
.
write
(
xml
)
policies_dir
=
export_fs
.
makeopendir
(
'policies'
)
# export the static assets
contentstore
.
export_all_for_course
(
course_location
,
root_dir
+
'/'
+
course_dir
+
'/static/'
,
root_dir
+
'/'
+
course_dir
+
'/policies/assets.json'
,
)
policies_dir
=
export_fs
.
makeopendir
(
'policies'
)
if
contentstore
:
contentstore
.
export_all_for_course
(
course_location
,
root_dir
+
'/'
+
course_dir
+
'/static/'
,
root_dir
+
'/'
+
course_dir
+
'/policies/assets.json'
,
)
# export the static tabs
export_extra_content
(
export_fs
,
modulestore
,
course_location
,
'static_tab'
,
'tabs'
,
'.html'
)
...
...
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