Note: You are currently viewing documentation for Moodle 3.3. Up-to-date documentation for the latest stable version of Moodle is probably available here: Formulas: Answers and marking.

Formulas: Answers and marking: Difference between revisions

From MoodleDocs
(Redirected page to Formulas question type)
 
Line 1: Line 1:
{{Formulas question type}}
#REDIRECT [[Formulas_question_type]]
 
=Note=
For a part to be valid, you must give a mark and define an answer for it. Also, grading criteria must be specified in order to check the correctness of a student answer.
 
=Answer types=
 
The Formulas question supports four answer types. Each type will accept a particular set of numbers, operators, functions and possibly algebraic variables. Depending on the purpose of the quiz, some or all of these answer types may be used.
 
{| class="nicetable"
|-
! Answer type
! Description
|-
| Number
| The answer can be entered using ordinary or scientific E-notation, for example <span style="font-family:monospace;font-size:113%;">3.14</span>, <span style="font-family:monospace;font-size:113%;">6.626e-34</span>.
|-
| Numeric
| The answer can include numbers, arithmetic operations <span style="font-family:monospace;font-size:113%;">+ - * / ^</span> and <span style="font-family:monospace;font-size:113%;">( )</span> as well as the constant π, for example <span style="font-family:monospace;font-size:113%;">5+1/2</span>, <span style="font-family:monospace;font-size:113%;">2^9</span>, <span style="font-family:monospace;font-size:113%;">3pi</span>.
|-
| Numerical formula
| The answer can include everything that the numeric answer includes, plus the following single variable functions: <span style="font-family:monospace;font-size:113%;">sin()</span>, <span style="font-family:monospace;font-size:113%;">cos()</span>, <span style="font-family:monospace;font-size:113%;">tan()</span>, <span style="font-family:monospace;font-size:113%;">asin()</span>, <span style="font-family:monospace;font-size:113%;">acos()</span>, <span style="font-family:monospace;font-size:113%;">atan()</span>, <span style="font-family:monospace;font-size:113%;">exp()</span>, <span style="font-family:monospace;font-size:113%;">log10()</span>, <span style="font-family:monospace;font-size:113%;">ln()</span>, <span style="font-family:monospace;font-size:113%;">sqrt()</span>, <span style="font-family:monospace;font-size:113%;">abs()</span>, <span style="font-family:monospace;font-size:113%;">ceil()</span>, <span style="font-family:monospace;font-size:113%;">floor()</span>. For example, <span style="font-family:monospace;font-size:113%;">sin(pi/12)</span>, <span style="font-family:monospace;font-size:113%;">10 ln(2)</span>.
|-
| Algebraic formula
| The answer can include everything that includes a numerical formula as well as algebraic variables.
|}
 
Notes:
 
<ul>
<li>Students will also need to know these rules in order to input the answers correctly.</li>
<li>The possible inputs have the following relation: Number ⊆ Numeric ⊆ Numerical formula ⊆ Algebraic formula.</li>
<li>The answer requires a list of strings for Algebraic formula and a list of numbers for the other answer types.</li>
<li><span style="font-family:monospace;font-size:113%;">^</span> in the algebraic formula means "power", not "exclusive or".</li>
<li>Juxtaposition between numbers or symbols mean multiplication.</li>
<li>The format check in the quiz interface shows a warning sign when the format is wrong for the answer type. It does not give any information about the correctness of the answer.</li>
<li>All symbols are treated as algebraic variable in the answer type of algebraic formula. Hence, you may need to hint students what symbols should be used in the question.</li>
</ul>
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:30px 0 25px;">
====<div style="font-family:Lucida Sans Unicode;font-size:116%;color:#f98012;margin:-20px 0 10px;>Example: The four types of answers</div>====
 
This question has four parts illustrating the four types of answers.
 
<pre style="font-size:113%;width: 97%;">
General
  Question name        The four types of answers
Main question
  Question text        This question has four parts illustrating the four types of answers.
Part 1
  Part's mark          1
  Answer type          Number
  Answer              pi()
  Grading criteria    Relative error < 0.01
  Part's text          Number
                      Give π with at least 1 % accuracy (3.14, 3.14159, etc.):
                      {_0}
Part 2
  Part's mark          1
  Answer type          Numeric
  Answer              10
  Grading criteria    Relative error < 0.01
  Part's text          Numeric
                      Give an expression whose value is equal to 10. For example, 2*5, 6 + 4, etc.:
                      {_0}
Part 3
  Part's mark          1
  Answer type          Numerical formula
  Answer              2
  Grading criteria    Relative error < 0.01
  Part's text          Numerical formula
                      Give an expression whose value is equal to 2. For example, 1 + 1, sqrt(4), abs(-10+2*4), log10(10^2), ceil(3.7)/sqrt(4), etc.:
                      {_0}
Part 4
  Part's mark          1
  Local variables      a = {-100:100:1};
                      b = {-100:100:1};
  Answer type          Algebraic formula
  Answer              "a^2 - b^2"
  Grading criteria    Absolute error == 0
  Part's text          Algebraic formula
                      Give an expression whose value is equal to a<sup>2</sup> - b<sup>2</sup>, for example, (a + b)(a - b):
                      {_0}
</pre>
 
The Formulas question should look like this:
 
[[File:Formules201801271435.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=321 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:30px 0 25px;">
 
====<div style="font-family:Lucida Sans Unicode;font-size:116%;color:#f98012;margin:-20px 0 10px;>Example: Scientific E‑notation</div>====
 
Variables can be defined and number answers can be entered in the standard scientific E‑notation. For example:
 
    5e2 = 5 x 10<sup>2</sup> = 500
 
This question illustrates the use of this notation.
 
<pre style="font-size:113%;width: 97%;">
General
  Question name        E-notation
Variables
  Global variables    me=9.10938356e-31;
Main question
  Question text        What is the approximate mass of an electron?
Part 1
  Part's mark          1
  Answer type          Number
  Answer              me
  Grading criteria    Relative error < 0.001
  Unit                kg
  Part's text          m<sub>e</sub> = {_0}{_u}
</pre>
 
The Formulas question should look like this:
 
[[File:Formules201801272318.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=326 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
=Correct answer=
 
Depending on the answer type, the answer options will accept an expression that evaluates to either a list of numbers or a list of strings for Algebraic formula. The size of the list will determine how many input boxes for the part. If only one answer is required, you can specify a number or a string instead of a one element list.
 
For the answer type of Number, Numeric and Numerical formula, a list of numbers or a single number is required. Suppose the variables are defined, each line below is a possible answer:
 
<pre style="font-size:113%;width: 97%;">
pi()
[sin(pi()/2), cos(pi()/2)]
[ans[0], ans[1], ans[2]]
ans
</pre>
 
For the answer type of Algebraic formula, a list of strings or a single string is required. Suppose the variables are defined, each line below is a possible answer:
 
<pre style="font-size:113%;width: 97%;">
"exp(-a x)"
" a x^2 + b y^2"
["a sin(x)", "b cos(x)"]
</pre>
 
Note that all algebraic variables must be defined in order to be usable in the answer. For the answers above to work, you need to define the following variables:
 
<pre style="font-size:113%;width: 97%;">
a = 2;
b = 3;
x = {-100:100:1};
y = {1:100:1};
</pre>
 
=Grading criterion=
 
A grading criterion is required to determine the correctness of the student answer. It requires an expression evaluated to a number whose 0 value means false and 1 value means true. Typically, the expression is either the absolute error or the relative error with a tolerance level.
 
For a question with only one answer, the absolute error is simply the different between the correct answer and the student answer. Hence if the correct answer is 3.2 and the student answer is 3.1, then the absolute error is |3.2-3.1| = 0.1 You may want to limit the range of correct answers, say to 0.05. In this case, you should select <span style="font-family:monospace;font-size:113%;">Absolute error < 0.05</span>. The relative error is defined as the absolute error divided by the absolute value of correct answer. See <span style="font-family:monospace;font-size:113%;">_err</span> and <span style="font-family:monospace;font-size:113%;">_relerr</span> in Grading variables below for more details.
 
==Grading variables==
 
Most of the time, the absolute error or the relative error satisfy the grading criterion. However, sometimes there is a need for other grading criteria.
 
The scope of Grading variables contains all local variables and the student answers. You can define your own grading criterion with the student answers. The information related to the student answers and correct answers is stored in a set of special variables that start with an underscore as shown below:
 
{| class="nicetable"
|-
! Variable name
! Description
|-
| <span style="font-family:monospace;font-size:113%;">_0</span>, <span style="font-family:monospace;font-size:113%;">_1</span>, <span style="font-family:monospace;font-size:113%;">_2</span>, ...
| The student answers. The first answer is <span style="font-family:monospace;font-size:113%;">_0</span> corresponding to the answer box <span style="font-family:monospace;font-size:113%;">{_0}</span> in the part, etc.
|-
| <span style="font-family:monospace;font-size:113%;">_a</span>
| The list of target answers, as defined in the answer field.
|-
| <span style="font-family:monospace;font-size:113%;">_r</span>
| The list of student answers with the same size as <span style="font-family:monospace;font-size:113%;">_a</span>. The 0<sup>th</sup> element is the same as <span style="font-family:monospace;font-size:113%;">_0</span>, etc.
|-
| <span style="font-family:monospace;font-size:113%;">_d</span>
| The list of differences between each element, where <span style="font-family:monospace;font-size:113%;">_d = diff(_a,_r);</span>. See the Appendix for the function details.
|-
| <span style="font-family:monospace;font-size:113%;">_err</span>
| The absolute error, using the Euclidean norm &#124;a-r&#124;, i.e. <span style="font-family:monospace;font-size:113%;">_err = sqrt(sum(map("*",_d,_d)));</span>.
|-
| <span style="font-family:monospace;font-size:113%;">_relerr</span>
| The relative error, obtained by dividing the absolute error by the norm of the correct answerd &#124;a-r&#124;/&#124;a&#124; , i.e. <span style="font-family:monospace;font-size:113%;">_relerr = _err/sqrt(sum(map("*",_a,_a)));</span>.
|}
 
Notes:
 
<ul>
<li>The corresponding input boxes of <span style="font-family:monospace;font-size:113%;">_0</span>, <span style="font-family:monospace;font-size:113%;">_1</span>, ... can be specified as <span style="font-family:monospace;font-size:113%;">{_0}</span>, <span style="font-family:monospace;font-size:113%;">{_1}</span>, ... in the part's text.</li>
<li><span style="font-family:monospace;font-size:113%;">_relerr</span> is <i>not</i> defined for algebraic answers! So <span style="font-family:monospace;font-size:113%;">_err</span> should be used instead.</li>
<li> For non-algebraic answers, the student answer is rescaled towards the unit of the target answer. For example, if the target answer is 2&nbsp;m and the student answer is 199&nbsp;cm, then _a is [2] , _r is [1.99] and _0 is 1.99 . It has no effect if no unit is used.</li>
<li> When there are more than on answer, for example if _a = [100,100]; and == _r = [101,102];, then _relerr = sqrt(1*1+2*2)/sqrt(100*100+100*100) ≒ 0.0158
In this sense, the answer defined in the answer field is only a target answer because it may not be related directly to the correctness of the answer.</li>
</ul>
 
=Manual grading criteria=
 
Other than true or false, the grading criterion can be any number between 0 (all incorrevt) and 1 (all correct). The value 1 means that the student gets the full mark for this par see Gng scheme). A fractional value represents the partial correctness of the student answer. Note that values less than 0 are treated as 0 and that values greater than 1 are treated as 1. The following examples illustrate cases where a manual grading criterion is required.
 
<div style="background:#faffbd;color:#000000;padding:4px 16px 6px;border:1px solid #d9d9d9;border-radius:4px;margin:10px 0;">
<p>
With site themes '''Clean''' and '''More''', the field for manual '''Grading Criteria''' is obtained by checking a box on the left hand side of the field. With the '''Boost''' theme, the check box does not display. Until this bug is fixed, you can get at the manual '''Grading criteria''' by changing the Moodle site theme to '''Clean''' or '''More''', or simply by downloading, from the '''Play it''' site, questions that use the field for '''Grading Criteria''', such as the ones below, and then editing them.
</p>
</div>
 
==Multiple correct answers==
 
The possibility for a student to give any correct answer among several correct answers can be allowed by establishing manually the required '''Grading criteria'''.
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:30px 0 25px;">
====<div style="font-family:Lucida Sans Unicode;font-size:116%;color:#f98012;margin:-20px 0 10px;>Example: Multiples of 7 between 40 and 50</div>====
 
Give a number <i>x</i> that is a multiple of 7 and satisfies 40 < <i>x</i> < 50.
 
<pre style="font-size:113%;width: 97%;">
General
  Question name!      Multiples of 7
Main question
  Question text!      Give a number x that is a multiple of 7 and satisfies 40 < x < 50:
Part 1
  Part's mark*        1
  Answer type          Number
  Answer*              1
  Grading criteria*    _0 == 42 || _0 == 49
  Part's text          {_0}
</pre>
 
In Part 1, Answer is specified as <span style="font-family:monospace;font-size:113%;">1</span> (or any other number) to indicate to the system that only one answer is expected. The grading criteria <span style="font-family:monospace;font-size:113%;">_0 == 42 || _0 == 49</span> means that the answer is correct if it is equal to 42 or 49.
 
The Formulas question should look like this:
 
[[File:Formules201801212219.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=270 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
==Variable criteria==
 
The above example uses only a fixed number, so how can you grade an answer with random variations? Suppose that you now ask questions with a variable range for each question a ≤ <i>x</i> ≤ <i>a</i>&nbsp;+&nbsp;10. To determine the correctness, you need to check two criteria. The following example illustrates how to do this.
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:30px 0 25px;">
====<div style="font-family:Lucida Sans Unicode;font-size:116%;color:#f98012;margin:-20px 0 10px;>Example: Multiples of 7 between 10 and 100   (Mark = 0 or 1)</div>====
 
Give a number <i>x</i> that is a multiple of 7 and satisfies <i>a</i> ≤  <i>x</i> ≤ <i>a</i> + 10, where <i>a</i> is equal to 10, 20, 30,... 90.
 
<pre style="font-size:113%;width: 97%;">
General
  Question name!      Multiples of 7 between 10 and 100
Variables
  Random variables    a={10:100:10};
Main question
  Question text!      Give a number x that is a multiple of 7
                      and satisfies a ≤  x ≤ a + 10,
                      where a is equal to 10, 20, 30,... 90:
Part 1
  Part's mark*        1
  Answer type          Number
  Answer*              1
  Grading variables    criterion1 = _0 % 7 == 0;
                      criterion2 = a <= _0 && _0 <= a+10;
  Grading criteria*    criterion1 && criterion2
  Part's text          {_0}
</pre>
 
In Part 1, Answer is specified as <span style="font-family:monospace;font-size:113%;">1</span> (or any other number) to indicate to the system that only one answer is expected. The grading variable <span style="font-family:monospace;font-size:113%;">criterion1 = _0 % 7 == 0</span> checks whether the remainder is 0. Note that <span style="font-family:monospace;font-size:113%;">criterion1</span> is equal to 1 if true, or 0 if false. The grading variable <span style="font-family:monospace;font-size:113%;">criterion2 = a <= _0 && _0 <= a+10</span> checks whether the response is in the desired range. The grading criteria <span style="font-family:monospace;font-size:113%;">criterion1 && criterion2</span> check both criteria.
 
The Formulas question should look like this:
 
[[File:Formules201801231540.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=272 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:30px 0 25px;">
 
====<div style="font-family:Lucida Sans Unicode;font-size:116%;color:#f98012;margin:-20px 0 10px;>Example: Multiples of 7 between 10 and 100   (Mark = 0, 0.5 or 1)</div>====
 
This example is the same as the previous one, but we want the student to get half a point if he meets one or the other of the two criteria. To do this, simply change the '''Grading criteria''' as follows:
 
<pre style="font-size:113%;width: 97%;">
  Grading criteria*    (criterion1 + criterion2)/2
</pre>
 
Remember that <span style="font-family:monospace;font-size:113%;">criterion1</span> and <span style="font-family:monospace;font-size:113%;">criterion2</span> are equal to 1 if true, or 0 if false. Hence, <span style="font-family:monospace;font-size:113%;">(criterion1 + criterion2)/2</span> is 0, 0.5 or 1 depending on the student's answer.
 
The Formulas question should look like this:
 
[[File:Formulas_en_20180128_1919.png|818px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=332 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
==Answers in one order or another==
 
Multiple criteria can also be used to allow students to enter their answers in one order or another. This is illustrated in the following example.
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:0px 0 25px;">
<div style="font-family:Lucida Sans Unicode;font-size:150%;color:#f98012;margin:10px 0 10px;>Example</div>
 
Use multiple criteria to allow students to give the roots of a quadratic equation in one order or another.
 
<pre style="font-size:113%;width: 97%;">
General
  Question name!      Roots of 2x^2 + 3x + 1 = 0
Main question
  Question text!      {#1}
Part 1
  Part's mark*        1
  Local variables      root1 = -1;
                      root2 = -0.5;
  Answer type          Number
  Answer*              [1,1]
  Grading criteria*    (_0 == root1 && _1 == root2) || (_0 == root2 && _1 == root1)
  Placeholder name    #1
  Part's text          Solve the quadratic equation 2x<sup>2</sup> + 3x + 1 = 0.
                      There are two roots, which are: {_0} and {_1}
</pre>
 
In Part 1, Answer is specified as <span style="font-family:monospace;font-size:113%;">[1,1]</span> (or any other pair of numbers) to indicate to the system that two answers are expected. The grading criteria <span style="font-family:monospace;font-size:113%;">(_0 == root1 && _1 == root2) || (_0 == root2 && _1 == root1)</span> means that the correct roots can be given as -1 and -0.5, or -0.5 and -1.
 
The Formulas question should look like this:
 
[[File:Formules201801231953.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=276 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
==Multiple criteria and errors==
When '''Grading criteria''' is used, the answers are checked by default with zero error. This is not a problem in the previous examples because the answers are round numbers. However, it is also possible to check the answers with errors other than zero. Note that when '''Grading criteria''' is used, the calculation of errors must be provided. The following example illustrates the use of '''Grading criteria''' together with absolute and relative errors.
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:0px 0 25px;">
<div style="font-family:Lucida Sans Unicode;font-size:150%;color:#f98012;margin:10px 0 10px;>Example</div>
 
Use '''Grading criteria''' to allow students to give answers in any order, with absolute and relative errors.
 
<pre style="font-size:113%;width: 97%;">
General
  Question name!      Enter two values in any order, with errors
Main question
  Question text!      Enter two values as follows: (answers can be given in any order)
                      4.7 ± 0.2 absolute error, i.e. any value between 4.5 and 4.9
                      9.6 ± 1% relative error, i.e. any value between 9.504 and 9.696
Part 1
  Part's mark*        1
  Local variables      exact0=4.7;
                      exact1=9.6;
  Answer type          Number
  Answer*              [1,1]
 
  Grading variables    # 4.7± 0.2 and 9.6 ± 1%
                      absoluteError0=abs(exact0-_0);
                      criterion0=absoluteError0<=0.20000001;
 
                      absoluteError1=abs(exact1-_1);
                      relativeError1=absoluteError1/exact1;
                      criterion1=relativeError1<=0.010000001;
 
                      # 9.6 ± 1% and 4.7± 0.2
                      absoluteError2=abs(exact1-_0);
                      relativeError2=absoluteError2/exact1;
                      criterion2=relativeError2<=0.010000001;
 
                      absoluteError3=abs(exact0-_1);
                      criterion3=absoluteError3<=0.20000001;
 
  Grading criteria*    (criterion0 && criterion1) || (criterion2 && criterion3)
  Part's text          The two values are: {_0} and {_1}
</pre>
 
The grading variables calculate the absolute and the relative errors, and define the four criteria to be checked. Grading criteria checks these four criteria. In this example, <span style="font-family:monospace;font-size:113%;">0000001</span> is appended to <span style="font-family:monospace;font-size:113%;">0.2</span> and <span style="font-family:monospace;font-size:113%;">0.01</span> in order to account for the computer inaccuracies and make sure that the limit values (4.5, 4.9, 9.504 and 9.696) are accepted. This would not be necessary in other cases.
 
The Formulas question should look like this:
 
[[File:Formules201801232255.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=271 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
===Mark for different accuracies===
 
Grading criteria can be used to give different marks for the accuracy of the response, for example full mark for a small error and half mark for a larger error. This is illustrated in the following example.
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:0px 0 25px;">
<div style="font-family:Lucida Sans Unicode;font-size:150%;color:#f98012;margin:10px 0 10px;>Example</div>
 
Use '''Grading criteria''' to account for the accuracy of the target answer, equal to 100 m. Give full mark for answers with an absolute error less than 1 m, i.e. for any answer between 99 m and 101 m. Give half mark for answers with an absolute error between 1 m and 5 m, i.e. for any answer between 95 m and 99 m, and between 101 m and 105 m.
 
<pre style="font-size:113%;width: 97%;">
General
  Question name!      Enter a value close or equal to 100 m
Main question
  Question text!      Enter a value close or equal to 100 m:
                      A value within ± 1 m, i.e. any value between 99 m and 101 m is worth 1 point.
                      A value within ± 5 m, i.e. any value between 95 m and 105 m is worth 0.5 point.
Part 1
  Part's mark*        1
  Answer type          Number
  Answer*              100
  Grading variables    case1 = _err < 1.0000001;
                      case2 = 0.5*(_err < 5.0000001);
  Grading criteria*    max(case1,case2)
  Unit                m
  Part's text          {_0}{_u}
Extra options
  [Global] - Deduction for wrong unit (0-1)*    1
  [Global] - Basic conversion rules            Common SI unit
Combined feedback
  For any correct response                      Your answer is correct within ± 1 m    (1 point)
  For any partially correct response            Your answer is correct within ± 5 m    (0.5 point)
</pre>
 
In this example, <span style="font-family:monospace;font-size:113%;">0000001</span> is appended to <span style="font-family:monospace;font-size:113%;">1</span> and <span style="font-family:monospace;font-size:113%;">5</span> in order to account for the computer inaccuracies and make sure that the limit values (95, 99, 101 and 105) are accepted. This would not be necessary in other cases.
 
An equivalent accuracy of the answer is used automatically if the answer is entered in a unit other than <span style="font-family:monospace;font-size:113%;">m</span>. For example, full mark is given for answers between 99 000 mm and 101 000 mm, half mark is given for answers between 9 500 cm and 9 900 cm, and between 10 100 cm and 10 500 cm, etc.
 
'''[Global] - Deduction for wrong unit (0-1)*''' equal to <span style="font-family:monospace;font-size:113%;">1</span> means that the unit must be specified, otherwise the answer is considered incorrect.
 
The Formulas question should look like this:
 
[[File:Formules201801252231.png|818px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=287 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
<!-- #######################################
This section is part of Hon Wai Lau's original text. KEEP IT FOR FUTURE REFERENCE.
The '''Trial mark sequence''' feature was removed when the Formulas question type was adapted to the quiz engine 2 for Moodle 2.1. See https://moodle.org/mod/forum/discuss.php?d=364713#p1470840.
 
 
=Trial mark sequence=
 
This option only apply to the adaptive mode of moodle quiz.
 
In the adaptive mode, students are allowed to submit answer to a particular question again and again. This field defines the mark sequence that a student can get for each resubmission. Note that it actually alter the default behavior of the adaptive mode.
 
The input is a list of numbers separated by comma. Each number represents a fraction of the maximum mark that a student can get in the first, second, third, etc. submission. Hence, if this field has value 1, the student can try it once only.
 
If the sequence is ended with a comma, infinite resubmission is allow. In this case, the mark that students can get in the following unlisted trial is decreased uniformly with the value equal to the difference of last two value. Note that the minimum mark is always zero (See grading scheme).
 
{| class="nicetable"
|-
! Trial mark sequence
! Maximum mark for each trial
! Description
|-
| 1
| 100%
| Only one trial is allowed.
|-
| 1, 0.7, 0.3
| 100%, 70%, 30%
| Three trials are allowed.
|-
| 1, 0.7, 0.3, 0
| 100%, 70%, 30%, 0%
| Four trials are allowed, but the last trial has no mark.
|-
| 1, 0, 0, 0
| 100%, 0%, 0%, 0%
| Four trials are allowed, but only the first trial has non-zero mark.
|-
| 1,
| 100%, 100%, 100%, ...
| Infinite trials. The difference is 0, which is repeated.
|-
| 1, .9,
| 100%, 90%, 80%, 70%, 60%, ...
| Infinite trials. Difference between 1st and 2nd trial is 10%, which is repeated.
|-
| 1, .6,
| 100%, 60%, 20%, 0%, 0%, ...
| Infinite trials. Difference between 1st and 2nd trial is 40%, which is repeated.
|-
| 1, .5, .3,
| 100%, 50%, 30%, 10%, 0%, 0%, ...
| Infinite trials. Difference between 2nd and 3rd trial is 20%, which is repeated.
|-
|}
########################################-->
==Grading scheme==
 
The following is the grading formula used to grade a particular subquestion:
 
{| class="nicetable"
|-
! Symbol
! Description
|-
| c
| Correctness. It takes value between 0 and 1. Boolean false is treated as 0 and true is treated as 1. Other values may be possible if manual condition is used (see Grading criteria)
|-
| u
| Deduction for wrong unit (see Unit system). In the formula, it always takes value 0 if the unit is correct under Conversion rules
|-
| m
| Default mark of the subquestion.
|-
| r_n
| Maximum mark fraction of the n-th submission, for adaptive mode only (See Trial mark sequence)
|-
| f
| The computed final mark.<br>
* For non-adaptive mode: f = m*c*(1-u)<br>
* For adaptive mode (see Moodle documentation): f = max(r_n*m*c*(1-u))<br>
The maximum is taken over all submissions. From the above formula, even though a student get a low mark in the first attempt, it is still possible for them to get a higher mark in the following attempt.
|-
|}
 
=Appendix=
 
==Core function diff()==
 
This function depends on context variables in addition to the function parameters. It is also the core function to compare the students' response and model answer (see Grading variables). If input X and Y are a list of string, then X[i] and Y[i] are treated as algebraic formulas and all variables in them must be defined before the location of evaluation. For example,
 
<pre style="font-size:113%;width: 97%;">
a = 3;
x = {1:100};
d = diff(["a x"],["a x^2"]);
</pre>
 
Please note that the actual algebraic formulas should be "3 x" and "3 x^2" in the above case. In the above evaluation, the d will take a finite value but not close to zero because the algebraic formula are different. In general, any evaluation failure between two algebraic formula will result in a infinite value INF, so that the expression, say, sum(d) < 0.01 will always be false.
 
==Idea of grading algebraic answer==
 
The evaluation will take place at N randomly selected points defined in all algebraic variables. The result of <span>diff("f(x,y)","f(x,y)")</span> will be the root mean square difference at all evaluation points (1/N)Σ<sub>i</sub>(f<sub>i</sub>-g<sub>i</sub>)<sup>2</sup>, which will converge when N tends to infinity. The N is 100 by default if it is not specified.
 
 
[[#top|Back to top of page]]
 
[[Formulas_question_type|← FORMULAS QUESTION TYPE]]
 
=In other languages=
[https://docs.moodle.org/all/es/F%C3%B3rmulas:_Respuestas_y_notaci%C3%B3n Español]<br>
[https://docs.moodle.org/3x/fr/Formules:_Réponses_et_notation Français]

Latest revision as of 00:58, 1 February 2018