Skip to content

Commit

Permalink
fix: Don't add 'x-is-pointer-node' to capa problems on paste
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald authored and farhaanbukhsh committed Nov 28, 2024
1 parent a4d3bf9 commit de21b82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cms/djangoapps/contentstore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion xmodule/xml_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit de21b82

Please sign in to comment.