default¶
<question type="default">
...
</question>
Can be used when the answer is a symbolic or numeric expression in a set of variables, possibly vector or matrix-valued. Student answers are graded by comparing them with the correct expression, optionally by random sampling.
Vectors and matrices are defined using square brackets and can be
unitful. For example a 3-vector can be written as [1,2,3]. A
matrix is similarly entered as [[1,0], [0,1]], where the inner
vectors corresponds to the rows of the matrix. There are a number of
vector operators available (see the help button for a default
question for the full list) such as cross(v1,v2), dot(v1,v2)
and norm(v).
Scalar variables can be defined as random sampled using the function
sample(value1, value2, ...). The answer will be compared using
random sampling in a neighbourhood around each value.
For example to correctly grade an answer containing the absolute value function,
<question type="default">
<variables>
x = sample(1, -1)
</variables>
<text>
What is $\sqrt(x^2)$?
</text>
<expression>abs(x)</expression>
</question>
The following tags can be used inside a default block.
Tag |
Attributes |
Description |
|---|---|---|
|
Question text shown in viscinity of the input field. |
|
|
Expression for the correct answer |
|
|
Variables in semicolon separated list of var=value, e.g. |
|
|
List of subtags |
Examples¶
Basic¶
<question type="default">
<text>What is 1+1?</text>
<expression>2</expression>
</question>
Variables¶
<question type="default">
<variables>
omega=[1,0,0]; r=[0,1,0];
</variables>
<text>
What is the velocity of a particle at a point $\vec{r}$ rotating around the origin with angular velocity $\vec{omega}$?
</text>
<expression>cross(omega, r)</expression>
</question>
Global variables, multiple questions, latex, units¶
<exercise>
<exercisename>Momentum and energy</exercisename>
<text>
A particle with mass $m$ is moving with velocity $\vec{v}$.
</text>
<global type="default">
x = sample(1)
m = kg; v = [x, 0, 0] meter / second;
</global>
<question type="default">
<text>
What is the linear momentum of the particle?
</text>
<expression>m*v</expression>
</question>
<question type="default">
<text>
What is the kinetic energy of the particle?
</text>
<expression>m*dot(v, v)/2</expression>
</question>
</exercise>