You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add logic to parse XBlock's XML with the pointer tag correctly. #823
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.
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:
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.
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.
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.
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:
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 ?
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?
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.
Reacted by Kyle D McCormick and Muhammad Farhan Khan
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.
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.
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.
@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.
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
Reacted by Muhammad Farhan Khan and Kyle D McCormick
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.
Activity
ttqureshi commentedon Mar 12, 2025
FYI @kdmccormick
cc: @farhan @salman2013 @irtazaakram
kdmccormick commentedon Mar 13, 2025
TY. Out on vacation currently but I will add some notes when I'm back on Friday.
kdmccormick commentedon Mar 17, 2025
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.
kdmccormick commentedon Mar 17, 2025
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 = Truein 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.
ttqureshi commentedon Mar 18, 2025
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.
bradenmacdonald commentedon May 14, 2025
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:
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 callruntime.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) toparse_xml?ttqureshi commentedon May 19, 2025
Thanks @bradenmacdonald for the input.
After brainstorming and connecting a few dots, I think that we might need to define
parse_xmlmethod inside theVerticalBlock. Thisparse_xmlmethod will:Please share your thoughts on this. Would this serve the purpose without touching the xblock core functionality?
ttqureshi commentedon May 19, 2025
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_xmlinVerticalBlockor something better) that could support the parsing of the blocks exported in the pointer tag format.bradenmacdonald commentedon May 20, 2025
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.
kdmccormick commentedon Jun 3, 2025
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:
@ttqureshi would you be able to implement this suggestion? My apologies for sending you in so many different directions with this task.
ttqureshi commentedon Jun 4, 2025
@kdmccormick I will surely take a look into it. If i get stuck at some point I'll drop my query.
9 remaining items
ttqureshi commentedon Oct 6, 2025
@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?
kdmccormick commentedon Oct 6, 2025
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.
ttqureshi commentedon Oct 7, 2025
@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.
kdmccormick commentedon Oct 7, 2025
Sounds good!
ttqureshi commentedon Oct 13, 2025
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
ttqureshi commentedon Oct 16, 2025
@kdmccormick
can we consider a green signal from you on this?
kdmccormick commentedon Oct 16, 2025
Yes, green light from me 👍🏻 Let's just avoid bringing in any extraneous XmlMixin logic that's not critical for correct pointer tag parsing.
chore: enrollment_date added to csv report and add custom fields method
ttqureshi commentedon Jan 1, 2026
I'm closing this issue in favor of this new one: openedx/public-engineering#477