Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: blocks/configurable reports/.

blocks/configurable reports/: Difference between revisions

From MoodleDocs
No edit summary
m (Fixed some grammar/typos)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Installation ==
== Installation ==


# Download the Custom Reports installation file and unzip it to the '''\blocks''' directory in your Moodle folder.
# Download the Configurable Reports installation file and unzip it to the '''\blocks''' directory in your Moodle folder.
# Login to Moodle as Administrator and click Notifications under Site Administration.
# Login to Moodle as Administrator and click Notifications under Site Administration.


Line 22: Line 22:


- Courses reports, with information regarding courses.
- Courses reports, with information regarding courses.
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.


- Users reports, with information regarding users and their activity in a course.
- Users reports, with information regarding users and their activity in a course.


- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries that [http://moodle.org/mod/data/view.php?d=13&rid=2884 Tim Hunt's Custom SQL queries] plugin.
- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.
 
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [http://moodle.org/mod/data/view.php?d=13&rid=2884 Tim Hunt's Custom SQL queries] plugin.


Note for developers: You can create your own type of reports.
Note for developers: You can create your own type of reports.
Line 71: Line 75:
=== Creating a users' report ===
=== Creating a users' report ===


Requirements: ''Users from Spain, but no from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user's city must be displayed. A pie plot showing the users' cities is required. A calculation table showing the total forum post views is required. The report must be order by users' lastname.''
Requirements: ''Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user's city must be displayed. A pie plot showing the users' cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users' lastname.''




Line 93: Line 97:
'''Adding Columns'''
'''Adding Columns'''


Here you can define the report table properties, width, align, cell padding, cell spacing, etc..
Here you can define the report table properties, width, align, cell padding, cell spacing, etc.
 
Add a Column called "User profile field"
Add a Column called "User profile field"


Choose the field "firstname" and enter a name for the column in the text field. You can leave blank the rest of elements.
Choose the field "firstname" and enter a name for the column in the text field. You can leave the rest of elements blank.


Repit the process above for the lastname and city fields.
Repeat the process above for the lastname and city fields.


Add a Column called "User module actions".
Add a Column called "User module actions".
Line 175: Line 180:




Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville etc. and test the report.
Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.


You can download the report in differents formats (ods and xls), remember to check these options in the report page.
You can download the report in different formats (ods and xls), remember to check these options in the report page.


[[blocks/custom_reports/#Users_report | See screenshot]]
[[blocks/configurable_reports/#Users_report | See screenshot]]


=== Creating a SQL Report ===
=== Creating a SQL Report ===
Line 202: Line 207:
Enter a name, description, choose "SQL" as Type of Report
Enter a name, description, choose "SQL" as Type of Report


The report will be saved and you redirect to the firs Tab named "Custom SQL"
The report will be saved and you redirect to the first Tab named "Custom SQL"


Add this query (''Courses activity''):
Add this query (''Courses activity''):
Line 222: Line 227:
Add a Pie graph, choosing coursename as Name and hits as value
Add a Pie graph, choosing coursename as Name and hits as value


So, here you have, a report with a Graph and calculations based on a SQL Query.
So, here you have a report with a Graph and calculations based on a SQL Query.




You can add a Course filter, is very easy:
You can add a Course filter, it's very easy:


Go to filters, choose Courses
Go to filters, choose Courses
Line 244: Line 249:




You cand add also, and Starttime and endtime filter
You can also add a Starttime and endtime filter


Go to filters, choose Stard / End date filter
Go to filters, choose Start / End date filter


Go to Custom SQL tab, this is the new query:
Go to Custom SQL tab, this is the new query:
Line 262: Line 267:
Go to View report, now you can filter by time also
Go to View report, now you can filter by time also


[[blocks/custom_reports/#SQL_report | See screenshot]]
[[blocks/configurable_reports/#SQL_report | See screenshot]]
 
 
=== Creating a timeline report ===
 
''This report assumes that you have created at least one user or course report''
 
Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.
 
In this example we are going to create a report showing the user logins to the site during the last month (day per day).
 
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)
 
Select the statistic (User logins)


Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.
Add three "Other report column" columns, selecting all the previous user report columns.
And that's all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.


== Advanced options ==
== Advanced options ==
Line 313: Line 336:
=== Embedded reports ===
=== Embedded reports ===


A embedded report consists in a report's set of columns that are embeeded in other report.
An embedded report consists in a report's set of columns that are embedded in another report.


You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.
You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.


Imaging you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.
{| class="wikitable"
|-
! Type of report
! Reports that can be embedded
|-
| Courses
| Users
|-
| Categories
| Courses
|-
| Timeline
| Users, courses
|}
 
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.


To embed a report just add a "Other report" column, a list of your reports will be showed.
To embed a report just add a "Other report" column, a list of your reports will be showed.


Inside a course report you can embed a user report and the other way.
Inside a course report you can embed a user report and the other way.
==== Timeline reports ====
Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.
Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.


== Developers documentation ==
== Developers documentation ==
Line 330: Line 374:
This folder contains a .class.php file with the child - class of the report_base.
This folder contains a .class.php file with the child - class of the report_base.


You only need to modify a few methos to add a new report type.
You only need to modify a few methods to add a new report type.
Please, take a look to any of the current reports. The SQL report is an example of a non-typical report,  
Please, take a look at any of the current reports. The SQL report is an example of a non-typical report,  
meanwhile the users and courses reports are standard reports.
meanwhile the users and courses reports are standard reports.


The best way to create a report is duplicate an existing one.
The best way to create a report is to duplicate an existing one.




Line 342: Line 386:
Others components are filters, permissions, plot, calculations..
Others components are filters, permissions, plot, calculations..


The best way to create a component is duplicate an existing one.
The best way to create a component is to duplicate an existing one.




'''Plugin''': A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc..)
'''Plugin''': A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.)
A plugins works usually for an unique report, but there are plugins that works for more than one report.
A plugin usually works for a unique report, but there are plugins that work for more than one report.
The best way to create a plugin is duplicate an existing one.
The best way to create a plugin is to duplicate an existing one.




Line 355: Line 399:


[http://twitter.com/jleyvadelgado Follow me in Twitter]
[http://twitter.com/jleyvadelgado Follow me in Twitter]


[[Category:Contributed code]]
[[Category:Contributed code]]
Line 366: Line 411:
=== SQL report ===
=== SQL report ===
[[Image:block_custom_reports_sample_sql_report.png|600px]]
[[Image:block_custom_reports_sample_sql_report.png|600px]]
== See Also ==
CONTRIB-2386
[http://tracker.moodle.org/browse/CONTRIB/component/10753 Block: Configurable reports] Tracker component
[http://moodle.org/mod/data/view.php?rid=4283 Modules & Plugins] database entry
[http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]


[[es:blocks/configurable_reports/]]
[[es:blocks/configurable_reports/]]

Latest revision as of 16:26, 5 January 2011

Installation

  1. Download the Configurable Reports installation file and unzip it to the \blocks directory in your Moodle folder.
  2. Login to Moodle as Administrator and click Notifications under Site Administration.


For more information see Installing contributed modules or plugins

Overview

This block is a Moodle custom reports builder.

It is designed in a modular way to allow developers to create new plugins in less than an hour.


Who can create custom reports?

Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.


What type of reports can I create?

- Courses reports, with information regarding courses.

- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.

- Users reports, with information regarding users and their activity in a course.

- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.

- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as Tim Hunt's Custom SQL queries plugin.

Note for developers: You can create your own type of reports.


Who can view the reports?

When you create a report you can select which users can view it.

The reports are displayed in a block in the course or site frontpage.

Creating a report

This is a very simple process.

If you are going to create a report for a course, you have to add the block in the course and click in the "Manage reports" link.

On the other hand, for site reports, add the block in the frontpage and click in the "Manage reports" link.

You must enter a name, an optional description, and you have to choose the type of report, pagination and exports formats.

Depending on the report choosen, there will be more or less tabs. These are the tabs for the courses and users report:

Columns: Here you can choose the differents columns of your report depending on the type of report. (Course Name, User firstname, etc..)

Conditions: Here you can define the conditions (i.e, only courses from this category, only users from Spain, etc.)

Ordering: Here you can choose how to order the report using fields and directions.

Filters: Here you can choose which filters will be displayed.

Template: You can modify the report's layout by creating a template.

Permissions: Here you can choose who can view a report.

Calculations: Here you can add calculations for columns, i.e: average of number of users enrolled in courses

Plots: Here you can add graphs to your report based on the report columns and values.

View report: Self explanatory

Tutorial

Creating a users' report

Requirements: Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user's city must be displayed. A pie plot showing the users' cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users' lastname.


Let's see how easy it is!

First of all, install the block.

Go to the course where the report will be created.

Add an instance of the Custom Reports block.

Click on "Manage reports"

Click on "Add report"

Enter a name, a description and choose "Users report" as Type of Report

The report will be saved and you will be redirected to the first Tab named "Columns".


Adding Columns

Here you can define the report table properties, width, align, cell padding, cell spacing, etc.

Add a Column called "User profile field"

Choose the field "firstname" and enter a name for the column in the text field. You can leave the rest of elements blank.

Repeat the process above for the lastname and city fields.

Add a Column called "User module actions".

Choose a module from the list, in this example, a forum.


Adding Conditions

Click on the Conditions Tab.

Add a Condition named "User field Condition".

Choose the column "Country", the Operator "=", and enter the value "ES" (this is the international code for Spain as Moodle stores it).

Add a Condition named "User field Condition".

Choose the column "city", the Operator "<>", and enter the value "Madrid".

Add a Condition named "Users in current report course".

These are the main conditions of the reports. Note that at the bottom there is a text box called condition, with this text:

"c2 and c1 and c3"

Here you can define a logic condition, in this case, we don't need to edit this condition but you can create complex expressions like:

(c1 and c2) or (c4 and c3)


Adding Ordering

Click on the Ordering Tab.

Add a ordering named "User field ordering".

Choose the column "Lastname" and the ordering "ASC" (Ascending).


Adding Filters

Click on the Filters Tab.

Add a filter named "User field filter".

Choose city.


Adding Permissions

Click on the Permissions Tab.

Choose "User field Value".

Choose the column "Country", and enter the value "ES".

Here you can add more permissions and a logic condition to be achieved.


Adding Calculations

Click on the Calculations tab.

Choose Sum.

Choose the column "User module actions".


Adding Plots

Click on the Plots tab.

Choose "Pie".

Choose the colum "City" as Name and Value.


Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.

You can download the report in different formats (ods and xls), remember to check these options in the report page.

See screenshot

Creating a SQL Report

You can find a lot of SQL Reports here: ad-hoc contributed reports

Since this block supports Tim Hunt's CustomSQL Queries Reports, you can use any query.

Remember to add a "Time filter" if you are going to use reports with time tokens.


First of all, install the block.

Go to the course where the report will be created.

Add an instance of the Custom Reports block.

Click on "Manage reports".

Click on "Add report

Enter a name, description, choose "SQL" as Type of Report

The report will be saved and you redirect to the first Tab named "Custom SQL"

Add this query (Courses activity):

SELECT COUNT(l.id) hits, l.course courseId, c.fullname coursename FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id GROUP BY courseId ORDER BY hits DESC

Go to Calculations Tab

Add a Sum calculation, choose the hits column


Go to Plot

Add a Pie graph, choosing coursename as Name and hits as value

So, here you have a report with a Graph and calculations based on a SQL Query.


You can add a Course filter, it's very easy:

Go to filters, choose Courses

Edit the Custom SQL query:

SELECT COUNT(l.id) hits, l.course courseId, c.fullname coursename FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id %%FILTER_COURSES:l.course%% GROUP BY courseId ORDER BY hits DESC

Note that we are adding a token called: %%FILTER_COURSES:l.courseid%%

Go to View report, and you will see a Courses Filter, choose a Course and click on Add, here you have a report filtered.


You can also add a Starttime and endtime filter

Go to filters, choose Start / End date filter

Go to Custom SQL tab, this is the new query:

SELECT COUNT(l.id) hits, l.course courseId, c.fullname coursename FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id %%FILTER_COURSES:l.course%% %%FILTER_STARTTIME:l.time:>%% %%FILTER_ENDTIME:l.time:<%% GROUP BY courseId ORDER BY hits DESC


Go to View report, now you can filter by time also

See screenshot


Creating a timeline report

This report assumes that you have created at least one user or course report

Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.

In this example we are going to create a report showing the user logins to the site during the last month (day per day).

Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)

Select the statistic (User logins)

Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.

Add three "Other report column" columns, selecting all the previous user report columns.

And that's all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.

Advanced options

Templates

You can customize the report output using a template.

Just enable the Template option in the same name tab.

This is an example html code for displaying a list of users:

Header:

##reportname##

Record:

<img src="http://yourmoodle.com/user/pix.php/id/f1.jpg">

Firstname Lastname

City: City


Footer:

    1. graphs##



    1. exportoptions##

Embedded reports

An embedded report consists in a report's set of columns that are embedded in another report.

You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.

Type of report Reports that can be embedded
Courses Users
Categories Courses
Timeline Users, courses

Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.

To embed a report just add a "Other report" column, a list of your reports will be showed.

Inside a course report you can embed a user report and the other way.

Timeline reports

Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.

Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.

Developers documentation

It's very easy to create new report types, components and plugins.

Report: A report plugin is a folder located at /report. This folder contains a .class.php file with the child - class of the report_base.

You only need to modify a few methods to add a new report type. Please, take a look at any of the current reports. The SQL report is an example of a non-typical report, meanwhile the users and courses reports are standard reports.

The best way to create a report is to duplicate an existing one.


Component: A component is part of a report, a component may be used by more than one report. The main Component is the component Columns, that is used to add the columns of a report.

Others components are filters, permissions, plot, calculations..

The best way to create a component is to duplicate an existing one.


Plugin: A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.) A plugin usually works for a unique report, but there are plugins that work for more than one report. The best way to create a plugin is to duplicate an existing one.


Credits

Juan Leyva Moodle profile

Follow me in Twitter

Screenshots

Users report

block custom reports sample user report.png


SQL report

block custom reports sample sql report.png


See Also

CONTRIB-2386

Block: Configurable reports Tracker component

Modules & Plugins database entry

Help forum