<h2>Advanced features of OEF</h2>
<h3>Hiding image names</h3>
If your exercise requires recognition of a randomly picked picture
, the
file
name of the picture might give clue to the exercise. In order to hide this
file name
, you can write in parts
<span class="tt wims_code_variable">statement</span>,
<span class="tt wims_code_variable">feedback</span>, etc
<pre>\img{\imagedir/picture.jpg alt="picture"}</pre>
Then on the browser, the student will see
<pre><img src="a_random_unrelated_file_name" alt="picture"></pre>
The
true file name is thus hidden to the student
.
<p><b>Note</b>. Do not use directly the WIMS command <span class="tt wims_code_words">rename</span> to
process the
file name
, or the exercise would not work correctly under saved
environment.
</p>
<h3>Multi-step exercises</h3>
Multi
-step exercises can be
defined via the command
<span
class="tt wims_code_variable">\steps
</span
>. For
example
, if you
define (among parameters
)
<pre>\steps{choice 1, reply 1
choice 2, reply 2, reply 3
choice 3
}</pre>
<p>
the exercise will be presented with 3 steps, the first asks for a multiple
choice (choice 1) and a freestyle reply (reply 1), the second a multiple
choice and two freestyle replies, etc.
</p><p>
The content of
<span
class="tt wims_code_variable">\steps
</span
> accepts
(earlier
-defined) parameters
as well
as
conditional definitions, in the same way as the definition of parameters.
This allows you to selectively present response
fields (according to random variations of parameters), even in the case
where there is only one step.
</p><p>
It is to be noted that if a user makes a mistake in
an early step, subsequent steps will not be presented (and will be
considered all wrong).
</p><p>
The
current step number is available to the statement of the exercise
,
via the variable
<span class="tt wims_code_variable">\step</span> which takes successively the values of 1,2,... when the user
advances in his/her answering.
</p><p>
To make dynamic multi-step exercises (steps varying with student answers), you
can use the command <span class="tt wims_code_words">\nextstep{...}</span>. The content of
<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
is effective. It is useful only when the content is given by a variable
which is changed by post-reply parameter definitions. The exercise stops when
the content of
<span
class="tt wims_code_variable">\nextstep
</span
> is
empty at some step
.
</p><p>
In any case, at most one declaration <span class="tt wims_code_variable">\steps</span> or <span class="tt wims_code_variable">\nextstep</span>
should appear in an OEF source.
</p>
<h3>Conditional branching and loops</h3>
Available commands:
<pre>
\if{condition}{if_content}
\if{condition}{if_content}{otherwise_content}
\ifval{condition}{if_content}
\ifval{condition}{if_content}{otherwise_content}
\for{var=n1 to n2}{loop_content}
\while{condition}{loop_content} (main environment only)
</pre>
These commands can be used either within statement, hint, solution or
feedback, or in the main environment. In the latter case, the conditional
execution only affects parameter definitions.
<h3>Preprocessed sources</h3>
This feature is not available for Createxo. You can use it if you write OEF
(and Deductio) exercises under Modtool.
<p>
It allows you to include common portions of codes into several oef files.
You can also use it to make batch generation of several oefs from one
pre
-source
, each differing from the others by some macro definitions
.
</p><p>
To use this feature, a subdirectory cpp/ should be created under src. Put
into it pre-source files with extension .cpp. In these files, you can add
cpp directives like <span class="tt wims_code_words">#include</span>,
<span class="tt wims_code_words">#define</span>
or <span class="tt wims_code_words">#if</span>.
(Please refer to cpp
manual and c specification for details of the syntax.)
</p><p>
The first line of the cpp
file must
define a
list of targets
, in the format
</p>
<pre>
target=targ1 targ2 targ3 ...
</pre>
This line means that this cpp
file should generate targ1
.oef
, targ2
.oef
, etc
.
(the extension .oef will be
appended to the output names
). When generating the target
file <em
>targ1
</em
>, a macro
Therefore in the cpp source
file, you can add lines like
<pre>
#if defined TARGET_targ1
\title{Exercise 1}
\integer{v1=3}
\text{t1=this is target 1}
#endif
#if defined TARGET_targ2
\title{Exercise 2}
\integer{v1=5}
\text{t1=this is target 2}
#endif
</pre>
in order to make the contents target-dependent.
<p>
The name of the
file (in the example
,
<span class="tt wims_code_words">targ1</span>, ...)
is available by the variable
<span class="tt wims_code_words">OEFFILE</span>.
In the following example, the title of the exercise will be
<span class="tt wims_code_words">targ1</span>
</p>
<pre>
#if defined TARGET_targ1
\title{OEFFILE}
\integer{v1=3}
\text{t1=dit is target 1}
#endif
</pre>
<p>
Include files should also be put into the src/cpp directory, with extension
.inc. A line
</p>
<pre>
#include "common.inc"
</pre>
will insert the content of common
.inc into the generated oef
file.
Please note that for security reasons, it is prohibited to specify
directories of include files.
<p>
A special remark
: cpp gets confused when your
file contains single or double
quotes in the text that are not closed. In this case, you can protect the
commands containing such texts by c comments (<span class="tt">/* ... */</span>).
</p>
<div class="wims_warning">
<span class="wims_warning">$wims_name_warning</span> : In the commands beginning by # as in
<span class="tt">#include</span>, the character <span class="tt">#</span> must be the
first character of the line. You must not
use <span class="tt">#</span> as a character comment.
</div>
<h3>Exercise environment</h3>
<h4>Debug variable</h4>
A special variable <span class="tt wims_code_variable">\oefenv</span> can be used to test the environment of
an exercise (if it is not redefined within the exercise).
<p>
For the
time being
, the only testable content of the variable is the word
<span class="tt wims_code_variable">debug</span>. This word appears within <span class="tt wims_code_variable">\oefenv</span> in the following
situations:
</p><ol>
<li>When it is executed within Createxo.</li>
<li>When it is under test in Modtool, by the developer himself.</li>
<li>When it is a class exercise and is executed by the supervisor.</li>
</ol>
<p>Note that in these cases, the good reply will appear as default in the input
fields of many types, allowing you to see what the exercise expects without
typing into the fields.
</p><p>
You may add debugging informations into your exercise using things like
</p>
<pre>
\if{debug iswordof \oefenv}{debugging informations to add into}
</pre>
These debugging informations will be automatically shown when the exercise
is under test, and automatically hidden when students work on it.
<h4>Autres variables</h4>
Deux autres variables d'environnement sont prédéfinies :
<span class="tt wims_code_variable">lang</span>
et <span class="tt wims_code_variable">presentgood</span>.
On peut récupérer leur valeur à l'aide de la slib <span class="tt wims_code"> oef/env</span>.
<p>
La variable <span class="tt wims_code_variable">lang</span> peut être utilisée
pour l'internationalisation des modules.
</p><div>
La variable <span class="tt wims_code_variable">presentgood</span> permet de tenir compte,
dans la présentation des textes d'un exercice, de la valeur que l'utilisateur choisira
pour le paramétrage "Afficher la bonne réponse" proposé dans l'introduction d'un module oef.
Cette variable vaut 0 lorsque la bonne réponse ne doit pas être affichée et 1 sinon.
Pour l'utiliser, écrire avant le <span class="tt wims_code_variable">\statement</span>
<pre>
\text{presentgood=}
</pre>
et après le <span class="tt wims_code_variable">\statement</span>
<pre>
\text{presentgood=slib(oef/env presentgood)}
</pre>
Il est alors possible de tester la valeur de cette variable
et d'afficher des textes différents selon sa valeur.
Attention, sa valeur est vide lors de l'affichage du premier "écran" de l'exercice,
puisqu'elle n'est utile que pour l'affichage de textes analysant la réponse
de l'élève.
</div>