Subversion Repositories wimsdev

Rev

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

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