Subversion Repositories wimsdev

Rev

Rev 8724 | Rev 14972 | 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>&lt;img src="a_random_unrelated_file_name" alt="picture" /&gt;</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
 
76
<h3>Preprocessed sources</h3>
77
 
78
This feature is not available for Createxo. You can use it if you write OEF
79
(and Deductio) exercises under Modtool.
80
<p>
81
It allows you to include common portions of codes into several oef files.
82
You can also use it to make batch generation of several oefs from one
83
pre-source, each differing from the others by some macro definitions.
6368 bpr 84
</p><p>
20 reyssat 85
To use this feature, a subdirectory cpp/ should be created under src. Put
86
into it pre-source files with extension .cpp. In these files, you can add
7423 bpr 87
cpp directives like <span class="tt wims_code_words">#include</span>,
88
<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
<p>
20 reyssat 132
Include files should also be put into the src/cpp directory, with extension
4892 bpr 133
.inc. A line
6368 bpr 134
</p>
20 reyssat 135
<pre>
136
#include "common.inc"
137
</pre>
138
will insert the content of common.inc into the generated oef file.
139
Please note that for security reasons, it is prohibited to specify
140
directories of include files.
141
<p>
142
A special remark: cpp gets confused when your file contains single or double
143
quotes in the text that are not closed. In this case, you can protect the
5903 bpr 144
commands containing such texts by c comments (<span class="tt">/* ... */</span>).
6368 bpr 145
</p>
4892 bpr 146
<div class="wims_warning">
147
<span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in
7423 bpr 148
<span class="tt">#include</span>, the character <span class="tt">#</span> must be the
149
first character of the line. You must not
8367 bpr 150
use <span class="tt">#</span> as a character comment.
4892 bpr 151
</div>
152
 
153
 
20 reyssat 154
<h3>Exercise environment</h3>
5903 bpr 155
A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of
20 reyssat 156
an exercise (if it is not redefined within the exercise).
157
<p>
158
For the time being, the only testable content of the variable is the word
5903 bpr 159
``debug''. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following
8367 bpr 160
situations:
6368 bpr 161
</p><ol>
5947 bpr 162
<li>When it is executed within Createxo.</li>
163
<li>When it is under test in Modtool, by the developer himself.</li>
164
<li>When it is a class exercise and is executed by the supervisor.</li>
20 reyssat 165
</ol>
6368 bpr 166
<p>Note that in these cases, the good reply will appear as default in the input
20 reyssat 167
fields of many types, allowing you to see what the exercise expects without
168
typing into the fields.
6368 bpr 169
</p><p>
20 reyssat 170
You may add debugging informations into your exercise using things like
5947 bpr 171
</p>
20 reyssat 172
<pre>
173
\if{debug iswordof \oefenv}{debugging informations to add into}
174
</pre>
175
These debugging informations will be automatically shown when the exercise
176
is under test, and automatically hidden when students work on it.