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