Subversion Repositories wimsdev

Rev

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