AssessmentItem:Template Processing

Template processing generates cloned items.

This section begins with a  tag and ends with a  tag.

A template processing section specifies a sequence of template rules which are evaluated by either a cloning or by a delivery engine. Template rules generate values for one or more template variables. Thereafter these values are used - inside the ItemBody section - to populate values in the item text.

Example of a Template Processing Section
We will now examine a template processing section. The following code is taken from an example question ("Digging a Hole")in the QTI specification. There are three steps to analysing the code :-

Step 1 – Examine Item Variables
We first examine the five item variables which will be referred to inside the template processing section      The above declares
 * four template variables - PEOPLE (string), A (integer), B (integer) and MIN (integer)
 * one response variable - RESPONSE (float i.e. decimal)

Step 2 – Examine Template Processing Section
The associated template processing section appears below   men women children  <setTemplateValue identifier="A"> <randomInteger min="2" max="4" /> </setTemplateValue> <templateCondition> <templateIf> <variable identifier="A" /> 2</baseValue> <setTemplateValue identifier="B"> <randomInteger min="4" max="12" step="2" /> </setTemplateValue> </templateIf> <templateElseIf> <variable identifier="A" /> 3</baseValue> <setTemplateValue identifier="B"> 6</baseValue> 12</baseValue> </setTemplateValue> </templateElseIf> <templateElse> <setTemplateValue identifier="B"> 8</baseValue> 12</baseValue> </setTemplateValue> </templateElse> </templateCondition> <setTemplateValue identifier="MIN"> <integerDivide> 120</baseValue> <variable identifier="A" /> </integerDivide> </setTemplateValue> <setCorrectResponse identifier="RESPONSE"> <integerDivide> 120</baseValue> <variable identifier="B" /> </integerDivide> </setCorrectResponse> </templateProcessing>

The above logic is written using QTI template processing elements. The following “pseudo-code” explains in English (not QTI!) how the template and response variables are assigned

1. Assign template variable PEOPLE the value “men” or “women” or “children”. 2. Assign template variable A the value 2 or 3 or 4. 3. If A equals 2 then 4.   Assign template variable B the value 4 or 6 or 8 or 10 or 12. 5. Else If A equals 3 then 6. Assign template B the value 6 or 12. 7. Else 8. Assign template B the value 8 or 12. 9. Assign template variable MIN the value (120 / A). 10.Assign response variable RESPONSE the value (120 / B)

Notes
 * the setTemplateValue element changes the value of a template variable
 * the flow of control is managed via the following elements
 * templateIf
 * templateElse
 * templateElseIf
 * when this logic has been executed, all five variables will have been assigned values (some set to a constant value; others set to a formula (such as 120/B))
 * observe the use of the random and randomInteger elements

Step 3 – Examine ItemBody Section
Finally, we look at the ItemBody section, to see what becomes of the item variables set in the template processing section.

<itemBody> If it takes <printedVariable identifier="A" /> <printedVariable identifier="PEOPLE" /> <printedVariable identifier="MIN" /> minutes to dig a hole, how long would it take <printedVariable identifier="B" /> <printedVariable identifier="PEOPLE" /> to dig a similar hole? Answer: <textEntryInteraction responseIdentifier="RESPONSE" expectedLength="8" /> minutes. </itemBody> The ItemBody section uses these variables to generate a single cloned item. It uses the printedVariable element to insert the value of a template value at a particular point in the question text.

Assume, on a particular occasion, the above template processing logic assigned the following values to the item variables:- PEOPLE = “women” A = 3 B = 6 (note: because A=3, B can only take the value 6 or the value 12) MIN = 40 RESPONSE = 20 Then plugging these values into the ItemBody above generates the following question text:- If it takes 3 women 40 minutes to dig a hole, how long would it take 6 women? The answer would be shown on screen as 20.