.. role:: xml(code)
:language: xml
default
=============
.. code-block:: xml
...
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,
.. code-block:: xml
x = sample(1, -1)
What is $\sqrt(x^2)$?
abs(x)
The following tags can be used inside a **default** block.
.. only:: latex
.. tabularcolumns:: |p{0.15\linewidth}|p{0.40\linewidth}|p{0.35\linewidth}|
.. rst-class:: tight-table
.. list-table::
:header-rows: 1
:widths: 20 10 70
* - 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. ``x=1;y=2;``
* - ````
-
- List of subtags ```` containing tokens
(variables, functions or operators) that are not allowed in the
answer.
Examples
--------
Basic
^^^^^
.. code-block:: xml
What is 1+1?
2
Variables
^^^^^^^^^
.. code-block:: xml
omega=[1,0,0]; r=[0,1,0];
What is the velocity of a particle at a point $\vec{r}$ rotating around the origin with angular velocity $\vec{omega}$?
cross(omega, r)
Global variables, multiple questions, latex, units
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: xml
Momentum and energy
A particle with mass $m$ is moving with velocity $\vec{v}$.
x = sample(1)
m = kg; v = [x, 0, 0] meter / second;
What is the linear momentum of the particle?
m*v
What is the kinetic energy of the particle?
m*dot(v, v)/2