Merge pull request #24813 from edx/ddumesnil/xml-import-lcm-disable
Disable updating Library Content children during import
This commit is contained in:
@@ -985,44 +985,44 @@ class TestCourseExportImport(LibraryTestCase):
|
||||
dest_child = self.store.get_item(dest_child_location)
|
||||
self.assertEqual(source_child.display_name, dest_child.display_name)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_library_content_on_course_export_import(self, publish_item):
|
||||
"""
|
||||
Verify that library contents in destination and source courses are same after importing
|
||||
the source course into destination course.
|
||||
"""
|
||||
self._setup_source_course_with_library_content(publish=publish_item)
|
||||
# @ddt.data(True, False)
|
||||
# def test_library_content_on_course_export_import(self, publish_item):
|
||||
# """
|
||||
# Verify that library contents in destination and source courses are same after importing
|
||||
# the source course into destination course.
|
||||
# """
|
||||
# self._setup_source_course_with_library_content(publish=publish_item)
|
||||
|
||||
# Create a course to import source course.
|
||||
dest_course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
|
||||
# # Create a course to import source course.
|
||||
# dest_course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
|
||||
|
||||
# Export the source course.
|
||||
export_course_to_xml(
|
||||
self.store,
|
||||
contentstore(),
|
||||
self.source_course.location.course_key,
|
||||
self.export_dir,
|
||||
'exported_source_course',
|
||||
)
|
||||
# # Export the source course.
|
||||
# export_course_to_xml(
|
||||
# self.store,
|
||||
# contentstore(),
|
||||
# self.source_course.location.course_key,
|
||||
# self.export_dir,
|
||||
# 'exported_source_course',
|
||||
# )
|
||||
|
||||
# Now, import it back to dest_course.
|
||||
import_course_from_xml(
|
||||
self.store,
|
||||
self.user.id,
|
||||
self.export_dir,
|
||||
['exported_source_course'],
|
||||
static_content_store=contentstore(),
|
||||
target_id=dest_course.location.course_key,
|
||||
load_error_modules=False,
|
||||
raise_on_failure=True,
|
||||
create_if_not_present=True,
|
||||
)
|
||||
# # Now, import it back to dest_course.
|
||||
# import_course_from_xml(
|
||||
# self.store,
|
||||
# self.user.id,
|
||||
# self.export_dir,
|
||||
# ['exported_source_course'],
|
||||
# static_content_store=contentstore(),
|
||||
# target_id=dest_course.location.course_key,
|
||||
# load_error_modules=False,
|
||||
# raise_on_failure=True,
|
||||
# create_if_not_present=True,
|
||||
# )
|
||||
|
||||
self.assert_problem_display_names(
|
||||
self.source_course.location,
|
||||
dest_course.location,
|
||||
publish_item
|
||||
)
|
||||
# self.assert_problem_display_names(
|
||||
# self.source_course.location,
|
||||
# dest_course.location,
|
||||
# publish_item
|
||||
# )
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
|
||||
@@ -822,20 +822,26 @@ def _update_and_import_module(
|
||||
# Get to the point where XML import is happening inside the
|
||||
# modulestore that is eventually going to store the data.
|
||||
# Ticket: https://openedx.atlassian.net/browse/PLAT-1046
|
||||
if block.location.block_type == 'library_content':
|
||||
# if library exists, update source_library_version and children
|
||||
# according to this existing library and library content block.
|
||||
if store.get_library(block.source_library_key):
|
||||
# Update library content block's children on draft branch
|
||||
with store.branch_setting(branch_setting=ModuleStoreEnum.Branch.draft_preferred):
|
||||
LibraryToolsService(store, user_id).update_children(
|
||||
block,
|
||||
version=block.source_library_version,
|
||||
)
|
||||
|
||||
# Publish it if importing the course for branch setting published_only.
|
||||
if store.get_branch_setting() == ModuleStoreEnum.Branch.published_only:
|
||||
store.publish(block.location, user_id)
|
||||
## Disabling library content children update during import as we saw it cause
|
||||
## an issue where the children were recalculated causing learner's to lose their
|
||||
## current state.
|
||||
## If this is brought back in, also uncomment the tests in
|
||||
## cms/djangoapps/contentstore/views/tests/test_import_export.py
|
||||
# if block.location.block_type == 'library_content':
|
||||
# # if library exists, update source_library_version and children
|
||||
# # according to this existing library and library content block.
|
||||
# if store.get_library(block.source_library_key):
|
||||
# # Update library content block's children on draft branch
|
||||
# with store.branch_setting(branch_setting=ModuleStoreEnum.Branch.draft_preferred):
|
||||
# LibraryToolsService(store, user_id).update_children(
|
||||
# block,
|
||||
# version=block.source_library_version,
|
||||
# )
|
||||
|
||||
# # Publish it if importing the course for branch setting published_only.
|
||||
# if store.get_branch_setting() == ModuleStoreEnum.Branch.published_only:
|
||||
# store.publish(block.location, user_id)
|
||||
|
||||
return block
|
||||
|
||||
|
||||
Reference in New Issue
Block a user