Limit Moodle quiz attempts per day

Moodle can limit total quiz attempts or force a wait between them, not cap attempts per day. Our free quizaccess_dailyattempts does that for practice quizzes.

Drawing of a round clock with a blue face next to a small stack of quiz sheets, the top one ticked.

Short answer: Moodle quizzes can limit the total number of attempts, or force a wait after each attempt, but they cannot say “three attempts a day”. Our free plugin, quizaccess_dailyattempts, adds that setting. It is made for practice quizzes with unlimited attempts, where some students retry the same quiz again and again in one evening until a lucky score comes up, instead of going back to the material.

This is the fifteenth plugin in our series: one plugin for each Moodle plugin type, each one teaching DevLMS Studio, our AI plugin builder, how that type works. We checked the Moodle plugins directory first: it lists 39 quiz access rules, and none limits attempts per day.

How to use it

In the quiz settings, under Extra restrictions on attempts, set Attempts per 24 hours (1 to 10).

When a student reaches the limit, the quiz page tells them when they can start their next attempt, and the attempt button is hidden until then. Everyone sees the limit on the quiz page, so it is no surprise. It supports Moodle 4.5 LTS to 5.3. The code is on GitHub.

A few details we chose on purpose:

  • Rolling 24 hours, not a calendar day. With a limit of 3, a student who started attempts at 9:00, 10:00 and 11:00 can start the next one after 9:00 the next day. A calendar day would depend on time zones, which students can change in their profile on many sites.
  • Started attempts count, abandoned ones too. Leaving an attempt unfinished does not give a free extra try.
  • Teacher previews never count.
  • If the quiz closes before the next attempt would be allowed, the student is told that, not given a time that will never come.

How a quiz access rule works

From Moodle 5.3’s own “Enforced delay between attempts” rule:

  1. A quiz access rule is one class that the quiz asks before every new attempt: “may this student start now?” The answer is either yes or a message that replaces the start button.
  2. A rule’s settings join the quiz’s own: one database query loads every rule’s settings with the quiz, and a rule that is not in use is never built.
  3. When no attempts are left anyway (all used, or the quiz closed), the rule stays quiet so Moodle’s own message is the one students see, not two messages that disagree.
  4. The rule stores only the teacher’s setting. It counts the attempts the quiz already records, so it adds no personal data.

We tested it with PHPUnit (attempts inside and outside the window, previews, other quizzes and other students, a quiz that closes first, backup and restore) and with browser tests in which a teacher sets the limit and a student who used it sees when to come back.

Need a plugin like this for your own Moodle?

Describe it in DevLMS Studio and watch it built and tested in a real Moodle, or ask our team for a fixed price.

Open DevLMS Studio