Skip to content

fix: serialize the Text (HTML) XBlock's include_theme setting [WIP] - #39178

Draft
rpenido wants to merge 3 commits into
openedx:masterfrom
open-craft:rpenido/text-xblock-include-theme
Draft

rpenido wants to merge 3 commits into
openedx:masterfrom
open-craft:rpenido/text-xblock-include-theme

Conversation

@rpenido

@rpenido rpenido commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

XBlockSerializer writes a hard-coded allowlist of fields to OLX. The Text (HTML) XBlock's new opt-in include_theme setting is not in that allowlist, so it survives in the block's in-memory state after a save but is silently dropped from the exported OLX. Reopening the unit loses the setting. This PR adds it to the serializer.

The reader (HtmlBlock.parse_xml_new_runtime) is generic and already picks the attribute up, so writing it here is all that is needed for a full round-trip.

User roles impacted: Course Author (the setting now survives save/export). No learner-visible change.

Supporting information

Principal PR: openedx/xblocks-core#308 — adds the include_theme field to the XBlock and the JavaScript that honours it. This PR is the openedx-platform half: without it the checkbox appears to work and then reverts on save.

Testing instructions

Other information

Deadline

None.


Private ref: FAL-4394

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 1, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @rpenido!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform-oncall.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Comment on lines +177 to +178
if "include_theme" in block.fields and block.fields["include_theme"].is_set_on(block):
olx_node.attrib["include_theme"] = serialize_field(block.include_theme)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_theme is from xblocks-core, but explicitly referenced here
We could try to use a more generic solution, but it may cause other fields to be serialized too

@rpenido
rpenido force-pushed the rpenido/text-xblock-include-theme branch from 969e072 to e39700c Compare October 2, 2026 07:02
@rpenido
rpenido force-pushed the rpenido/text-xblock-include-theme branch from e39700c to 8c518f4 Compare October 2, 2026 07:35
@rpenido
rpenido force-pushed the rpenido/text-xblock-include-theme branch from 8c518f4 to 5b6f1ad Compare October 2, 2026 07:52
olx_node.attrib["editor"] = block.editor
if block.use_latex_compiler:
olx_node.attrib["use_latex_compiler"] = "true"
# The deprecated built-in html block does not declare this field.

@samuelallan72 samuelallan72 Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpenido is it possible to make the html block declare the field? Or is this just an unnecessary comment? I see plenty of other special handling for the html block here, so I don't think this needs an extra comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to declare it. The comment is about the "include_theme" in block.fields guard to avoid an exception when using the legacy HTML xblock from here (xmodule/html_block.py).

if not settings.USE_EXTRACTED_HTML_BLOCK:
warnings.warn(
"The built-in `xmodule.html_block` HtmlBlock implementation is deprecated. "
"To fix this warning, enable `USE_EXTRACTED_HTML_BLOCK` (set it to True) to use "
"`xblocks_contrib.html.HtmlBlock` instead. "
"Support for the built-in implementation, and the `USE_EXTRACTED_HTML_BLOCK` setting, "
"will be removed in Willow.",
DeprecationWarning,
stacklevel=2,
)

We probably don't need this comment. Removed here: d5fbdf2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying :) @rpenido

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

3 participants