Skip to content

Commit 84f6593

Browse files
committed
docs: ADR for pointer tag
1 parent 557be84 commit 84f6593

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
0002 Handling Pointer Tags for Extracted XBlocks
2+
####################################################
3+
4+
Date
5+
****
6+
2025-10-10
7+
8+
Status
9+
******
10+
Draft
11+
12+
Context
13+
*******
14+
15+
In the Open edX ecosystem, course content is represented in **OLX (Open Learning XML)**.
16+
OLX supports **two organizational formats** for defining blocks:
17+
18+
1. **Inline Format** - The block's full definition is written inline within its tag attributes.
19+
2. **Pointer Tag Format** - The block's definition is stored separately, and the tag only contains a `url_name` attribute pointing to that definition file.
20+
21+
**Example - Inline Format**
22+
23+
.. code-block:: xml
24+
25+
<vertical display_name="LTI">
26+
<lti url_name="lti_789b78a45ec7"
27+
button_text="Launch third-party stuff"
28+
display_name="LTI Testing"
29+
has_score="true"
30+
weight="20.0"/>
31+
</vertical>
32+
33+
**Example - Pointer Tag Format**
34+
35+
.. code-block:: xml
36+
37+
<vertical display_name="LTI">
38+
<lti url_name="e73666f5807e47cbbd161d0d3aa5132b"/>
39+
</vertical>
40+
41+
Here, the ``<lti/>`` tag is a **pointer tag** because its configuration is stored separately at:
42+
43+
.. code-block:: xml
44+
45+
lti/e73666f5807e47cbbd161d0d3aa5132b.xml
46+
47+
<lti button_text="Launch third-party stuff"
48+
display_name="LTI Testing"
49+
has_score="true"
50+
weight="20.0"/>
51+
52+
Both formats are supported by edx-platform's `XmlMixin`, which handles:
53+
54+
- **Parsing:** detecting pointer tags and loading their definitions from the pointed-to file.
55+
- **Exporting:** serializing blocks in pointer format.
56+
57+
However, this was disrupted when **built-in XBlocks** (such as `WordCloud`, `Annotatable`, `LTI`, `HTML`, `Poll`, `Video`, `Problem`) were **extracted from edx-platform** into a new repository: **xblocks-contrib**.
58+
59+
The key architectural change was that **extracted XBlocks no longer depend on `XmlMixin`** and instead inherit directly from the base `XBlock` class — following the *pure XBlock* pattern.
60+
This transition removed pointer-tag handling functionality for those blocks.
61+
62+
Problem
63+
*******
64+
65+
When extracted XBlocks are enabled (e.g., via `USE_EXTRACTED_<BLOCK_NAME>_BLOCK` settings) and a course containing pointer tag definitions is imported:
66+
67+
- The import path calls **XBlock.core's** ``parse_xml``, which only understands inline definitions.
68+
- Since it does not recognize pointer tags, the system fails to load full definitions from referenced files.
69+
- As a result, **empty XBlocks with default configurations** are created.
70+
71+
This issue was introduced when pointer-tag parsing logic from `XmlMixin` was no longer applied to extracted XBlocks.
72+
73+
Attempts & Exploration
74+
**********************
75+
76+
Multiple approaches were explored to restore pointer-tag support for the extracted XBlocks:
77+
78+
1. **Add pointer-tag parsing to XBlock.core ``parse_xml``**
79+
80+
- Attempted in `openedx/XBlock#830`.
81+
82+
- This would modify XBlock core to recognize pointer nodes and load their definitions.
83+
84+
- Omitted to avoid changing the XBlock API and core parsing logic.
85+
86+
2. **Implement pointer loading in edx-platform runtime (parent containers)**
87+
88+
- PR `openedx/edx-platform#37133`.
89+
90+
- The idea was to have parent container blocks (e.g., `VerticalBlock`, `SequentialBlock`) recognize child pointer tags and load their definitions.
91+
92+
- This approach worked but required extending the same support to **external container XBlocks**, which would necessitate new interfaces in the XBlock API.
93+
94+
Alternatives To Consider
95+
************************
96+
97+
1. **Core Interface (Containers or Leaf Blocks)**
98+
- Would unify pointer-tag logic within XBlock core.
99+
- Rejected for now due to the scope and cross-repo impact.
100+
101+
2. **XML Preprocessing Step in edx-platform**
102+
- Architecturally cleaner (resolve all pointer tags before XBlock parsing).
103+
- Rejected as a longer-term project not suited for immediate release needs.
104+
105+
Future Work
106+
***********
107+
108+
Longer-term architectural improvements to consider:
109+
110+
- Introduce a **preprocessing layer** in edx-platform's OLX pipeline to centralize pointer resolution i.e., resolve all pointer tags into inline XML. (Alternative #1).
111+
- Define a **standard XBlock API interface** for pointer-tag handling (Alternative #2).
112+
113+
References
114+
**********
115+
116+
- `openedx/XBlock#830` - Initial attempt to add pointer-tag parsing to XBlock core
117+
- `openedx/edx-platform#37133` - Runtime-based pointer resolution PR
118+
- `xblocks_contrib` - Repository containing extracted XBlocks and new `PointerTagMixin`

0 commit comments

Comments
 (0)