Grade calculations: Difference between revisions
(Created page with "{{Managing grades}} A grade calculation is a formula used to determine grades, based (optionally) on other grade items. Note that this is not the same as Calculated_question...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{ | {{Work in progress | ||
|forumurl =https://tracker.moodle.org/browse/MDL-14274 | |||
|info = Changes to Grade Calculation documentation | |||
}} | |||
==Calculation functions== | ==Calculation functions== | ||
Line 38: | Line 15: | ||
with their usual precedence rules: exponentiations are evaluated first, then multiplications and divisions are performed, finally additions and subtraction are carried out; so, the expression =1+2-3*4/5^6 gives almost 3 (2,999232). Precedences can be forced using parentheses, as in the expression =((((1+2)-3)*4)/5)^6 which yields 0. | with their usual precedence rules: exponentiations are evaluated first, then multiplications and divisions are performed, finally additions and subtraction are carried out; so, the expression =1+2-3*4/5^6 gives almost 3 (2,999232). Precedences can be forced using parentheses, as in the expression =((((1+2)-3)*4)/5)^6 which yields 0. | ||
Comparison operators are supported: | |||
* greater, using (>) character | |||
* greater or equal, usign (>=) characters | |||
* less, using (<) character, | |||
* less than, using (<=) characters | |||
* equal, using (==) characters | |||
each comparison operator evaluates to 0 when false and 1 when true. They can be used in any expression with precedence over the rest of the operators. I.e. the expression =2<3*10 yields 10 because 2<3 yields 1, but for legibility it is recommended to use parentheses or the 'if' function as in: =(2<3)*10 or =if(2<3, 10, 0) that are quantitatively equivalent. | |||
'''Note''': Moodle does not allow calculations involving no ID numbers. | '''Note''': Moodle does not allow calculations involving no ID numbers. | ||
Line 53: | Line 38: | ||
* ceil(number): Maps a real number to the smallest following integer | * ceil(number): Maps a real number to the smallest following integer | ||
* sum(<nowiki>[[item1]], [[item2]]...)</nowiki>: Returns the sum of all arguments | * sum(<nowiki>[[item1]], [[item2]]...)</nowiki>: Returns the sum of all arguments | ||
* if(<nowiki>[[item1]], [[item2]], [[item3]])</nowiki>: Evaluates the first argument (condition) and returns the second argument if the condition is not zero (true condition) and returns the third argument if the condition is zero (false condition). | |||
Many other mathematical functions are also supported: | Many other mathematical functions are also supported: | ||
Line 85: | Line 71: | ||
* <nowiki>=average(max([[Quiz.1]], [[Quiz.4]], [[Assignment.1]]), min([[Quiz.1]], [[Quiz.4]], [[Assignment.1]]))</nowiki> - Returns the average of the maximum and the minimum values among Quiz.1, Quiz.4 and Assignment.1 (functions can be nested) | * <nowiki>=average(max([[Quiz.1]], [[Quiz.4]], [[Assignment.1]]), min([[Quiz.1]], [[Quiz.4]], [[Assignment.1]]))</nowiki> - Returns the average of the maximum and the minimum values among Quiz.1, Quiz.4 and Assignment.1 (functions can be nested) | ||
* <nowiki>=sum([[1]]*0.3, [[2]]*0.6, [[3]]*2)</nowiki> - Returns a weighted grade calculations where item 1 is weighted 30%, item 2 is weighted at 60% and item 3 is weighted at 200% | * <nowiki>=sum([[1]]*0.3, [[2]]*0.6, [[3]]*2)</nowiki> - Returns a weighted grade calculations where item 1 is weighted 30%, item 2 is weighted at 60% and item 3 is weighted at 200% | ||
Revision as of 12:43, 12 June 2018
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments. Changes to Grade Calculation documentation
Calculation functions
Every calculation must start with an equal sign (=). Following is an expression using operators and functions supported by the system. All common arithmetic operators are supported:
- addition, using the plus (+) sign
- subtraction, using the minus (-) sign
- multiplication, using the asterisk (*) character
- division, using the slash (/) character
- exponentiation, using the caret (^) character
with their usual precedence rules: exponentiations are evaluated first, then multiplications and divisions are performed, finally additions and subtraction are carried out; so, the expression =1+2-3*4/5^6 gives almost 3 (2,999232). Precedences can be forced using parentheses, as in the expression =((((1+2)-3)*4)/5)^6 which yields 0.
Comparison operators are supported:
- greater, using (>) character
- greater or equal, usign (>=) characters
- less, using (<) character,
- less than, using (<=) characters
- equal, using (==) characters
each comparison operator evaluates to 0 when false and 1 when true. They can be used in any expression with precedence over the rest of the operators. I.e. the expression =2<3*10 yields 10 because 2<3 yields 1, but for legibility it is recommended to use parentheses or the 'if' function as in: =(2<3)*10 or =if(2<3, 10, 0) that are quantitatively equivalent.
Note: Moodle does not allow calculations involving no ID numbers.
Functions can also appear in expressions, using the comma (,) character to separate their arguments listed within function (round) brackets. (The separator character could be a semicolon (;) in other languages, see below).
- average([[item1]], [[item2]]...): Returns the average of the values in a list of arguments
- max([[item1]], [[item2]]...): Returns the maximum value in a list of arguments
- min([[item1]], [[item2]]...): Returns the minimum value in a list of arguments
- mod(dividend, divisor): Calculates the remainder of a division
- pi(): Returns the value of the number Pi
- power(base, power): Raises a number to the power of another
- round(number, count): Rounds number to count decimal digits
- floor(number): Maps a real number to the largest previous integer
- ceil(number): Maps a real number to the smallest following integer
- sum([[item1]], [[item2]]...): Returns the sum of all arguments
- if([[item1]], [[item2]], [[item3]]): Evaluates the first argument (condition) and returns the second argument if the condition is not zero (true condition) and returns the third argument if the condition is zero (false condition).
Many other mathematical functions are also supported:
- sin()
- sinh()
- arcsin()
- asin()
- arcsinh()
- asinh()
- cos()
- cosh()
- arccos()
- acos()
- arccosh()
- acosh()
- tan()
- tanh()
- arctan()
- atan()
- arctanh()
- atanh()
- sqrt()
- abs()
- ln()
- log()
- exp()
Example calculations
- =max([[Quiz.1]], [[Quiz.4]], [[Assignment.1]]) - Returns the maximum value of Quiz.1, Quiz.4 and Assignment.1
- =average(max([[Quiz.1]], [[Quiz.4]], [[Assignment.1]]), min([[Quiz.1]], [[Quiz.4]], [[Assignment.1]])) - Returns the average of the maximum and the minimum values among Quiz.1, Quiz.4 and Assignment.1 (functions can be nested)
- =sum([[1]]*0.3, [[2]]*0.6, [[3]]*2) - Returns a weighted grade calculations where item 1 is weighted 30%, item 2 is weighted at 60% and item 3 is weighted at 200%