Push individualized data to Moodle users for dashboard access

There is a generic need for school administration to push data to students. However the nature of the data makes a broadcast type communication not feasible such as:

  1. When the data is private and varies with individual
  2. When data cannot be tied to a course because data persists beyond course time limits

So how to do this? Algorithmically this involves the following steps:

  1. Generate data for each student either by pulling data from another site or generating it manually by means such as a spreadsheet. This data can be inside or outside of Moodle.
  2. A method to take this data and incorporate it inside of Moodle as belonging to the student user. This somehow involves permanent storage in the database.
  3. Finally, a means to access the data by each student when they log into the site.

One such implementation is described below:

  1. A custom user profile field is created to store this data. Since most data is in form of records, it is convenient to store a string that is JSON encoded. A Moodle custom user profile field of type text or text area is suitable for this depending on amount of data anticipated. In effect we are obviating the need to create our own data tables for a custom plugin by using the Moodle provided mechanism to store user’s data.
  2. A custom block such as a modified block_configurable_reports is used to read the spreadsheet and build the data depending on any other dependencies. The data is then added to existing data in the custom user profile field by the plugin.
  3. Finally, build another simple plugin block that can be installed on the dashboard which will grab the logged in user’s data from this custom profile field and display information to the user.

Examples of such information could be:

  • Student payments made to date
  • Student payments due
  • Etc.

We will describe the detailed implementation below for the case of student payments due.


The data is prepared in a spreadsheet. The spreadsheet is a Google Sheet located in some directory in a Google Drive and published as a CSV. Anyone with a link can download this CSV file. This file contains tuition fee amounts due for students moving from a lower grade to an upper grade.

Pushing data to users’ profile field

We use the plugin block_configurable_reports for this purpose. We filter the students using SQL appropriately and replace the download CSV export with our own php code that will read the above spreadsheet file using config settings to get the path of the file. These need to be set appropriately. The data from the file is processed and based on which grade the student is (data from a certain profile field) the fee amount due is searched for. Any existing fee records are read form the user profile field with shortname fees and the new record is added and the whole re-written back to the user profile field.

Block to list the fees due

Posted in Configurable Reports, moodle, plugin.