Rev 8559 | Rev 14040 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | reyssat | 1 | |
6133 | bpr | 2 | <h2>Advanced features of OEF</h2> |
20 | reyssat | 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 | |||
7423 | bpr | 9 | <pre>\img{\imagedir/picture.jpg alt="picture"}</pre> |
20 | reyssat | 10 | |
11 | Then on the browser, the student will see |
||
12 | |||
6368 | bpr | 13 | <pre><img src="a_random_unrelated_file_name" alt="picture" /></pre> |
20 | reyssat | 14 | |
15 | The true file name is thus hidden to the student. |
||
16 | |||
5903 | bpr | 17 | <p><b>Note</b>. Do not use directly the WIMS command <span class="tt wims_code_words">rename</span> to |
4427 | bpr | 18 | process the file name, or the exercise would not work correctly under saved |
20 | reyssat | 19 | environment. |
6368 | bpr | 20 | </p> |
20 | reyssat | 21 | <h3>Multi-step exercises</h3> |
5903 | bpr | 22 | Multi-step exercises can be defined via the command <span class="tt wims_code_variable">\steps</span>. For |
20 | reyssat | 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> |
||
6368 | bpr | 29 | <p> |
20 | reyssat | 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. |
||
6368 | bpr | 33 | </p><p> |
5903 | bpr | 34 | The content of <span class="tt wims_code_variable">\steps</span> accepts (earlier-defined) parameters as well as |
20 | reyssat | 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. |
||
6368 | bpr | 39 | </p><p> |
20 | reyssat | 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). |
||
6368 | bpr | 43 | </p><p> |
20 | reyssat | 44 | The current step number is available to the statement of the exercise, |
45 | via the variable |
||
5903 | bpr | 46 | <span class="tt wims_code_variable">\step</span> which takes successively the values of 1,2,... when the user |
20 | reyssat | 47 | advances in his/her answering. |
6368 | bpr | 48 | </p><p> |
20 | reyssat | 49 | To make dynamic multi-step exercises (steps varying with student answers), you |
5903 | bpr | 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 |
||
20 | reyssat | 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 |
||
5903 | bpr | 54 | the content of <span class="tt wims_code_variable">\nextstep</span> is empty at some step. |
6368 | bpr | 55 | </p><p> |
5903 | bpr | 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> |
20 | reyssat | 57 | should appear in an OEF source. |
6368 | bpr | 58 | </p> |
20 | reyssat | 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} |
||
8367 | bpr | 66 | \ifval{condition}{if_content} |
67 | \ifval{condition}{if_content}{otherwise_content} |
||
20 | reyssat | 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 | |||
5912 | bpr | 76 | <a id="special"></a> |
1179 | bpr | 77 | <h3>Special methods</h3> |
20 | reyssat | 78 | |
5903 | bpr | 79 | With the command <span class="tt wims_code_words">\special{...}</span> in the statement of an exercise, the |
20 | reyssat | 80 | following special methods are available: |
6368 | bpr | 81 | <br /> |
20 | reyssat | 82 | !if $special_parm=all |
83 | !for sp in $special_list |
||
5947 | bpr | 84 | <h4 class="wimscenter">The special method <span class="tt wims_code_words">$sp</span></h4> |
8367 | bpr | 85 | General syntax: <span class="wims_code_words">\special{$sp <i>parameters</i>}</span> |
6368 | bpr | 86 | <div> |
20 | reyssat | 87 | |
88 | !read oef/special/$sp.phtml help |
||
5947 | bpr | 89 | </div> |
20 | reyssat | 90 | !next sp |
91 | !else |
||
92 | !for sp in $special_list |
||
93 | !href cmd=help&special_parm=oefadv&special_parm2=$sp#special $sp |
||
94 | |
||
95 | !next sp |
||
96 | !endif |
||
97 | |||
98 | !if $special_parm2 isitemof $special_list |
||
5947 | bpr | 99 | <h4 class="wimscenter">The special method <span class="tt wims_code_words">$special_parm2</span></h4> |
6368 | bpr | 100 | General syntax: <span class="wims_code_words">\special{$special_parm2 <i>parameters</i>}</span> <div> |
20 | reyssat | 101 | |
102 | !read oef/special/$special_parm2.phtml help |
||
5947 | bpr | 103 | </div> |
20 | reyssat | 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. |
||
6368 | bpr | 114 | </p><p> |
20 | reyssat | 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 |
||
7423 | bpr | 117 | cpp directives like <span class="tt wims_code_words">#include</span>, |
118 | <span class="tt wims_code_words">#define</span> |
||
8367 | bpr | 119 | or <span class="tt wims_code_words">#if</span>. |
7423 | bpr | 120 | (Please refer to cpp |
20 | reyssat | 121 | manual and c specification for details of the syntax.) |
6368 | bpr | 122 | </p><p> |
20 | reyssat | 123 | The first line of the cpp file must define a list of targets, in the format |
6368 | bpr | 124 | </p> |
20 | reyssat | 125 | <pre> |
126 | target=targ1 targ2 targ3 ... |
||
127 | </pre> |
||
2664 | reyssat | 128 | This line means that this cpp file should generate targ1.oef, targ2.oef, etc. |
20 | reyssat | 129 | (the extension .oef will be |
7423 | bpr | 130 | appended to the output names). When generating the target file <em>targ1</em>, a macro |
131 | <em>TARGET_targ1</em> is defined. |
||
20 | reyssat | 132 | Therefore in the cpp source file, you can add lines like |
133 | <pre> |
||
8367 | bpr | 134 | #if defined TARGET_targ1 |
20 | reyssat | 135 | \title{Exercise 1} |
136 | \integer{v1=3} |
||
137 | \text{t1=this is target 1} |
||
138 | #endif |
||
8367 | bpr | 139 | #if defined TARGET_targ2 |
20 | reyssat | 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> |
||
8559 | bpr | 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> |
||
20 | reyssat | 162 | Include files should also be put into the src/cpp directory, with extension |
4892 | bpr | 163 | .inc. A line |
6368 | bpr | 164 | </p> |
20 | reyssat | 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 |
||
5903 | bpr | 174 | commands containing such texts by c comments (<span class="tt">/* ... */</span>). |
6368 | bpr | 175 | </p> |
4892 | bpr | 176 | <div class="wims_warning"> |
177 | <span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in |
||
7423 | bpr | 178 | <span class="tt">#include</span>, the character <span class="tt">#</span> must be the |
179 | first character of the line. You must not |
||
8367 | bpr | 180 | use <span class="tt">#</span> as a character comment. |
4892 | bpr | 181 | </div> |
182 | |||
183 | |||
20 | reyssat | 184 | <h3>Exercise environment</h3> |
5903 | bpr | 185 | A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of |
20 | reyssat | 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 |
||
5903 | bpr | 189 | ``debug''. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following |
8367 | bpr | 190 | situations: |
6368 | bpr | 191 | </p><ol> |
5947 | bpr | 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> |
||
20 | reyssat | 195 | </ol> |
6368 | bpr | 196 | <p>Note that in these cases, the good reply will appear as default in the input |
20 | reyssat | 197 | fields of many types, allowing you to see what the exercise expects without |
198 | typing into the fields. |
||
6368 | bpr | 199 | </p><p> |
20 | reyssat | 200 | You may add debugging informations into your exercise using things like |
5947 | bpr | 201 | </p> |
20 | reyssat | 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. |