Stories from Moodle Dev: Moodle Event Monitoring | Eummena
Stories from Moodle Dev: Moodle Event Monitoring

As our technical team works on Moodle, we find ourselves tackling issues that may be of interest to other developers. As a part of the Moodle community and advocators of openness, we decided to share our own experiences from Moodle Dev, among other things of course! If you haven’t read our previous post, take a look at “The Antivirus MIME Blocker

What is Moodle event monitoring?

Sometimes we need updates on the basis of some actions in an email. Such actions are related to who has logged in to the site, what manipulation is going on, on the site such as adding/deleting/viewing any activity, submission of assignment etc. Moodle provides action based notification system ‘Event monitoring’ to keep user updated for any action happens in the LMS.

Event monitoring allows admins and teachers to receive notifications when certain events happen in Moodle such as user logged in, user created, quiz creation & quiz submission etc. Any role that has tool/monitor:subscribe can subscribe to the event. By default, this is only for admin, manager and teachers.

Before version 2.7, Moodle used simple logging API to log any action in the database, these actions were then displayed on log report and live log reports. We can’t receive any notification of action performed through logging API. In Moodle 2.8, Moodle introduced ‘Event monitoring system’ that is used to add all logs into a database as well as we to receive email notifications.

[image source]

Categorisation of event monitoring

We can categorise Moodle events into two parts:

  1. Existing events in core
  2. Custom events by event API

1. Existing events in core

The Moodle event system contains multiple built-in actions for notifications such as “view module”, “role assign”, “user created” etc. We can see the list of available events from Moodle documentation:

Create event monitoring rule for existing events

Enable event monitoring

An administrator can enable it from Site administration > Reports > Event monitoring rules.

Create rule

The first step is to create the rule to be monitored. Then, a user such as an admin and teacher, can subscribe to created event.

A teacher can create a rule from Course administration > Reports > Event monitoring rules

The administrator can, additionally, create a rule from Site administration > Reports > Event monitoring rules

  1. Click on ‘Add new rule’
  2. Add necessary information such ad Rule name, Area to monitor such as ‘core’ & event name such as ‘User has logged in’
  3. Click on ‘Save changes’ button
  4. Now go to ‘Event monitoring page’
  5. Select a course ‘Site’
  6. Click on plus + sign for subscribe
Student subscription

By default, students get notifications that are shown in User menu > Preferences > Notification(configuration needed by the administrator), there are a lot of events created for monitoring in which a student can also subscribe to events that will be created by administrator or teachers. The administrator will allow access to students so that they can subscribe to the event. Below are the steps that have to be followed in order to allow students to get notification of any event.

  • Go to Site administration > Users > Define roles and click edit icon for student role.
  • Allow ‘tool/monitor:subscribe’ capability to student role.
  • Now student can subscribe created event via the user menu Preferences > Event monitoring.

2. Custom Events by event API

Moodle provides event API which can be added in plugin, so we can create custom events within a plugin and once the event is triggered, a notification will be generated. Below is the overview of how can we implement event API to our plugin.

Moodle provides detailed documentation that describes how to implement event API into your plugin:


Below you may find some screenshots that depict the actions explained throughout this post.

View event list

Enable Event Monitoring

Add new rule  

Subscribe to the rule

Stories from Moodle Dev: Moodle Event Monitoring
Eummena 30 september 2019
Deel deze post
Why do teachers love Moodle?