Moodle 3.2: Unique Gradebook Calculations

Applies to: Moodle 3.2.

Moodle automatically calculates course and category totals in the gradebook. There may be special times when you want to override this automatic function and create your own unique gradebook calculations.

If you do decide to use unique calculations you MUST:

  1. Modify the Grade Book Settings for hidden items.
  2. Create item ID numbers.
  3. Create the unique formula for a category total.

NOTE: Moodle Support does NOT recommend using this option lightly.Be aware that unique calculations may not copy correctly to new course sites.For help using your own gradebook calculations, Contact Moodle Support.

Modifying the gradebook settings for hidden items

The use of unique calculations basically interferes with some of Moodle's built in gradebook functions. You will need to change the setting to exclude hidden items from category totals to including hidden items.

  1. Go to the course homepage.
  2. Find the Administration block:
    • Click Gradebook setup.
  3. Select Course grade settings from the drop down menu in the upper right.
  4. Scroll down to the Student View area, expand it if necessary, and for the option to "Hide totals if they contain hidden items" select Show totals including hidden items.
  5. Click Save changes.

Creating your own gradebook calculation

Before you can create your own formula, you have to assign an ID number to each activity or item you want to use in the formula. Moodle does not create ID numbers for them by default.

  1. Go to the course homepage.
  2. Find the Administration block:
    • Click Gradebook setup.
  3. Go to the category total row.
    • Click the Edit link, then Edit calculation.
  4. Enter an ID Number for each activity/item you plan to use in your formula. You can use text characters.
  5. Example: Quiz #1 ID Number = Q1.
  6. Click Add ID Numbers. The page refreshes itself saving the new ID numbers.
  7. The ID number is surrounded by double square brackets. Example: [[Q1]]
  8. Go to the Calculation box at the top of the page.
  9. Type the calculation using the following syntax:
    • =func([[gradeitem]]) Example: =average([[Q1]], [[Q2]], [[Q3]])
  10. Click Save Changes button.

Calculation Functions

Every calculation must start with an equal sign (=). The comma (,) is used to separate arguments within function parentheses, and can be used to separate different functions.


  • average([[item1]], [[item2]], ...): Returns the average of a sample
  • max([[item1]], [[item2]], ...): Returns the maximum value in a list of arguments
  • mod(dividend, divisor): Calculates the remainder of a division
  • power(base, power): Raises the base number by the input power
  • Normal arithmetic operators are also available for use in calculations. For example, [[item1]]*[[item2]] will return the product of the two items.

Supported Mathematical Functions


    • sum
    • average
    • max
    • min
    • round
    • +, -, *, /

    • mod(dividend, divisor): returns the remainder of a division
    • pi: returns the value of Pi
    • power(base, power): raises the base number to the input power
    • sin: sine
    • sinh: hyperbolic sine
    • arcsin: inverse sine
    • asin: inverse sine in radians
    • arcsinh: inverse hyperbolic sine
    • asinh: inverse hyperbolic sine in radians
    • cos: cosine
    • cosh: hyperbolic cosine
    • arccos: inverse cosine
    • acos: inverse cosine in radians
    • arccosh: inverse hyperbolic cosine
    • acosh: inverse hyperbolic cosine in radians
    • tan: tangent
    • tanh: hyperbolic tangent
    • arctan: inverse tangent
    • atan: inverse tangent in radians
    • arctanh: inverse hyperbolic tangent
    • atanh: inverse hyperbolic tangent in radians
    • sqrt: square root
    • abs: absolute value
    • ln: natural logarithm (base e)
    • log: logarithm (base 10)
    • exp: exponential function; takes e to the power of the number in the parentheses