3.3.9. Expressions

class pyslet.qtiv2.expressions.Expression(parent, name=None)

Bases: pyslet.qtiv2.core.QTIElement

Abstract class for all expression elements.

evaluate(state)

Evaluates this expression in the context of the session state.

integer_or_template_ref(state, value)

Given a value of type integerOrTemplateRef this method returns the corresponding integer by looking up the value, if necessary, in state. If value is a variable reference to a variable with NULL value then None is returned.

float_or_template_ref(state, value)

Given a value of type floatOrTemplateRef this method returns the corresponding float by looking up the value, if necessary, in state. If value is a variable reference to a variable with NULL value then None is returned.

string_or_template_ref(state, value)

Given a value of type stringOrTemplateRef this method returns the corresponding string by looking up the value, if necessary, in state. If value is a variable reference to a variable with NULL value then None is returned. Note that unlike the integer and float expansions this expansion will not raise an error if value is a syntactically valid reference to a non-existent template variable, as per this condition in the specification.

“if a string attribute appears to be a reference to a template variable but there is no variable with the given name it should be treated simply as string value”
Evaluate(*args, **kwargs)

Deprecated equivalent to evaluate()

class pyslet.qtiv2.expressions.NOperator(parent)

Bases: pyslet.qtiv2.expressions.Expression

An abstract class to help implement operators which take multiple sub-expressions.

evaluate_children(state)

Evaluates all child expressions, returning an iterable of Value instances.

EvaluateChildren(*args, **kwargs)

Deprecated equivalent to evaluate_children()

class pyslet.qtiv2.expressions.UnaryOperator(parent)

Bases: pyslet.qtiv2.expressions.Expression

An abstract class to help implement unary operators.

3.3.9.1. Built-in General Expressions

class pyslet.qtiv2.expressions.BaseValue(parent)

Bases: pyslet.qtiv2.expressions.Expression

The simplest expression returns a single value from the set defined by the given baseType

<xsd:attributeGroup name="baseValue.AttrGroup">
        <xsd:attribute name="baseType" type="baseType.Type"
        use="required"/>
</xsd:attributeGroup>

<xsd:complexType name="baseValue.Type">
        <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                        <xsd:attributeGroup
                        ref="baseValue.AttrGroup"/>
                </xsd:extension>
        </xsd:simpleContent>
</xsd:complexType>
class pyslet.qtiv2.expressions.Variable(parent)

Bases: pyslet.qtiv2.expressions.Expression

This expression looks up the value of an itemVariable that has been declared in a corresponding variableDeclaration or is one of the built-in variables:

<xsd:attributeGroup name="variable.AttrGroup">
        <xsd:attribute name="identifier" type="identifier.Type"
        use="required"/>
        <xsd:attribute name="weightIdentifier"
        type="identifier.Type" use="optional"/>
</xsd:attributeGroup>
class pyslet.qtiv2.expressions.Default(parent)

Bases: pyslet.qtiv2.expressions.Expression

This expression looks up the declaration of an itemVariable and returns the associated defaultValue or NULL if no default value was declared:

<xsd:attributeGroup name="default.AttrGroup">
        <xsd:attribute name="identifier" type="identifier.Type"
        use="required"/>
</xsd:attributeGroup>
class pyslet.qtiv2.expressions.Correct(parent)

Bases: pyslet.qtiv2.expressions.Expression

This expression looks up the declaration of a response variable and returns the associated correctResponse or NULL if no correct value was declared:

<xsd:attributeGroup name="correct.AttrGroup">
        <xsd:attribute name="identifier" type="identifier.Type"
        use="required"/>
</xsd:attributeGroup>
class pyslet.qtiv2.expressions.MapResponse(parent)

Bases: pyslet.qtiv2.expressions.Expression

This expression looks up the value of a response variable and then transforms it using the associated mapping, which must have been declared. The result is a single float:

<xsd:attributeGroup name="mapResponse.AttrGroup">
        <xsd:attribute name="identifier" type="identifier.Type"
        use="required"/>
</xsd:attributeGroup>
class pyslet.qtiv2.expressions.MapResponsePoint(parent)

Bases: pyslet.qtiv2.expressions.Expression

This expression looks up the value of a response variable that must be of base-type point, and transforms it using the associated areaMapping:

<xsd:attributeGroup name="mapResponsePoint.AttrGroup">
        <xsd:attribute name="identifier" type="identifier.Type"
        use="required"/>
</xsd:attributeGroup>
class pyslet.qtiv2.expressions.Null(parent, name=None)

Bases: pyslet.qtiv2.expressions.Expression

null is a simple expression that returns the NULL value - the null value is treated as if it is of any desired baseType

<xsd:complexType name="null.Type"/>
class pyslet.qtiv2.expressions.RandomInteger(parent)

Bases: pyslet.qtiv2.expressions.Expression

Selects a random integer from the specified range [min,max] satisfying min + step * n for some integer n:

<xsd:attributeGroup name="randomInteger.AttrGroup">
        <xsd:attribute name="min" type="integerOrTemplateRef.Type"
        use="required"/>
        <xsd:attribute name="max" type="integerOrTemplateRef.Type"
        use="required"/>
        <xsd:attribute name="step" type="integerOrTemplateRef.Type"
        use="optional"/>
</xsd:attributeGroup>
class pyslet.qtiv2.expressions.RandomFloat(parent)

Bases: pyslet.qtiv2.expressions.Expression

Selects a random float from the specified range [min,max]

<xsd:attributeGroup name="randomFloat.AttrGroup">
        <xsd:attribute name="min" type="floatOrTemplateRef.Type"
        use="required"/>
        <xsd:attribute name="max" type="floatOrTemplateRef.Type"
        use="required"/>
</xsd:attributeGroup>

3.3.9.2. Expressions Used only in Outcomes Processing

3.3.9.3. Operators

class pyslet.qtiv2.expressions.Multiple(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The multiple operator takes 0 or more sub-expressions all of which must have either single or multiple cardinality:

<xsd:group name="multiple.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Ordered(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The multiple operator takes 0 or more sub-expressions all of which must have either single or multiple cardinality:

<xsd:group name="ordered.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.ContainerSize(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The containerSize operator takes a sub-expression with any base-type and either multiple or ordered cardinality:

<xsd:group name="containerSize.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.IsNull(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The isNull operator takes a sub-expression with any base-type and cardinality

<xsd:group name="isNull.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Index(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The index operator takes a sub-expression with an ordered container value and any base-type

<xsd:attributeGroup name="index.AttrGroup">
        <xsd:attribute name="n" type="integer.Type"
        use="required"/>
</xsd:attributeGroup>

<xsd:group name="index.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.FieldValue(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The field-value operator takes a sub-expression with a record container value. The result is the value of the field with the specified fieldIdentifier:

<xsd:attributeGroup name="fieldValue.AttrGroup">
        <xsd:attribute name="fieldIdentifier"
        type="identifier.Type" use="required"/>
</xsd:attributeGroup>

<xsd:group name="fieldValue.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Random(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The random operator takes a sub-expression with a multiple or ordered container value and any base-type. The result is a single value randomly selected from the container:

<xsd:group name="random.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Member(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The member operator takes two sub-expressions which must both have the same base-type. The first sub-expression must have single cardinality and the second must be a multiple or ordered container. The result is a single boolean with a value of true if the value given by the first sub-expression is in the container defined by the second sub-expression:

<xsd:group name="member.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Delete(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The delete operator takes two sub-expressions which must both have the same base-type. The first sub-expression must have single cardinality and the second must be a multiple or ordered container. The result is a new container derived from the second sub-expression with all instances of the first sub-expression removed:

<xsd:group name="delete.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Contains(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The contains operator takes two sub-expressions which must both have the same base-type and cardinality – either multiple or ordered. The result is a single boolean with a value of true if the container given by the first sub-expression contains the value given by the second sub-expression and false if it doesn’t:

<xsd:group name="contains.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.SubString(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The substring operator takes two sub-expressions which must both have an effective base-type of string and single cardinality. The result is a single boolean with a value of true if the first expression is a substring of the second expression and false if it isn’t:

<xsd:attributeGroup name="substring.AttrGroup">
        <xsd:attribute name="caseSensitive" type="boolean.Type"
        use="required"/>
</xsd:attributeGroup>

<xsd:group name="substring.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Not(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The not operator takes a single sub-expression with a base-type of boolean and single cardinality. The result is a single boolean with a value obtained by the logical negation of the sub-expression’s value:

<xsd:group name="not.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.And(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The and operator takes one or more sub-expressions each with a base-type of boolean and single cardinality. The result is a single boolean which is true if all sub-expressions are true and false if any of them are false:

<xsd:group name="and.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Or(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The or operator takes one or more sub-expressions each with a base-type of boolean and single cardinality. The result is a single boolean which is true if any of the sub-expressions are true and false if all of them are false:

<xsd:group name="or.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.AnyN(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The anyN operator takes one or more sub-expressions each with a base-type of boolean and single cardinality. The result is a single boolean which is true if at least min of the sub-expressions are true and at most max of the sub-expressions are true:

<xsd:attributeGroup name="anyN.AttrGroup">
        <xsd:attribute name="min" type="integerOrTemplateRef.Type"
        use="required"/>
        <xsd:attribute name="max" type="integerOrTemplateRef.Type"
        use="required"/>
</xsd:attributeGroup>

<xsd:group name="anyN.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Match(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The match operator takes two sub-expressions which must both have the same base-type and cardinality. The result is a single boolean with a value of true if the two expressions represent the same value and false if they do not:

<xsd:group name="match.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.StringMatch(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The stringMatch operator takes two sub-expressions which must have single and a base-type of string. The result is a single boolean with a value of true if the two strings match:

<xsd:attributeGroup name="stringMatch.AttrGroup">
        <xsd:attribute name="caseSensitive" type="boolean.Type"
        use="required"/>
        <xsd:attribute name="substring" type="boolean.Type"
        use="optional"/>
</xsd:attributeGroup>

<xsd:group name="stringMatch.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.PatternMatch(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The patternMatch operator takes a sub-expression which must have single cardinality and a base-type of string. The result is a single boolean with a value of true if the sub-expression matches the regular expression given by pattern and false if it doesn’t:

<xsd:attributeGroup name="patternMatch.AttrGroup">
        <xsd:attribute name="pattern"
        type="stringOrTemplateRef.Type"
        use="required"/>
</xsd:attributeGroup>

<xsd:group name="patternMatch.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Equal(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The equal operator takes two sub-expressions which must both have single cardinality and have a numerical base-type. The result is a single boolean with a value of true if the two expressions are numerically equal and false if they are not:

<xsd:attributeGroup name="equal.AttrGroup">
        <xsd:attribute name="toleranceMode"
                       type="toleranceMode.Type" use="required"/>
        <xsd:attribute name="tolerance" use="optional">
                <xsd:simpleType>
                        <xsd:list
                        itemType="floatOrTemplateRef.Type"/>
                </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="includeLowerBound" type="boolean.Type"
        use="optional"/>
        <xsd:attribute name="includeUpperBound" type="boolean.Type"
        use="optional"/>
</xsd:attributeGroup>

<xsd:group name="equal.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.ToleranceMode

Bases: pyslet.xml.xsdatatypes.Enumeration

When comparing two floating point numbers for equality it is often desirable to have a tolerance to ensure that spurious errors in scoring are not introduced by rounding errors. The tolerance mode determines whether the comparison is done exactly, using an absolute range or a relative range:

<xsd:simpleType name="toleranceMode.Type">
        <xsd:restriction base="xsd:NMTOKEN">
                <xsd:enumeration value="absolute"/>
                <xsd:enumeration value="exact"/>
                <xsd:enumeration value="relative"/>
        </xsd:restriction>
</xsd:simpleType>

Defines constants for the above modes. Usage example:

ToleranceMode.exact

The default value is exact:

ToleranceMode.DEFAULT == ToleranceMode.exact

For more methods see Enumeration

class pyslet.qtiv2.expressions.EqualRounded(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The equalRounded operator takes two sub-expressions which must both have single cardinality and have a numerical base-type. The result is a single boolean with a value of true if the two expressions are numerically equal after rounding and false if they are not:

<xsd:attributeGroup name="equalRounded.AttrGroup">
        <xsd:attribute name="roundingMode" type="roundingMode.Type"
        use="required"/>
        <xsd:attribute name="figures"
                       type="integerOrTemplateRef.Type"
                       use="required"/>
</xsd:attributeGroup>

<xsd:group name="equalRounded.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                           minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.RoundingMode

Bases: pyslet.xml.xsdatatypes.Enumeration

Numbers are rounded to a given number of significantFigures or decimalPlaces:

<xsd:simpleType name="roundingMode.Type">
        <xsd:restriction base="xsd:NMTOKEN">
                <xsd:enumeration value="decimalPlaces"/>
                <xsd:enumeration value="significantFigures"/>
        </xsd:restriction>
</xsd:simpleType>

Defines constants for the above modes. Usage example:

RoundingMode.decimalPlaces

The default value is significantFigures:

RoundingMode.DEFAULT == RoundingMode.significantFigures

For more methods see Enumeration

class pyslet.qtiv2.expressions.Inside(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator, pyslet.qtiv2.core.ShapeElementMixin

The inside operator takes a single sub-expression which must have a baseType of point. The result is a single boolean with a value of true if the given point is inside the area defined by shape and coords. If the sub-expression is a container the result is true if any of the points are inside the area:

<xsd:attributeGroup name="inside.AttrGroup">
        <xsd:attribute name="shape" type="shape.Type"
        use="required"/>
        <xsd:attribute name="coords" type="coords.Type"
        use="required"/>
</xsd:attributeGroup>

<xsd:group name="inside.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.LT(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The lt operator takes two sub-expressions which must both have single cardinality and have a numerical base-type. The result is a single boolean with a value of true if the first expression is numerically less than the second and false if it is greater than or equal to the second:

<xsd:group name="lt.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.GT(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The gt operator takes two sub-expressions which must both have single cardinality and have a numerical base-type. The result is a single boolean with a value of true if the first expression is numerically greater than the second and false if it is less than or equal to the second:

<xsd:group name="gt.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.LTE(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The lte operator takes two sub-expressions which must both have single cardinality and have a numerical base-type. The result is a single boolean with a value of true if the first expression is numerically less than or equal to the second and false if it is greater than the second:

<xsd:group name="lte.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.GTE(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The gte operator takes two sub-expressions which must both have single cardinality and have a numerical base-type. The result is a single boolean with a value of true if the first expression is numerically less than or equal to the second and false if it is greater than the second:

<xsd:group name="durationGTE.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.DurationLT(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The durationLT operator takes two sub-expressions which must both have single cardinality and base-type duration. The result is a single boolean with a value of true if the first duration is shorter than the second and false if it is longer than (or equal) to the second:

<xsd:group name="durationLT.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.DurationGTE(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The durationGTE operator takes two sub-expressions which must both have single cardinality and base-type duration. The result is a single boolean with a value of true if the first duration is longer (or equal, within the limits imposed by truncation) than the second and false if it is shorter than the second:

<xsd:group name="durationGTE.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Sum(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The sum operator takes 1 or more sub-expressions which all have single cardinality and have numerical base-types. The result is a single float or, if all sub-expressions are of integer type, a single integer that corresponds to the sum of the numerical values of the sub-expressions:

<xsd:group name="sum.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Product(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The product operator takes 1 or more sub-expressions which all have single cardinality and have numerical base-types. The result is a single float or, if all sub-expressions are of integer type, a single integer that corresponds to the product of the numerical values of the sub-expressions:

<xsd:group name="product.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Subtract(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The subtract operator takes 2 sub-expressions which all have single cardinality and numerical base-types. The result is a single float or, if both sub-expressions are of integer type, a single integer that corresponds to the first value minus the second:

<xsd:group name="subtract.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Divide(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The divide operator takes 2 sub-expressions which both have single cardinality and numerical base-types. The result is a single float that corresponds to the first expression divided by the second expression:

<xsd:group name="divide.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Power(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The power operator takes 2 sub-expression which both have single cardinality and numerical base-types. The result is a single float that corresponds to the first expression raised to the power of the second:

<xsd:group name="power.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.IntegerDivide(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The integer divide operator takes 2 sub-expressions which both have single cardinality and base-type integer. The result is the single integer that corresponds to the first expression (x) divided by the second expression (y) rounded down to the greatest integer (i) such that i<=(x/y):

<xsd:group name="integerDivide.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.IntegerModulus(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The integer modulus operator takes 2 sub-expressions which both have single cardinality and base-type integer. The result is the single integer that corresponds to the remainder when the first expression (x) is divided by the second expression (y). If z is the result of the corresponding integerDivide operator then the result is x-z*y:

<xsd:group name="integerModulus.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="2" maxOccurs="2"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Truncate(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The truncate operator takes a single sub-expression which must have single cardinality and base-type float. The result is a value of base-type integer formed by truncating the value of the sub-expression towards zero:

<xsd:group name="truncate.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.Round(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The round operator takes a single sub-expression which must have single cardinality and base-type float. The result is a value of base-type integer formed by rounding the value of the sub-expression. The result is the integer n for all input values in the range [n-0.5,n+0.5):

<xsd:group name="round.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.IntegerToFloat(parent)

Bases: pyslet.qtiv2.expressions.UnaryOperator

The integer to float conversion operator takes a single sub-expression which must have single cardinality and base-type integer. The result is a value of base type float with the same numeric value:

<xsd:group name="integerToFloat.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
</xsd:group>
class pyslet.qtiv2.expressions.CustomOperator(parent)

Bases: pyslet.qtiv2.expressions.NOperator

The custom operator provides an extension mechanism for defining operations not currently supported by this specification:

<xsd:attributeGroup name="customOperator.AttrGroup">
        <xsd:attribute name="class" type="identifier.Type"
        use="optional"/>
        <xsd:attribute name="definition" type="uri.Type"
        use="optional"/>
        <xsd:anyAttribute namespace="##other"/>
</xsd:attributeGroup>

<xsd:group name="customOperator.ContentGroup">
        <xsd:sequence>
                <xsd:group ref="expression.ElementGroup"
                minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:group>