Moodle FEE Docs
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Edit calculation

You can set up the calculation in the tab Gradebook setup on the page Grades. Then you must select a category or Course total and click Edit calculation.

Edit calculation
Edit calculation

The easiest way to set up the grade calculation is to leave the calculation to Moodle. Within each category (both root and user-created), you can set a ‘Summary Grades’ type called category name total for each category or Course total for all grade items.

If this is not enough, you can also use a calculation “formula” (1). The calculation always starts with the symbol “=”. You can include the value of other grades or categories in the calculation if needed. To do so, you must define the category ID by typing its name without paces in the white box next to the category name (2) and then clicking the Add ID numbers button (3). The added IDs will be displayed as [[ID]] – you must write them in the calculation formula in double square brackets. In the calculation, you also can use standard algebraic operations and functions.

Edit calculation of a grade item
Edit calculation of a grade item

Functions

  • + – addition
  • - – subtraction
  • * – multiplication
  • / – division
  • ^ – exponentiation
  • 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
  • sum([[item1]], [[item2]]…) – returns the sum of all arguments. This is the same as [[item1]]+[[item2]]+…
  • 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).
  • round(number, count) – rounds number to count decimal digits

You can find more information and a list of functions in the official Moodle documentation.

Calculation examples

  1. Calculation that returns a weighted grade sum where item1 is weighted 30%, item2 is weighted at 60% and item3 is weighted at 200%:
=sum([[item1]]*0.3, [[item2]]*0.6, [[item3]]*2)
  1. Calculation that 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([[midtermexam]]>=5, [[midtermexam]]+[[lab]], 0)

Scaling

If you want to convert points 0-100 to Moodle scale A-F you can use the formula:

=if([[sum]]>=50;if([[sum]]>=60;if([[sum]]>=70;if([[sum]]>=80;if([[sum]]>=90;6;5);4);3);2);1)

where “sum” is the ID of category from which points 0-100 are taken.