Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.50 KB | None | 0 0
  1.  
  2. Rules variables on the actual question.
  3. The variables are allways assigned to the template.
  4. The arguments are placed on the instance according to the mapTo name, when certain eventes occurr.
  5. In this example a timer is created internally when a new instance is created.
  6.  
  7. <rules-data>
  8.     <variables>
  9.         <points access="object" mapTo="totalPoints">500</points>
  10.         <reductionFactor access="xml" mapTo="ReductionFactor">5</reductionFactor>
  11.         <correct access="private" >55</correct>
  12.     </variables>
  13.     <parameters>   
  14.         <events>       
  15.             <new>
  16.                 <timer access="object" mapTo="timerInstance">
  17.                     <toolCall>createTimer("question",$this.id,20,true,false,false)</toolCall>
  18.                 </timer>
  19.             </new>
  20.         </events>
  21.     </parameters>
  22. </rules-data>
  23.  
  24.  
  25. Extra data xml will require a special schema. the rules need to be any node goes but the attributes available in nodes are restricted.
  26. <extra-data>
  27.     <mycollection mapTo="varellerintevaravariabler">
  28.         <var1 access="object">vara</var1>
  29.         <var1 access="xml">inte</var1>
  30.         <var1 access="private">vara</var1>
  31.         <var1 access="object">vara igen</var1>
  32.         <var2 access="object" mapTo="daVariable">variabel</var2>
  33.         <var4 access="xml">this one is not mapped to a property in the value object but is still available on the xml property</var3>
  34.         <var5 access="private" >this one is not mapped to a property in the value object and also removed from the xml</var5>
  35.     </mycollection>
  36.     <daNested access="object">
  37.             <variabel access="private">varinteenvar</variable>
  38.     </daNested>
  39. </extra-data>
  40.  
  41.  
  42. xslt template
  43.  
  44. 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.
  45. The answer data is bound to parameters with their name.
  46. example pseudo code:
  47. <xsl:variable name="totalPoints" select="/variables/points" />
  48. <xsl:variable name="reductionFactor" select="/variables/reductionFactor" />
  49. <xsl:variable name="correct" select="/variables/correct" />
  50. <xsl:parameter name="timer" />
  51. <xsl:parameter name="answerid" />
  52. <choice>
  53.     <when  test="$timer/created + ttl < now()>
  54.         </choice>
  55.           <when $answerid = $correct>
  56.             <output format="html">
  57.             <template type="sprintf">
  58.             <tmpl><!CDATA[You answered correctly and hence are awardet <b>%d</b> points]]></tmpl>
  59.                 <digit>
  60.                     <math type=division>
  61.                         <arg>$totalPoints</arg>
  62.                         <arg>
  63.                             <math type=multiplier>
  64.                                 <arg>reductionFactor</arg>
  65.                                 <arg>
  66.                                     <math type="subtraction">
  67.                                         <arg>NOW()</arg>
  68.                                         <arg>$timer/created</arg>
  69.                                     </math>
  70.                                 </arg>
  71.                             </math>
  72.                         </arg>
  73.                     </math>
  74.                 </digit>
  75.             </output>
  76.             </when
  77.         <otherwise>
  78.             <output format="html"><!CDATA[You answered incorrectly and hence are awardet <b>0</b> points]]></output>
  79.         </otherwise>
  80.     </when>
  81. <otherwise>
  82.         <output format="html">
  83.         <template type="sprintf">
  84.             <tmplt>
  85.                 <!CDATA[You answered %d seconds too late and hence are awardet <b>0</b> points]]>
  86.             </tmplate>
  87.             <digit>now () - timer.created + ttl</digit>
  88.         </template>
  89. </output>
  90.  
  91. 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
  92. If it hasnt it will check if the  variable named answerid equals the variable in named correct in the xml.
  93. If it does a math template kicks in.
  94. 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
  95. multiplying the reduction factor variable with ( current time minus - created time)
  96.  
  97.  
  98.  
  99. render the following properties on the QuestionInstanceVO
  100. +uuid = xyz
  101.  
  102. +timerInstance.ttl = 20
  103. +timerInstance.creator = question
  104. +timerInstance.uuid = abc
  105. +timerInstance.creatorAccess = true
  106. +timerInstance.creatorUuid = xyz
  107. ......
  108. +totalPoints = 500
  109. +reductionFactor = 5
  110. varellerintevaravariabler.var1[0] = vara
  111. varellerintevaravariabler.var1[1] = vara igen
  112.  
  113. varellerintevaravariabler.daVariable = variabel
  114. daNested= null
  115. +questionText
  116. +resources
  117. +typeId
  118. +typeFriendlyName
  119. +TypeMachineName
  120. +rulesXml
  121. +xslt
  122. +edXml
  123. <extra-data>
  124.     <mycollection mapTo="varellerintevaravariabler">
  125.         <var1 access="object">vara</var1>
  126.         <var1 access="xml">inte</var1>
  127.         <var1 access="object">vara igen</var1>
  128.         <var2 access="object" mapTo="daVariable">variabel</var2>
  129.         <var4 access="xml">this one is not mapped to a property in the value object but is still available on the xml property</var3>
  130.     </mycollection>
  131.     <daNested access="object" />
  132. </extra-data>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement