News
Index
Working with MUMIE as author
- Initial steps:
- Articles:
- Problems:
- Programming with Python
- Visualizations with JSXGraph
- Media Documents:
Working with MUMIE as teacher
Using MUMIE via plugin in local LMS
FAQ
You're not logged in
Working with MUMIE as author
Working with MUMIE as teacher
Using MUMIE via plugin in local LMS
FAQ
For the general structure of input field questions
see Structure of Questions.
The answer blocks are of the form:
12345678910111213 \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}
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:
1234567891011121314151617181920212223 \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:
a
having the value 11, a number b
having the value 16, and a variable f
which\var{..}
,f
. As\correctorprecision
is set to 3 with argument rounded, the input will be marked as correct,f
rounded to the third decimal place. 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:
1234567891011121314151617 \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}
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.
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 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$$.
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
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:
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.
1234567891011121314151617181920212223 \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}
Any answers by a user to a problem (called user input) can be
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:
\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 ORTo check the user's answer numerically, use the command \checkAsFunction or \checkFuncForZero
Remarks:
\checkStringsForRelation
you need equal() (see the following example) as part of your conditions if\checkAsFunction
(see above) in addition to achieve a numerical comparison instead. 123456789101112131415161718192021 \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}
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:
1234567891011121314151617181920212223242526272829303132 \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}
\inputAsFunction{y}{h}
as a new function (of $$y$$) for subsequent use. It cannot be evaluated by its own.\inputAsFunction{x}{k}
as new function $$k$$, and the following command checks, whether $$h[k]$$ coincides numerically with $$c = sqrt(2x^2+1)$$.\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$$.\checkFuncForZero[ _epsilon_ ]{ _expression_ }{ _start_value_ }{ _end_value_ }{ _number_of_checkpoints_ }
.\score
command, since it needs two correctly adjusted inputs. WebMiau example\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
1234567891011121314151617181920 \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}
\inputAsFunction
and \checkAsFunction
accept at first mandatory argument a comma separated list of
variable identifiers instead of only one identifier.
12345678910111213141516171819 \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.
$$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>]
12345678910111213141516171819202122232425 \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}
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\checkAsFunction
in input.cases.function are set to:\allowForInput
(see above for details) to limit the users input for the implications in the case\allowForConditionInput
(analog to \allowForInput) to limit the users input for the conditions inAn example:
123456789101112131415161718192021222324252627282930 \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}
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
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.
\format
is specified, the user must specify both the row and column count himself.Example:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 \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}
for input.matrix answer type, you have the following correction options
See Example in Webmiau.
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.
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:
1234567891011121314 \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}
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}
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}
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
\solution{ _varname_ }
as usualfulfilling 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:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 \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}
The type input.interval is explained on the page Interval
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:
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):
12345 begin{question}
\text{What are the roots of f(x)=$\var{f}$ ?}
\explanation{}
\type{input.number}
\field{real}
1 \permuteAnswers{1, 2, 3}
1234567891011121314151617181920212223
\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}
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
Updated by Petrus Tan, 3 years, 3 months ago – 27221aa