fix: duplicate rendering of instructions in annotatable xblock (#36445)
In the Annotatable XBlock, the <instructions> element was appearing twice in the student view: * Once in "annotatable-instructions" (where it should be). * Again in "annotatable-content" (where annotations and other content are rendered). The _render_content method processed and rendered the entire XML data, including <instructions>, without removing it. The _extract_instructions method, which is responsible for removing <instructions>, was not called in _render_content, leading to duplication. This fix will: * Prevents duplicate instructions in the student view. * Maintains the expected behavior of showing instructions only in "annotatable-instructions". * No impact on existing annotation functionality.
This commit is contained in:
@@ -134,3 +134,11 @@ class AnnotatableBlockTestCase(unittest.TestCase): # lint-amnesty, pylint: disa
|
||||
xmltree = etree.fromstring('<annotatable>foo</annotatable>')
|
||||
actual = self.annotatable._extract_instructions(xmltree) # lint-amnesty, pylint: disable=protected-access
|
||||
assert actual is None
|
||||
|
||||
def test_instruction_removal(self):
|
||||
xmltree = etree.fromstring(self.sample_xml)
|
||||
instructions = self.annotatable._extract_instructions(xmltree) # pylint: disable=protected-access
|
||||
|
||||
assert instructions is not None
|
||||
assert "Read the text." in instructions
|
||||
assert xmltree.find("instructions") is None
|
||||
|
||||
Reference in New Issue
Block a user