Rev 8724 | Rev 14972 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6133 | bpr | 1 | <h2>Advanced features of OEF</h2> |
20 | reyssat | 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 | |||
6368 | bpr | 8 | <pre>\img{\imagedir/picture.jpg alt="picture"}</pre> |
20 | reyssat | 9 | |
10 | Then on the browser, the student will see |
||
11 | |||
6368 | bpr | 12 | <pre><img src="a_random_unrelated_file_name" alt="picture" /></pre> |
20 | reyssat | 13 | |
14 | The true file name is thus hidden to the student. |
||
15 | |||
5903 | bpr | 16 | <p><b>Note</b>. Do not use directly the WIMS command <span class="tt wims_code_words">rename</span> to |
4427 | bpr | 17 | process the file name, or the exercise would not work correctly under saved |
20 | reyssat | 18 | environment. |
7423 | bpr | 19 | </p> |
20 | reyssat | 20 | <h3>Multi-step exercises</h3> |
5903 | bpr | 21 | Multi-step exercises can be defined via the command <span class="tt wims_code_variable">\steps</span>. For |
20 | reyssat | 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> |
||
6368 | bpr | 28 | <p> |
20 | reyssat | 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. |
||
6368 | bpr | 32 | </p><p> |
5903 | bpr | 33 | The content of <span class="tt wims_code_variable">\steps</span> accepts (earlier-defined) parameters as well as |
20 | reyssat | 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. |
||
6368 | bpr | 38 | </p><p> |
20 | reyssat | 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). |
||
6368 | bpr | 42 | </p><p> |
20 | reyssat | 43 | The current step number is available to the statement of the exercise, |
44 | via the variable |
||
5903 | bpr | 45 | <span class="tt wims_code_variable">\step</span> which takes successively the values of 1,2,... when the user |
20 | reyssat | 46 | advances in his/her answering. |
6368 | bpr | 47 | </p><p> |
20 | reyssat | 48 | To make dynamic multi-step exercises (steps varying with student answers), you |
5903 | bpr | 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 |
||
20 | reyssat | 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 |
||
5903 | bpr | 53 | the content of <span class="tt wims_code_variable">\nextstep</span> is empty at some step. |
6368 | bpr | 54 | </p><p> |
5903 | bpr | 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> |
20 | reyssat | 56 | should appear in an OEF source. |
6368 | bpr | 57 | </p> |
20 | reyssat | 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} |
||
8367 | bpr | 65 | \ifval{condition}{if_content} |
66 | \ifval{condition}{if_content}{otherwise_content} |
||
20 | reyssat | 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 | <h3>Preprocessed sources</h3> |
||
7423 | bpr | 76 | |
20 | reyssat | 77 | This feature is not available for Createxo. You can use it if you write OEF |
78 | (and Deductio) exercises under Modtool. |
||
7423 | bpr | 79 | <p> |
20 | reyssat | 80 | It allows you to include common portions of codes into several oef files. |
81 | You can also use it to make batch generation of several oefs from one |
||
82 | pre-source, each differing from the others by some macro definitions. |
||
6368 | bpr | 83 | </p><p> |
20 | reyssat | 84 | To use this feature, a subdirectory cpp/ should be created under src. Put |
85 | into it pre-source files with extension .cpp. In these files, you can add |
||
7423 | bpr | 86 | cpp directives like <span class="tt wims_code_words">#include</span>, <span class="tt wims_code_words">#define</span> |
8367 | bpr | 87 | or <span class="tt wims_code_words">#if</span>. |
7423 | bpr | 88 | (Please refer to cpp |
20 | reyssat | 89 | manual and c specification for details of the syntax.) |
6368 | bpr | 90 | </p><p> |
20 | reyssat | 91 | The first line of the cpp file must define a list of targets, in the format |
6368 | bpr | 92 | </p> |
20 | reyssat | 93 | <pre> |
94 | target=targ1 targ2 targ3 ... |
||
95 | </pre> |
||
2664 | reyssat | 96 | This line means that this cpp file should generate targ1.oef, targ2.oef, etc. |
20 | reyssat | 97 | (the extension .oef will be |
7423 | bpr | 98 | appended to the output names). When generating the target file <em>targ1</em>, a macro |
99 | <em>TARGET_targ1</em> is defined. |
||
20 | reyssat | 100 | Therefore in the cpp source file, you can add lines like |
101 | <pre> |
||
8367 | bpr | 102 | #if defined TARGET_targ1 |
20 | reyssat | 103 | \title{Exercise 1} |
104 | \integer{v1=3} |
||
105 | \text{t1=this is target 1} |
||
106 | #endif |
||
8367 | bpr | 107 | #if defined TARGET_targ2 |
20 | reyssat | 108 | \title{Exercise 2} |
109 | \integer{v1=5} |
||
110 | \text{t1=this is target 2} |
||
111 | #endif |
||
112 | </pre> |
||
113 | in order to make the contents target-dependent. |
||
114 | <p> |
||
8559 | bpr | 115 | The name of the file (in the example, |
116 | <span class="tt wims_code_words">targ1</span>, ...) |
||
117 | is available by the variable |
||
118 | <span class="tt wims_code_words">OEFFILE</span>. |
||
119 | In the following example, the title of the exercise will be |
||
120 | <span class="tt wims_code_words">targ1</span> |
||
121 | </p> |
||
122 | <pre> |
||
123 | #if defined TARGET_targ1 |
||
124 | \title{OEFFILE} |
||
125 | \integer{v1=3} |
||
126 | \text{t1=dit is target 1} |
||
127 | #endif |
||
128 | </pre> |
||
129 | |||
130 | <p> |
||
20 | reyssat | 131 | Include files should also be put into the src/cpp directory, with extension |
4892 | bpr | 132 | .inc. A line |
7423 | bpr | 133 | </p> |
134 | <pre> |
||
20 | reyssat | 135 | #include "common.inc" |
136 | </pre> |
||
7423 | bpr | 137 | will insert the content of common.inc into the generated oef file. |
20 | reyssat | 138 | Please note that for security reasons, it is prohibited to specify |
139 | directories of include files. |
||
7423 | bpr | 140 | <p> |
20 | reyssat | 141 | A special remark: cpp gets confused when your file contains single or double |
142 | quotes in the text that are not closed. In this case, you can protect the |
||
5903 | bpr | 143 | commands containing such texts by c comments (<span class="tt">/* ... */</span>). |
6368 | bpr | 144 | </p> |
4892 | bpr | 145 | <div class="wims_warning"> |
146 | <span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in |
||
7423 | bpr | 147 | <span class="tt">#include</span>, the character <span class="tt">#</span> must be the |
148 | first character of the line. You must not |
||
8367 | bpr | 149 | use <span class="tt">#</span> as a character comment. |
4892 | bpr | 150 | </div> |
151 | |||
152 | |||
20 | reyssat | 153 | <h3>Exercise environment</h3> |
5903 | bpr | 154 | A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of |
20 | reyssat | 155 | an exercise (if it is not redefined within the exercise). |
156 | <p> |
||
157 | For the time being, the only testable content of the variable is the word |
||
5903 | bpr | 158 | ``debug''. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following |
8367 | bpr | 159 | situations: |
6368 | bpr | 160 | </p><ol> |
161 | <li>When it is executed within Createxo.</li> |
||
162 | <li>When it is under test in Modtool, by the developer himself.</li> |
||
163 | <li>When it is a class exercise and is executed by the supervisor.</li> |
||
20 | reyssat | 164 | </ol> |
7423 | bpr | 165 | <p>Note that in these cases, the good reply will appear as default in the input |
20 | reyssat | 166 | fields of many types, allowing you to see what the exercise expects without |
167 | typing into the fields. |
||
6368 | bpr | 168 | </p><p> |
20 | reyssat | 169 | You may add debugging informations into your exercise using things like |
7423 | bpr | 170 | </p> |
171 | <pre> |
||
20 | reyssat | 172 | \if{debug iswordof \oefenv}{debugging informations to add into} |
173 | </pre> |
||
174 | These debugging informations will be automatically shown when the exercise |
||
175 | is under test, and automatically hidden when students work on it. |