Maths with QTI – Variable Declarations

Please note that this is a work in progress!

The first thing that you need to do in an assessment item, in a QTI XML file, is to declare your variables. These declarations come in 3 types – responseDeclarationoutcomeDeclaration and templateDeclaration.

responseDeclarations

This is where you declare variables used for responses and response processing. The following should be useful building blocks:

User Response

These are variables used to store the user’s response to a question.

<responseDeclaration identifier="RESPONSE_INTEGER" cardinality="single" baseType="integer"/><!-- integer response -->
<responseDeclaration identifier="RESPONSE_FLOAT" cardinality="single" baseType="float"/><!-- float response -->
<responseDeclaration identifier="RESPONSE_STRING" cardinality="single" baseType="string"/><!-- string response -->
<responseDeclaration identifier="RESPONSE_MATHS" cardinality="record"/><!-- maths response -->

printMath

This is a variable into which Presentation MathML form of a RESPONSE expression is copied.

<responseDeclaration identifier="printMath" cardinality="single" baseType="string"/>

Hint and Solution Request

These can be set to true when the hint or solution is requested, and should be tested at the start of the responseProcessing.

<responseDeclaration identifier="HINTREQUEST" cardinality="single" baseType="boolean"/>
<responseDeclaration identifier="SOLREQUEST" cardinality="single" baseType="boolean"/>

outcomeDeclarations

These are used for identifying and recording the outcomes from a user’s interactions, e.g. score and feedback.

Correct Response

These can be used to store the correct response to a question, for comparison with the user’s response.

<outcomeDeclaration identifier="iAnswer" cardinality="single" baseType="integer"/>
<outcomeDeclaration identifier="mAnswer" cardinality="record"/>

Score and Feedback

<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float" normalMaximum="2">
   <defaultValue>
      <value>0</value>
   </defaultValue>
</outcomeDeclaration>
<outcomeDeclaration identifier="FEEDBACK" cardinality="multiple" baseType="identifier"/><!-- multiple cardinality - container for multiple values. For feedback, this means we can show multiple feedback sections at once -->
<outcomeDeclaration baseType="identifier" cardinality="single" identifier="EMPTY"/><!-- Empty value, for emptying FEEDBACK container -->

Hint and Solution Related

<outcomeDeclaration baseType="boolean" cardinality="single" identifier="seenSolution">
   <defaultValue>
      <value>false</value>
   </defaultValue>
</outcomeDeclaration>
<outcomeDeclaration baseType="boolean" cardinality="single" identifier="seenHint">
   <defaultValue>
      <value>false</value>
   </defaultValue>
</outcomeDeclaration>
<outcomeDeclaration baseType="identifier" cardinality="single" identifier="ASKHINT">
   <defaultValue>
      <value>askhint</value>
   </defaultValue>
</outcomeDeclaration>
<outcomeDeclaration baseType="identifier" cardinality="single" identifier="ASKSOLUTION">
   <defaultValue>
      <value>asksolution</value>
   </defaultValue>
</outcomeDeclaration>

templateDeclarations

These are used for defining and randomising variables used in the question itself.

Template Variables

<templateDeclaration identifier="iInt" cardinality="single" baseType="integer" mathVariable="true"/><!-- Integer -->
<templateDeclaration identifier="fFloat" cardinality="single" baseType="float" mathVariable="true"/><!-- Float -->
<templateDeclaration identifier="sString" cardinality="single" baseType="string" mathVariable="true"/><!-- String -->
<templateDeclaration identifier="mX" cardinality="record" mathVariable="true"/><!-- Maths -->

Use mathVariable=”true” to enable the variable to be used in MathML expressions.

Maxima Script Dummy Variable

<templateDeclaration identifier="tDummy" cardinality="single" baseType="boolean"/>

Leave a Reply

Your email address will not be published. Required fields are marked *