Skip to content

Expressions

Input fields for mathematical expressions can be created using the input type expression in the input element.

The inputs into this input field are passed to the computer algebra system and compared with the specified solution.

Example

<p>
    According to Newton's laws of motion, how can the force <m>F</m>
    be expressed in terms of the mass <m>m</m> and the acceleration <m>a</m>?
</p>
<p>
    Answer: <m>F = </m> <input><expression>m*a</expression></input>
</p>

Attributes

The expression element supports the following attributes:

Attribute Type Default Description
credits xs:nonNegativeInteger 1 Number of credit points the user gets awarded for this input value.
expanded xs:boolean - If this attribute is set to true, the expression entered by the user must be fully expanded for this field to be correct. This means that the collections of node types and node values appearing in the user expression tree and the expression tree of its expanded form must agree without order but with counting.
expect ExpressionNodeTypeList | All - Whitespace-separated list of expression node types that are allowed for the root node of the expression, or the special value "all" which means that all types are allowed for the root element.
model xs:Name - Name of the model to use for this input value. If this attribute is not set, the input model associated to the input field containing this input value is used.
simplified xs:boolean - If this attribute is set to true, the expression entered by the user must be simplified for this field to be correct. This means that the collections of node types and node values appearing in the user expression tree and the expression tree of its simplification must agree without order but with counting.
testmode ExpressionTestMode - The test mode defines in what way the expression entered by the user is compared with the expression in the solution. By default, they must be equal.
usenot ExpressionNodeTypeList - Whitespace-separated list of expression node types that are forbidden to occur in the expression.
useonce ExpressionNodeTypeList - Whitespace-separated list of expression node types that have to appear exactly once in the expression.
useonly ExpressionNodeTypeList | All - Whitespace-separated list of expression node types that are allowed to appear in the expression or the special value "all", which means that all types are allowed.