Skip to content
Draft
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
2 changes: 2 additions & 0 deletions openedx/core/lib/xblock_serializer/block_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def _serialize_html_block(self, block) -> etree.Element:
olx_node.attrib["editor"] = block.editor
if block.use_latex_compiler:
olx_node.attrib["use_latex_compiler"] = "true"
if "include_theme" in block.fields and block.include_theme:
olx_node.attrib["include_theme"] = "true"
for field_name in block.fields:
if (
field_name.startswith(("upstream", "downstream")) or field_name == "top_level_downstream_parent_key"
Expand Down
54 changes: 54 additions & 0 deletions openedx/core/lib/xblock_serializer/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,60 @@ def test_html_with_fields(self):
"""
)

def test_html_with_include_theme(self):
""" Test that the extracted HTML block's include_theme setting is serialized. """
course = CourseFactory.create(display_name='test course', run="Testing_course")
html_block = BlockFactory.create(
parent_location=course.location,
category="html",
display_name="Themed HTML Block",
include_theme=True,
data="🍔",
)
serialized = api.serialize_xblock_to_olx(html_block)
self.assertXmlEqual(
serialized.olx_str,
f"""
<html
copied_from_block="{str(html_block.location)}"
url_name="Themed_HTML_Block"
display_name="Themed HTML Block"
include_theme="true"
><![CDATA[
🍔
]]></html>
"""
)

def test_html_without_include_theme_is_not_serialized(self):
""" Blocks that leave the setting unset must not gain the attribute. """
course = CourseFactory.create(display_name='test course', run="Testing_course")
html_block = BlockFactory.create(
parent_location=course.location,
category="html",
data="🍔",
)
serialized = api.serialize_xblock_to_olx(html_block)
assert "include_theme" not in serialized.olx_str

def test_html_with_include_theme_false_is_not_serialized(self):
""" A block carrying the default value must not gain the attribute either.

Syncing a library into a course copies every declared field into the
block's field data, so the setting arrives present and False rather than
absent. Writing it out would put include_theme="false" on every synced
HTML block.
"""
course = CourseFactory.create(display_name='test course', run="Testing_course")
html_block = BlockFactory.create(
parent_location=course.location,
category="html",
data="🍔",
include_theme=False,
)
serialized = api.serialize_xblock_to_olx(html_block)
assert "include_theme" not in serialized.olx_str

def test_export_sequential(self):
"""
Export a sequential from the toy course, including all of its children.
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ constraint-dependencies = [
"edx-enterprise==8.17.0",
"djangorestframework<3.18",
]

# TODO: drop this once xblocks-contrib ships a release carrying the Text
# (HTML) block's include_theme field. Tracked by openedx/xblocks-core#308.
[tool.uv.sources]
xblocks-contrib = { git = "https://github.com/open-craft/xblocks-core.git", rev = "rpenido/text-xblock-include-theme" }

[tool.edx_lint]
uv_constraints = [
# Date: 2025-10-07
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ xblock==6.3.3
xblock-drag-and-drop-v2==5.1.1
xblock-google-drive==0.8.2
xblock-poll==1.16.1
xblocks-contrib==1.0.6
xblocks-contrib @ git+https://github.com/open-craft/xblocks-core.git@25702c61b6a9f3cf1afbc6e49a60790ca90f34c1
xmlsec==1.3.14
# via python3-saml
xss-utils==1.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ xblock==6.3.3
xblock-drag-and-drop-v2==5.1.1
xblock-google-drive==0.8.2
xblock-poll==1.16.1
xblocks-contrib==1.0.6
xblocks-contrib @ git+https://github.com/open-craft/xblocks-core.git@25702c61b6a9f3cf1afbc6e49a60790ca90f34c1
xmlsec==1.3.14
# via python3-saml
xss-utils==1.0.0
Expand Down
20 changes: 8 additions & 12 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading