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
2db79732
Commit
2db79732
authored
Oct 07, 2014
by
Don Mitchell
Committed by
Zia Fazal
Apr 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Video module must handle xml attrs
LMS-11491
parent
de4170d5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
54 deletions
+54
-54
common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py
+8
-7
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+41
-41
common/lib/xmodule/xmodule/video_module/video_module.py
+5
-6
No files found.
common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py
View file @
2db79732
...
...
@@ -313,13 +313,14 @@ class CrossStoreXMLRoundtrip(CourseComparisonTest):
create_new_course_if_not_present
=
True
,
)
export_to_xml
(
dest_store
,
dest_content
,
dest_course_key
,
self
.
export_dir
,
'exported_dest_course'
,
)
# NOT CURRENTLY USED
# export_to_xml(
# dest_store,
# dest_content,
# dest_course_key,
# self.export_dir,
# 'exported_dest_course',
# )
self
.
exclude_field
(
None
,
'wiki_slug'
)
self
.
exclude_field
(
None
,
'xml_attributes'
)
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
2db79732
...
...
@@ -492,6 +492,46 @@ def _import_course_draft(
field_data
=
KvsFieldData
(
kvs
=
DictKeyValueStore
()),
)
def
_import_module
(
module
):
# IMPORTANT: Be sure to update the module location in the NEW namespace
module_location
=
module
.
location
.
map_into_course
(
target_course_id
)
# Update the module's location to DRAFT revision
# We need to call this method (instead of updating the location directly)
# to ensure that pure XBlock field data is updated correctly.
_update_module_location
(
module
,
module_location
.
replace
(
revision
=
MongoRevisionKey
.
draft
))
# make sure our parent has us in its list of children
# this is to make sure private only verticals show up
# in the list of children since they would have been
# filtered out from the non-draft store export.
# Note though that verticals nested below the unit level will not have
# a parent_sequential_url and do not need special handling.
if
module
.
location
.
category
==
'vertical'
and
'parent_sequential_url'
in
module
.
xml_attributes
:
sequential_url
=
module
.
xml_attributes
[
'parent_sequential_url'
]
index
=
int
(
module
.
xml_attributes
[
'index_in_children_list'
])
course_key
=
descriptor
.
location
.
course_key
seq_location
=
course_key
.
make_usage_key_from_deprecated_string
(
sequential_url
)
# IMPORTANT: Be sure to update the sequential in the NEW namespace
seq_location
=
seq_location
.
map_into_course
(
target_course_id
)
sequential
=
store
.
get_item
(
seq_location
,
depth
=
0
)
non_draft_location
=
module
.
location
.
map_into_course
(
target_course_id
)
if
not
any
(
child
.
block_id
==
module
.
location
.
block_id
for
child
in
sequential
.
children
):
sequential
.
children
.
insert
(
index
,
non_draft_location
)
store
.
update_item
(
sequential
,
user_id
)
_import_module_and_update_references
(
module
,
store
,
user_id
,
source_course_id
,
target_course_id
,
runtime
=
mongo_runtime
,
)
for
child
in
module
.
get_children
():
_import_module
(
child
)
# now walk the /vertical directory where each file in there
# will be a draft copy of the Vertical
...
...
@@ -563,51 +603,11 @@ def _import_course_draft(
logging
.
exception
(
'Error while parsing course xml.'
)
# For each index_in_children_list key, there is a list of vertical descriptors.
for
key
in
sorted
(
drafts
.
iterkeys
()):
for
descriptor
in
drafts
[
key
]:
course_key
=
descriptor
.
location
.
course_key
try
:
def
_import_module
(
module
):
# IMPORTANT: Be sure to update the module location in the NEW namespace
module_location
=
module
.
location
.
map_into_course
(
target_course_id
)
# Update the module's location to DRAFT revision
# We need to call this method (instead of updating the location directly)
# to ensure that pure XBlock field data is updated correctly.
_update_module_location
(
module
,
module_location
.
replace
(
revision
=
MongoRevisionKey
.
draft
))
# make sure our parent has us in its list of children
# this is to make sure private only verticals show up
# in the list of children since they would have been
# filtered out from the non-draft store export.
# Note though that verticals nested below the unit level will not have
# a parent_sequential_url and do not need special handling.
if
module
.
location
.
category
==
'vertical'
and
'parent_sequential_url'
in
module
.
xml_attributes
:
sequential_url
=
module
.
xml_attributes
[
'parent_sequential_url'
]
index
=
int
(
module
.
xml_attributes
[
'index_in_children_list'
])
seq_location
=
course_key
.
make_usage_key_from_deprecated_string
(
sequential_url
)
# IMPORTANT: Be sure to update the sequential in the NEW namespace
seq_location
=
seq_location
.
map_into_course
(
target_course_id
)
sequential
=
store
.
get_item
(
seq_location
,
depth
=
0
)
non_draft_location
=
module
.
location
.
map_into_course
(
target_course_id
)
if
not
any
(
child
.
block_id
==
module
.
location
.
block_id
for
child
in
sequential
.
children
):
sequential
.
children
.
insert
(
index
,
non_draft_location
)
store
.
update_item
(
sequential
,
user_id
)
_import_module_and_update_references
(
module
,
store
,
user_id
,
source_course_id
,
target_course_id
,
runtime
=
mongo_runtime
,
)
for
child
in
module
.
get_children
():
_import_module
(
child
)
_import_module
(
descriptor
)
except
Exception
:
logging
.
exception
(
'while importing draft descriptor
%
s'
,
descriptor
)
...
...
common/lib/xmodule/xmodule/video_module/video_module.py
View file @
2db79732
...
...
@@ -583,15 +583,14 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler
# If the user has specified html5 sources, make sure we don't use the default video
if
youtube_id
!=
''
or
'html5_sources'
in
field_data
:
field_data
[
'youtube_id_{0}'
.
format
(
normalized_speed
.
replace
(
'.'
,
'_'
))]
=
youtube_id
elif
attr
in
conversions
:
field_data
[
attr
]
=
conversions
[
attr
](
value
)
elif
attr
not
in
cls
.
fields
:
field_data
.
setdefault
(
'xml_attributes'
,
{})[
attr
]
=
value
else
:
# Convert XML attrs into Python values.
if
attr
in
conversions
:
value
=
conversions
[
attr
](
value
)
else
:
# We export values with json.dumps (well, except for Strings, but
# for about a month we did it for Strings also).
value
=
deserialize_field
(
cls
.
fields
[
attr
],
value
)
field_data
[
attr
]
=
value
field_data
[
attr
]
=
deserialize_field
(
cls
.
fields
[
attr
],
value
)
# For backwards compatibility: Add `source` if XML doesn't have `download_video`
# attribute.
...
...
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