A grade formula is a calculation used to determine grades that is based on other grade items and numeric calculations. Instructors can use the Calculation tool in the Moodle Gradebook to create their own formulas as an alternative to Moodle's preset calculations.
Note: Preset calculations include Mean of Grades, Custom Weights, and Natural. For more details using preset calculations, see Grade Calculation in Moodle.
This page describes the process of creating a custom grade formula. First you will assign ID values to columns in the gradebook (used to identify items in your formula), and then you will input the custom formula.
Open the Edit Calculation Page
To open the edit calculation page in Moodle:
- On your course page, in the Navigation tray (hamburger menu
, top left) click Grades. The Grader report will open.
- On the Grader report page, in the navigations tab (at top), click Setup. The Gradebook setup page will open.
- Locate the item for which you would like to create a calculation. Under Actions (at far right), click Edit and from the drop-down menu, select Edit Settings. The Edit calculation page will open.
Note: The Edit Calculation icon will only be available next to category totals, manually created grade items, and the Course total.
Assign Column ID Numbers
To use existing grade items in a custom formula, you must first assign ID Numbers (short text labels), which are used as variables in the text of the formula. Columns are referenced in a formula by placing double square brackets ( [[...]] ) around the ID Number (e.g., a grade item with the ID Number "Quiz3" will be referred to as "[[Quiz3]]" in the formula).
- On the Edit grade items page, click expand all. In the text box under Grade, enter an ID number value for each grade item you want to use in the formula. Values can include text, spaces, and numbers, however short names are strongly recommended (i.e., "Quiz3", "Exam 1", etc.).
Note: If a grade item already has an ID number (surrounded with double square brackets) instead of an input field, you can use this ID number in your formula. - Click Save Changes at the bottom to save your ID number.
Create a Formula
Custom formulas for the Moodle gradebook follow the pattern of formulas/functions in popular spreadsheet programs. Formulas start with an equals (=) 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.
Common calculation functions and operations include the following:
- average([[item1]], [[item2]]...): Returns the average of a sample
- max([[item1]], [[item2]]...): Returns the maximum value in a list of arguments
- min([[item1]], [[item2]]...): Returns the minimum value in a list of arguments
- round([[item1]], count): Rounds a number to a predefined accuracy (e.g., "round([[item1]], 2)" will round the value of "item1" to the second decimal place.)
- sum([[item1]], [[item2]]...): Returns the sum of all arguments
- an asterisk (*) multiplies two items: [[item1]]*[[item2]]
- a forward slash (/) divides items: [[item1]]/[[item2]]
For a full list of available functions, see Grade Calculations.
Note: There are no logical conditional (IF, AND, OR) statements in the Calculator tool.
-
In the Calculation box, start by entering an equals sign (=).
-
Enter the calculation function you wish to use (see above).
Example: =sum -
Enter an open parenthesis.
Example: =sum( -
Enter your ID numbers being sure to include the double square brackets.
Example: =sum([[quiz1]] -
Separate additional ID numbers with a comma.
Example: =sum([[quiz1]],[[quiz2]],[[quiz3]] -
Enter a close parenthesis.
Example: =sum([[quiz1]],[[quiz2]],[[quiz3]]) - Click Save Changes (below the Calculation box).