Subversion Repositories wimsdev

Rev

Rev 17347 | 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
14972 bpr 7
file name, you can write in parts
8
<span class="tt wims_code_variable">statement</span>,
9
<span class="tt wims_code_variable">feedback</span>, etc
20 reyssat 10
 
7423 bpr 11
<pre>\img{\imagedir/picture.jpg alt="picture"}</pre>
20 reyssat 12
 
13
Then on the browser, the student will see
14
 
17347 bpr 15
<pre>&lt;img src="a_random_unrelated_file_name" alt="picture"></pre>
20 reyssat 16
 
17
The true file name is thus hidden to the student.
18
 
5903 bpr 19
<p><b>Note</b>. Do not use directly the WIMS command <span class="tt wims_code_words">rename</span> to
4427 bpr 20
process the file name, or the exercise would not work correctly under saved
20 reyssat 21
environment.
6368 bpr 22
</p>
20 reyssat 23
<h3>Multi-step exercises</h3>
5903 bpr 24
Multi-step exercises can be defined via the command <span class="tt wims_code_variable">\steps</span>. For
20 reyssat 25
example, if you define (among parameters)
26
 
27
<pre>\steps{choice 1, reply 1
28
choice 2, reply 2, reply 3
29
choice 3
30
}</pre>
6368 bpr 31
<p>
20 reyssat 32
the exercise will be presented with 3 steps, the first asks for a multiple
33
choice (choice 1) and a freestyle reply (reply 1), the second a multiple
34
choice and two freestyle replies, etc.
6368 bpr 35
</p><p>
5903 bpr 36
The content of <span class="tt wims_code_variable">\steps</span> accepts (earlier-defined) parameters as well as
20 reyssat 37
conditional definitions, in the same way as the definition of parameters.
38
This allows you to selectively present response
39
fields (according to random variations of parameters), even in the case
40
where there is only one step.
6368 bpr 41
</p><p>
20 reyssat 42
It is to be noted that if a user makes a mistake in
43
an early step, subsequent steps will not be presented (and will be
44
considered all wrong).
6368 bpr 45
</p><p>
20 reyssat 46
The current step number is available to the statement of the exercise,
47
via the variable
5903 bpr 48
<span class="tt wims_code_variable">\step</span> which takes successively the values of 1,2,... when the user
20 reyssat 49
advances in his/her answering.
6368 bpr 50
</p><p>
20 reyssat 51
To make dynamic multi-step exercises (steps varying with student answers), you
5903 bpr 52
can use the command <span class="tt wims_code_words">\nextstep{...}</span>. The content of
53
<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 54
is effective. It is useful only when the content is given by a variable
55
which is changed by post-reply parameter definitions. The exercise stops when
5903 bpr 56
the content of <span class="tt wims_code_variable">\nextstep</span> is empty at some step.
6368 bpr 57
</p><p>
5903 bpr 58
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 59
should appear in an OEF source.
6368 bpr 60
</p>
20 reyssat 61
<h3>Conditional branching and loops</h3>
62
 
63
Available commands:
64
 
65
<pre>
66
\if{condition}{if_content}
67
\if{condition}{if_content}{otherwise_content}
8367 bpr 68
\ifval{condition}{if_content}
69
\ifval{condition}{if_content}{otherwise_content}
20 reyssat 70
\for{var=n1 to n2}{loop_content}
17514 bpr 71
\while{condition}{loop_content} (main environment only)
20 reyssat 72
</pre>
73
 
74
These commands can be used either within statement, hint, solution or
75
feedback, or in the main environment. In the latter case, the conditional
76
execution only affects parameter definitions.
77
 
78
<h3>Preprocessed sources</h3>
79
 
80
This feature is not available for Createxo. You can use it if you write OEF
81
(and Deductio) exercises under Modtool.
82
<p>
83
It allows you to include common portions of codes into several oef files.
84
You can also use it to make batch generation of several oefs from one
85
pre-source, each differing from the others by some macro definitions.
6368 bpr 86
</p><p>
20 reyssat 87
To use this feature, a subdirectory cpp/ should be created under src. Put
88
into it pre-source files with extension .cpp. In these files, you can add
7423 bpr 89
cpp directives like <span class="tt wims_code_words">#include</span>,
90
<span class="tt wims_code_words">#define</span>
8367 bpr 91
or <span class="tt wims_code_words">#if</span>.
7423 bpr 92
(Please refer to cpp
20 reyssat 93
manual and c specification for details of the syntax.)
6368 bpr 94
</p><p>
20 reyssat 95
The first line of the cpp file must define a list of targets, in the format
6368 bpr 96
</p>
20 reyssat 97
<pre>
98
target=targ1 targ2 targ3 ...
99
</pre>
2664 reyssat 100
This line means that this cpp file should generate targ1.oef, targ2.oef, etc.
20 reyssat 101
(the extension .oef will be
7423 bpr 102
appended to the output names). When generating the target file <em>targ1</em>, a macro
103
<em>TARGET_targ1</em> is defined.
20 reyssat 104
Therefore in the cpp source file, you can add lines like
105
<pre>
8367 bpr 106
#if defined TARGET_targ1
20 reyssat 107
 \title{Exercise 1}
108
 \integer{v1=3}
109
 \text{t1=this is target 1}
110
#endif
8367 bpr 111
#if defined TARGET_targ2
20 reyssat 112
 \title{Exercise 2}
113
 \integer{v1=5}
114
 \text{t1=this is target 2}
115
#endif
116
</pre>
117
in order to make the contents target-dependent.
118
<p>
8559 bpr 119
The name of the file (in the example,
120
<span class="tt wims_code_words">targ1</span>, ...)
121
is available by the variable
122
<span class="tt wims_code_words">OEFFILE</span>.
123
In the following example, the title of the exercise will be
124
<span class="tt wims_code_words">targ1</span>
125
</p>
126
<pre>
127
#if defined TARGET_targ1
128
 \title{OEFFILE}
129
 \integer{v1=3}
130
 \text{t1=dit is target 1}
131
#endif
132
</pre>
133
<p>
20 reyssat 134
Include files should also be put into the src/cpp directory, with extension
4892 bpr 135
.inc. A line
6368 bpr 136
</p>
20 reyssat 137
<pre>
138
#include "common.inc"
139
</pre>
140
will insert the content of common.inc into the generated oef file.
141
Please note that for security reasons, it is prohibited to specify
142
directories of include files.
143
<p>
144
A special remark: cpp gets confused when your file contains single or double
145
quotes in the text that are not closed. In this case, you can protect the
5903 bpr 146
commands containing such texts by c comments (<span class="tt">/* ... */</span>).
6368 bpr 147
</p>
4892 bpr 148
<div class="wims_warning">
149
<span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in
7423 bpr 150
<span class="tt">#include</span>, the character <span class="tt">#</span> must be the
151
first character of the line. You must not
8367 bpr 152
use <span class="tt">#</span> as a character comment.
4892 bpr 153
</div>
154
 
155
 
20 reyssat 156
<h3>Exercise environment</h3>
15209 bpr 157
<h4>Debug variable</h4>
5903 bpr 158
A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of
20 reyssat 159
an exercise (if it is not redefined within the exercise).
160
<p>
161
For the time being, the only testable content of the variable is the word
15209 bpr 162
<span class="tt wims_code_variable">debug</span>. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following
8367 bpr 163
situations:
6368 bpr 164
</p><ol>
5947 bpr 165
<li>When it is executed within Createxo.</li>
166
<li>When it is under test in Modtool, by the developer himself.</li>
167
<li>When it is a class exercise and is executed by the supervisor.</li>
20 reyssat 168
</ol>
6368 bpr 169
<p>Note that in these cases, the good reply will appear as default in the input
20 reyssat 170
fields of many types, allowing you to see what the exercise expects without
171
typing into the fields.
6368 bpr 172
</p><p>
20 reyssat 173
You may add debugging informations into your exercise using things like
5947 bpr 174
</p>
20 reyssat 175
<pre>
176
\if{debug iswordof \oefenv}{debugging informations to add into}
177
</pre>
178
These debugging informations will be automatically shown when the exercise
179
is under test, and automatically hidden when students work on it.
15209 bpr 180
 
181
<h4>Autres variables</h4>
182
Deux autres variables d'environnement sont prédéfinies :
183
<span class="tt wims_code_variable">lang</span>
184
et <span class="tt wims_code_variable">presentgood</span>.
185
On peut récupérer leur valeur à l'aide de la slib <span class="tt wims_code"> oef/env</span>.
186
<p>
187
La variable <span class="tt wims_code_variable">lang</span> peut être utilisée
188
pour l'internationalisation des modules.
189
</p><div>
17514 bpr 190
La variable <span class="tt wims_code_variable">presentgood</span> permet de tenir compte,
15209 bpr 191
dans la présentation des textes d'un exercice, de la valeur que l'utilisateur choisira
192
pour le paramétrage "Afficher la bonne réponse" proposé dans l'introduction d'un module oef.
193
Cette variable vaut 0 lorsque la bonne réponse ne doit pas être affichée et 1 sinon.
194
 
195
Pour l'utiliser, écrire avant le <span class="tt wims_code_variable">\statement</span>
196
<pre>
197
\text{presentgood=}
198
</pre>
199
et après le <span class="tt wims_code_variable">\statement</span>
200
<pre>
201
\text{presentgood=slib(oef/env presentgood)}
202
</pre>
203
Il est alors possible de tester la valeur de cette variable
204
et d'afficher des textes différents selon sa valeur.
205
Attention, sa valeur est vide lors de l'affichage du premier "écran" de l'exercice,
206
puisqu'elle n'est utile que pour l'affichage de textes analysant la réponse
207
de l'élève.
208
</div>
209