A while ago I wrote a blog about learning analytics from different perspectives giving examples of different analytics based tools that could benefit different users. Since then I’ve had discussions with numerous people, many of whom have great ideas for analytics tools, but I’ve discovered there is a disconnect between the analytics people want and their understanding of where to find the data.
To get from question to answer there needs to be an understanding of where the data are located and how they can be brought together. My intention with this blog is to show you where to find data for analytics in Moodle.
Source 1: Database tables
The database tables are used by Moodle and its plugins for data storage. They are able to be queried for information about users, and their involvement, as well as course and site information. I would estimate that more than half of the data needed for analytics are stored in these database tables.
The limitation of these data is that they are not historical – they represent the current state of the system. There is some historical data, for example Forum posts and Chat sessions, but for historical information generally you need logs or observers. One advantage of drawing from database tables rather than logs is that such data can be gathered in real-time, all the time, which is not advisable for log data (more on that later).
Here is a summary of the data in Moodle database tables. I’ve categorised the data by the perspectives relevant to analytics.
User information |
|
---|---|
Activity involvement |
|
Grades and achievements |
|
Course information |
|
Site information |
|
Examples of using database data
Here are some examples of how data in Moodle’s database tables could be used for learning analytics. It’s not a comprehensive list, but perhaps there are ideas here that could inspire some great analytics tools.
- Student involvement and achievement
- Accesses to enrolled courses
- Progress through course
- Relative success or risk of failure
- Opportunities for students to undertake activities or interact
- Teacher involvement
- Regularity of access to courses
- Timely interaction with students
- Timely grading
- Success of students in teacher’s courses
- Potential to assist students at risk or commend success
- Course quality
- Richness of content and activities
- Use of assessment
- Student-teacher ratios
Source 2: Logs, Events and Observers
Currently the logging of events in Moodle is undergoing change. Rather than referring to past implementations of logging, I’ll be more forward looking, referring to events and logging as used to some extent in Moodle 2.6 and used fully in Moodle 2.7. The new logs are richer and more focussed on educational activities.
From logs it is possible to extract information about events that have taken place. Here are some relevant aspects of events that are captured.
Component | The part of Moodle (module, block, core) in which the event took place |
---|---|
Action | What took place, based on a pre-defined list of verbs |
CRUD | Whether the action was to create, read, update or delete |
Educational level | Whether the action was teaching, participating or other (eg. administering) |
User IDs | Who was responsible for the action and who they might have been affecting (eg. a teacher grading a student) |
Course and context | Where it happened |
Timestamp | When it happened |
Here is a list of verbs (action words) that are used with events currently. This set may grown.
accepted, added, answered, assessed, attempted, awarded, backedup, called, commented, completed, created, deleted, duplicated, evaluated, failed, graded, imported, loggedin/loggedout, loggedinas, locked, moved, passed, previewed, reassessed, reevaluated, submitted, suspended, switched, viewed, registered, removed, restored, reset, revealed, unlocked, upgraded, updated
One of the problems with logs is that they grow very large. This makes efficient searching and processing of log information almost impossible, particularly on larger sites. With richer event information being captured, there are also events being recorded from more places in Moodle. There is the potential to direct log information to log stores outside of the Moodle database. The intention of this change is to allow searching and processing of logs without impacting the performance of the Moodle server itself. There is also the potential to export log data to files for filtering and analysis outside Moodle. So it is possible to get detailed log information, but this cannot be used in real-time, say for a block or a report that combines logs with other information.
One way to capture event information so that it can be used in real-time is with observers. As each action takes place an event is “triggered” within Moodle and observers can “observe” events based on certain criteria. The new logging system is an event observer that consumes all events that are triggered and stores them (to one or more log storage plugins). It’s possible to create new observers that can focus on a subset of events, store relevant information so that it can later be presented efficiently. If you were interested in, say, creating a report that focussed on enrolment actions, you could allow the report to observe enrolment events, store records in its own table and then present the results to users appropriately, any time it was needed. The report could even make use of messages to send out alerts when necessary.
Examples using events and log data
- Monitoring site activity and focal points
- Number of user accesses, which could be used to infer time online
- Repeated exposure to resources and activities within courses
- Students accessing teacher feedback on activities
- Student retention in courses (based on enrolments and unenrolments)
Source 3: Click tracking by external monitors

The term “analytics” has been popularised by Google who offer a service that allows you to track users as they move through the pages of your website and then report information about the users back to you. It is possible to use Google Analytics with a Moodle site. After registering your site you need to slip some JavaScript into the pages of your site (Site administration > Appearance > Additional HTML or in your theme’s footer.html file). Google will then collect and present information about your users including…
- their environment (browser, OS, device),
- where in the world they are coming from and
- the paths they are following through your site.
This information is useful to administrators wanting to ensure their Moodle site is catering to users’ needs. To discover learning analytics from Google Analytics, it is possible to drill down into usage information, This will not yield the same sort of information as the Moodle database or logs, instead showing patterns of behaviour. This information could potentially be fed back into Moodle as Google provides an API to query analytics data, which could be presented in a Moodle report or block.

Another relevant click-tracking tool is the Moodle Activity Viewer or MAV. This is a system in two parts: a server-side component that collects course activity usage statistics and a browser plugin that takes the page delivered from Moodle to your browser and overlays the page with colour to turn the course page into a heatmap. This shows teachers where the focus of activity in a course is taking place.
Could this understanding be built-in?
Unfortunately, at this stage, there are no simple generic mechanisms built into Moodle that allow you to freely gather and combine information without writing code. There are some exceptions attempting to allow generic report writing, but I don’t think these are simple enough for ordinary users yet. Currently, if you have specific questions that can’t be answered using standard Moodle reports, the best way to get the answers you want is by writing (or get a developer to write) a plugin (report or block). Hopefully this guide so far will provide an understanding of what data are available and where to find them.
Is there a possibility to create the reports without coding them from scratch?
One potential future step would be to allow plugins (and Moodle itself) to be able to describe the data they store. With this meta information, it could be possible to use a generic tool to gather and combine specified information on-the-fly and tweak the criteria as needed. This would allow access to the rich data in the Moodle database (with appropriate security constraints, of course).
It could also be possible to create a generic observer that can be configured on-the-fly to consume events of interest and record them. The current logging and events system APIs allow such alternative logging. Providing a sense of what events could be observed would be the challenge here, but at least events are now somewhat “self describing” meaning meta information is recorded with the coded description of the event objects.
For administrators interested in the sort of user information that Google Analytics reveals, it is possible in Moodle to determine a user’s browser, OS and device type. Moodle already does this to allow page customisation for different combinations of these factors. It would not be a great step to capture and present this information in a report. Google could probably do this better, but perhaps you’re not too keen to allow Google to snoop on your students and their learning activities. Moodle logs could be used to infer the paths and behaviour of students, but this would be a very costly exercise, requiring a great deal of computing power, preferably away from the Moodle server.
What to do with this data?
The final challenge then is to go beyond data gathering and analysis to provide tools that can use this information to support teaching; tools that help students learn, teachers teach and administrators to cover their butts. Only then will we see the LMS take education beyond what could be achieved in the classroom.
Thanks for writing this, Michael – it’s a helpful distinction of the various layers / ways to access data and a nice preview of the logging features coming down the pike – which look strikingly similar to the Tin Can API in some respects (especially “verbs”). It would be helpful if you could provide some direct links to “drill down” to the tables & variables, as well as the values, that we can use to create some of the reports you’ve suggested
Thanks for your comment, John. We did discuss the Tin Can API when we were planning this (well spotted) and tried to ensure their verbs were covered. The current events API design should allow for an observer to be created that can act as a source of Tin Can information.
Hello Michael,
First of all congratulations for this great post! I am from Uruguay and I started my Final Degree project in 2016 about how an analytics application can help to students to improve their learning and I had not found any post like this yet that explains how to start exploring the Moodle Database in order to apply analytics. For about 9 months I had been doing a state of the art of research on the concepts related to our project and to experiment with a Moodle database that has got information about some courses given by an institution here in Uruguay. Now I have the challenge to explore this Moodle database and build a summary including only the most valuable tables and features in order to create indicators to apply analytics and obtain final grade’s predictions and recommendations for students (for example to help to choose a new course or recommend the right type of resource that help the student understand best some concept).
I would be glad if you contact me in order to help me with this project and clear some doubts that I have.
Contact: emilianotorrano@gmail.com