Date watcher

Administration tools ::: tool_datewatch
Maintained by Moodle Workplace
Part of set Moodle Workplace.
The Datewatch plugin allows other Moodle plugins to execute a callback every time some date occurs.
Latest release:
798 sites
154 downloads
14 fans
Current versions available: 2
The Datewatch plugin allows other Moodle plugins to execute a callback every time some date occurs.

For example, plugins can monitor such things as "course enrolment ended", "2 days before the due date", etc.

To use, add this callback it in your plugin's lib.php:

function YOURPLUGINNAME_datewatch() {
    $watchers = [];

// Example 1: Send notification when course enrolment ended.
$watchers[] = \tool_datewatch\watcher::instance('user_enrolments', 'timeend') ->set_callback(function(\tool_datewatch\notification $notification) { if ($userenrolment = $notification->get_record()) { $enrol = $notification->get_snapshot('enrol', $userenrolment->enrolid); YOURPLUGINNAME_send_notification_enrollment_ended($userenrolment->userid, $enrol->courseid); } });
// Example 2: Do something 3 days before assignment due date.
$watchers[] = \tool_datewatch\watcher::instance('assign', 'duedate', - 3 * DAYSECS) ->set_callback(function(\tool_datewatch\notification $notification) { // ... }); return $watchers; }

There are two requirements to the watched dates:
  • The watched date has to be a field in a database table plus/minus a fixed offset (i.e. "7 days before the due date");
  • There must be events triggered every time a record is added, updated or deleted in the respective database table and this event must have correct `objecttable` and `objectid` properties.
For more details refer to the README.md file in the plugin


Moodle WorkplaceThis plugin has been contributed and is maintained by the Moodle Workplace team.

Screenshots

Screenshot #0

Contributors

Moodle Workplace (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Plugins bot
    Tue, 18 Jan 2022, 7:40 PM
    Approval issue created: CONTRIB-8823
  • Wazza
    Wed, 16 Mar 2022, 4:16 PM
    Sounds really interesting, but I do think it needs a web interface to make it more available for everyone.
Please login to post comments