# lint-amnesty, pylint: disable=missing-module-docstring from abc import ABCMeta, abstractmethod import six from lxml import etree from six.moves import range, zip class ResponseXMLFactory(six.with_metaclass(ABCMeta, object)): """ Abstract base class for capa response XML factories. Subclasses override create_response_element and create_input_element to produce XML of particular response types""" @abstractmethod def create_response_element(self, **kwargs): """ Subclasses override to return an etree element representing the capa response XML (e.g. ). The tree should NOT contain any input elements (such as ) as these will be added later.""" return None @abstractmethod def create_input_element(self, **kwargs): """ Subclasses override this to return an etree element representing the capa input XML (such as )""" return None def build_xml(self, **kwargs): """ Construct an XML string for a capa response based on **kwargs. **kwargs is a dictionary that will be passed to create_response_element() and create_input_element(). See the subclasses below for other keyword arguments you can specify. For all response types, **kwargs can contain: *question_text*: The text of the question to display, wrapped in