Grade calculations: Difference between revisions

From MoodleDocs
No edit summary
 
(57 intermediate revisions by 22 users not shown)
Line 1: Line 1:
{{Grades}}
{{Managing grades}}
==Enabling Calculations==
A grade calculation is a formula used to determine grades, based on other grade items. Note that this is not the same as [[Calculated_question_type|Calculated question types]].
To enable calculations for you gradebook:


# Login as teacher or other user with permission to edit grades.
Grade calculations follow the pattern of formulas/functions in popular spreadsheet programs. They start with an equal (=) sign, and use common mathematical operators and functions to produce a single numerical output. This output is then used as the computed value for the grade item you are editing.
# Go to course.
# Click on ''Grades'' in the Administration block.
# Click the "Turn Editing On" button on the top right corner.
# Click the "Show Calculations" icon on the middle top.
# Click the little calculator symbol under Course Total column which will bring you to the calculations page.


[[Image:Calc.JPG|thumb|center|"Show Calculations" Icon]][[Image:Calc_icon.JPG|thumb|center|Little Calculator Symbol]]
Conditional (IF) operators can be used in grade calculations of the grade book, and logical operators (AND,OR) can be also used (MDL-64414).
==Setting a grade calculation==
[[File:Edit Calculated Grade.png|alt=|thumb|Edit calculation setting]]
[[Image:newcalculationgrade.png|thumb|Example calculation]]


==Assigning ID Numbers==
ID numbers are similar to nicknames for each grade item. In a calculation, instead of referring back to a whole assignment name, we can substitute it for it's ID number which becomes a lot easier. Think of it as substituting 143 as X and then using X for various math problems.


ID numbers on the bottom of the page. Use simple to remember numbers or variables like 1, X, or Quiz1. Remember to click "Add id numbers"!
To set a grade calculation:


==Understanding Calculation Functions==
# Login as teacher or other user with permission to edit grades
Click the yellow question mark next to the word "Calculation". This will bring a pop-up explaining the various functions that can be used in calculations and how to use them.
# Click on Grades in the course administration block
# Click 'View > Grader Report'
# Click 'Turn Editing On'; a 'Controls' bar should appear above the grades
# Click the 'Calculator' icon above the grade item or category you wish to edit. Note: if you don't see this, then it must be enabled in ''Site administration>Grades>Report settings>Grader report>Show calculations''
# Start with an equal sign (=)
# Type an expression using numbers, arithmetic operators, mathematical functions and ID numbers; for example =average()
# Plug in your ID numbers (see below) enclosed in double square brackets, for example =<nowiki>[[item1]]</nowiki>+<nowiki>[[item2]]</nowiki>
# Separate each function argument with a comma, as in =average(<nowiki>[[item1]]</nowiki>, <nowiki>[[item2]]</nowiki>)+<nowiki>[[item3]]</nowiki>)
# Click the "Save Changes" button


Every calculation must start with an equal sign (=). Following is a list of the functions supported by the calculation. The comma (,) character is used to separate arguments within function brackets. The comma can also be used to separate different functions.
==Assigning ID numbers==
You can include the values of other grade items by using their ID number as references in your formulas. The ID number must be surrounded by double square brackets, for example if you have a grade item with Quiz.3 as ID number, you can refer this item using <nowiki>[[Quiz.3]]</nowiki> in your calculation.


* average<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the average of a sample
Below the calculation field there is a list of your course grade categories and grade items. Next to each item or category's total there is the ID number you can use in your calculation (already surrounded with the required double square brackets).
* max<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the maximum value in a list of arguments
* min<nowiki>([[item1]], [[item2]]...):</nowiki> 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 a number to a predefined accuracy
* sum(<nowiki>[[item1]], [[item2]]...)</nowiki>: Returns the sum of all arguments


A number of mathematical functions is also supported:
However, since ID numbers are optional, some items may not yet have one. Each item without ID number have a form field that you can use to enter its ID number directly. As soon as you have assigned the ID numbers you need, you must click the "Add ID numbers" button; the page will reload and show you the same list including the ID numbers you have just assigned. Now you can use them in your grade calculation.


* sin
'''Note''': Moodle does not allow calculations involving no ID numbers.
* sinh
==Calculation functions==
* arcsin
Every grade calculation must start with an equal sign (=) followed by an expression using operators and functions supported by the system.
* asin
All common arithmetic operators are supported
* arcsinh
* addition, using the plus (+) sign
* asinh
* subtraction, using the minus (-) sign
* cos
* multiplication, using the asterisk (*) character
* cosh
* division, using the slash (/) character
* arccos
* exponentiation, using the caret (^) character
* acos
with their usual evaluation 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). Different precedences can be forced using round parentheses, as in the expression =((((1+2)-3)*4)/5)^6 which yields 0.
* arccosh
* acosh
* tan
* tanh
* arctan
* atan
* arctanh
* atanh
* sqrt
* abs
* ln
* log
* exp


==Making your Calculation==
Functions can also appear in expressions, using a separator between their arguments listed within round brackets.
Back on the calculations page, start typing the various functions and the ID numbers chosen for your calculation.
<div class="alert alert-danger">Important:
<ul><li>For the English language pack this separator is a comma (,).</li>
<li>For other [[Language|languages]] the separator could be a different character, for example a semicolon (;).</li></ul></div>
* average<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the average of the values in a list of arguments
* ceil(number): Maps a real number to the smallest following integer
* floor(number): Maps a real number to the largest previous integer
* 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).
* max<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the maximum value in a list of arguments
* min<nowiki>([[item1]], [[item2]]...)</nowiki>: 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 (3.14159265...)
* power(base, exponent): Raises a number to the exponent power (this is the same as base^exponent)
* round(number, count): Rounds number to count decimal digits
* sum<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the sum of all arguments (this is the same as <nowiki>[[item1]]+[[item2]]+...</nowiki>
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==
* <nowiki>=max([[Quiz.1]], [[Quiz.4]], [[Assignment.1]])</nowiki> - Returns the maximum value of the grades referred by Quiz.1, Quiz.4 and Assignment.1
* <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([[item1]]*0.3, [[item2]]*0.6, [[item3]]*2)</nowiki> - Returns a weighted grade sum where item1 is weighted 30%, item2 is weighted at 60% and item3 is weighted at 200%
* <nowiki>=if([[midtermexam]]>=5, [[midtermexam]]+[[lab]], 0)</nowiki> - Returns the sum of midtermexam and lab items if the midtermexam grade is 5 of more, and 0 otherwise. This is a very handy way of dealing with conditional evaluation in a course.
* <nowiki>=if(AND([[item1]]>=5, [[item2]]>=5), ([[item1]]+[[item2]])/2, 0)</nowiki> - Returns the average of item1 and item2 if both have 5 of more, and 0 otherwise. This is a very handy way of dealing with sine qua non activities.
==Calculations when user language is not English==
Calculations and formulas use decimal and list separators as defined in the [https://docs.moodle.org/dev/Translation_langconfig langconfig.php] file of each [[Language packs|language pack]].


# Start with an equal sign (=)
The [[Decimal separator|decimal separator]] (the symbol used to mark the boundary between the integral and the fractional parts of a decimal number) is a point (.) in English. In other languages it may be a comma (,).
# Choose a function; Example: =sum()
# Plug in your ID numbers enclosed in 2 hard brackets; Example: <nowiki>=sum([[item1]][[item2]][[item3]])</nowiki>
# Separate each ID number with a comma; Example: <nowiki>=sum([[item1]],[[item2]],[[item3]])</nowiki>
# Click the "Save Changes" button.
[[Image:Final_calc.JPG|center|Final example calculation]]


Analogously, the list separator (the symbol used to separate the items within a list, such as the arguments of a function) is a comma (,) in English. In other languages it may be a semicolon (;).
==See also==
==See also==
*[http://www.youtube.com/watch?v=WKUGyzAXcyA Video on how to set up calculations in the gradebook (basic)]
*[http://www.youtube.com/watch?v=WKUGyzAXcyA Video on how to set up calculations in the gradebook (basic)]
*[http://www.youtube.com/watch?v=VBEj8mmu8lM Video on how to set up calculations in the gradebook (advanced)]
*[http://www.youtube.com/watch?v=VBEj8mmu8lM Video on how to set up calculations in the gradebook (advanced)]
[[ca:grade/edit/tree/calculation]]
[[es:Cálculos de calificación]]
[[fr:Calcul de note]]
[[ru:Формулы и вычисления оценок]]
[[ja:評定計算]]
[[de:Bewertungen berechnen]]

Latest revision as of 11:58, 3 December 2021

A grade calculation is a formula used to determine grades, based on other grade items. Note that this is not the same as Calculated question types.

Grade calculations follow the pattern of formulas/functions in popular spreadsheet programs. They start with an equal (=) sign, and use common mathematical operators and functions to produce a single numerical output. This output is then used as the computed value for the grade item you are editing.

Conditional (IF) operators can be used in grade calculations of the grade book, and logical operators (AND,OR) can be also used (MDL-64414).

Setting a grade calculation

Edit calculation setting
Example calculation


To set a grade calculation:

  1. Login as teacher or other user with permission to edit grades
  2. Click on Grades in the course administration block
  3. Click 'View > Grader Report'
  4. Click 'Turn Editing On'; a 'Controls' bar should appear above the grades
  5. Click the 'Calculator' icon above the grade item or category you wish to edit. Note: if you don't see this, then it must be enabled in Site administration>Grades>Report settings>Grader report>Show calculations
  6. Start with an equal sign (=)
  7. Type an expression using numbers, arithmetic operators, mathematical functions and ID numbers; for example =average()
  8. Plug in your ID numbers (see below) enclosed in double square brackets, for example =[[item1]]+[[item2]]
  9. Separate each function argument with a comma, as in =average([[item1]], [[item2]])+[[item3]])
  10. Click the "Save Changes" button

Assigning ID numbers

You can include the values of other grade items by using their ID number as references in your formulas. The ID number must be surrounded by double square brackets, for example if you have a grade item with Quiz.3 as ID number, you can refer this item using [[Quiz.3]] in your calculation.

Below the calculation field there is a list of your course grade categories and grade items. Next to each item or category's total there is the ID number you can use in your calculation (already surrounded with the required double square brackets).

However, since ID numbers are optional, some items may not yet have one. Each item without ID number have a form field that you can use to enter its ID number directly. As soon as you have assigned the ID numbers you need, you must click the "Add ID numbers" button; the page will reload and show you the same list including the ID numbers you have just assigned. Now you can use them in your grade calculation.

Note: Moodle does not allow calculations involving no ID numbers.

Calculation functions

Every grade calculation must start with an equal sign (=) followed by 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 evaluation 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). Different precedences can be forced using round parentheses, as in the expression =((((1+2)-3)*4)/5)^6 which yields 0.

Functions can also appear in expressions, using a separator between their arguments listed within round brackets.

Important:
  • For the English language pack this separator is a comma (,).
  • For other languages the separator could be a different character, for example a semicolon (;).
  • average([[item1]], [[item2]]...): Returns the average of the values in a list of arguments
  • ceil(number): Maps a real number to the smallest following integer
  • floor(number): Maps a real number to the largest previous integer
  • 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).
  • 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 (3.14159265...)
  • power(base, exponent): Raises a number to the exponent power (this is the same as base^exponent)
  • round(number, count): Rounds number to count decimal digits
  • sum([[item1]], [[item2]]...): Returns the sum of all arguments (this is the same as [[item1]]+[[item2]]+...

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 the grades referred by 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([[item1]]*0.3, [[item2]]*0.6, [[item3]]*2) - Returns a weighted grade sum where item1 is weighted 30%, item2 is weighted at 60% and item3 is weighted at 200%
  • =if([[midtermexam]]>=5, [[midtermexam]]+[[lab]], 0) - Returns the sum of midtermexam and lab items if the midtermexam grade is 5 of more, and 0 otherwise. This is a very handy way of dealing with conditional evaluation in a course.
  • =if(AND([[item1]]>=5, [[item2]]>=5), ([[item1]]+[[item2]])/2, 0) - Returns the average of item1 and item2 if both have 5 of more, and 0 otherwise. This is a very handy way of dealing with sine qua non activities.

Calculations when user language is not English

Calculations and formulas use decimal and list separators as defined in the langconfig.php file of each language pack.

The decimal separator (the symbol used to mark the boundary between the integral and the fractional parts of a decimal number) is a point (.) in English. In other languages it may be a comma (,).

Analogously, the list separator (the symbol used to separate the items within a list, such as the arguments of a function) is a comma (,) in English. In other languages it may be a semicolon (;).

See also