Skip to content

Command line

All scripts live in local/loop/cli/ and follow Moodle's conventions: run them as the web server user, from the Moodle root. Every script accepts --help.

Export the configuration

bash
php local/loop/cli/export.php --output=/tmp/configuration.csv
php local/loop/cli/export.php --output=/tmp/configuration.csv --delimiter=semicolon
OptionShortDefaultMeaning
--output-ostandard outputFile to write
--delimiter-dcommaField delimiter: comma, semicolon or tab

Every edition is in the file, including the ones LOOP recognises from the courses themselves. It never needs a licence. Anything the export could not write is reported on standard error, so it survives the file being redirected into a pipe.

Import the configuration

bash
php local/loop/cli/import.php --file=/tmp/configuration.csv --preview
php local/loop/cli/import.php --file=/tmp/configuration.csv --execute
php local/loop/cli/import.php --file=/tmp/configuration.csv --execute --allow-rename
OptionShortDefaultMeaning
--file-fFile to read
--preview-poffPrint what the file would change, write nothing
--execute-eoffApply the file
--delimiter-dautoForce a delimiter instead of detecting one: comma, semicolon or tab
--allow-renameoffLet the file rename a certification whose stored name differs

--preview prints the same sentences the import page shows, and it reflects the options it is run with: without --allow-rename, previewing a file that renames something reports the refusal that --execute would give.

What an import does not do: it never deletes a certification, and a certification row with no edition rows under it keeps the editions it has. One error refuses the whole file, before anything is written. See Import and export the configuration.

Export and import notification texts

bash
php local/loop/cli/export_messages.php --output=texts.csv
php local/loop/cli/import_messages.php --file=texts.csv --preview
php local/loop/cli/import_messages.php --file=texts.csv --execute

Same options as above, --allow-rename aside: it means nothing here. The file has one row per notice and language; its rules are in CSV format.

Recalculate stored dates

bash
php local/loop/cli/recalculate.php --preview
php local/loop/cli/recalculate.php --execute
php local/loop/cli/recalculate.php --certification=7 --execute
OptionShortDefaultMeaning
--preview-poffReport what would change, write nothing
--execute-eoffApply the recalculation
--certification-cevery active certificationRestrict to one certification, active or not

Repeatable: running it twice with nothing new in between leaves everything as it was. It is also how a site brings in completions recorded before LOOP was installed. See Recalculate stored dates.

Changes made this way appear in the site log (Site administration → Reports → Logs) with cli as their origin. Moodle records cron under the same origin, since both run without a browser.

Running a scheduled task by hand

Not a LOOP script, but the one you will reach for most. Use it to bring a status or a queue up to date without waiting for the night.

bash
php admin/cli/scheduled_task.php --execute='\local_loop\task\<task>'
TaskReplace <task> with
Sync certification editionssync_editions_task
Rebuild derived certification dataproject_task
Check certification expiriescheck_expiries_task
Check overdue certificationscheck_overdue_task
Check expired certificationscheck_expired_task
Send monthly manager compliance reportssend_manager_reports_task
Process LOOP mail queueprocess_mail_queue_task
Validate LOOP licensevalidate_license_task
Purge anonymised audit rows past retentionpurge_anonymized_audit_task

For example:

bash
php admin/cli/scheduled_task.php --execute='\local_loop\task\check_expiries_task'

The same tasks can be run from Site administration → Server → Scheduled tasks, which is easier if you do not have shell access.