https://docs.moodle.org/37/en/api.php?action=feedcontributions&user=Wretched&feedformat=atomMoodleDocs - User contributions [en]2022-01-24T04:56:52ZUser contributionsMediaWiki 1.35.4https://docs.moodle.org/37/en/index.php?title=Talk:Grade_calculations&diff=135733Talk:Grade calculations2019-10-18T13:32:13Z<p>Wretched: </p>
<hr />
<div>I tried to improve this page providing explanations of the examples, generalize the content, correct some minor errors.<br />
<br />
As of october 2018 there is no more 'Categories and items' to click in Grades. Also, the image https://docs.moodle.org/37/en/images_en/6/68/neweditcalculation.png is outdated. Probably https://docs.moodle.org/37/en/Grade_calculations#Setting_a_grade_calculation should be rewritten.<br />
<br />
I wanted to add the exactly same comment.<br />
Click the 'Categories and items' is not even a proper phrase IMHO.<br />
<br />
[[User:Luca Bösch|Luca Bösch]] ([[User talk:Luca Bösch|talk]]) 12:24, 12 April 2019 (UTC)<br />
<br />
I have discovered through trial and error that if the condition in a grade calculation includes an equals sign / comparison operator, it must be double.<br />
<br />
For example, =IF([[A1]]==10, 10, 0) is a valid calculation, but =IF([[A1]]=10, 10, 0) is not.<br />
<br />
Furthermore, functions can be written in uppercase or lowercase letters.<br />
<br />
--[[User:Richard Samson|Richard Samson]] ([[User talk:Richard Samson|talk]]) 11:27, 17 October 2019 (UTC)<br />
<br />
I've seen on the document attached to MDL-64414 that these are the supported comparison operators : <br />
• greater, using (>) character<br />
• greater or equal, usign (>=) characters<br />
• less, using (<) character,<br />
• less than, using (<=) characters<br />
• equal, using (==) characters<br />
<br />
https://tracker.moodle.org/secure/attachment/66195/Documentation%20in%20the%20Wiki.docx<br />
<br />
It seems like the idea was to bring that documentation to the wiki but nobody did it.<br />
<br />
A month ago I just noted that functionality and added some examples but it makes sense to copy that full document here, doesn't it?<br />
<br />
Iñigo, you are right. Will you include the documentation in the page?<br />
<br />
--[[User:Richard Samson|Richard Samson]] ([[User talk:Richard Samson|talk]]) 13:32, 18 October 2019 (UTC)</div>Wretchedhttps://docs.moodle.org/37/en/index.php?title=Talk:Grade_calculations&diff=135727Talk:Grade calculations2019-10-17T11:28:16Z<p>Wretched: More details that should be included in the page.</p>
<hr />
<div>I tried to improve this page providing explanations of the examples, generalize the content, correct some minor errors.<br />
<br />
As of october 2018 there is no more 'Categories and items' to click in Grades. Also, the image https://docs.moodle.org/37/en/images_en/6/68/neweditcalculation.png is outdated. Probably https://docs.moodle.org/37/en/Grade_calculations#Setting_a_grade_calculation should be rewritten.<br />
<br />
I wanted to add the exactly same comment.<br />
Click the 'Categories and items' is not even a proper phrase IMHO.<br />
<br />
[[User:Luca Bösch|Luca Bösch]] ([[User talk:Luca Bösch|talk]]) 12:24, 12 April 2019 (UTC)<br />
<br />
I have discovered through trial and error that if the condition in a grade calculation includes an equals sign / comparison operator, it must be double.<br />
<br />
For example, =IF([[A1]]==10, 10, 0) is a valid calculation, but =IF([[A1]]=10, 10, 0) is not.<br />
<br />
Furthermore, functions can be written in uppercase or lowercase letters.<br />
<br />
--[[User:Richard Samson|Richard Samson]] ([[User talk:Richard Samson|talk]]) 11:27, 17 October 2019 (UTC)</div>Wretchedhttps://docs.moodle.org/37/en/index.php?title=Grade_calculations&diff=135067Grade calculations2019-08-13T15:06:06Z<p>Wretched: One spelling mistake and an added example calculation.</p>
<hr />
<div>{{Managing grades}}<br />
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]].<br />
<br />
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.<br />
<br />
As of Moodle 3.6 onwards, conditional (if) operators can be used in grade calculations of the grade book.<br />
<br />
==Setting a grade calculation==<br />
[[Image:neweditcalculation.png|thumb|Edit calculation setting]]<br />
[[Image:newcalculationgrade.png|thumb|Example calculation]]<br />
To set a grade calculation:<br />
# Login as teacher or other user with permission to edit grades<br />
# Click on Grades in the course administration block<br />
# Click the 'Categories and items' <br />
# Click the 'Edit settings' and then 'Edit calculation'. Note: if you don't see this, then it must be enabled in ''Site administration>Grades>Report settings>Grader report''<br />
# Start with an equal sign (=)<br />
# Type an expression using numbers, arithmetic operators, mathematical functions and ID numbers; for example <nowiki>=average()</nowiki><br />
# Plug in your ID numbers (see below) enclosed in double square brackets, for example <nowiki>=[[item1]]+[[item2]]</nowiki><br />
# Separate each function argument with a comma, as in <nowiki>=average([[item1]], [[item2]])+[[item3]])</nowiki><br />
# Click the "Save Changes" button<br />
<br />
==Assigning ID numbers==<br />
<br />
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.<br />
<br />
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).<br />
<br />
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.<br />
<br />
'''Note''': Moodle does not allow calculations involving no ID numbers.<br />
<br />
==Calculation functions==<br />
<br />
Every grade calculation must start with an equal sign (=) followed by an expression using operators and functions supported by the system.<br />
All common arithmetic operators are supported<br />
<br />
* addition, using the plus (+) sign<br />
* subtraction, using the minus (-) sign<br />
* multiplication, using the asterisk (*) character<br />
* division, using the slash (/) character<br />
* exponentiation, using the caret (^) character<br />
<br />
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.<br />
<br />
Functions can also appear in expressions, using a separator between their arguments listed within round brackets. <br />
<div class="alert alert-danger">Important:<br />
<ul><li>For the English language pack this separator is a comma (,).</li><br />
<li>For other [[Language|languages]] the separator could be a different character, for example a semicolon (;).</li></ul></div><br />
<br />
* average<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the average of the values in a list of arguments<br />
* ceil(number): Maps a real number to the smallest following integer<br />
* floor(number): Maps a real number to the largest previous integer<br />
* 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).<br />
* max<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the maximum value in a list of arguments<br />
* min<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the minimum value in a list of arguments<br />
* mod(dividend, divisor): Calculates the remainder of a division<br />
* pi(): Returns the value of the number Pi (3.14159265...)<br />
* power(base, exponent): Raises a number to the exponent power (this is the same as base^exponent)<br />
* round(number, count): Rounds number to count decimal digits<br />
* sum<nowiki>([[item1]], [[item2]]...)</nowiki>: Returns the sum of all arguments (this is the same as <nowiki>[[item1]]+[[item2]]+...</nowiki><br />
<br />
Many other mathematical functions are also supported:<br />
<br />
* sin()<br />
* sinh()<br />
* arcsin()<br />
* asin()<br />
* arcsinh()<br />
* asinh()<br />
* cos()<br />
* cosh()<br />
* arccos()<br />
* acos()<br />
* arccosh()<br />
* acosh()<br />
* tan()<br />
* tanh()<br />
* arctan()<br />
* atan()<br />
* arctanh()<br />
* atanh()<br />
* sqrt()<br />
* abs()<br />
* ln()<br />
* log()<br />
* exp()<br />
<br />
==Example calculations==<br />
<br />
* <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<br />
* <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)<br />
* <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%<br />
* <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.<br />
<br />
==Calculations when user language is not English==<br />
<br />
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]].<br />
<br />
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 (,).<br />
<br />
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 (;).<br />
<br />
==See also==<br />
*[http://www.youtube.com/watch?v=WKUGyzAXcyA Video on how to set up calculations in the gradebook (basic)]<br />
*[http://www.youtube.com/watch?v=VBEj8mmu8lM Video on how to set up calculations in the gradebook (advanced)]<br />
<br />
[[ca:grade/edit/tree/calculation]]<br />
[[es:Cálculos de calificación]]<br />
[[fr:Calcul de note]]<br />
[[ru:Формулы и вычисления оценок]]<br />
[[ja:評定計算]]<br />
[[de:Bewertungen berechnen]]</div>Wretched