Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rules variables on the actual question.
- The variables are allways assigned to the template.
- The arguments are placed on the instance according to the mapTo name, when certain eventes occurr.
- In this example a timer is created internally when a new instance is created.
- <rules-data>
- <variables>
- <points access="object" mapTo="totalPoints">500</points>
- <reductionFactor access="xml" mapTo="ReductionFactor">5</reductionFactor>
- <correct access="private" >55</correct>
- </variables>
- <parameters>
- <events>
- <new>
- <timer access="object" mapTo="timerInstance">
- <toolCall>createTimer("question",$this.id,20,true,false,false)</toolCall>
- </timer>
- </new>
- </events>
- </parameters>
- </rules-data>
- Extra data xml will require a special schema. the rules need to be any node goes but the attributes available in nodes are restricted.
- <extra-data>
- <mycollection mapTo="varellerintevaravariabler">
- <var1 access="object">vara</var1>
- <var1 access="xml">inte</var1>
- <var1 access="private">vara</var1>
- <var1 access="object">vara igen</var1>
- <var2 access="object" mapTo="daVariable">variabel</var2>
- <var4 access="xml">this one is not mapped to a property in the value object but is still available on the xml property</var3>
- <var5 access="private" >this one is not mapped to a property in the value object and also removed from the xml</var5>
- </mycollection>
- <daNested access="object">
- <variabel access="private">varinteenvar</variable>
- </daNested>
- </extra-data>
- xslt template
- When player submits answerdata its is convertet to a xml document. It is then transformet with this xslt file to render the appropiate data to the system.
- The answer data is bound to parameters with their name.
- example pseudo code:
- <xsl:variable name="totalPoints" select="/variables/points" />
- <xsl:variable name="reductionFactor" select="/variables/reductionFactor" />
- <xsl:variable name="correct" select="/variables/correct" />
- <xsl:parameter name="timer" />
- <xsl:parameter name="answerid" />
- <choice>
- <when test="$timer/created + ttl < now()>
- </choice>
- <when $answerid = $correct>
- <output format="html">
- <template type="sprintf">
- <tmpl><!CDATA[You answered correctly and hence are awardet <b>%d</b> points]]></tmpl>
- <digit>
- <math type=division>
- <arg>$totalPoints</arg>
- <arg>
- <math type=multiplier>
- <arg>reductionFactor</arg>
- <arg>
- <math type="subtraction">
- <arg>NOW()</arg>
- <arg>$timer/created</arg>
- </math>
- </arg>
- </math>
- </arg>
- </math>
- </digit>
- </output>
- </when
- <otherwise>
- <output format="html"><!CDATA[You answered incorrectly and hence are awardet <b>0</b> points]]></output>
- </otherwise>
- </when>
- <otherwise>
- <output format="html">
- <template type="sprintf">
- <tmplt>
- <!CDATA[You answered %d seconds too late and hence are awardet <b>0</b> points]]>
- </tmplate>
- <digit>now () - timer.created + ttl</digit>
- </template>
- </output>
- The xslt checks if time has ran out. if it has ran out it will output You answered x seconds too late and hence are awardet <b>0</b> points
- If it hasnt it will check if the variable named answerid equals the variable in named correct in the xml.
- If it does a math template kicks in.
- it will use division with the first argument being total points and the second being a new group meaning paratenesis where a new calculation is done
- multiplying the reduction factor variable with ( current time minus - created time)
- render the following properties on the QuestionInstanceVO
- +uuid = xyz
- +timerInstance.ttl = 20
- +timerInstance.creator = question
- +timerInstance.uuid = abc
- +timerInstance.creatorAccess = true
- +timerInstance.creatorUuid = xyz
- ......
- +totalPoints = 500
- +reductionFactor = 5
- varellerintevaravariabler.var1[0] = vara
- varellerintevaravariabler.var1[1] = vara igen
- varellerintevaravariabler.daVariable = variabel
- daNested= null
- +questionText
- +resources
- +typeId
- +typeFriendlyName
- +TypeMachineName
- +rulesXml
- +xslt
- +edXml
- <extra-data>
- <mycollection mapTo="varellerintevaravariabler">
- <var1 access="object">vara</var1>
- <var1 access="xml">inte</var1>
- <var1 access="object">vara igen</var1>
- <var2 access="object" mapTo="daVariable">variabel</var2>
- <var4 access="xml">this one is not mapped to a property in the value object but is still available on the xml property</var3>
- </mycollection>
- <daNested access="object" />
- </extra-data>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement