Subversion Repositories wimsdev

Rev

Rev 17347 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1.  
  2. <h2>Advanced features of OEF</h2>
  3.  
  4. <h3>Hiding image names</h3>
  5. If your exercise requires recognition of a randomly picked picture, the file
  6. name of the picture might give clue to the exercise. In order to hide this
  7. file name, you can write in parts
  8. <span class="tt wims_code_variable">statement</span>,
  9. <span class="tt wims_code_variable">feedback</span>, etc
  10.  
  11. <pre>\img{\imagedir/picture.jpg alt="picture"}</pre>
  12.  
  13. Then on the browser, the student will see
  14.  
  15. <pre>&lt;img src="a_random_unrelated_file_name" alt="picture"></pre>
  16.  
  17. The true file name is thus hidden to the student.
  18.  
  19. <p><b>Note</b>. Do not use directly the WIMS command <span class="tt wims_code_words">rename</span> to
  20. process the file name, or the exercise would not work correctly under saved
  21. environment.
  22. </p>
  23. <h3>Multi-step exercises</h3>
  24. Multi-step exercises can be defined via the command <span class="tt wims_code_variable">\steps</span>. For
  25. example, if you define (among parameters)
  26.  
  27. <pre>\steps{choice 1, reply 1
  28. choice 2, reply 2, reply 3
  29. choice 3
  30. }</pre>
  31. <p>
  32. the exercise will be presented with 3 steps, the first asks for a multiple
  33. choice (choice 1) and a freestyle reply (reply 1), the second a multiple
  34. choice and two freestyle replies, etc.
  35. </p><p>
  36. The content of <span class="tt wims_code_variable">\steps</span> accepts (earlier-defined) parameters as well as
  37. conditional definitions, in the same way as the definition of parameters.
  38. This allows you to selectively present response
  39. fields (according to random variations of parameters), even in the case
  40. where there is only one step.
  41. </p><p>
  42. It is to be noted that if a user makes a mistake in
  43. an early step, subsequent steps will not be presented (and will be
  44. considered all wrong).
  45. </p><p>
  46. The current step number is available to the statement of the exercise,
  47. via the variable
  48. <span class="tt wims_code_variable">\step</span> which takes successively the values of 1,2,... when the user
  49. advances in his/her answering.
  50. </p><p>
  51. To make dynamic multi-step exercises (steps varying with student answers), you
  52. can use the command <span class="tt wims_code_words">\nextstep{...}</span>. The content of
  53. <span class="tt wims_code_variable">\nextstep</span> is the similar to <span class="tt wims_code_variable">\steps</span> but only the first line
  54. is effective. It is useful only when the content is given by a variable
  55. which is changed by post-reply parameter definitions. The exercise stops when
  56. the content of <span class="tt wims_code_variable">\nextstep</span> is empty at some step.
  57. </p><p>
  58. In any case, at most one declaration <span class="tt wims_code_variable">\steps</span> or <span class="tt wims_code_variable">\nextstep</span>
  59. should appear in an OEF source.
  60. </p>
  61. <h3>Conditional branching and loops</h3>
  62.  
  63. Available commands:
  64.  
  65. <pre>
  66. \if{condition}{if_content}
  67. \if{condition}{if_content}{otherwise_content}
  68. \ifval{condition}{if_content}
  69. \ifval{condition}{if_content}{otherwise_content}
  70. \for{var=n1 to n2}{loop_content}
  71. \while{condition}{loop_content} (main environment only)
  72. </pre>
  73.  
  74. These commands can be used either within statement, hint, solution or
  75. feedback, or in the main environment. In the latter case, the conditional
  76. execution only affects parameter definitions.
  77.  
  78. <h3>Preprocessed sources</h3>
  79.  
  80. This feature is not available for Createxo. You can use it if you write OEF
  81. (and Deductio) exercises under Modtool.
  82. <p>
  83. It allows you to include common portions of codes into several oef files.
  84. You can also use it to make batch generation of several oefs from one
  85. pre-source, each differing from the others by some macro definitions.
  86. </p><p>
  87. To use this feature, a subdirectory cpp/ should be created under src. Put
  88. into it pre-source files with extension .cpp. In these files, you can add
  89. cpp directives like <span class="tt wims_code_words">#include</span>,
  90. <span class="tt wims_code_words">#define</span>
  91. or <span class="tt wims_code_words">#if</span>.
  92. (Please refer to cpp
  93. manual and c specification for details of the syntax.)
  94. </p><p>
  95. The first line of the cpp file must define a list of targets, in the format
  96. </p>
  97. <pre>
  98. target=targ1 targ2 targ3 ...
  99. </pre>
  100. This line means that this cpp file should generate targ1.oef, targ2.oef, etc.
  101. (the extension .oef will be
  102. appended to the output names). When generating the target file <em>targ1</em>, a macro
  103. <em>TARGET_targ1</em> is defined.
  104. Therefore in the cpp source file, you can add lines like
  105. <pre>
  106. #if defined TARGET_targ1
  107. \title{Exercise 1}
  108.  \integer{v1=3}
  109.  \text{t1=this is target 1}
  110. #endif
  111. #if defined TARGET_targ2
  112. \title{Exercise 2}
  113.  \integer{v1=5}
  114.  \text{t1=this is target 2}
  115. #endif
  116. </pre>
  117. in order to make the contents target-dependent.
  118. <p>
  119. The name of the file (in the example,
  120. <span class="tt wims_code_words">targ1</span>, ...)
  121. is available by the variable
  122. <span class="tt wims_code_words">OEFFILE</span>.
  123. In the following example, the title of the exercise will be
  124. <span class="tt wims_code_words">targ1</span>
  125. </p>
  126. <pre>
  127. #if defined TARGET_targ1
  128. \title{OEFFILE}
  129.  \integer{v1=3}
  130.  \text{t1=dit is target 1}
  131. #endif
  132. </pre>
  133. <p>
  134. Include files should also be put into the src/cpp directory, with extension
  135. .inc. A line
  136. </p>
  137. <pre>
  138. #include "common.inc"
  139. </pre>
  140. will insert the content of common.inc into the generated oef file.
  141. Please note that for security reasons, it is prohibited to specify
  142. directories of include files.
  143. <p>
  144. A special remark: cpp gets confused when your file contains single or double
  145. quotes in the text that are not closed. In this case, you can protect the
  146. commands containing such texts by c comments (<span class="tt">/* ... */</span>).
  147. </p>
  148. <div class="wims_warning">
  149. <span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in
  150. <span class="tt">#include</span>, the character <span class="tt">#</span> must be the
  151. first character of the line. You must not
  152. use <span class="tt">#</span> as a character comment.
  153. </div>
  154.  
  155.  
  156. <h3>Exercise environment</h3>
  157. <h4>Debug variable</h4>
  158. A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of
  159. an exercise (if it is not redefined within the exercise).
  160. <p>
  161. For the time being, the only testable content of the variable is the word
  162. <span class="tt wims_code_variable">debug</span>. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following
  163. situations:
  164. </p><ol>
  165. <li>When it is executed within Createxo.</li>
  166. <li>When it is under test in Modtool, by the developer himself.</li>
  167. <li>When it is a class exercise and is executed by the supervisor.</li>
  168. </ol>
  169. <p>Note that in these cases, the good reply will appear as default in the input
  170. fields of many types, allowing you to see what the exercise expects without
  171. typing into the fields.
  172. </p><p>
  173. You may add debugging informations into your exercise using things like
  174. </p>
  175. <pre>
  176. \if{debug iswordof \oefenv}{debugging informations to add into}
  177. </pre>
  178. These debugging informations will be automatically shown when the exercise
  179. is under test, and automatically hidden when students work on it.
  180.  
  181. <h4>Autres variables</h4>
  182. Deux autres variables d'environnement sont prédéfinies :
  183. <span class="tt wims_code_variable">lang</span>
  184. et <span class="tt wims_code_variable">presentgood</span>.
  185. On peut récupérer leur valeur à l'aide de la slib <span class="tt wims_code"> oef/env</span>.
  186. <p>
  187. La variable <span class="tt wims_code_variable">lang</span> peut être utilisée
  188. pour l'internationalisation des modules.
  189. </p><div>
  190. La variable <span class="tt wims_code_variable">presentgood</span> permet de tenir compte,
  191. dans la présentation des textes d'un exercice, de la valeur que l'utilisateur choisira
  192. pour le paramétrage "Afficher la bonne réponse" proposé dans l'introduction d'un module oef.
  193. Cette variable vaut 0 lorsque la bonne réponse ne doit pas être affichée et 1 sinon.
  194.  
  195. Pour l'utiliser, écrire avant le <span class="tt wims_code_variable">\statement</span>
  196. <pre>
  197. \text{presentgood=}
  198. </pre>
  199. et après le <span class="tt wims_code_variable">\statement</span>
  200. <pre>
  201. \text{presentgood=slib(oef/env presentgood)}
  202. </pre>
  203. Il est alors possible de tester la valeur de cette variable
  204. et d'afficher des textes différents selon sa valeur.
  205. Attention, sa valeur est vide lors de l'affichage du premier "écran" de l'exercice,
  206. puisqu'elle n'est utile que pour l'affichage de textes analysant la réponse
  207. de l'élève.
  208. </div>
  209.  
  210.