You're not reading the latest revision of this page, which is
here.
advanced topics
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
.
Consider a problem with several questions, all of them of type input.number
or type input.function
.
Assume the solution of the nth question depends on the solution of the mth question for some question numbers $$m$$,$$n$$
with $$m < n$$. Say the student's solution of the mth question was wrong. Then the student used a wrong input for the
nth question. Assume that, apart from starting with a wrong input, the student solved the nth question correctly.
This is what we call a consecutive error.
Taking into account consecutive errors means the student doesn't get the points for the mth question, but the solution
of the nth question is counted as correct and the points are awarded.
Taking into account consecutive errors works as follows. The questions are corrected one after the other.
For each question, the following happens:
 First, the question is corrected normally, meaning the student's solution is compared to the correct solution.
 If the student's solution coincide with the correct solution, everything is ok and the correction proceeds to the
next question.
 Otherwise, the correction of this question is repeated with certain variables bound to student answers of previous
questions. This is called conditional correction. Which variable is bound to which answer is controlled by the author
using the \earlierAnswer
command described below.
 The score resulting from the conditional correction is compared to that of the normal correction. The correction
with the higher score counts.
The \earlierAnswer
command has the following form:
\earlierAnswer{VARIABLE}{QUESTION_NUMBER,ANSWER_NUMBER}
where VARIABLE
is the name of the variable defined on global (not question or answer) level, QUESTION_NUMBER
the number of the question and ANSWER_NUMBER
the number of the answer.
If another variable depends on a variable that is referenced in `\earlierAnswer`, the
dependent variable must also be defined in the global (and not in a question/answer) variable environment.
The answer number and the comma before it can be omitted:
\earlierAnswer{VARIABLE}{QUESTION_NUMBER}
In that case, the answer number defaults to 1.
The \earlierAnswer
command is only allowed in the "variables" environment of a question.
Do not use the command \earlierAnswer
to refer to an earlier question in a problem that has
\randomquestionpool
enabled! Problems with random question pools can only use \earlierAnswer
for subtasks within the same question, by using the value 1 for the question number.
Below is a complete example of a problem. The problem is trivial: a random number Q is given, and the student has to
compute $$x = Q + 1$$ in the first question, $$y = x + 1$$ in the second, and $$z = y + 1$$ in the third. The second
and third question depend on the solutions of previous questions. To take this into account, we added \earlierAnswer
commands to bind variables to earlier answers. In the second question, for example, we bound x to the first answer of
question 1.
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  \begin{problem}
\begin{variables}
\randint{Q}{4}{4}
\function{x}{Q+1}
\function{y}{x+1}
\function{z}{y+1}
\end{variables}
\begin{question}
\text{\textbf{Step 1}\\ \textit{Let Q = $\var{Q}$. Compute x = Q + 1:}}
\explanation{Simply add one}
\type{input.number}
\precision{3}
\field{real}
\begin{answer}
\text{ x = }
\solution{x}
\end{answer}
\end{question}
\begin{question}
\begin{variables}
\earlierAnswer{x}{1,1}
\end{variables}
\text{\textbf{Step 2}\\ \textit{Compute y = x + 1:}}
\explanation{Simply add one}
\type{input.number}
\precision{3}
\field{real}
\begin{answer}
\text{ y = }
\solution{y}
\end{answer}
\end{question}
\begin{question}
\begin{variables}
\earlierAnswer{x}{1,1}
\earlierAnswer{y}{2,1}
\end{variables}
\text{\textbf{Step 3}\\ \textit{Compute z = y + 1:}}
\explanation{Simply add one}
\type{input.number}
\precision{3}
\field{real}
\begin{answer}
\text{ z = }
\solution{z}
\end{answer}
\end{question}
\end{problem}

Here you find a more advanced example in WebMiau with consecutive errors with text answers: https://miau.mumie.net/webmiau/editor/content%2Fexamples%2FcomplexExamples%2Fprb_consecutive_error_text_number.src.tex
Consecutive errors within one question
You can also set the QUESTION_NUMBER
to 1 to refer to a previous answer in the same question:
\earlierAnswer{VARIABLE}{1,ANSWER_NUMBER}
When you use \randomquestionpool
(see Randomquestionpool) at the begin of
a problem to make a selection, this is the only case of \earlierAnswer
that you can use.
Warning:
If you use \earlierAnswer{VARIABLE}{1,ANSWER_NUMBER}
, be aware of the correction procedure described above.
Wrong use:
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  \begin{problem}
\begin{variables}
\randint{Q}{4}{4}
\function{x}{Q+1}
\function{y}{x+1}
\end{variables}
\begin{question}
\begin{variables}
\earlierAnswer{x}{1,1}
\end{variables}
\text{Let Q = $\var{Q}$.}
\type{input.number}
\begin{answer}
\text{Compute x = Q + 1:}
\solution{x}
\end{answer}
\begin{answer}
\text{Compute y = x + 1:}
\solution{y}
\end{answer}
\end{question}
\end{problem}

In this line of code, the student will always get full score for the first answer. Indeed, if
the answer is wrong, the correction will be repeated with x
being the student's first answer,
and so evaluate the first answer as conditionally correct.
The correct way is given by using a copy of the variable x
:
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  \begin{problem}
\begin{variables}
\randint{Q}{4}{4}
\function{x}{Q+1}
\function{xc}{x}
\function{y}{xc+1}
\end{variables}
\begin{question}
\begin{variables}
\earlierAnswer{xc}{1,1}
\end{variables}
\text{Let Q = $\var{Q}$.}
\type{input.number}
\begin{answer}
\text{Compute x = Q + 1:}
\solution{x}
\end{answer}
\begin{answer}
\text{Compute y = x + 1:}
\solution{y}
\end{answer}
\end{question}
\end{problem}

Now the solution x
of the first answer is not affected by the \earlierAnswer
command,
but the solution y
of the second answer will.
Weighting the score of answers
By default the user obtains the same amount of points for every correct answer within a problem.
An exception is the case where an answer is not evaluated directly (compare the example for CheckFunctionForZero ).
This default can be changed by using the \score
command.
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  \usepackage{mumie.genericproblem}
\title{Different Score Weights Per Answer}
\begin{problem}
\begin{variables}
\number{a}{1}
\number{b}{2}
\end{variables}
\begin{question}
\text{1 or 2?}
\explanation{}
\type{input.number}
\field{real}
\begin{answer}
\text{$1\cdot 1=$}
\solution{a}
\end{answer}
\begin{answer}
\text{$1\cdot 2=$}
\solution{b}
\score{2} % default score is 1
\end{answer}
\end{question}
\end{problem}

In the example above, the second answer is given the score weight 2.
Hence, if the total amount of points for the problem is 6, a correct first answer gives 2 points, a correct second answer 4 points.
This also works with answers in multiple questions.
Remark: The total amount of points for a problem is set in the "Settings" of a course in which it is used, and can change from course to course.