Custom Grade Formulas in the Moodle Gradebook

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 MoodleGradebook 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 (add article:  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:

  1. On the course page, in the Navigation tray, click Grades. The Grade report will open.
  2. In the navigations tab (at top) click Setup. The Gradebook setup page will open.
     Note: You can also get to the Gradebook setup by selecting the Course Management button, under Grading, click Gradebook setup. The Gradebook setup page will open.
  3. Locate the item for which you would like to create a calculation, and under Actions (at far right), click Edit, and from the drop-down menu, select  Edit CalculationScreenshot of edit calculation in gradebook setup. 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).

  1. On the Edit Calculation page, below the Calculation field, is a list of all grade items. In the text box provided, 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. 
  2. After you have entered ID numbers, check them carefully; you will only have one chance to save them.
  3. To save your ID numbers, click Add ID numbers (at bottom). The page will refresh to show an updated list of grade items and corresponding ID numbers.

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 (add article: Grade Calculations.)

Note: There are no logical conditional (IF, AND, OR) statements in the Calculator tool.

  1. In the Calculation box, start by entering an equals sign (=).
  2. Enter the calculation function you wish to use (see above).
        Example: =sum
  3. Enter an open parenthesis.
        Example: =sum(
  4. Enter your ID numbers being sure to include the double square brackets.
        Example: =sum([[quiz1]]
  5. Separate additional ID numbers with a comma.
        Example: =sum([[quiz1]],[[quiz2]],[[quiz3]]
  6. Enter a close parenthesis.
     Example: =sum([[quiz1]],[[quiz2]],[[quiz3]])
  7. Click Save Changes (below the Calculation box).