Home  > Blog  > 2019  > Moodle event monitoring

Stories from Moodle Dev: Moodle Event Monitoring

30 September 2019

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.

Moodle Analytics Image

[image source]

Categorisation of event monitoring

We can categorise Moodle events into to two parts:

1.Existing events in core

2. Custom events by event API

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 https://docs.moodle.org/dev/Event_2#Existing_events

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 admin and teacher can subscribe on 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 notification that are show in User menu > Preferences > Notification (configuration needed by administrator), there are 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 in the event. Below are the steps that have to be followed in order to allow student 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.

Custom Events by event API

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

Moodle provides detailed documentation which describe how to implement event API into your plugin.

Screenshots

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

View event list

Mime Image

CC BY-NC-SA

Enable Event Monitoring

Mime Image

CC BY-NC-SA

Add new rule

Mime Image

CC BY-NC-SA

Mime Image

CC BY-NC-SA

Mime Image

CC BY-NC-SA

Subscribe to the rule

Mime Image

CC BY-NC-SA

Mime Image

CC BY-NC-SA

Story by: Azmat Ullah, Eummena

Stories from Moodle Dev: Moodle Event Monitoring

© Copyright since 2011 Eummena™

CC-BY-SA Some rights reserved.