Subversion Repositories wimsdev

Rev

Rev 8454 | Rev 8724 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8454 bpr 1
!set special_list=imagefill,codefill,expandlines,rename,help,tooltip
20 reyssat 2
 
6133 bpr 3
<h2>Advanced features of OEF</h2>
20 reyssat 4
 
5
<h3>Hiding image names</h3>
6
If your exercise requires recognition of a randomly picked picture, the file
7
name of the picture might give clue to the exercise. In order to hide this
8
file name, you can write
9
 
7423 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>&lt;img src="a_random_unrelated_file_name" alt="picture" /&gt;</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.
6368 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
 
5912 bpr 77
<a id="special"></a>
1179 bpr 78
<h3>Special methods</h3>
20 reyssat 79
 
5903 bpr 80
With the command <span class="tt wims_code_words">\special{...}</span> in the statement of an exercise, the
20 reyssat 81
following special methods are available:
6368 bpr 82
<br />
20 reyssat 83
!if $special_parm=all
84
 !for sp in $special_list
5947 bpr 85
  <h4 class="wimscenter">The special method <span class="tt wims_code_words">$sp</span></h4>
8367 bpr 86
  General syntax: <span class="wims_code_words">\special{$sp <i>parameters</i>}</span>
6368 bpr 87
<div>
20 reyssat 88
 
89
  !read oef/special/$sp.phtml help
5947 bpr 90
  </div>
20 reyssat 91
 !next sp
92
!else
93
 !for sp in $special_list
94
  !href cmd=help&special_parm=oefadv&special_parm2=$sp#special $sp
95
  &nbsp;
96
 !next sp
97
!endif
98
 
99
!if $special_parm2 isitemof $special_list
5947 bpr 100
<h4 class="wimscenter">The special method <span class="tt wims_code_words">$special_parm2</span></h4>
6368 bpr 101
General syntax: <span class="wims_code_words">\special{$special_parm2 <i>parameters</i>}</span> <div>
20 reyssat 102
 
103
!read oef/special/$special_parm2.phtml help
5947 bpr 104
</div>
20 reyssat 105
!endif
106
 
107
<h3>Preprocessed sources</h3>
108
 
109
This feature is not available for Createxo. You can use it if you write OEF
110
(and Deductio) exercises under Modtool.
111
<p>
112
It allows you to include common portions of codes into several oef files.
113
You can also use it to make batch generation of several oefs from one
114
pre-source, each differing from the others by some macro definitions.
6368 bpr 115
</p><p>
20 reyssat 116
To use this feature, a subdirectory cpp/ should be created under src. Put
117
into it pre-source files with extension .cpp. In these files, you can add
7423 bpr 118
cpp directives like <span class="tt wims_code_words">#include</span>,
119
<span class="tt wims_code_words">#define</span>
8367 bpr 120
or <span class="tt wims_code_words">#if</span>.
7423 bpr 121
(Please refer to cpp
20 reyssat 122
manual and c specification for details of the syntax.)
6368 bpr 123
</p><p>
20 reyssat 124
The first line of the cpp file must define a list of targets, in the format
6368 bpr 125
</p>
20 reyssat 126
<pre>
127
target=targ1 targ2 targ3 ...
128
</pre>
2664 reyssat 129
This line means that this cpp file should generate targ1.oef, targ2.oef, etc.
20 reyssat 130
(the extension .oef will be
7423 bpr 131
appended to the output names). When generating the target file <em>targ1</em>, a macro
132
<em>TARGET_targ1</em> is defined.
20 reyssat 133
Therefore in the cpp source file, you can add lines like
134
<pre>
8367 bpr 135
#if defined TARGET_targ1
20 reyssat 136
 \title{Exercise 1}
137
 \integer{v1=3}
138
 \text{t1=this is target 1}
139
#endif
8367 bpr 140
#if defined TARGET_targ2
20 reyssat 141
 \title{Exercise 2}
142
 \integer{v1=5}
143
 \text{t1=this is target 2}
144
#endif
145
</pre>
146
in order to make the contents target-dependent.
147
<p>
8559 bpr 148
The name of the file (in the example,
149
<span class="tt wims_code_words">targ1</span>, ...)
150
is available by the variable
151
<span class="tt wims_code_words">OEFFILE</span>.
152
In the following example, the title of the exercise will be
153
<span class="tt wims_code_words">targ1</span>
154
</p>
155
<pre>
156
#if defined TARGET_targ1
157
 \title{OEFFILE}
158
 \integer{v1=3}
159
 \text{t1=dit is target 1}
160
#endif
161
</pre>
162
<p>
20 reyssat 163
Include files should also be put into the src/cpp directory, with extension
4892 bpr 164
.inc. A line
6368 bpr 165
</p>
20 reyssat 166
<pre>
167
#include "common.inc"
168
</pre>
169
will insert the content of common.inc into the generated oef file.
170
Please note that for security reasons, it is prohibited to specify
171
directories of include files.
172
<p>
173
A special remark: cpp gets confused when your file contains single or double
174
quotes in the text that are not closed. In this case, you can protect the
5903 bpr 175
commands containing such texts by c comments (<span class="tt">/* ... */</span>).
6368 bpr 176
</p>
4892 bpr 177
<div class="wims_warning">
178
<span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in
7423 bpr 179
<span class="tt">#include</span>, the character <span class="tt">#</span> must be the
180
first character of the line. You must not
8367 bpr 181
use <span class="tt">#</span> as a character comment.
4892 bpr 182
</div>
183
 
184
 
20 reyssat 185
<h3>Exercise environment</h3>
5903 bpr 186
A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of
20 reyssat 187
an exercise (if it is not redefined within the exercise).
188
<p>
189
For the time being, the only testable content of the variable is the word
5903 bpr 190
``debug''. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following
8367 bpr 191
situations:
6368 bpr 192
</p><ol>
5947 bpr 193
<li>When it is executed within Createxo.</li>
194
<li>When it is under test in Modtool, by the developer himself.</li>
195
<li>When it is a class exercise and is executed by the supervisor.</li>
20 reyssat 196
</ol>
6368 bpr 197
<p>Note that in these cases, the good reply will appear as default in the input
20 reyssat 198
fields of many types, allowing you to see what the exercise expects without
199
typing into the fields.
6368 bpr 200
</p><p>
20 reyssat 201
You may add debugging informations into your exercise using things like
5947 bpr 202
</p>
20 reyssat 203
<pre>
204
\if{debug iswordof \oefenv}{debugging informations to add into}
205
</pre>
206
These debugging informations will be automatically shown when the exercise
207
is under test, and automatically hidden when students work on it.