When it comes to writing creative reports for Moodle, eThink is definitely the go-to resource. Our goal is to help you make the most out of your Moodle installation and a big part of that is being able to analyze the data that is stored in Moodle so that you can make informed decisions.
During our ten years of business, we’ve written hundreds of reports for our clients and we’ve saved every one of them! It’s difficult to find a reporting need that we haven’t met yet, but if we don’t already have the report you need, we will be happy to create it for you.
eThink has extensive experience with Configurable Reports in Moodle and we are experts in how to maximize the functionality that the Configurable Reports plugin offers, especially when it comes to embedded reports.
Here’s some information on how you can set up embedded reports yourself in Moodle.
Embedded Reports in Moodle
An embedded report in Moodle is one that is triggered by clicking on a value inside of a report result. For example, let’s say you need a report that lists all students enrolled in a course and you’d like to click on a student and get a detailed listing of their attendance.
Another example, and one we’ll dive into in this article, would be a report that lists all sessions in a course and provides a drill down report that lists all the attendees for the session selected. We can accomplish this with an embedded report and the use of Configurable Reports Variables called the Filter Variable (%%FILTER_VAR%%) and the Course ID Variable (%%COURSEID%%).
To create this latter report, let’s walk through a few easy steps.
- Create the first “Main” report. This will be the “Main” report that will list all courses and the sessions that are in each course, along with the session date and the total number of attendees, for example.
This “Main” report above lists the courses and associated sessions…
- Create the “Detail” report that will be the embedded report. This will be the “Detail” report that will list all attendees for the session that is selected from the “Main” report.
Clicking any of the “GO” links indicated in the “Main” report above triggers the detail (or embedded) report to run and list all attendees in the selected session…
Note: Each report above will be assigned its own configurable reports id. You’ll find this id in the address bar of your browser when you run the report. Make a note of this id because you’ll need it later. It will look like this:
- Edit the first report and go to the “Custom SQL” tab.
- For this example, we will create a new column in the report that will be used as the trigger to run the “Detail” report. In this example, we will assign a column heading as “viewroster”, load the word “GO” into this column, and build a hyperlink into it that will run the “Detail” report. The “&filter_var=” will be the placeholder for the selected session from the “Main” report. See below:
- Save the first report.
- Edit the “Detail” report and go to the “Custom SQL” tab.
- Since this is the “Detail” report that will run when you select “Go” from the “viewroster” column in the “Main” report, we want this report to run for the selected course. We accomplish this by using the %%COURSEID%% variable in Configurable Reports. The %%COURSEID%% variable will contain the Moodle course id for the course that is currently active at the time that you run the report. There are other variables like this, but we will save those for a future eThink blog article. Add the %%COURSEID%% variable to the WHERE clause in the SQL code for the “Detail” report. Like this:
- Click the “Save Changes” button.
- While still editing the second report, go to the “Reports” tab. Since this report needs to run for any course, you’ll need to make sure that the “Global report” checkbox is checked.
TIP: If you forget to check this box, you will know it right away because the “Detail” report will never return any results. Without checking this box, the report will run for the default course id which is 1.
- Click the “Add” button at the bottom of the page to save your changes.
Take your new report for a test drive
1. Run the “Main” report.
There are a few different ways to do this, so here’s an example:
- Edit the “Main” report and click the “View Report” tab.
- The report should look similar to report in the screenshot provided earlier in this article:
2. Click the “GO” link in the “viewroster” column for the desired course. This should trigger the “Detail” report to run and it should look similar to the report in the screenshot provided earlier in this article:
If the “Detail” report is not looking as expected, check the URL path that displays after the “Detail” report runs. Does it look correct? It should look something like this:
Is this the correct Moodle id for the “Detail” report? Edit the “Detail” report and check the URL path. Make sure that the Moodle id assigned to the report matches the above.
Is this the correct course id for the course you selected in the “Main” report? Go back to the “Main” report and verify.
Is this the correct id that will pull the detail you’re looking for? Temporarily modify the “Detail” report to pull only the course id and filter_var id that you see in this path. Are you getting the results you expected?
Mastering the use of the %%FILTER_VAR%% will significantly expand your reporting capabilities in Moodle using the Configurable Reports plugin. And, this only scratches the surface as far as what reports can be accomplished with this amazing plugin. For an overview on configurable reports, check out “Configurable Reports in Moodle.”
If you have any questions, don’t hesitate to contact us.Contact Us