Moodle gradebook setup for mastery grading

In my course Fundamentals of Algebra and Calculus, students complete weekly Unit Tests. Their grade is determined by the number of Unit Tests passed at Mastery (80%+) or Distinction (95%+) levels. For instance, to pass the course, students need to get Mastery in at least 7 of the 10 units. You can find more details about the course in this paper:

  • Kinnear, G., Wood, A. K., Gratwick, R. (2021). Designing and evaluating an online course to support transition to university mathematicsInternational Journal of Mathematical Education in Science and Technology

All the Unit Tests are set up as Moodle quizzes, and I needed a way to compute the number of tests completed as Mastery level (and at Distinction level) for each student.

To make matters more complicated, there are 4 different versions of each Unit Test:

  • Unit Test – the first attempt
  • Unit Test Resit – a second attempt, available to students shortly after the first attempt if they did not reach Mastery
  • Unit Test (Extra Resit) – a third attempt, available at the end of semester
  • Unit Test (Resit Diet) – a fourth attempt, available during the resit diet in August

Each subsequent attempt replaces the result of previous ones – e.g. if a student with a Mastery result on the first attempt decides to take the Unit Test (Extra Resit) to try to get a Distinction, then they will lose the Mastery result if they do not reach the 80% threshold.

To set this up in the Moodle gradebook, I have given each of the variants an ID, with the pattern:

  • WnFT
  • WnFTR
  • WnFTR2
  • WnFTRD

(where n is the week number).

Then I have added a calculated grade item called “Number of Mastery results”, with a complicated formula to determine this. It is the sum of 10 terms like this:


where this snippet computes the number of Mastery results in week 1 (i.e. it will return 0 or 1).

Note that the 25.5 appears throughout this expression because that is the threshold for 80% on these tests.

  • ceil([[W1FTRD]]/32)*floor([[W1FTRD]]/25.5) means “if they took the Resit Diet version, then use their score on that to decide if they got a Mastery result”
  • (1-ceil([[W1FTRD]]/32))*(...) means “if they didn’t take the Resit Diet version, then use their other scores to decide”
  • There’s then a similar pattern with W1FTR2
  • And finally, if students didn’t take either W1FTRD or W1FTR2, we use the best of the W1FT and W1FTR results to decide (simple “best of” is OK here, since students can only take W1FTR if they did not get Mastery on W1FT).

This is all quite complicated, I know! It has grown up over time, as the FTR2 and FTRD versions were added after I first set up this approach.

Also, when I first implemented this, our version of Moodle did not support “if” statements – since the Moodle grade calculations can now make use of “if” statements, this calculation could be greatly simplified.