Skip to content

Add logic to parse XBlock's XML with the pointer tag correctly. #823

Closed
1 of 1 issue completed
openedx/openedx-platform
#37133

Description

@ttqureshi

Currently parse_xml function in xblock/core.py doesn't support the implementation to parse the pointer tags within an XBlock's XML file. It instantiates the XBlock without picking fields data (and other metadata, if any) if there is a pointer tag.

Example XML with pointer tag

<vertical display_name="LTI">
  <lti url_name="lti"/>
</vertical>

Why need it?

We are extracting BuiltIn XBlocks from edx-platform, in order for the extracted XBlocks to work properly we want this pointer tag logic to be implemented in xblock/core.py. This will prevent breaking any functionality, ensuring that XBlock's definition is loaded correctly.

Here's the reference from Demo course, which was exported from Studio as recently as Redwood:

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. ttqureshi commented on Mar 12, 2025

    @ttqureshi
    MemberAuthor
  2. kdmccormick commented on Mar 13, 2025

    @kdmccormick
    Member

    TY. Out on vacation currently but I will add some notes when I'm back on Friday.

  3. kdmccormick commented on Mar 17, 2025

    @kdmccormick
    Member

    I have created this ticket for the overall bug investigation:

    We can keep this issue (xblock/823) focused on fixing the immediate bug, and use edx-platform/36390 for the big-picture investigation of what happened.

  4. kdmccormick commented on Mar 17, 2025

    @kdmccormick
    Member

    There is one big-picture thing we need to worry about for this ticket:

    In order to keep Teak course exports compatible with the broken releases (which are most likely Redwood and Sumac), we should continue to export the currently-external blocks using inline syntax, even though we will restore the ability to import them with pointer syntax. I think we could do this by adding a new class variable to XBlock called export_with_pointer_tag, defaulting to False. The currently-built-in blocks and their extracted counterparts can override this variable to True. The export process can look at the variable to determine whether to export that block using inline or pointer syntax.

    For example: Because drag-and-drop-v2 fails to import with pointer syntax in Redwood and Sumac, we should make sure to export it via inline syntax going forward, so that if an author exports drag-and-drop-v2 from Teak, it will load correctly into Redwood and Sumac.

    Another example: Because word_cloud imports OK with pointer syntax in all releases, we can export it using pointer syntax even after we extract it, because it pointer syntax will work fine for it in Redwood and Sumac. So, we would set export_with_pointer_syntax = True in its class definition.

    Alternatively, if we can find out when and why pointer syntax stopped working and backport a bugfix to all affected releases, then we can instead return to the behavior of always exporting every block with pointer syntax.

  5. ttqureshi commented on Mar 18, 2025

    @ttqureshi
    MemberAuthor

    Thanks @kdmccormick for the introspective look into the issue.
    I will be starting to work on this issue (XBlock/823) as it is blocking the LTI XBlock Extraction.

  6. moved this to 👀 In review in Aximprovements Teamon Apr 3, 2025
  7. bradenmacdonald commented on May 14, 2025

    @bradenmacdonald
    Contributor

    We have previously made the decision to move away from XBlocks having children, and move toward a system where we use Containers for hierarchy above the Component level. So I'm a little bit hesitant to add this logic (which is strictly related to parsing/encoding children) into XBlock core.

    When you see something like the example linked above:

    <vertical display_name="Code Grading">
       ...
      <lti url_name="8e71d278e94f4913bc564cc6141fde53"/>
       ...
    </vertical>

    It's true that we could put logic into the XBlock core so that the LTI block can parse that itself, but it's equally possible (and I would argue, better) to shift this up one level and have the vertical block in this case realize that the child is a pointer node and load the full definition before telling the LTI block to parse it.

    In fact, I don't think we need to make any XBlocks aware of pointer nodes. With the example code here, when the vertical block encounters <lti url_name="..." />, it should call runtime.add_node_as_child(block, child). Why can't we just make it so that that runtime function understands pointer nodes and substitutes in the full XML before calling the child (LTI in this example) to parse_xml ?

  8. ttqureshi commented on May 19, 2025

    @ttqureshi
    MemberAuthor

    Thanks @bradenmacdonald for the input.

    but it's equally possible (and I would argue, better) to shift this up one level and have the vertical block in this case realize that the child is a pointer node and load the full definition before telling the LTI block to parse it.

    After brainstorming and connecting a few dots, I think that we might need to define parse_xml method inside the VerticalBlock. This parse_xml method will:

    • load the vertical block definition from the file
    • check if the child node is a pointer node then load it's full definition and
    • return the block

    Please share your thoughts on this. Would this serve the purpose without touching the xblock core functionality?

  9. ttqureshi commented on May 19, 2025

    @ttqureshi
    MemberAuthor

    I want to highlight one more point here, the edx-platform exports BuiltIn XBlocks in the pointer format, examples can be seen from the Demo course linked in the description, while all other XBlocks that reside outside the edx-platform are exported in the inline format by default (e.g., a, b).

    The whole point of creating this issue is to support the previously exported BuiltIn XBlocks in the pointer tag format after extracting them in the xblocks-contrib.

    Also, there is one test case that is failing in the test PR for extracted LTIBlock which is because of the pointer tag format in which the LTI block is present inside the edx-platform's test course, scoreable.

    So, in any way, I believe we've to come up with a solution (either by adding a parse_xml in VerticalBlock or something better) that could support the parsing of the blocks exported in the pointer tag format.

  10. bradenmacdonald commented on May 20, 2025

    @bradenmacdonald
    Contributor

    Adding the support to Vertical Block is fine with me, though I would prefer to keep it in the runtime itself.

    Also, just as a side note, I find the pointer form is annoying to work with and much prefer the inline form wherever possible. Manually editing a course tarball that uses the pointer form extensively involves much more tedious work correlating files with each other compared to simple tarballs where each unit contains the vertical with all children inline.

  11. kdmccormick commented on Jun 3, 2025

    @kdmccormick
    Member

    Okay, good points @bradenmacdonald , I agree that it would be best if this logic lived in the edx-platform XBlock runtime rather than the XBlock system itself.

    This suggestion is compelling:

    In fact, I don't think we need to make any XBlocks aware of pointer nodes. With the example code here, when the vertical block encounters , it should call runtime.add_node_as_child(block, child). Why can't we just make it so that that runtime function understands pointer nodes and substitutes in the full XML before calling the child (LTI in this example) to parse_xml ?

    @ttqureshi would you be able to implement this suggestion? My apologies for sending you in so many different directions with this task.

  12. ttqureshi commented on Jun 4, 2025

    @ttqureshi
    MemberAuthor

    @kdmccormick I will surely take a look into it. If i get stuck at some point I'll drop my query.

  13. 9 remaining items

  14. ttqureshi commented on Oct 6, 2025

    @ttqureshi
    MemberAuthor

    @kdmccormick
    Since the PR has been reverted. Could you please tell me what should be the next steps? How should I go about this issue?

  15. kdmccormick commented on Oct 6, 2025

    @kdmccormick
    Member

    Hey @ttqureshi , I'm not sure yet why the PR caused pointer tags to fail to import. I need to do some research and consider what the best approach is for pointer tags moving forward.

    However, since we missed this bug in manual testing, we should add new automated tests. Could you add a unit test to ensure that an external block, e.g. drag-and-drop-v2, can be imported from inline format? And, could you ensure that this is tested both for a vertical parent and for a dynamic block parent (e.g. conditional)?

    There is some existing test OLX in edx-platform already, such as common/test/data/toy. To avoid having to build a new test OLX course and import test case from scratch, you could consider enhancing this existing OLX export and/or just adding some new assertions to import test cases which already use it.

    In the future, once this pointer enhancement fix re-merges, we should enhance the test to check that externally-defined blocks can be imported from pointer format as well.

  16. ttqureshi commented on Oct 7, 2025

    @ttqureshi
    MemberAuthor

    @kdmccormick It’s a good idea to modify the existing course and add relevant tests to verify the pointer tag and inline assertions.
    However, before doing that, I’d like to investigate why it broke in the first place. I’m currently debugging the issue to understand what might be going wrong with the existing pointer tag implementation that’s preventing the external blocks from parsing successfully.
    If there's any findings, i'll share here.

  17. kdmccormick commented on Oct 7, 2025

    @kdmccormick
    Member

    Sounds good!

  18. moved this from ✅ Done to 🏗 In progress in Aximprovements Teamon Oct 8, 2025
  19. moved this from 🏗 In progress to 🛑 Blocked in Aximprovements Teamon Oct 9, 2025
  20. ttqureshi commented on Oct 13, 2025

    @ttqureshi
    MemberAuthor

    Hi @kdmccormick
    The team has groomed the issue and, for the time being, we've decided to have custom parsing logic insdie the Extracted XBlocks which will hande the pointer tag parsing for them correctly. This will not break any functionality and we can release the blocker of other tickets on it.
    In the long term, we can have a better solution architecturally involving the community and for that, I've created this ADR. We can create an epic on it to work in future. Thanks!

    cc: @openedx/axim-aximprovements

  21. ttqureshi commented on Oct 16, 2025

    @ttqureshi
    MemberAuthor

    @kdmccormick

    The team has groomed the issue and, for the time being, we've decided to have custom parsing logic insdie the Extracted XBlocks which will hande the pointer tag parsing for them correctly.

    can we consider a green signal from you on this?

  22. kdmccormick commented on Oct 16, 2025

    @kdmccormick
    Member

    Yes, green light from me 👍🏻 Let's just avoid bringing in any extraneous XmlMixin logic that's not critical for correct pointer tag parsing.

  23. moved this from 🛑 Blocked to 📋 Backlog in Aximprovements Teamon Oct 29, 2025
  24. ttqureshi commented on Jan 1, 2026

    @ttqureshi
    MemberAuthor

    I'm closing this issue in favor of this new one: openedx/public-engineering#477

  25. moved this from 📋 Backlog to ✅ Done in Aximprovements Teamon Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions