You're not reading the latest revision of this page, which is here.

input.fields

Create input field problems

  • input field questions must have the question type
    • input.number
    • input.function
    • input.matrix
    • input.text
    • input.interval
  • instead of defining choices, this question type contains one or several answers.

Defining answers and precision of real numbers

Every answer must be defined in an answer environment and will be represented by a single input field for entering values. Answers must use the \solution{} command which will be compared to the users answer to determine its correctness. The comparison of the user answer will be done with a certain precision, this value can be specified in the question environment.

The precision in the generic problem is divided into:

  • \displayprecision{} defines the number of digits used for displaying real numbers in the mathlet. If not specified, then the generic problem will use the default value of 2.
  • \correctorprecision[<correctorOption, default is atleast>]{} defines the precision used for the corrector to compare answer and solution. corrector precision should not be greater than display precision. If corrector precision is not defined, then the display precision will be used.

Corrector Option

There are three options for comparing the real answer with the solution:

  1. atleast means that the answer must be typed in (rounded) with atleast the given precision. This is the default option.
  2. rounded means that the answer must be rounded.

    If you use this option, make sure you tell the user that they must round the result with the given precision

  3. truncate means that the answer should not be rounded, and should just be typed in up to the defined number of decimal digits.

Type: Input Number

Optionally, one can use the following commands within the answer environment:

  • \text{}: will add a label in front of the input field. It's probably best not to make this label too long. It would be better to put longer descriptions within the question task.
  • \explanation{}: this explanation will be visible in the corrector page. It will be shown below the explanation defined for the question and will have the label of the task in front of it.
    • If \showExplanation{always} is used within the question, it will always show both the question and answer explanation, regardless of the correctness of the users answer.
The argument of the solution must be a variable name defined in the variables 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}
        \function{f}{a/b}
        \number{a}{11}
        \number{b}{16}
    \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}

In the above example the following commands where used.

  • \text an optional label that will be placed in front of an answer (input) field
  • \solution the solution that will be used to compare with the answer of the user.
  • \precision determines, a.) how many digits behind the decimal mark the corrector will be using to determine whether the user's answer was correct, and b.) the amount of digits behind the decimal mark when displaying a number of type real. The default value for precision is set to 2. Both a.) and b.) can be overridden using \correctorprecision and \displayprecision respectively.
    • \correctorprecision overrides the (default) value of \precision when comparing the correct solution with the user's answer.
    • \displayprecision overrides the (default) value of \precision when displaying real numbers on the screen. Logically displayprecision $$\geq$$ correctorprecision
1
2
3
% Real numbers will be shown with 4 digits behind the decimal mark,
% but correct with only 2 (default).
\displayprecision{4}
1
2
3
% The following is NOT allowed,
% since displayprecision (default 2) is now smaller then the correctorprecision
\correctorprecision{4}
When a function was created using the calculate option, the precision defined with the above command will be ignored. This is because computations should not be rounded while not visible to the user. In case you do want to display the calculated value then set the precision within the function command. Again this value should be $$\geq$$ corrector precision.

Type : Input Function

If the question has the type input.function, then it is appropriate 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}{-10}{10}{100}
    \end{answer}
 
\end{question}

Corrector commands of input.function

1. \checkAsFunction

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 -10 (min) and 10 (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 submit 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$$.
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}{-10}{10}{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 = -10$$ and $$max = 10$$ 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 comparision 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
\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}
      \end{answer}
 
  \end{question}
 
\end{problem}

3. \checkStringsForRelation

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

  • corrected algebraically using the command equal(),
  • checked for relations using the command checkStringForRelation{}.

Additionally the user's input may also be checked numerically using the command checkAsFunction.
How this is done is explained below including 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.

To check the user's answer

  • algebraically against the correct solution we use the 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 \checkStringForRelation{ count number of plus signs, identifier-input-user }.

To check the user's answer numerically, you have to use the command \checkAsFunction.

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
  • Observe that the identity of operations with equal() is tested here algebraically, not numerically.
  • You can use \checkAsFunction (see above) in addition to achieve a numeric comparison.
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. Check of a functional of answers (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}{-10}{10}{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_ )}{-10}{10}{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}{-10}{10}{100}  
  \end{answer}
 
\end{question}

5. 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}{-10}{10}{100}  
    \end{answer}
 
\end{question}

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 function can't be used if you have different answer types in one question!

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

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}

Adjust randomized variables

If you randomize variables, it could happen that the random values do not satisfy some conditions the author wishes to
be fulfilled in the question, or that the problem is not correctly posed for some combinations of the random values.
So they have to be adjusted. Therefore, you can use the following syntax to achieve this:

\randadjustIf{ _list_of_variables_ }{ _avoidance_relation_ }

Example

1
2
3
4
5
6
7
\begin{variables}
   \randint{a}{2}{5}
   \randint[Z]{b}{-5}{5}
   \randint{c}{2}{5}
   \randint{d}{-4}{4}
   \randadjustIf{a,b,c}{a^2+b^2 > c^2 OR a=b}
\end{variables}

This has the following consequence:
If the random integer point $$[a,b]$$ is outside the circle (centered at the origin) with radius $$c$$, or if it is situated
at the main diagonal, then new values for $$a$$,$$b$$ and $$c$$ are picked up randomly, possibly several times, until the
given avoidance condition is no longer fulfilled.

The list_of_variables is a comma separated list which contains those random variables of the same variables
environment, for which the author wishes adjustment in case the avoidance_relation is fulfilled.

This avoidance_relation has to be a logical (boolean) combination (use $$NOT$$, $$AND$$, $$OR$$) of simple comparison
relations $$(=, !=, <, <=, >, >=)$$ between expressions in the variables.

These expressions may include random and non-random variables defined in the same environment.

See Expressions And Relations for a more detailed description.

Hint:

  • Make sure that the avoidance relation can be avoided at all for the random variables with the ranges given.
    The \randint commands jointly define a product set which has to have a non-empty intersection with the
    complement of the avoidance set. Otherwise you get a runtime error when the problem is run.
  • Even if the intersection is non-empty but has a equi-distribution probability being too small,
    a runtime error might be the result, though the algorithm tries its best to find an admissible point.

Input matrix questions

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.

You can define a matrix within the @variables@ environment using the following syntax:

1
\matrix[<options>]{<variable>}{<entries>}

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.

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.

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}

Input text questions

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 function cases questions

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

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 interval

The type input.interval is explained on the page Interval