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>

Leave a Reply

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