Recalculate stored dates
Every date LOOP holds is worked out from something else: a completion date and a validity period make an expiration date; an entry date and a completion timeframe make a deadline. The nightly rebuild works them all out again from the configuration in force, and this page does the same thing on demand — showing what would change before anything does.
Use it:
- after changing a validity period, a completion timeframe or a hard deadline, to bring the people already tracked onto the new numbers now instead of at the next nightly run — and to see how many of them move before it happens;
- after correcting course data;
- on a site whose cron has been stopped for a while;
- on a site that was running courses before LOOP was installed, to bring those completions in.

Run it from the interface
- Go to Site administration → Plugins → Local plugins → LOOP → Recalculate dates.
- Choose the scope: all active certifications, or one in particular. An inactive certification is only included when you name it.
- Choose Scan and preview. Nothing is written.
- Read the preview: how many certificates it would issue, how many validity windows no longer follow from the configuration, how many status rows it would create, update or remove, and which statuses change — per certification, with a sample.
- If the numbers are what you expect, choose Apply recalculation.

Run it as often as you need. Nothing locks, and running it twice with nothing new in between changes nothing the second time.
Run it from the command line
php local/loop/cli/recalculate.php --preview
php local/loop/cli/recalculate.php --execute
php local/loop/cli/recalculate.php --certification=7 --executeWhat it works out again
| Value | Worked out from | Result |
|---|---|---|
| Validity window of each certificate | Its completion date plus the certification's current validity period | Every window that no longer follows from the configuration is written again, so the expiry date of the person holding it moves with it |
| Expiration date on the row | The certificate that covers longest | The status follows: Valid, Expiring if inside the current warning window, or the cycle closes if the window has already ended |
| Completion due date | The end of the last validity — or the entry date, for somebody never certified — plus the current completion timeframe, capped by the hard deadline where one is set | Pending, or Overdue if the new due date has already passed. A completion timeframe of 0 means no deadline at all, so nobody is Overdue |
It also issues a certificate for every completion of a course belonging to a certification that does not have one yet. This is how completions recorded before LOOP was installed enter the certification history: there is no separate import to run.
The completion date is the one value it never recomputes: that is Moodle's record of what happened, and everything else is worked out from it.
It moves statuses backwards as well as forwards
Every date is compared against the current configuration, in both directions, so extending a validity period returns an Expiring certificate to Valid, and lengthening a completion timeframe returns an overdue enrolment to Pending. The nightly rebuild does the same work; this page does it now, and counts what would move before it does.
What it cannot do is bring back somebody whose cycle has already closed with no renewal under way: that row is no longer on the User status page for a recalculation to find. Their certificates are on the Certification history page.
A shortened validity period can close cycles
Shortening a validity period rewrites the windows already issued, and a window that now ends in the past ends that cycle there and then: the person returns to Pending if they are already enrolled on a later edition, and leaves the User status page if they are not. The certificate itself stays in the certification history, but any notice still queued for somebody who leaves is removed with them.
The preview counts both the windows that would move and the statuses that would follow, which is what it is for. The nightly rebuild does the same thing without asking, so read the count here before the night does it.
What it does not touch
- Certifications, editions and the wording of notices. It changes no configuration, only the dates worked out from it.
- The completion dates, and the certificates themselves: none is ever removed.
- Anything with no date to work from: a row with no completion keeps its expiration date, a row with no enrolment keeps its due date.
- Rows that already agree with the configuration. They are skipped, and reported as unchanged.
It sends nothing and cancels nothing: a person who has been overdue for two years does not receive two years of reminders because you ran it today, and mail already queued is left exactly as it is.
The report on screen lists what moved, per certification, with a sample of the people affected and the status each one moved from and to.
What to check afterwards
- Open Home. The three coverage figures should describe the organisation you recognise. If almost everybody is in progress, the completions are probably on courses that are not editions of any certification yet — see Link courses as editions.
- Open Certification history for one certification. Every completion it found is a row there, with the window it was issued for.