Extracting the data

The code to determine the number of times a user has interacted with a resource or activity, we will take from the Heatmap block plugin by Michael de Raadt (visit https://moodle.org/plugins/pluginversions.php?plugin=block_heatmap for details). We will create a new script called /locallib.php and add a new function to return the number of interactions with each resource or activity.

This code can be taken from the Heatmap block code:

Let's work through this function step by step to see how it operates. The function is passed the ID number of the course for which we need user interaction data:

 function course_report_get_views($courseid) ...

Get Moodle 3.x Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.