Grade calculations with functions
If there is several types of scales in use or not all the grades are in the course total grade calculations you must use calculation functions.
- Add new grade calculation
- Add IDs to evaluation items
- Add grade calculation
- Arithmetic operations (+, -, *, /, ^)
- Mathematical functions (average, sum, min, max)
- Examples of grade calculations
Add new grade calculation
Functions are set category total Edit > Edit calculation

Add IDs to evaluation items
Add first the item ids and Add ID numbers.

Add grade calculation
Then write the calculation function by using the IDs in the function.

For example this function
=if(AND([[assignments]],[[seminar]],[[attendance]])>=1, [[exam]], 0)
can be read something like this "If assignments, seminar and attendance are all graded "pass" (=1), then course total is the exam grade, otherwise 0"
Arithmetic operations, such as:
- + add
- - subtraction
- * multiplication
- / division
- ^ exponentiation
with their usual evaluation precedence rules: exponentiations are evaluated first, then multiplications and divisions are performed, filanny additions and subtractions are carried out. Different precedences can be forced using round parenthesis. For example the sum of the demo points can be counted with =[[demo1]] + [[demo2]] and =(1+2)*(3+4) is the same as =3+7
Mathematical functions
Note that if you are using Moodle in Finnish, the separator is semicolon (;) and comma (,) if you are using Moodle in English. If you need to have decimals use comma (,) in Finnish and dot (.) in English.
- average([[demo1]];[[demo2]]...): 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([[demo1]];pass;fail): 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([[demo1]];[[demo2]]): returns the maximum value in a list of arguments
- min([[demo1]];[[demo2]]): returns the minimum value in a list of arguments
- mod(dividend;divisior): calculates the remainder of a division
- sum([[demo1]];[[demo2]]...): returns the sum of all arguments (this is the same as [[demo1]]+[[demo2]]+...)
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()
Examples of using the functions
- =max([[exam1]]; [[exam2]]; [[exam3]]) - returns the maximum value of the exams.
- =average(max([[exam1]]; [[exam2]]; [[exam3]]); max([[Assignment1]]; [[Assignment4]]; [[Assignment5]])) - returns average of maximum values of exams and assignments (Functions can be combined)
- =sum([[assign1]]*0,3; [[assign2]]*0,6; [[assign3]]*0,1) - Returns the sum of weighted grades/points, assignment grades are weighted in the function, assignment 1 is 30%, assignment 2 is 60% and assignment 3 is 10% of the final grade.
- =if([[practice]]>=10; [[quiz]]+[[assignment]]; 0) - Returns sum of quiz and assignment, if the practice points are at least 10. In other cases function returns 0 (failed).
More detailed information