Subversion Repositories wimsdev

Rev

Rev 8724 | Rev 14972 | 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. <h3>Preprocessed sources</h3>
  77.  
  78. This feature is not available for Createxo. You can use it if you write OEF
  79. (and Deductio) exercises under Modtool.
  80. <p>
  81. It allows you to include common portions of codes into several oef files.
  82. You can also use it to make batch generation of several oefs from one
  83. pre-source, each differing from the others by some macro definitions.
  84. </p><p>
  85. To use this feature, a subdirectory cpp/ should be created under src. Put
  86. into it pre-source files with extension .cpp. In these files, you can add
  87. cpp directives like <span class="tt wims_code_words">#include</span>,
  88. <span class="tt wims_code_words">#define</span>
  89. or <span class="tt wims_code_words">#if</span>.
  90. (Please refer to cpp
  91. manual and c specification for details of the syntax.)
  92. </p><p>
  93. The first line of the cpp file must define a list of targets, in the format
  94. </p>
  95. <pre>
  96. target=targ1 targ2 targ3 ...
  97. </pre>
  98. This line means that this cpp file should generate targ1.oef, targ2.oef, etc.
  99. (the extension .oef will be
  100. appended to the output names). When generating the target file <em>targ1</em>, a macro
  101. <em>TARGET_targ1</em> is defined.
  102. Therefore in the cpp source file, you can add lines like
  103. <pre>
  104. #if defined TARGET_targ1
  105. \title{Exercise 1}
  106.  \integer{v1=3}
  107.  \text{t1=this is target 1}
  108. #endif
  109. #if defined TARGET_targ2
  110. \title{Exercise 2}
  111.  \integer{v1=5}
  112.  \text{t1=this is target 2}
  113. #endif
  114. </pre>
  115. in order to make the contents target-dependent.
  116. <p>
  117. The name of the file (in the example,
  118. <span class="tt wims_code_words">targ1</span>, ...)
  119. is available by the variable
  120. <span class="tt wims_code_words">OEFFILE</span>.
  121. In the following example, the title of the exercise will be
  122. <span class="tt wims_code_words">targ1</span>
  123. </p>
  124. <pre>
  125. #if defined TARGET_targ1
  126. \title{OEFFILE}
  127.  \integer{v1=3}
  128.  \text{t1=dit is target 1}
  129. #endif
  130. </pre>
  131. <p>
  132. Include files should also be put into the src/cpp directory, with extension
  133. .inc. A line
  134. </p>
  135. <pre>
  136. #include "common.inc"
  137. </pre>
  138. will insert the content of common.inc into the generated oef file.
  139. Please note that for security reasons, it is prohibited to specify
  140. directories of include files.
  141. <p>
  142. A special remark: cpp gets confused when your file contains single or double
  143. quotes in the text that are not closed. In this case, you can protect the
  144. commands containing such texts by c comments (<span class="tt">/* ... */</span>).
  145. </p>
  146. <div class="wims_warning">
  147. <span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in
  148. <span class="tt">#include</span>, the character <span class="tt">#</span> must be the
  149. first character of the line. You must not
  150. use <span class="tt">#</span> as a character comment.
  151. </div>
  152.  
  153.  
  154. <h3>Exercise environment</h3>
  155. A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of
  156. an exercise (if it is not redefined within the exercise).
  157. <p>
  158. For the time being, the only testable content of the variable is the word
  159. ``debug''. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following
  160. situations:
  161. </p><ol>
  162. <li>When it is executed within Createxo.</li>
  163. <li>When it is under test in Modtool, by the developer himself.</li>
  164. <li>When it is a class exercise and is executed by the supervisor.</li>
  165. </ol>
  166. <p>Note that in these cases, the good reply will appear as default in the input
  167. fields of many types, allowing you to see what the exercise expects without
  168. typing into the fields.
  169. </p><p>
  170. You may add debugging informations into your exercise using things like
  171. </p>
  172. <pre>
  173. \if{debug iswordof \oefenv}{debugging informations to add into}
  174. </pre>
  175. These debugging informations will be automatically shown when the exercise
  176. is under test, and automatically hidden when students work on it.
  177.