The block currently has a String field, xml_content, which lets course authors edit the XML defining the mentoring block and all of its children, much like the advanced editor of capa problems.
However, while the re-engineered block is now working perfectly in the SDK, it is not yet working in Studio. I can't figure out how the XBlock can ask the runtime to assign its children based on the xml_content.
In our studio_submit() ajax handler, if I try parsing the XML and then calling self.runtime.add_node_as_child(...) on each node found in the XML, it fails because it depends on id_generator.create_definition() which doesn't seem to be implemented. I tried implementing it but it became whack-a-mole where each attempted fix caused a new issue elsewhere.
I also considered breaking the XBlock abstraction and using self.runtime.modulestore.add_child() followed by updating the child's fields with the XML data, but the XBlock API has no way for an instantiated XBlock to set its fields from an XML node - the parse_xml method always attempts to create a new block, which won't work in Studio or the LMS.
For now we would be happy with a way to instantiate XBlock children from XML at runtime even if there is no persistence of the children, though that would be ideal.
Any advice?
Thanks!!
--
Braden MacDonald
@OpenCraft