Drip content in Moodle: open lessons days after each learner enrols
Core Moodle can only open content on a fixed date. Our free availability_drip plugin opens it a set number of days after each learner enrolled. How it works and how we built it.
Short answer: core Moodle can release content on a calendar date, but not “7 days after this learner joined”. For courses with rolling enrolment, that is the rule teachers actually want. We built a small free plugin, availability_drip, that adds it to the normal “Restrict access” settings.
This is the first plugin in a series: one plugin for each Moodle plugin type, each solving a real need, each tested, and each one teaching our AI plugin builder, DevLMS Studio, how that type works.
What can core Moodle restrict on?
A Moodle 5.3 site ships six restriction conditions, in availability/condition/: activity completion, date, grade, group, grouping and user profile field. The date condition compares the current time with one fixed date for everyone. That works when a whole class starts together. It breaks when people enrol every week, because a learner who joins late finds every lesson already open, and one who joins early waits on a date that means nothing to them.
What availability_drip does
- In any activity or section: Restrict access, Add restriction…, Days since enrolment, then enter a number of days (0 to 3650).
- Each learner sees the exact date it opens for them, in the form “Available 7 days after you enrolled (from their date and time)”.
- The start is the learner’s earliest active enrolment in the course. Adding a second enrolment method later does not reset the clock.
- Someone who is not enrolled never gets access through this rule.
- It combines with the other conditions the usual way, so “7 days after enrolment AND completed lesson 1” works.
It supports Moodle 4.5 LTS to 5.3, stores no personal data, and is GPL. The code is on GitHub.
How a restriction condition plugin works
We read core’s own code for this, so here is what matters if you want to build one:
classes/condition.phpextends\core_availability\condition. Moodle saves each rule as a small JSON object,{"type":"drip","d":7}. The constructor reads it,save()writes it, andis_available()answers one question: can this user open it right now? A$notflag flips the answer when the teacher picks “must not”.get_description()is the sentence learners see under the activity. Ours computes the learner’s own date.classes/frontend.phppasses strings and settings to the form.- The form is YUI JavaScript, not the newer AMD modules. Moodle only loads the files in
yui/build, and every input must callM.core_availability.form.update()on change, or nothing is saved. This is the part that trips people up.
We tested it with PHPUnit (enrolled 10 days ago opens at 7 and stays closed at 14, the “must not” flip, not enrolled, two enrolment methods, bad data) and a Behat run that adds the rule through the real dialog and checks what a learner sees.
How this makes DevLMS Studio better
Every type we build leaves a short guide behind: what the type is for, what it cannot do, the files and classes, the traps, and how to test it, each point checked in Moodle’s code. Studio’s builder now gets that guide the moment it starts a plugin of that type. Ask it for a restriction rule today and it already knows about the yui/build trap above.
Want a restriction rule of your own, like “open after a payment” or “open on the learner’s birthday”? Describe it in DevLMS Studio and watch it built and tested in a real Moodle.
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