MathDox exercises

Creating interactive pages or exerices in MathDox can be done with the help of XForms and Monet queries. This is not always an easy task.

MathDox Exercises, however, provide a much more user friendly way of producing interactive pages.

The MathDox exercises make use of LEAMEL, the LeActiveMath exercise language developed in cooperation with the ActiveMath group from Saarbruecken.

Example 1. 

We start with a trivial exercise.


<exercise>
 <interaction>
   <feedback>
    <para> 
       This is a trivial exercise.
     </para>
   </feedback>
 </interaction>
</exercise>

See the example running.


In this exerice, one finds the <exercise/> and <interaction/> and <feedback/> tags. The <exercise/> is just the container tag for the whole exercise. The <feedback/> elements inside an exercise are containers for MathDox fragments to be presentend. The interaction represents a screen presented to the user. In a more elaborate exercise, users can jump from one to another interaction. Just have a look at the next example.

Example 2. 

We extend the previous example a bit.


<exercise>
 <interaction id="one">
   <feedback>
    <para> 
       This is a the first interaction ...
     </para>
   </feedback>
  <answer_map text="go to two">
   <interaction  xref="two"/>
  </answer_map>
 </interaction>

 <interaction id="two">
   <feedback>
    <para> 
       ... and this the second.
     </para>
   </feedback> 
 <answer_map text="back">
   <interaction  xref="one"/>
  </answer_map>
 </interaction>
</exercise>

See the example running.


The main new feature of this exercise is the <answer_map/>. Inside this <answer_map/> one finds an <interaction xref=""/>. The answer map represents an XForm that takes the user to the specified interaction.

The switch from one interaction to another can be conditional as you see in the next example.

Example 3. 

We extend the previous examples somewhat more.



<exercise xmlns:macro="http://www.mathdox.org/MathBook/Macro" 
      xmlns:j_x="jelly:xml"
      xmlns:q="http://www.mathdox.org/MathBook/Query"
      xmlns:mdf="http://www.mathdox.org/MathDox/Functions"
      xmlns:c="jelly:core"
      xmlns:x="jelly:xml"
      xmlns:cont="http://www.mathdox.org/MathBook/Context"
      xmlns:monet="http://monet.nag.co.uk/monet/ns"
      xmlns:om="http://www.openmath.org/OpenMath"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xhtml="http://www.w3.org/2002/xhtml"
      xmlns:mdu="jelly:org.mathdox.util.UtilLibrary">

<interaction id="one">

<mdu:random var="r" minimum="1" maximum="4"/>   

<feedback>
    <para> 
       We pick a random number: 
     </para>
   </feedback>


<answer_map text="go">
<set name="test2">
<OMOBJ>
<OMS name="false" cd="logic1"/>
</OMOBJ>
</set>
<set name="test3">
<OMOBJ>
<OMS name="false" cd="logic1"/>
</OMOBJ>
</set>


<c:if test="false">
<set name="test2">
<OMOBJ>
<OMS name="true" cd="logic1"/>
</OMOBJ>
</set>
</c:if>
<c:if test="false">
<set name="test3">
<OMOBJ>
<OMS name="true" cd="logic1"/>
</OMOBJ>
</set>
</c:if>

<choose>
<when target="two">
   <out name="test2"/>
</when>
<when target="three">
   <out name="test3"/>
</when>

<otherwise target="one"/>
</choose>
</answer_map> 

 </interaction>

 <interaction id="two">
   <feedback>
    <para> 
       ... and this the second.
     </para>
   </feedback> 
 <answer_map text="back">
   <interaction  xref="one"/>
  </answer_map>
 </interaction>
<interaction id="three">
   <feedback>
    <para> 
       ... and this the third.
     </para>
   </feedback> 
 <answer_map text="back">
   <interaction  xref="one"/>
  </answer_map>
 </interaction>
</exercise>



The main difference between this and the previous examples is the <choose/> inside the <answer_map/>.

If a <when/>-tag inside the <choose/> contains the OpenMath symbol <OMS name="true" cd="logic1"/>, the user will be taken to the interaction specified in the target attribute of the <when/>. The evaluation starts at the top and goes down the list of <when/>'s. If none of them contains a <OMS name="true" cd="logic1"/>, the user is taken to the interaction specified in the <otherwise/>-tag.

Another new tags in this example are <set/> and <out/>, with which one can set variables, both as strings and as XML-objects, output them, respectively.

See the example running.


Of course, instead of just jumping from one to another interaction can then also be ruled by user input and Monet queries.

Example 4. 


<exercise 
      xmlns:macro="http://www.mathdox.org/MathBook/Macro" 
      xmlns:j_x="jelly:xml"
      xmlns:q="http://www.mathdox.org/MathBook/Query"
      xmlns:mdf="http://www.mathdox.org/MathDox/Functions"
      xmlns:c="jelly:core"
      xmlns:x="jelly:xml"
      xmlns:cont="http://www.mathdox.org/MathBook/Context"
      xmlns:monet="http://monet.nag.co.uk/monet/ns"
      xmlns:om="http://www.openmath.org/OpenMath"
      xmlns:xforms='http://www.w3.org/2002/xforms'
      xmlns:mdu="jelly:org.mathdox.util.UtilLibrary">

<interaction id="question">  


<mdu:random var="a" minimum="1000" maximum="4000"/>   
<mdu:random var="b" minimum="1000" maximum="4000"/>   

<feedback>  
<para>
Compute 
<OMOBJ>   
   <OMA>
      <OMS cd="arith1" name="plus"/>
      <OMI></OMI>
      <OMI></OMI>
   </OMA>
</OMOBJ>.
</para>
</feedback>  

<feedback>  
	<userinput type="blank">  <set name="answer"/>  </userinput>  
</feedback>  

<answer_map>
<choose>  
<otherwise target="wrong"/>  
<when target="good"> 
<monet:query>
      <monet:classification>
        <monet:directive-type href='http://mathdox.org/phrasebook/maxima#eval'/>
      </monet:classification>
      <monet:body>
        <monet:output>
         <OMOBJ>
          <OMA><OMS name="eq" cd="relation1"/>
            <OMA><OMS name="plus" cd="arith1"/>
                 <OMI></OMI>
                 <OMI></OMI>
            </OMA>
            <out name="answer"/>
          </OMA>
         </OMOBJ>
         </monet:output>
      </monet:body>
    </monet:query>
</when>  
</choose>  
</answer_map>     
</interaction>  

<interaction id="wrong">  
<feedback>  
<para>Sorry, that is wrong.</para>  
</feedback>  
	  
	 <answer_map text="again">  
		 <interaction xref="question"/>  
	 </answer_map>  	 
</interaction> 

<interaction id="good"> 

	 <feedback>  

<para> Well done</para>
 </feedback>  

	 <answer_map text="again">  
		 <interaction xref="question"/>  
	 </answer_map> 

</interaction>
</exercise>

The user input field is created by the <userinput/>-tag. By default the input field is the MathDox formula editor, with which the user can create OpenMath. The <userinput/>-tag contains a <set name="answer"/>-tag. This tag sets the user's input in a variable with the name "answer".

Try the exercise yourself.