diff --git a/cms/djangoapps/contentstore/helpers.py b/cms/djangoapps/contentstore/helpers.py index 8ff1f1aa39cc..e40eddb6c99e 100644 --- a/cms/djangoapps/contentstore/helpers.py +++ b/cms/djangoapps/contentstore/helpers.py @@ -7,6 +7,7 @@ import urllib from lxml import etree from mimetypes import guess_type +import re from attrs import frozen, Factory from django.conf import settings @@ -447,6 +448,10 @@ def _import_xml_node_to_parent( temp_xblock = xblock_class.parse_xml(node_without_children, runtime, keys) child_nodes = list(node) + if issubclass(xblock_class, XmlMixin) and "x-is-pointer-node" in getattr(temp_xblock, "data", ""): + # Undo the "pointer node" hack if needed (e.g. for capa problems) + temp_xblock.data = re.sub(r'([^>]+) x-is-pointer-node="no"', r'\1', temp_xblock.data, count=1) + # Restore the original id_generator runtime.id_generator = original_id_generator diff --git a/xmodule/xml_block.py b/xmodule/xml_block.py index 2753d455adc7..63dbedb17e1e 100644 --- a/xmodule/xml_block.py +++ b/xmodule/xml_block.py @@ -123,7 +123,11 @@ class XmlMixin: # places in the platform rely on it. 'course', 'org', 'url_name', 'filename', # Used for storing xml attributes between import and export, for roundtrips - 'xml_attributes') + 'xml_attributes', + # Used by _import_xml_node_to_parent in cms/djangoapps/contentstore/helpers.py to prevent + # XmlMixin from treating some XML nodes as "pointer nodes". + "x-is-pointer-node", + ) # This is a categories to fields map that contains the block category specific fields which should not be # cleaned and/or override while adding xml to node.