input.fields

Create input field problems

  • input field questions must have one of the question types
    • input.number
    • input.finite-number-set
    • input.function
    • input.cases.function
    • input.interval
    • input.matrix
    • input.text
    • input.truth-table

For the general structure of input field questions
see Structure of Questions.

The answer blocks are of the form:

1
2
3
4
5
6
7
8
9
10
11
12
13
\begin{answer}
    \type{...}       % only if the question-type is input.generic
    \text{...}       % Text that appears next to the input box. This command is ignored,
                     % if in the question text the answer is referenced by \ansref.
 
    \solution{...}   % Defines what a correct solution would be. The argument
                     % has to be a variable name defined in the variables environment.
 
    ...              % Some commands specifying how the student input should be
                     % checked for correctness.
    \explanation{..} % optional explanation text that appears if the student answer was not correct.
    \score{..}       % optional, provides the answer with a different score than 1. 
\end{answer}

Input Number

For type input.number there are no additional corrector specifications in the answer environment.

The following example shows a question with a number as input which has one single constant as an answer:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
\begin{question}
 
    \begin{variables}
        \number{a}{11}
        \number{b}{16}
        \function{f}{a/b}
    \end{variables}
 
    \type{input.number}
    \field{real}
    \displayprecision{3}
    \correctorprecision[rounded]{3}
 
    \text{Determine the decimal expansion of $\var{f}$ correct to three decimal places.}
    \explanation{Think about what rounded off to three decimal places means.}
 
    \begin{answer}
        \text{Answer: }
        \explanation{The explanation that belongs to this specific answer}
        \solution{f}
    \end{answer}
 
\end{question}

What happens in the code:

  • Between \begin{variables} and \end{variables} three variables are defined, namely
    a number a having the value 11, a number b having the value 16, and a variable f which
    is equal to the fraction $$\frac{a}{b}=\frac{11}{16}$$, and which will be displayed as
    $$\frac{11}{16}$$.
  • \type{input.number}: all answers demand for a number as input.
  • \field{real}: Numbers are treated as decimal numbers and corrected as those
    (see Number fields for more details).
  • \displayprecision{3} and \correctorprecision[rounded]{3}: Determine to which
    precision numbers are displayed and corrected
    (see Precision for real numbers for more details).
  • \text{Determine ...}: This is the text shown at the beginning of the question.
    It accepts LaTeX-style text as argument. Variables can be displayed via the command \var{..},
    which should usually be enclosed in $-signs for correct mathematical display.
  • \explanation{Think...}: Text that is shown if at least one answer was incorrect.
  • The answer block is embraced with \begin{answer} and \end{answer}.
  • \text{Answer: } Text that will be placed in front of the answer (input) field
  • \explanation{The explanation ...}: Text that is shown if the answer of this
    answer block was incorrect.
  • \solution{f} the student input will be compared to the value of the variable f. As
    \correctorprecision is set to 3 with argument rounded, the input will be marked as correct,
    if it equals the value of f rounded to the third decimal place.

Field 'rational'

If you set the number field to rational \field{rational} the student's answer has to be canceled down. Otherwise it will not be correct. If you want that the student gets (some or all) points for a correct answer that wasn't canceled down, you can achieve that with the command \scoreNotCanceledDown.

An example: The default score is 1. You want that the student gets half of the score if the answer is not canceled down properly. You can achieve that with \scoreNotCanceledDown{0.5}.

WebMiau example

Field 'complex'

Be aware, even though the input field is of type input.number the provided solution has to be a function. Otherwise the corrector always evaluates the solution as 0.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
\begin{question}
 
    \begin{variables}
        \function{sol}{2+i}
    \end{variables}
 
    \type{input.number}
    \field{complex}
 
    \text{Type "2+i":}
 
    \begin{answer}
        \solution{sol}
    \end{answer}
 
\end{question}

Input Finite Number Set

The question type input.finite-number-set requires that the user inputs a finite set of numbers whose cardinality is not provided to the user.

Example code (full example )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
\begin{variables}
  \number{a1}{1}
  \number{a2}{-1}
  \drawFromSet{a}{7,1/3,3/5}
  \function{f}{(x^2-1)*(x-a)}
\end{variables}
 
\begin{question}
    \text{Give the roots of $f(x) =\var{f}$.}
    \type{input.finite-number-set}
    \field{rational}
 
    \begin{answer}
        \text{$ \{ x\in\R \; | \; f(x)=0 \} =$}
        \solution{a1,a_1,a}
    \end{answer}
\end{question}

The set of valid symbols can be extended using e.g. \allowForInput{+ - * / pi}.

Input Function

If the question has the type input.function, then there are several ways to check
the user's answer for correctness.
The simplest way is to compare the user's answer numerically with the pre-given solution.
This can be done using the command \checkAsFunction. Here is an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
\begin{question}
 
    \begin{variables}
        \function{f}{x^2+7*x}
    \end{variables}
 
    \type{input.function}
    \field{real}
    \text{Enter the solution to this problem as a function of x.}
 
    \begin{answer}
        \text{Answer: $f =$}
        \solution{f}
        \checkAsFunction{x}{-1}{1}{100}
    \end{answer}
 
\end{question}

The syntax for \checkAsFunction is explained in the next paragraph.

If one has to refer to the user's input in this or a later correction, e.g. when using the
corrector command \checkFuncForZero, one can give it a variable name using the command
\inputAsFunction{x}{t}. Here the first argument (x) is a comma separated list of free
variables that the user is allowed to use for input, and the second argument (t) is the
name which can be used later on.

Warning: Whitespaces in the list are not allowed.

See also the examples for \checkStringsForRelation,
\checkFuncForZero,
and Multivariate Functions.

Corrector commands of input.function

1. \checkAsFunction

Example from above:

1
2
3
4
5
\begin{answer}
        \text{Answer: $f =$}
        \solution{f}
        \checkAsFunction{x}{-1}{1}{100}
\end{answer}

The corrector now compares the values of the function entered by the user to those of the function $$f = x^2+7x$$ at one
hundred randomly chosen points (steps) between -1 (min) and 1 (max) and accepts the solution if and only if
none of these differ by more than the standard $$epsilon = 1E-8.$$ I.e. $$|\text{UserAnswer} - \text{CorrectAnswer}| < 10^{-8}$$
So the syntax is given by \checkAsFunction{ _variable_}{ _min_}{ _max_}{ _steps_}.
In case you wish to use a different tolerance value epsilon instead of the default 1E-8, you may provide it by an optional parameter:

\checkAsFunction[ _epsilon_]{ _variable_}{ _min_}{ _max_}{ _steps_}.

In fact, the implemented comparison method uses randomly chosen points (as mentioned), and it does not take into account points, where the function f takes values which are very large.
These points are excluded for reasons of numerical stability. 'Very large' means larger in absolute value than the default $$cutoff = 1E5$$.

Take care that you choose the interval for evaluation wisely! If the corrector has to exclude all chosen values, it will grade the answer as correct! Also numerical rounding errors can cause a false correction.

If you have to take into account a situation, where the correct result is determined only up to a constant (because the user is expected to find an indefinite integral, e.g.),
you can change the behavior of the method accordingly. So there is another extended syntax:

\checkAsFunction[ _epsilon_ | _cutoff_ | _random_ | _constDiff_ ]{ _variable_}{ _min_}{ _max_}{ _steps_}.

This is an example:

1
\checkAsFunction[1E-2|1e7|false|true]{x}{-1}{1}{100}

The consequence of using \checkAsFunction with that syntax is that

  • now the tolerance is $$1E-2$$ instead of default $$1E-8$$
  • the cutoff is now at $$1E7$$ instead of $$1E5$$
  • the comparison values are not chosen at random, but at equal spacing between $$min = -1$$ and $$max = 1$$ and
  • the function entered by the user is considered as correct if it is numerically equal to $$f + C$$ for some constant $$C$$
    (the same at each of the comparison points).
Observe that in case you want to use this extended syntax version, you have to fill in all four fields, with '|' as separator.

2. \allowForInput

With the command \allowForInput[true|false]{<expression list>} you can decide if some operations or symbols are
permitted/prohibited for answer input. The default value for the optional argument is true. The entries in the
expression list should be separated by blanks. Remarks:

  • Using this command doesn't effect the correction, but only the input itself.
  • The digits $$0-9$$ are always permitted if the optional argument is set to true, but you can exclude single
    digits or numbers by setting the optional command to false.

In the following examples (i) sin and _pi_ are excluded from input, so the user can't give the given task as answer.
As the user also shouldn't give any free variable, the first parameter of \checkAsFunction
(which contains the list of free variables) can just be left empty.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
\begin{problem}
 
  \begin{question}
 
      \begin{variables}
          \function{f}{sin(pi)}
      \end{variables}
 
      \type{input.function}
      \field{real}
      \text{\textit{Compute} $\var{f}$.}     
      \explanation{} 
 
      \begin{answer}
          \text{$ \var{f} = $}
          \solution{f}
          \allowForInput[false]{sin pi}
          \checkAsFunction{}{-1}{1}{10}
      \end{answer}
 
  \end{question}
 
\end{problem}

3. \checkStringsForRelation

Any answers by a user to a problem (called user input) can be

  • corrected using the command equal(),
  • checked using the command checkStringsForRelation{}.

Additionally the user's input may also be checked numerically using the command checkAsFunction.
How this is done is explained below including by an example.

The user's input (answer to a problem) is stored in a variable using the command
\inputAsFunction{<variable name>}{<identifier>}. Hence we can refer to the user input by its identifier.

Details:

  • inside the command checkStringsForRelation{} several tests can be accommodated. They can be combined using the logical AND, OR, NOT.
    • equal: in a first step it checks whether 2 strings are algebraically equal. After that, in a second step, it compares the two terms numerically. (boolean)
    • Commands of type "string" compare just two strings i.e. NO algebraic or numerical comparison:
      • equalString compares two strings (boolean)
      • equalTrimmedString disregards blancs and compares the resulting two strings (boolean)
      • equalIgnoreCaseString sets all capital letters to small letters, trimms the string und then compares the two resulting strings.
    • Compare two or more alternatives for one \ansref input of type string
      • \string{solution_list}{würde,wuerde} % comma separated list of valid solutions
      • \inputAsString{user_answer}
      • \checkStringsForRelation[,]{equalIgnoreCaseString(user_answer, solution_list)} % [,] the corrector knows now, that solution_list is a comma separated list and checks with OR
      • WebMiau example
    • count(x,g)=2 checks the string g and takes the value true if it contains precisely 2 letters x.
  • syntax \checkStringsForRelation{equal( identifier-input-user, correct-solution ) }.
  • for relations we put the corresponding expressions as arguments into the command e.g. we count the number of plus-signs in the user input by \checkStringsForRelation{ count number of plus signs, identifier-input-user }.

To check the user's answer numerically, use the command \checkAsFunction or \checkFuncForZero

Remarks

If you use \checkStringsForRelation you need equal() (see the following example) as part of your conditions if you want an equals check with the correct solution. If you don't use equal() there will be no equals check. Here is list of possible [relations](Expression-Syntax-For-Generic-Applets).

Observe that by default, the identity of operations with equal() is tested here algebraically, not numerically. But you can use \checkAsFunction (see above) in addition to achieve a numerical comparison instead.

If you use \inputAsString within an answer you either have to set score to zero \score{0} or use \checkStringsForRelation. Otherwise there will be a correction error.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
\begin{problem}
 
  \begin{question}
 
      \begin{variables}
          \function{f}{x^2 + 2x + 1}
      \end{variables}
 
      \type{input.function}
      \field{real}
      \text{\textit{Expand the expression} $(x+1)^2$.}     
      \explanation{} 
 
      \begin{answer}
          \text{$(x+1)^2 = $}
          \inputAsFunction{x}{g}
          \solution{f}
          \checkStringsForRelation{count(x,g)=2 AND count(+,g)=2 AND count(-,g)=0 AND count((,g)=0 AND equal(g,f)}
      \end{answer}
 
  \end{question}

4. \checkFuncForZero

In some cases, the correct user answer is not unique. For instance, if the user is expected to find two functions $$f$$, $$g$$ with $$f[g] = sqrt(2x^2+1)$$ , the number of possible correct answers is unlimited.
So $$f(y) = sqrt(2y+1)$$ with $$g(x) = x^2$$ or $$f(y) = sqrt(y)$$ with $$g(x) = 2x^2+1$$ is correct, as well as $$f = sqrt(y+1)$$ with $$g(x) = 2x^2$$,...
Consider the following code snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
\begin{problem}
 
  \begin{question}
 
      \begin{variables}
          \function{c}{sqrt(2x^2+1)}
          \function{f}{sqrt(y)}
          \function{g}{2x^2+1}
      \end{variables}
 
      \type{input.function}
      \field{real}
      \text{\textit{Find two functions such that their composition is} $\var{c}$}     
      \explanation{} 
 
      \begin{answer}
          \text{$ f(y) = $}
          \solution{f}
          \inputAsFunction{y}{h}
      \end{answer}
 
      \begin{answer}
          \text{$ g(x) =$ }
          \solution{g}
          \inputAsFunction{x}{k}
          \checkFuncForZero{h[k]-c}{-1}{1}{100}
          \score{2.0}
      \end{answer}
 
  \end{question}
 
\end{problem}
  • The first user input is marked by \inputAsFunction{y}{h} as a new function (of $$y$$) for subsequent use. It cannot be evaluated by its own.
  • The second user input is also marked by \inputAsFunction{x}{k} as new function $$k$$, and the following command checks, whether $$h[k]$$ coincides numerically with $$c = sqrt(2x^2+1)$$.
  • Example solutions are given by $$f$$ and $$g$$ listed under 'variables'.
  • So \checkFuncForZero checks whether its first argument is zero on the interval from $$- 10$$ to $$10$$, using $$100$$ randomly generated checkpoints. The default precision value is $$1E-8$$.
    If you prefer another precision, you may specify it by an optional
    parameter $$epsilon$$ included in square brackets: \checkFuncForZero[ _epsilon_ ]{ _expression_ }{ _start_value_ }{ _end_value_ }{ _number_of_checkpoints_ }.
  • The correct answer would have been evaluated by score 1.0 (default), this was changed to 2.0 by the \score command, since it needs two correctly adjusted inputs. WebMiau example
  • The first argument could be any expression of the function symbols and numbers defined under 'variables' and the
    user defined function symbols, where the basic binary operations $$+,-,*,/,^$$ are allowed, as well as the standard functions as
    $$sin(..)$$, $$ln(..)$$, $$abs(..)$$, $$theta(..)$$ (the Heaviside function), $$sign(..)$$.
    These functions have to be written with round brackets. Square brackets have to be used in case of function symbols.
  • Observe that all used function symbols may occur in expression without argument, but standard functions
    as $$sin$$ or $$ln$$ may only be used with an argument included in round brackets.
    The argument may be another expression in the declared number- and
    function-variables plus $$x$$ as standard (placeholder) variable.
  • Instead of $$abs(f)$$ you may write $$|f|$$, alternatively. Hint: To check some expression for positivity,
    you may write \checkFuncForZero{1-sign( _expression_ ) * theta( _expression_ )}{-1}{1}{100} .

Finally, you may use the syntax $$D[f]$$ to refer to the derivative of a function $$f$$, see the following code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
\begin{question}
 
  \begin{variables}
    \function{f}{-cos(7x)}
    \function{g}{7sin(7x)}
  \end{variables}
 
  \type{input.function}
  \field{real}      
  \text{\textit{Find an anti-derivative F of $\var{g}$}}         
  \explanation{} 
 
  \begin{answer}
    \text{$F(x) =$}
    \solution{f}
    \inputAsFunction{x}{k}
    \checkFuncForZero{D[k]-g}{-1}{1}{100}  
  \end{answer}
 
\end{question}

Multivariate Functions

inputAsFunction, checkAsFunction

\inputAsFunction and \checkAsFunction accept at first mandatory argument a comma separated list of
variable identifiers instead of only one identifier.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
\begin{question}
 
  \begin{variables}
    \function{f}{x^2+2xy+y^2}
  \end{variables}
 
  \type{input.function}
  \field{real}      
  \text{Expand:}         
  \explanation{} 
 
  \begin{answer}
    \text{$(x+y)^2 = $}
    \solution{f}
    \inputAsFunction{x,y}{g}
    \checkStringsForRelation{count(x,g)=2 AND count(y,g)=2 AND count(+,g)=2 AND count(-,g)=0 AND count((,g)=0 AND equal(f,g)}  
  \end{answer}
 
\end{question}

Remark: Whitespaces in the list are not allowed.

checkFuncForZero and checkStringsForRelation (substitution, derivative)

$$D[k]$$ computes the derivative for function $$k$$ and the (default) variable $$x$$. If you want to
compute the derivative for a different variable e.g. $$y$$, you can achieve that by the following
notation: $$D[k,y]$$ (with function $$k$$ and variable $$y$$)

1
D[<function identifier>,<variable identifier>]

The same notation can be used for substitution: $$f[k,y]$$ with $$y$$ being the variable in function $$f$$ that
should be replaced with function $$k$$.

1
<function 1 identifier>[<function 2 identifier>,<variable identifier>]
If the function has more than one variable identifier, you have to use the syntax above and explicitly define the variable you want to substitute or the variable with respect to which you want to compute the derivative of the function.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
\begin{question}
 
    \begin{variables}
        \function{f}{sin(y)+cos(x)}
        \derivative[normalize]{g}{f}{y}
    \end{variables}
 
    \type{input.function}
    \field{real}      
    \text{Compute the partial derivative of $\var{f}$ with respect to $y$}      
 
    \begin{answer}
        \text{Give a multivariate function $f$ with variables $x$ and $y$. $f(x,y) = $}
        \solution{f}
        \inputAsFunction{x,y}{k}  
    \end{answer}
 
    \begin{answer}
        \text{$\frac{\delta f}{\delta y} = $}
        \solution{g}
        \inputAsFunction{x,y}{l}
        \checkFuncForZero{D[k,y]-l}{-1}{1}{100}  
    \end{answer}
 
\end{question}

Input Function Cases

Another input type in the generic framework is input.cases.function. This type is designed for case
differentiations of e.g. absolute value functions. Note that you can only use this input type in an
answer environment. The questions input type has to be set to input.generic.

In answer you must use the command \solution{<variable>=<if-else expression>} where variable is an
identifier of an in the variables environment defined variable. With the if-else expression a correct solution
is defined. The syntax should be as followed: IFELSE{<if condition>}{<then implication>}{<else implication>}.

The else implication can be another if-else expression.

The answer of the user is checked numerically in a default (or by the author defined) range and in dependence
of the users given answer. At the moment you can use the following commands in the answer environment:

  • \checkAsFunction (see above for details) to customize the numeric comparison
    The default parameters of \checkAsFunction in input.cases.function are set to:
    $$min = -100$$, $$max = 100$$, $$steps = 300$$, $$epsilon = 1E-8$$.
  • \allowForInput (see above for details) to limit the users input for the implications in the case
    differentiation
  • \allowForConditionInput (analog to \allowForInput) to limit the users input for the conditions in
    the case differentiation
Be aware: The user input of 'infty' in the condition entry field of a case is disabled because it doesn't make any sense in any case and would cause problems with automatic correction. There is no need to put it into the \allowForConditionInput list. It's already handled by the system.

An example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
\begin{problem}
 
  \begin{question}
 
    \type{input.cases.function}
    \text{Fallunterscheidung, distinguish cases}
 
    \begin{variables}
        \function{g}{abs(abs(x-1)+2x)}
        \function{h}{sin(x)}
    \end{variables}
 
    \begin{answer}
        \text{$\var{g} =$}
        \solution{g=IFELSE{x>=1}{3x-1}{IFELSE{x<-1}{-x-1}{x+1}}}
        \allowForInput[false]{abs}
        \allowForConditionInput[false]{abs}
    \end{answer}
 
    \begin{answer}
        \text{$(\sin(x))^2+(\cos(x))^2=1$. Bestimme für $0\le x\le 2\pi$ $\var{h} =$}
        \solution{h=IFELSE{0<=x<=pi}{sqrt(1-(cos(x)^2))}{-sqrt(1-(cos(x)^2))}}
        \allowForInput[false]{sin}
        \allowForConditionInput[false]{sin}
        \checkAsFunction[1E-6]{x}{0}{6.283}{100} 
    \end{answer}
 
  \end{question}
 
\end{problem}

Input Matrix

If the solution to a question is a row vector, a column vector or a matrix, the generic problem is of the type input.matrix.

To define a matrix within the @variables@ environment, you can use the syntax described here

You can define a matrix within the @variables@ environment using the following syntax: ```LaTeX \matrix[]{}{} ``` You can define a matrix with **parentheses** within the @variables@ environment using the following syntax: ```LaTeX \pmatrix[]{}{} ``` Within the **** you can use **&** to to start a new matrix column and use \\\ to start a new matrix row. Entries can be: * numbers * functions * other variables The `\matrix` takes the same **** as a function, that is **calculate**, **normalize**, **expand**, and **sort**.

Per default, the answer matrix is displayed as a bmatrix. You can use the command \matrixType{pmatrix|p|bmatrix|b}
within the answer environment to explicitly set the answer matrix type.

Finally, one can specify a \format{<row_count>}{<col_count>} within the answer environment.

  • When specifying this format an empty matrix will be displayed with the given row and col count as format
    and it's dimension can not be changed by the user.
  • When $$-1$$ is used as either the row or column count, then the user has te determine this property himself.
  • When no \format is specified, the user must specify both the row and column count himself.
    The matrix size is limited 10 rows and 10 columns. Higher values in the parameters of the 'format' command will be automatically set to 10.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
\begin{problem}
 
  %%% QUESTION 1 %%%
  \begin{question}
 
    \type{input.matrix}
 
    \begin{variables}           
      % Row vector (1x4)
      \number{a}{1/3}
      \number{b}{1/7}
      \matrix[calculate]{v_r}{a +1 & 1 & 3 & b}
 
      % Column vector (4x1)   
      \matrix[calculate]{v_c}{3^2/7 \\ x \\ 10 \\ 0}
    \end{variables}
 
    \displayprecision{4}
    \correctorprecision{3}
    \field{real}
 
    \text{
      \textbf{Question 1}\\
      Determine the decimal expansion of the entries in\\
      $\var{v_r}$ and \\
      $\var{v_c}$ \\
      rounded to three decimal places.}
      \explanation{Think about what rounded off to three decimal places means.}
    }
 
    \begin{answer}
      \text{Answer: }
      \solution{v_r}
      \format{1}{-1}
    \end{answer}
 
    \begin{answer}
      \text{Answer: }
      \solution{v_c}
      \format{-1}{1}
    \end{answer}
 
  \end{question}
 
 
  %%% QUESTION 2 %%%
  \begin{question}
 
    \type{input.matrix}
    \displayprecision{4}
    \correctorprecision{2}
    \field{real}
 
    \begin{variables}
      \matrix{m}{
        3/7 & x^2 & 0 \\  % 3/7 is shown as a fraction
        5   & 2   & 3
      }
 
      \matrix[calculate]{m_1}{
        3/7 & x^2 & 0 \\  %3/7 is shown as a decimal rounded to _displayprecision_
        5   & 2   & 3
      }
    \end{variables}
 
    \text{
      \textbf{Question 2}\\
      Determine the decimal expansion of the entries in $\var{m}$ rounded to two decimal places.}
      \explanation{Think about what rounded off to three decimal places means.}
    }
 
    \begin{answer}
      \text{Answer: }
      \solution{m_1}
    \end{answer}
 
  \end{question}
 
\end{problem}
 
\embedapplet{applet}

Corrector Options for input.matrix

for input.matrix answer type, you have the following correction options

  • simple comparison
  • \checkAsFunction
  • \checkFunctionForZero
  • \checkMatrixForZero

See Example in Webmiau.

1. Simple comparison

The user input will be compared with the solution. You only need to supply a solution matrix.
Use this only if you have a unique solution with exact numbers (integer or rational).
If your solution matrix contains real numbers or even a function with variables, you should use \checkAsFunction instead.

2. input.matrix \checkAsFunction

Here, each entry of the user matrix will be compared numerically with the entries of the solution matrix.
Use this method if you have a unique solution with real numbers or function with variables in the entries.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
\begin{question}
    \begin{variables}
       \matrix{M4}{[ [z;b] ; [0;1] ]}              % 2x2 matrix
       \matrix[normalize]{sol8}{transpose(M4)} % matrix transposition
    \end{variables}
    \text{\textcolor{blue}{Comparison with checkAsFunction}}
    \begin{answer}
      \type{input.matrix}
      \format{2}{2}
      \text{$\var{M4}^{T}=$} 
      \checkAsFunction[0.01]{z}{1}{2}{1}
      \solution{sol8}
    \end{answer}
  \end{question}

3. input.matrix \checkFuncForZero

Here you can specify a function expression, which results to zero if the input is correct.
This requires \inputAsMatrix so that you can refer to the user matrix in the function expression.
Use this method if the solution is not unique, and you can check it with a function.

Example:

\begin{question}
    \field{real}
    \begin{variables}
        \matrix{sol}{[ [1;2] ; [1;2] ]}
    \end{variables}
    \debug
    \text{Find a matrix $M$ with $det(M)=0$}
    \begin{answer}
      \type{input.matrix}
      \text{M :=}
      \inputAsMatrix{}{ansMat}
      \solution{sol}
      \checkFuncForZero{det(ansMat)}{-1}{1}{1}
    \end{answer}
  \end{question}

4. input.matrix \checkMatrixForZero

Here you can specify matrix operations, which results to a zero matrix if the input is correct.
This requires \inputAsMatrix so that you can refer to the user matrix in the function expression.
Use this method if the solution is not unique, and you can check it with matrix operations.

Example:

\begin{question}
    \begin{variables}
      \matrix{M3}{[ [a;b] ; [0;1] ]}       % 2x2 matrix
      \matrix{M6}{[ [1;0] ; [0;1] ]}       % 2x2 matrix
    \end{variables}
    \text{\textcolor{blue}{Comparison with checkMatrixForZero}}
    \begin{answer}
      \type{input.matrix}
      \format{2}{2}
      \text{Find a matrix $A$ with $\det(A)\ne 0$. $A=$} 
      \inputAsMatrix{}{ansMat1}
      \solution{M3}
      \checkFuncForZero{dirac(det(ansMat1))}{-1}{1}{1}
    \end{answer}
    \begin{answer}
      \type{input.matrix}
      \format{2}{2}
      \text{Find a matrix $B$ with $A\cdot B=\var{M6}$. $B=$} 
      \inputAsMatrix{}{ansMat2}
      \solution{sol4}
      \checkMatrixForZero{ansMat1*ansMat2-M6}{-1}{1}{1}
    \end{answer}
  \end{question}

Input Text

A new question type input.text has been implemented in generic framework.
In generic problem TeX files a new variable type \string{ varname }{ string-content } can be used.
The user is expected to fill in fields of type MMString. The user answer can be checked for

  • coincidence with a pre-given string variable varname (default) by simply specifying this via \solution{ _varname_ } as usual
  • fulfilling some conditions; for this sake it has to be given a variable name first via: \inputAsString{ _user-varname_ }
    (this is completely analogous to \inputAsFunction in input.function problems), and then several conditions can be checked.

    As by now you can check:

    • length( user-varname ) e.g. \checkStringsForRelation{length( _user-varname_ ) < length( _varname_ ) AND length( _varname_ ) > 3}

    • count( symbol , user-varname ) e.g. \checkStringsForRelation{count((, _user-varname_ )+count(), _user-varname_ ) < 10}
      i.e. total number of parentheses less than 10

    • valid( user-varname ) checks for user inputs to be valid math operations,
      e.g. \checkStringsForRelation{valid( _user-varname1_ ) AND valid( _user-varname2_ )}

    • equal( user-varname , varname ) checks whether user-varname stores a valid operation which
      is identical to the one stored in varname , e.g. \checkStringsForRelation{equal( user-varname , varname )}
      Observe that identity of operations is tested here algebraically, not numerically, so only rather simple cases can be expected to work flawlessly

    • equalString( user-varname , varname ) Checks whether the stored strings are identical.
      There is no validity or identity check of operations. Just a character comparision.

    • equalTrimmedString( user-varname , varname ) This does the same as equalString, but removes all
      spaces before comparing the two strings.

Here is an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
\usepackage{mumie.genericproblem}
 
\lang{de}{
    \title{Eingabe von Textstrings}
}
    \begin{problem}
 
    \begin{variables}
        \string{q}{Hallo}
    \end{variables} 
 
    \begin{question}
 
        \lang{de}{
            \text{\textbf{Frage 1}\\
                Schreib doch mal 'Hallo'!}
            \explanation{'Hallo' und nix anderes!}
        }
 
        \type{input.text}
 
        \begin{variables}
            \string{f}{Hallo}
        \end{variables}
 
        \begin{answer}
            \text{Answer: }
            \solution{f}  %%only 'Hallo' is accepted
        \end{answer}
 
    \end{question}
 
    \begin{question}
        \lang{de}{
            \text{\textbf{Frage 2}\\
                Schreibe bitte einen gültigen mathematischen Ausdruck!}
            \explanation{}
        }
 
        \type{input.text}
 
        \begin{variables}
            \string{f}{x^2+3x+1}
        \end{variables}
 
        \begin{answer}
            \text{Answer: }
            \solution{q}
            \inputAsString{g}
            \checkStringsForRelation{valid(g)}
            %%if you write 'sin x' it is not accepted, since only sin(x) is valid in MUMIE expressions
        \end{answer}
    \end{question}
 
    \begin{question}
        \lang{de}{
            \text{\textbf{Frage 3}\\
                Schreibe den Ausdruck '(sin(x))^2+(cos(x))^2'!}
            \explanation{}
        }
 
        \type{input.text}
 
        \begin{variables}
            \string{h}{(sin(x))^2+(cos(x))^2}
        \end{variables}
 
        \begin{answer}
            \text{Answer: }
            \solution{h}
            \inputAsString{w}
            \checkStringsForRelation{equal(w,h)} 
            %% observe that the input '(cos(x))^2+(sin(x))^2' is accepted (commutativity),
            but '1' is rejected, since the system does not   know trigonometric identities
        \end{answer}
    \end{question}
 
\end{problem}
 
\embedmathlet{gwtmathlet}

Input Interval

The type input.interval is explained on the page Interval

Further options on input field questions

Permutable answers

In case the solutions of a question are a set, i.e. the answers $$x_1$$, $$x_2$$, $$x_3$$ are interchangeable,
the answers must be permutable (e.g. the roots $$x_1$$ , $$x_2$$ and $$x_3$$ of a cubic equation). This can be achieved
with the command \permuteAnswers which takes a comma separated list of answer indices (numbering starts with one).

Currently this functionality is only available for questions with the types:

  • input.number
  • input.function (WARNING: not available if \inputAsFunction is used)
  • input.finite-number-set
  • input.interval
  • input.matrix

The command \permuteAnswers can't be used if you have different answer types in one question!

The following example demonstrates this technique for a question with three answers
(index 1, 2 and 3):

1
2
3
4
5
begin{question}
    \text{What are the roots of f(x)=$\var{f}$ ?}
    \explanation{}
    \type{input.number}
    \field{real}
1
\permuteAnswers{1, 2, 3}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    \begin{answer}
        \text{$x_1 = $}
        \solution{a}
    \end{answer}
 
    \begin{answer}
        \text{$x_2 = $}
        \solution{b}
    \end{answer}
 
    \begin{answer}
        \text{$x_3 = $}
        \solution{c}
    \end{answer}
 
    \begin{variables}
        \function[expand]{f}{(x-a)(x-b)(x-c)}
        \randint[Z]{a}{-5}{5}
        \randint[Z]{b}{-5}{5}
        \randint[Z]{c}{-5}{5}
        \randadjustIf{a,b,c}{a=b OR a=c OR b=c}
    \end{variables}
\end{question}

Consecutive errors

The automatic correction of generic TeX problems can take into account consecutive errors. This feature is only
available for questions of type input.number or input.function.

More details in Advanced Programming