Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't add x-is-pointer-node attribute to Capa problem XML on paste [FC-0062] #35701

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading