diff --git a/xmodule/modulestore/inheritance.py b/xmodule/modulestore/inheritance.py index bf05a192ec59..91ad17f2f701 100644 --- a/xmodule/modulestore/inheritance.py +++ b/xmodule/modulestore/inheritance.py @@ -287,7 +287,12 @@ def compute_inherited_metadata(descriptor): # inherited_settings values are json repr parent_metadata[field.name] = field.read_json(descriptor) - for child in descriptor.get_children(): + get_children_kwargs = {} # @medality_custom start + + if descriptor.category == "select_from_library": + get_children_kwargs["context"] = "course_import" + + for child in descriptor.get_children(**get_children_kwargs): # @medality_custom end inherit_metadata(child, parent_metadata) compute_inherited_metadata(child) diff --git a/xmodule/modulestore/xml.py b/xmodule/modulestore/xml.py index 0830281ba426..7801e2a1cc08 100644 --- a/xmodule/modulestore/xml.py +++ b/xmodule/modulestore/xml.py @@ -204,7 +204,12 @@ def fallback_name(orig_name=None): xmlstore.modules[course_id][descriptor.scope_ids.usage_id] = descriptor if descriptor.has_children: - for child in descriptor.get_children(): + get_children_kwargs = {} # @medality_custom start + + if descriptor.category == "select_from_library": + get_children_kwargs["context"] = "course_import" + + for child in descriptor.get_children(**get_children_kwargs): # @medality_custom end # parent is alphabetically least if child.parent is None or child.parent > descriptor.scope_ids.usage_id: child.parent = descriptor.location diff --git a/xmodule/modulestore/xml_importer.py b/xmodule/modulestore/xml_importer.py index d7824f5edd99..ce15e9c17484 100644 --- a/xmodule/modulestore/xml_importer.py +++ b/xmodule/modulestore/xml_importer.py @@ -489,7 +489,12 @@ def depth_first(subtree): Import top down just so import code can make assumptions about parents always being available """ if subtree.has_children: - for child in subtree.get_children(): + get_children_kwargs = {} # @medality_custom start + + if subtree.category == "select_from_library": + get_children_kwargs["context"] = "course_import" + + for child in subtree.get_children(**get_children_kwargs): # @medality_custom end try: all_locs.remove(child.location) except KeyError: @@ -858,7 +863,9 @@ def _convert_ref_fields_to_new_namespace(reference): fields = _update_module_references(module, source_course_id, dest_course_id) asides = module.get_asides() if isinstance(module, XModuleMixin) else None - if module.location.block_type == 'library_content': + lib_content_block_already_published = False # @medality_custom + + if module.location.block_type == 'library_content' or module.location.block_type == 'library_content': # @medality_custom with store.branch_setting(branch_setting=ModuleStoreEnum.Branch.published_only): lib_content_block_already_published = store.has_item(module.location) @@ -875,7 +882,7 @@ def _convert_ref_fields_to_new_namespace(reference): # Special case handling for library content blocks. The fact that this is # in Modulestore code is _bad_ and breaks abstraction barriers, but is too # much work to factor out at this point. - if block.location.block_type == 'library_content': + if block.location.block_type == 'library_content' or block.location.block_type == 'select_from_library': # @medality_custom # If library exists, update source_library_version and children # according to this existing library and library content block. if block.source_library_id and store.get_library(block.source_library_key):