1.3.3. Content Model

class pyslet.qtiv2.content.ItemBody(parent)

Bases: pyslet.qtiv2.content.BodyElement

The item body contains the text, graphics, media objects, and interactions that describe the item’s content and information about how it is structured:

<xsd:attributeGroup name="itemBody.AttrGroup">
        <xsd:attributeGroup ref="bodyElement.AttrGroup"/>
</xsd:attributeGroup>

<xsd:group name="itemBody.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="block.ElementGroup" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
RenderHTML(parent, profile, itemState)

Overrides BodyElement.RenderHTML(), the result is always a Div with class set to “itemBody”. Unlike other such method parent may by None, in which case a new parentless Div is created.

class pyslet.qtiv2.content.BodyElement(parent)

Bases: pyslet.qtiv2.core.QTIElement

The root class of all content objects in the item content model is the bodyElement. It defines a number of attributes that are common to all elements of the content model:

<xsd:attributeGroup name="bodyElement.AttrGroup">
        <xsd:attribute name="id" type="identifier.Type" use="optional"/>
        <xsd:attribute name="class" use="optional">
                <xsd:simpleType>
                        <xsd:list itemType="styleclass.Type"/>
                </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute ref="xml:lang"/>
        <xsd:attribute name="label" type="string256.Type" use="optional"/>
</xsd:attributeGroup>
RenderHTML(parent, profile, itemState)

Renders this element in html form, adding nodes to parent. This method effectively overrides html40_19991224.XHTMLElement.RenderHTML enabling QTI and XHTML elements to be mixed freely.

The state of the item (e.g., the values of any controls), is taken from itemState, a variables.ItemSessionState instance.

RenderHTMLChildren(parent, profile, itemState)

Renders this element’s children to an external document represented by the parent node

1.3.3.1. Basic Classes

Many of the basic classes are drawn directly from the html40_19991224 module, as a result there are slight modifications to some of the abstract base class definitions. See InlineMixin, BlockMixin and FlowMixin; there is no class corresponding to the objectFlow concept (see Object for more information). There is also no representation of the static base classes used to exclude interactions or any of the other basic container classes, these are all handled directly by their equivalent html abstractions.

class pyslet.qtiv2.content.FlowContainerMixin

Mixin class used for objects that can contain flows.

PrettyPrint()

Deteremins if this flow-container-like object should be pretty printed.

This is similar to the algorithm we use in HTML flow containers, suppressing pretty printing if we have inline elements (ignoring non-trivial data). This could be refactored in future.

1.3.3.2. XHMTL Elements

Again, these classes are defined in the accompanying html40_19991224 module, however we do define some profiles here to make it easier to constraint general HTML content to the profile defined here.

pyslet.qtiv2.content.TextElements = {'em': ('id', 'class', 'label'), 'pre': ('id', 'class', 'label'), 'code': ('id', 'class', 'label'), 'h2': ('id', 'class', 'label'), 'h3': ('id', 'class', 'label'), 'h1': ('id', 'class', 'label'), 'h6': ('id', 'class', 'label'), 'kbd': ('id', 'class', 'label'), 'h5': ('id', 'class', 'label'), 'span': ('id', 'class', 'label'), 'dfn': ('id', 'class', 'label'), 'var': ('id', 'class', 'label'), 'samp': ('id', 'class', 'label'), 'cite': ('id', 'class', 'label'), 'blockquote': ('id', 'class', 'label'), 'acronym': ('id', 'class', 'label'), 'h4': ('id', 'class', 'label'), 'br': ('id', 'class', 'label'), 'address': ('id', 'class', 'label'), 'strong': ('id', 'class', 'label'), 'q': ('id', 'class', 'label'), 'p': ('id', 'class', 'label'), 'div': ('id', 'class', 'label'), 'abbr': ('id', 'class', 'label')}

Basic text formatting elements

pyslet.qtiv2.content.ListElements = {'dl': ('id', 'class', 'label'), 'ol': ('id', 'class', 'label'), 'dd': ('id', 'class', 'label'), 'li': ('id', 'class', 'label'), 'ul': ('id', 'class', 'label'), 'dt': ('id', 'class', 'label')}

Elements required for lists

pyslet.qtiv2.content.ObjectElements = {'object': ('id', 'class', 'label', 'data', 'type', 'width', 'height'), 'param': ('id', 'class', 'label', 'name', 'value', 'valuetype', 'type')}

The object element

pyslet.qtiv2.content.PresentationElements = {'caption': ('id', 'class', 'label'), 'tfoot': ('id', 'class', 'label'), 'th': ('id', 'class', 'label', 'headers', 'scope', 'abbr', 'axis', 'rowspan', 'colspan'), 'colgroup': ('id', 'class', 'label', 'span'), 'table': ('id', 'class', 'label', 'summary'), 'td': ('id', 'class', 'label', 'headers', 'scope', 'abbr', 'axis', 'rowspan', 'colspan'), 'thead': ('id', 'class', 'label'), 'tr': ('id', 'class', 'label'), 'col': ('id', 'class', 'label', 'span'), 'tbody': ('id', 'class', 'label')}

Tables

pyslet.qtiv2.content.ImageElement = {'img': ('id', 'class', 'label', 'src', 'alt', 'longdesc', 'height', 'width')}

Images

pyslet.qtiv2.content.HypertextElement = {'a': ('id', 'class', 'label', 'href', 'type')}

Hyperlinks

pyslet.qtiv2.content.HTMLProfile = {'em': ('id', 'class', 'label'), 'pre': ('id', 'class', 'label'), 'code': ('id', 'class', 'label'), 'h2': ('id', 'class', 'label'), 'h3': ('id', 'class', 'label'), 'h1': ('id', 'class', 'label'), 'h6': ('id', 'class', 'label'), 'kbd': ('id', 'class', 'label'), 'h5': ('id', 'class', 'label'), 'table': ('id', 'class', 'label', 'summary'), 'span': ('id', 'class', 'label'), 'img': ('id', 'class', 'label', 'src', 'alt', 'longdesc', 'height', 'width'), 'caption': ('id', 'class', 'label'), 'tr': ('id', 'class', 'label'), 'tbody': ('id', 'class', 'label'), 'param': ('id', 'class', 'label', 'name', 'value', 'valuetype', 'type'), 'li': ('id', 'class', 'label'), 'dfn': ('id', 'class', 'label'), 'tfoot': ('id', 'class', 'label'), 'th': ('id', 'class', 'label', 'headers', 'scope', 'abbr', 'axis', 'rowspan', 'colspan'), 'var': ('id', 'class', 'label'), 'td': ('id', 'class', 'label', 'headers', 'scope', 'abbr', 'axis', 'rowspan', 'colspan'), 'samp': ('id', 'class', 'label'), 'cite': ('id', 'class', 'label'), 'thead': ('id', 'class', 'label'), 'dl': ('id', 'class', 'label'), 'blockquote': ('id', 'class', 'label'), 'acronym': ('id', 'class', 'label'), 'dd': ('id', 'class', 'label'), 'object': ('id', 'class', 'label', 'data', 'type', 'width', 'height'), 'h4': ('id', 'class', 'label'), 'br': ('id', 'class', 'label'), 'address': ('id', 'class', 'label'), 'dt': ('id', 'class', 'label'), 'strong': ('id', 'class', 'label'), 'abbr': ('id', 'class', 'label'), 'a': ('id', 'class', 'label', 'href', 'type'), 'ol': ('id', 'class', 'label'), 'colgroup': ('id', 'class', 'label', 'span'), 'q': ('id', 'class', 'label'), 'p': ('id', 'class', 'label'), 'div': ('id', 'class', 'label'), 'col': ('id', 'class', 'label', 'span'), 'ul': ('id', 'class', 'label')}

The full HTML profile defined by QTI