Subversion Repositories wimsdev

Rev

Rev 8559 | Rev 14972 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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