Maths with QTI – Solution and Hint

Use the following chunks of code to add “Show Hint” and “Show Solution” buttons to the question, define the hint and solution that are shown and do all the necessary processing

Variable Declarations

Request variables set to true when user asks for Hint or Solution

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

Outcome variables for tracking whether the user has viewed the Hint or Solution

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

Outcome variables for tracking whether the user has viewed the Hint or Solution

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

ItemBody

Hint and Solution feedback blocks

<feedbackBlock identifier="SOLUTION" outcomeIdentifier="FEEDBACK" showHide="show"> Solution goes here </feedbackBlock>
<feedbackBlock identifier="HINT" outcomeIdentifier="FEEDBACK" showHide="show"> Hint goes here </feedbackBlock>

“Show Hint” and “Show Solution” buttons

<div class="">
   <feedbackBlock showHide="show" identifier="askhint" outcomeIdentifier="ASKHINT">
      <p>
         <endAttemptInteraction responseIdentifier="HINTREQUEST" title="Show Hint"/>
      </p>
   </feedbackBlock>
   <feedbackBlock showHide="show" identifier="asksolution" outcomeIdentifier="ASKSOLUTION">
      <p>
         <endAttemptInteraction responseIdentifier="SOLREQUEST" title="Show Solution"/>
      </p>
   </feedbackBlock>
</div>

responseProcessing

The code below can be used as the framework for the responseProcessing section. The responseProcessing expressions that, for example, idenitfy whether the question has been answered correctly should be inserted at the “***Response Processing goes here***” comment.

<responseProcessing>
   <responseCondition>
      <responseIf>
         <!-- If user has asked for the Hint -->
         <variable identifier="HINTREQUEST"/>
         <!-- Show the Hint -->
         <setOutcomeValue identifier="FEEDBACK">
            <multiple>
               <baseValue baseType="identifier">HINT</baseValue>
            </multiple>
         </setOutcomeValue>
         <!-- Set seenHint to true -->
         <setOutcomeValue identifier="seenHint">
            <baseValue baseType="boolean">true</baseValue>
         </setOutcomeValue>
      </responseIf>
      <responseElseIf>
         <!-- If user has asked for the Solution -->
         <variable identifier="SOLREQUEST"/>
         <!-- Show the Solution -->
         <setOutcomeValue identifier="FEEDBACK">
            <multiple>
               <baseValue baseType="identifier">SOLUTION</baseValue>
            </multiple>
         </setOutcomeValue>
         <setOutcomeValue identifier="seenSolution">
            <baseValue baseType="boolean">true</baseValue>
         </setOutcomeValue>
         <setOutcomeValue identifier="completionStatus">
            <baseValue baseType="identifier">completed</baseValue>
         </setOutcomeValue>
         <setOutcomeValue identifier="ASKHINT">
            <baseValue baseType="identifier">null</baseValue>
         </setOutcomeValue>
         <setOutcomeValue identifier="ASKSOLUTION">
            <baseValue baseType="identifier">null</baseValue>
         </setOutcomeValue>
      </responseElseIf>
      <responseElse> 
         <!-- ***Response Processing goes here*** -->
         <responseCondition>
            <responseIf>
               <!-- If the user has seen the solution, set the score to 0 -->
               <variable identifier="seenSolution"/>
               <setOutcomeValue identifier="FEEDBACK">
                  <multiple>
                     <variable identifier="FEEDBACK"/>
                     <baseValue baseType="identifier">SEEN-SOLUTION</baseValue>
                  </multiple>
               </setOutcomeValue>
               <setOutcomeValue identifier="SCORE">
                  <baseValue baseType="float">0.0</baseValue>
               </setOutcomeValue>
            </responseIf>
            <responseElseIf>
               <!-- If the user has seen the hint, divide the score by 2 -->
               <variable identifier="seenHint"/>
               <setOutcomeValue identifier="FEEDBACK">
                  <multiple>
                     <variable identifier="FEEDBACK"/>
                     <baseValue baseType="identifier">SEEN-HINT</baseValue>
                  </multiple>
               </setOutcomeValue>
               <setOutcomeValue identifier="SCORE">
                  <divide>
                     <variable identifier="SCORE"/>
                     <baseValue baseType="float">2.0</baseValue>
                  </divide>
               </setOutcomeValue>
            </responseElseIf>
         </responseCondition>
      </responseElse>
   </responseCondition>
</responseProcessing>

Maths with QTI – Things I wish I’d known before I started

Writing maths questions in QTI has been a bit of a learning curve, and I took my (/everyone’s?) usual approach of diving straight in and trying things out, without spending too much time reading the specification. As a result, there have been some things that I didn’t really understand when I started, but have realised along the way, and really wish that I had  taken the time to find out before I started. As with pretty much all of my QTI-related posts, this is a work in progress and will probably be updated as and when more things that I should have known crop up!

The meaning of adaptive (for an assessmentItem)

I didn’t really look too much at the assessmentItem properties when creating new questions, I just copied an old question, changed the identifier and title, and added extra namespace definitions if I found I hadn’t defined one that I was using (e.g. MathML or MathAssess) when I tested the question. I didn’t really pay attention to the ‘adaptive’ property, and didn’t notice that on some questions it was true and some it was false.

It was not until I put tests together and tried them out that I found out that items for which adaptive was set to false only allowed a single attempt. Since these are formative questions, I wanted students to be able to have multiple attempts, see a hint, see the solution, etc, which means setting adaptive to true. Therefore, had to go back through lots of questions, change adaptive to true and then re-add them to my tests.

What setCorrectResponse does

The name of the setCorrectReponse class gives a pretty good hint as to what it does, but I hadn’t fully understood it. As well as setting the correct response for a response variable (explained below), it is also used for displaying the model answer when a student is reviewing a test. If the test is set up to allow solutions to be shown when reviewing (using <itemSessionControl showSolution="true" /> in the testPart in the assessment.xml file for the test), the user can then choose the show the model solution by clicking the “Show Solution” button. This replaces their answer in the answer box with the model solution. The can switch back to the answer they gave by clicking the “Hide Solution” button.

To summarise the setting/getting of a correct response in an asssessment item, there are two ways to assign a correct response to a response variable:

  1. When declaring the response variable:
    <responseDeclaration identifier="RESPONSE" cardinality="single" baseType="float" >
       <correctResponse>
          <value>5.2</value>
       </correctResponse>
    </responseDeclaration>
  2. Using setCorrectResponse in templateProcessing. This is often more useful as the correct response can be assigned after template variables have been set and/or calculated.
    <setCorrectResponse identifier="RESPONSE">
       <variable identifier="fAns"/>
    </setCorrectResponse>

It is then possible to get the correct response for a response variable, in the responseProcessing, as follows:

<correct identifier="RESPONSE"/>

This can be used for comparing a given response to the correct response:

<equalRounded roundingMode="decimalPlaces" figures="0">
   <correct identifier="RESPONSE"/>
   <variable identifier="RESPONSE"/>
</equalRounded>