Difference between revisions of "Configurable reports"

Jump to: navigation, search
(New page: == Instalación == # Descargar el fichero de instalación del bloque "Custom Report" y descomprimirlo en el directorio '''/blocks''' del directorio de instalación de Moodle. # Iniciar se...)
 
m (Maintainer list)
 
(41 intermediate revisions by 12 users not shown)
Line 1: Line 1:
== Instalación ==
+
{{Infobox plugin
 +
|type = Block
 +
|entry = https://moodle.org/plugins/view.php?plugin=block_configurable_reports
 +
|tracker = http://tracker.moodle.org/browse/CONTRIB/component/10753
 +
|discussion = https://moodle.org/mod/forum/view.php?id=7979
 +
|maintainer = [[User:Juan Leyva|Juan Leyva]], [[User:Sara Arjona Téllez|Sara Arjona Téllez]]
 +
|float = right
 +
}}
  
# Descargar el fichero de instalación del bloque "Custom Report" y descomprimirlo en el directorio '''/blocks''' del directorio de instalación de Moodle.
+
== Installation ==
# Iniciar sesión como administrador y pulsar en el enlace Notificaciones, dentro del bloque de administración del sitio.
 
  
Para más información véase [https://docs.moodle.org/en/Installing_contributed_modules_or_plugins Installing contributed modules or plugins] (en inglés)
+
# Download the Configurable Reports installation file and unzip it to the '''\blocks''' directory in your Moodle folder.
 +
# Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports
 +
# Login to Moodle as Administrator and click Notifications under Site Administration.
  
== Resumen ==
 
  
Este bloque sirve para generar informes a medida de Moodle.
+
For more information see [[Installing contributed modules or plugins]]
  
Ha sido diseñado de forma modular para permitir a los desarrolladores crear nuevos plugins en menos de una hora.
+
== Overview ==
  
=== ¿Quién puede crear informes a medida? ===
+
This block is a Moodle custom reports builder. It its also connected to a [https://github.com/jleyva/moodle-configurable_reports_repository public repository of sample reports] (only plugin version 2.3 and above)
  
Cualquier usuario que tenga los permisos '''block/custom_reports:managereports'', '''blocks/custom_reports:manageownreports''' o '''block/custom_report/managesqlreports''' asignados en un CURSO o en el SITIO (estos permisos se definen durante la instalación del bloque).
+
It is designed in a modular way to allow developers to create new plugins in less than an hour.
  
=== ¿Qué tipo de informes puedo crear? ===
 
  
* Informes de cursos, con informaciones relativas a los cursos.
+
'''Who can create custom reports?'''
* Informes de usarios, con informaciones relativas a los usuarios y su actividad en un curso.
 
* Informes SQL personalizados, consultas SQL personalizadas. Este bloque puede usar las mismas consultas SQL que el plugin  [http://moodle.org/mod/data/view.php?d=13&rid=2884 de consultas SQL personalizadas de Tim Hunt].
 
  
Nota para los desarrolladores: se pueden crear sus propios tipos de informes.
+
Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.
  
=== ¿Quién puede ver los informes? ===
 
  
Cuando se crea un informe se puede elegir qué usuarios pueden verlo.
+
'''What type of reports can I create?'''
  
Los informes se muestra en un bloque del curso o en la portada del sitio.
+
- Courses reports, with information regarding courses.
  
== Cómo crear un informe ==
+
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.
  
Este es un proceso muy sencillo. Si va a crear un informe para un curso, necesita añadir el bloque en el curso y pulsar sobre "Gestionar informes". Por su parte, para los informes del sitio, añada el bloque en la portada y pulse sobre el enlace "Gestionar informes".
+
- Users reports, with information regarding users and their activity in a course.
  
Necesita introducir un nombre, una descripción (opcional) y tiene que elegir el tipo de informe, paginación y formatos de exportación.
+
- 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.
  
Dependiendo del tipo de informe elegido habrá más o menos pestañas. Estas son las pestañas para los informes de cursos y usuarios:
+
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [https://moodle.org/plugins/view.php?plugin=report_customsql Tim Hunt's Custom SQL queries] plugin.
  
* '''Columnas''': Aquí se puede elegir las diferentes columnas del informe, dependiendo del tipo de informe (Nombre del curso, Nombre de pila del usuarios, etc.)
+
Note for developers: You can create your own type of reports.
* '''Condiciones''': Aquí se pueden definir las condiciones (p.ej., sólo cursos de esta categoría, sólo usuarios de España, etc.)
+
 
* '''Ordenación''': Aquí se puede elegir como ordenar el informe usando los campos y direcciones (ascendente, descendente).
+
 
* '''Filtros''': Aquí se puede elegir qué filtros se visualizarán.
+
'''Who can view the reports?'''
* '''Plantilla''': Se puede modificar la disposición del informe creando una plantilla.
+
 
* '''Permisos''': Aquí se puede escoger quien puede ver el informe.
+
When you create a report you can select which users can view it.
* '''Cálculos''': Aquí se pueden añadir cálculos para las columnas; p.ej., media del número de usuarios matriculados en los cursos.
+
 
* '''Gráficas''': Aquí se pueden añadir gráficas al informe basadas en las columnas del informe y los valores.
+
The reports are displayed in a block in the course or site frontpage.
* '''Ver informes''': Auto explicativa
+
 
 +
== 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 ==
 
== Tutorial ==
  
=== Como crear un informe de usuario ===
+
=== 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.
  
Requisitos: ''Usuarios de España, pero no de Madrid, en este curso. Este informe se puede ver sólo por usuarios de España. Hay que visualizar un filtro basado en la ciudad del usuario. Se pide mostrar una gráfica de tarta con las ciudades de los usuarios. Se pide una tabla calculada que muestre el total de vistas de mensajes de foros El informe debe ordenarse por el apellido de los usuarios''.
+
Add an instance of the Custom Reports block.
  
¡Veamos qué fácil es!
+
Click on "Manage reports"
  
# Primero de todo, instale el bloque.
+
Click on "Add report"
# Vaya al curso donde se quiere crear el informe.
 
# Añada una instancia del bloque "Informes personalizados".
 
# Pulse en "Gestionar informes".
 
# Pulse en "Añadir informe".
 
# Introduzca un nombre, una descripción y elija "Informes de usuarios" como tipo de informe.
 
# Opcionalmente puede marcar las casillas "Exportar en formato ODS" y "Exportar en formato XLS" si desea poder exportar el informe en alguno de estos formatos.
 
# Pulse el botón "Agregar".
 
# Se guardará el informe y se le redirigirá a la pestaña denominada "Columnas".
 
  
==== Añadir columnas ====
+
Enter a name, a description and choose "Users report" as Type of Report
  
Aquí se puede efinir las propiedades de la tabla del informe como anchura, alineación, relleno de las celdas, espaciados de las celdas, etc.
+
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.
  
# Añada una columna de tipo "Campo del perfiel de usuario"
 
# Teclee un nombre para esta columna y en el desplegable llamado "Columna" elija el valor "firstname". Puede dejar en blanco el resto de elementos. Pulse sobre el botón "Agregar".
 
# Repita el proces para los campos "lastname" y "city".
 
# Añada una nueva columna de tipo "Acciones de usuario en el módulo".
 
# Teclee un nombre parae esta columna y elija un módulo de la lista, en nuestro caso, el foro sobre el que queremos elaborar el informe. Pulse sobre el botón "Agregar".
 
 
   
 
   
==== Añadir condiciones ====
+
'''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".
  
# Pulse en la pestaña "Condiciones".
+
Add a Condition named "Users in current report course".
# Añada una condición del tipo "Condición sobre campo de perfil del usuario".
 
# Escoga la columna "country" de la lista desplegable, el operador "=" e introduzca el valor "ES" (este es el código internacional para España tal y como lo almancena Moodle internamente). Pulse el botón "Agregar".
 
# Añada una nueva condición del tipo "Condición sobre campo de perfil del usuario".
 
# Escoja la columna "city", el operador "<>" e introduzca el valor "Madrid". Pulse el botón "Agregar".
 
# Añada una condición del tipo "Usuarios en el curso donde se ha creado el informe" y escoja el valor "Student". Pulse el botón "Agregar".
 
  
Estas son las condiciones principales del informe. Note que en la parte inferior hay una caja de texto llamada "Condición lógica" con el texto:
+
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
+
"c2 and c1 and c3"
  
Aquí se puede definir una condición lógica cualquiera. En este caso no necesitamos editar esta condición, pero puede crear expresiones complejas como:
+
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)
+
(c1 and c2) or (c4 and c3)
  
==== Añadir ordenación ====
 
  
# Pulse en la pestaña "Ordenación".
+
'''Adding Ordering'''
# Añada una ordenación del tipo "Ordenación por campo de usuario".
 
# Escoja la columna "lastname" y la ordenación "ASC" (ascendente). Pulse "Agregar".
 
  
==== Añadir filtros ====
+
Click on the Ordering Tab.
  
# Pulse en la pestaña "Filtros".
+
Add a ordering named "User field ordering".
# Añáda un filtro del tipo "Filtro sobre campo del perfil del usuario".
 
# Escoja el campo "city". Pulse "Agregar".
 
  
==== Añadir permisos ====
+
Choose the column "Lastname" and the ordering "ASC" (Ascending).
  
# Pulse en la pestaña "Permisos".
 
# Añada un permiso del tipo "Valor en el perfil del usuario".
 
# Escoja la columna "country" e introduzca el valor "ES". Pulse el botón "Agregar".
 
  
Aquí puede añadir más tipos de permisos y la condición lógica que debe cumplirse en caso de tener más un tipo de permiso.
+
'''Adding Filters'''
  
==== Añadir cálculos ====
+
Click on the Filters Tab.
  
# Pulse en la pestaña "Cálculos".
+
Add a filter named "User field filter".
# Añada un cálculo de tipo "Suma".
 
# Escoja la columna que representa la acción del usuario en el módulo (en nuestro caso el foro).
 
  
==== Añadir gráficas ====
+
Choose city.
  
# Pulse en la pestaña "Gráficas".
 
# Elija el tipo de gráfico "Tarta".
 
# Escoja la columna "city" tanto para la opción "Nombre" como para la opción "Valor". Pulse el botón "Agregar".
 
  
Por último, añada unos cuantos usuarios en Moodle con el país "España" y diferentes ciudades: Madrid, Barcelona, Sevilla, etc. y pruebe a visualizar el informe pulsando en la pestaña "Ver informe".
+
'''Adding Permissions'''
  
Si ha habilitado las opciones de exportar el informe en alguno de los formatos , podrá descargarlo pulsando sobre los enlaces que aparecen en la parte inferior del informe.
+
Click on the Permissions Tab.
  
[[#Informe_de_usuarios | Ver pantalla mostrando el informe]]
+
Choose "User field Value".
  
=== Crear un informe SQL ===
+
Choose the column "Country", and enter the value "ES".
  
Puede encontrar un montón de informes SQL aquí: [https://docs.moodle.org/en/ad-hoc_contributed_reports ad-hoc contributed reports]
+
Here you can add more permissions and a logic condition to be achieved.
  
Puesto que este bloque puede utilizar los informes de consultas SQL personalizadas de Tim Hunt, puede utilizar cualquier consulta.
 
  
Recuerde añadir un filtro de tipo "Filtro de fechas" si va a usar informes con valores temporales.
+
'''Adding Calculations'''
  
Para crear un informe de este tipo:
+
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.
 +
 
 +
[[blocks/configurable_reports/#Users_report | 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''):
  
# Pulse en el enlace "Gestionar informes" del bloque de informes personalizados
 
# Pulse en "Añadir informe".
 
# Introduzca un nombre y una descripción para el informe y seleccione "Informe SQL" como el tipo del informe.
 
# Opcionalmente puede marcar las casillas "Exportar en formato ODS" y "Exportar en formato XLS" si desea poder exportar el informe en alguno de estos formatos.
 
# Pulse el botón "Agregar".
 
# Se guardará el informe y se le redirigirá a la pestaña denominada "Sentencia SQL".
 
# Añada esta consulta (''Actividad de los cursos''):
 
 
<code sql>
 
<code sql>
SELECT COUNT(l.id) AS hits, l.course courseId, c.fullname coursename
+
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
 
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id
 
GROUP BY courseId
 
GROUP BY courseId
 
ORDER BY hits DESC
 
ORDER BY hits DESC
 
</code>
 
</code>
y pulse el botón "Guardar cambios".
 
# Vaya a la pestaña "Cálculos".
 
# Añada un cálculo de tipo "Suma" y escoja la columna "hits". Pulse el botón "Agregar".
 
# Vaya a la pestaña "Gráficas".
 
# Elija el tipo de gráfico "Tarta".
 
# Escoja la columna "hits" tanto para la opción "Nombre" como para la opción "Valor". Pulse el botón "Agregar".
 
# Pruebe a visualizar el informe pulsando en la pestaña "Ver informe".
 
  
Ahí lo tiene, un informe con una gráfica y cálculos basados en una consulta SQL.
+
==== Adding a calculation ====
 +
# Go to Calculations Tab
 +
# Add a Sum calculation, choose the hits column
  
Puede añadir un filtro de cursos, es muy sencillo:
+
==== Adding a Plot ====
 +
# Go to Plot
 +
# Add a Pie graph, choosing coursename as Name and hits as value
  
# Vaya a la pestaña "Filtros" y añada un filtro de tipo "Cursos".
+
So, here you have a report with a Graph and calculations based on a SQL Query.
# Edite la consulta SQL y ponga lo siguiente:
+
 
 +
Note: Bar charts are currently not displaying on systems using PHP 7: https://github.com/jleyva/moodle-block_configurablereports/issues/101
 +
 
 +
==== Filters ====
 +
 
 +
Filters add a control to the report that allows the user to select a subset of data when the report runs.  Filters require two steps:
 +
 
 +
# Select the filter you want to use on the "Filters" tab
 +
# Add SQL code to make the filter affect the output.
 +
 
 +
These are the filters that can be used to constrain your report:
 +
 
 +
<code sql>
 +
%%FILTER_CATEGORIES:
 +
%%FILTER_COURSEMODULEID:
 +
%%FILTER_COURSEMODULEFIELDS:
 +
%%FILTER_COURSEMODULE:
 +
%%FILTER_COURSES:
 +
%%FILTER_COURSEENROLLEDSTUDENTS:
 +
%%FILTER_USERS:
 +
%%FILTER_ROLE:
 +
%%FILTER_SEARCHTEXT:
 +
%%FILTER_SEMESTER:
 +
%%FILTER_STARTTIME:
 +
%%FILTER_ENDTIME:
 +
%%FILTER_SUBCATEGORIES:
 +
%%FILTER_COURSEUSER:
 +
%%FILTER_SYSTEMUSER:
 +
%%FILTER_YEARHEBREW:
 +
%%FILTER_YEARNUMERIC:
 +
</code>
 +
 
 +
'''Using Filters'''
 +
 
 +
When using a filter you need at least one static WHERE condition, followed by one or more filters. For example
 +
 
 +
<code sql>
 +
WHERE 1
 +
%%FILTER_COURSES:c.id%%
 +
</code>
 +
 
 +
You can technically add multiple filters, but once a user applies one filter to a report all filters for report are applied. So it can be a little tricky to have multiple filters on the same report. For example if you add a course and date filter to a report, then if you just want to filter by course you have to make sure your date filters are set to date range that covers all courses.
 +
 
 +
Many of the filters are hard coded to be drop down menus which are sorted by database id number instead of alphabetically. This can be problematic if you have a large number of users, courses, or categories. However, you can use one search text filter per report, which can be used to work around the issue in some cases.
 +
 
 +
Many filters require a logical operator to specify how the filter works. For example
 
<code sql>
 
<code sql>
SELECT COUNT(l.id) AS hits, l.course courseId, c.fullname coursename
+
%%FILTER_STARTTIME:l.TIME:>%% %%FILTER_ENDTIME:l.TIME:<%%
 +
</code>
 +
 
 +
You can add a Course filter; it's very easy.
 +
# Go to filters, choose Courses
 +
# Edit the Custom SQL query:
 +
 
 +
<code sql>
 +
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  
 
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id  
 
%%FILTER_COURSES:l.course%%  
 
%%FILTER_COURSES:l.course%%  
Line 175: Line 298:
 
ORDER BY hits DESC
 
ORDER BY hits DESC
 
</code>
 
</code>
Observe que estamos añadiendo un token llamado %%FILTER_COURSES:l.courseid%%
 
# Vaya a la pestaña "Ver informe" y verá un filtro de cursos. Elija un curso y pulse en "Añadir" para ver el informe filtrado por ese curso.
 
  
También puede añadir un filtro de tipo "Filtro de fechas" para filtrar por fecha de inicio y fin:
+
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:
  
# Vaya a la pestaña "Filtros" y añada un filtro de tipo "Filtro de fechas".
 
# Edite la consulta SQL y ponga lo siguiente:
 
 
<code sql>
 
<code sql>
SELECT COUNT(l.id) AS hits, l.course courseId, c.fullname coursename
+
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  
 
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id  
 
%%FILTER_COURSES:l.course%%  
 
%%FILTER_COURSES:l.course%%  
Line 190: Line 317:
 
ORDER BY hits DESC
 
ORDER BY hits DESC
 
</code>
 
</code>
Observe que estamos añadiendo un token llamado %%FILTER_STARTTIME:l.time:>%% %%FILTER_ENDTIME:l.time:<%%
 
# Vaya a la pestaña "Ver informe" y verá también un filtro para indicar la fecha de inicio y fin a usar para el informe.
 
  
[[#Informe_SQL | Ver pantalla mostrando el informe]]
 
  
== Opciones avanzadas ==
+
If you want to filter text (for example, lastname)
=== Plantillas ===
+
 
 +
# Go to filters, choose Search Text filter
 +
# Go to Custom SQL tab and type your query. Here is an example for querying the user table:
 +
 
 +
<code sql>
 +
SELECT u.firstname, u.lastname
 +
FROM prefix_user u
 +
WHERE 1=1
 +
%%FILTER_SEARCHTEXT:u.lastname:~%%
 +
ORDER BY u.lastname
 +
</code>
 +
 
 +
Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.
 +
 
 +
One more example (for filtering a group of courses by category)
 +
 
 +
<code sql>
 +
SELECT COUNT(l.id) hits, c.fullname as Course,c.id as CourseID
 +
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra
 +
JOIN prefix_context AS ctx ON ra.contextid = ctx.id
 +
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students
 +
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id
 +
%%FILTER_CATEGORIES:c.category%%
 +
GROUP BY l.course
 +
ORDER BY hits DESC
 +
</code>
 +
 
 +
Go to View report, now you can filter by time also
 +
 
 +
==== SQL variables ====
 +
 
 +
If you place one of these strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url), etc.)
 +
 
 +
<code sql>
 +
%%CATEGORYID%%
 +
%%COURSEID%%
 +
%%CURRENTUSER%%
 +
%%DEBUG%%
 +
%%FILTER_VAR%%
 +
%%STARTTIME%%','%%ENDTIME%%
 +
%%USERID%%
 +
%%WWWROOT%%
 +
</code>
 +
 
 +
[[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).
  
Se puede personalizar el informe usando una plantilla. Sólo hace falta ir a la pestaña llamada "Plantilla" y habilitarla, y a continuación rellenar cada una de las partes de la plantilla (cabecera, plantilla para un registro y pie)
+
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)
  
Este es un ejemplo de código HTML para visualizar una lista de usuarios:
+
Select the statistic (User logins)
  
Cabecera:
+
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 ==
 +
 
 +
=== Export and import of reports ===
 +
 
 +
Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the "Other report field" column.
 +
 
 +
Reports that uses the user module outline column can't be exported either
 +
 
 +
=== Use the same report in different courses ===
 +
 
 +
(Available only in Configurable Report version 2.3 and above)
 +
 
 +
In order to use the same report in different courses you have to check the "Global report" option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to "Display global reports".
 +
 
 +
If you don't want to display global reports in a certain block instance you can always edit the instance settings for selecting "No" in the "Display global reports" block setting.
 +
 
 +
Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed
 +
 
 +
=== Reports can run on a different DB then the current (production) DB ===
 +
 
 +
(Available only in Configurable Report version 2.3 and above)
 +
 
 +
This functionality is for using a copy of the same moodle database, not for queries to other database sources.
 +
 
 +
Go to Admin -> Plugins -> Blocks -> Configurable Report settings
 +
 
 +
=== DataTables for the report table ===
 +
 
 +
(Available only in Configurable Report version 2.3 and above)
 +
 
 +
Go to Admin -> Plugins -> Blocks -> Configurable Report settings to enable this functionality
 +
 
 +
=== CodeMirror.js for highlighting SQL query code ===
 +
 
 +
(Available only in Configurable Report version 2.3 and above)
 +
 
 +
Go to Admin -> Plugins -> Blocks -> Configurable Report settings to disable this functionality
 +
 
 +
=== Using GITHUB as a repository to distribute and manage sharable SQL queries ===
 +
 
 +
(Available only in Configurable Report version 2.3 and above)
 +
 
 +
Go to Admin -> Plugins -> Blocks -> Configurable Report settings to point to your own repository
 +
 
 +
=== Cron SQL queries ===
 +
 
 +
(Available only in Configurable Report version 2.3 and above)
 +
 
 +
=== Settings to control security of SQL Queries ===
 +
 
 +
(Available only in Configurable Report version 2.3 and above)
 +
 
 +
Go to Admin -> Plugins -> Blocks -> Configurable Report settings to change the security level
 +
 
 +
=== 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:
  
 
<code html4strict>
 
<code html4strict>
Line 211: Line 455:
 
</code>
 
</code>
  
Plantilla para un registro:
+
Record:
  
 
<code html4strict>
 
<code html4strict>
 
<table width="100%">
 
<table width="100%">
 
<tr>
 
<tr>
<td><img src="http://tu.sitio.moodle.es/user/pix.php/[[id]]/f1.jpg"></td>
+
<td><img src="http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg"></td>
<td><h2>[[firstname]] [[lastname]]</h2>
+
<td><h2>[[Firstname]] [[Lastname]]</h2>
Ciudad: [[city]]
+
City: [[City]]
 
</td>
 
</td>
 
</tr>
 
</tr>
Line 225: Line 469:
 
</code>
 
</code>
  
Pie:
+
Footer:
  
 
<code html4strict>
 
<code html4strict>
Line 237: Line 481:
 
</code>
 
</code>
  
=== Informes incrustados ===
+
=== Embedded reports ===
Un informe incrustado consiste en un juego de columnas de un informe que están incrustadas entro.
 
  
Por ejemplo, puede incrustar un informe de usuario en un informe de curso. En este caso, las filas resultantes del curso se expandirán duplicando cada fila para cada usuario.
+
An embedded report consists in a report's set of columns that are embedded in another report.
  
Para incrustar un informe, simplemente añada una nueva columna de tipo "Columna de otro informe". Aparecerá una lista de informes existentes. Una vez seleccionado uno aparecerá la lista de columnas de dicho informe para que podamos escoger la deseada.
+
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.
  
Dentro de un informe de curso se puede incrustar un informe de usuario y viceversa. No es posible sin embargo incrustar informes de curso dentro de informes de curso, o informes de usuario dentro de informes de usuario.
+
{| class="wikitable"
 +
|-
 +
! Type of report
 +
! Reports that can be embedded
 +
|-
 +
| Courses
 +
| Users
 +
|-
 +
| Categories
 +
| Courses
 +
|-
 +
| Timeline
 +
| Users, courses
 +
|}
  
== Documentación para desarrolladores ==
+
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.
  
Es muy fácil crear nuevos tipos de informes, componentes y plugins.
+
To embed a report just add a "Other report" column, a list of your reports will be showed.
  
'''Informe''': Un informe es un directorio ubicado dentro de /reports (con respecto al directorio de instalación del bloque). Este directorio contiene un fichero llamado report.class.php con la definición de la clase hija que extiende de report_base.
+
Inside a course report you can embed a user report and the other way.
  
Sólo necesita modificar unos pocos métodos para añadir un nuevo tipo de informe. Por favor, eche una ojeada a cualquiera de los informes existentes. El informe SQL es un ejemplo de un informe no típico, mientras que los informes de usuarios y cursos son informes estándar.
+
==== Timeline reports ====
  
La mejor manera de crear un nuevo informe es duplicando uno existente.
+
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.
  
'''Componente''': Un componente es parte de un informe, y puede ser usado por más de un informe. Además es un directorio ubicado dentro de /components (con respecto al directorio de instalación del bloque). Este directorio contiene un fichero llamado component.class.php con la definición de la clase hija que extiende de component_base.
+
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.
  
El componente princial es el componente llamado "columns", que se usa para añadir las columnas de un informe. Otros componentes son los filtros, permisos, gráficas, cálculos, etc.
+
== Reports repository ==
  
La mejor manera de crear un nuevo componente es duplicando uno existente.
+
Configurable Reports is connected to two different repositories:
  
'''Plugin''': Un plugin es un módulo de un componente. Además es un directorio ubicado dentro de /components/nombre-del-componente/. Este directorio contiene un fichero llamado plugin.class.php con la definición de la clase hija que extiende de plugin_base.
+
* https://github.com/jleyva/moodle-configurable_reports_repository A repository of any type of reports (users, courses, sql, etc...)
 +
* https://github.com/jleyva/moodle-custom_sql_report_queries A repository of just SQL queries to be used in the SQL repor type
  
Por ejemplo, el componente columna tiene unos pocos plugins (coursefield, userfield, etc..).
+
You can use your custom repository following this instructions:
  
Un plugin funciona normalmente para un único tipo de informe, pero existen plugins que funcionan para más de un tipo de informe.
+
* First, you need a github account (free)
  
La mejor manera de crear un nuevo plugin es duplicando uno existente.
+
* Fork any of the previous repositorys, using the GITHUB fork tool
  
== Créditos ==
+
* Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)
Juan Leyva [http://moodle.org/user/view.php?id=49568&course=1 Perfil de Moodle]
 
  
[http://twitter.com/jleyvadelgado Sígueme en Twitter]
+
* Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name
[[Category:Contributed code]]
 
  
== Pantallazos ==
+
* If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)
=== Informe de usuarios ===
+
 
 +
 
 +
== 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.
 +
 
 +
== How to request a new feature ==
 +
 
 +
* Go to the Plugin Tracker http://tracker.moodle.org/browse/CONTRIB/component/10753
 +
* Check in the open issues if your feature have been already requested http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&jqlQuery=project+%3D+CONTRIB+AND+component+%3D+%22Block%3A+Configurable+report%22+AND+status+%3D+Open+ORDER+BY+priority+DESC&mode=hide
 +
* If not, create a New issue (Component: Non-core contributed modules Issue type: New feature) (You have to register yourself in the tracker)
 +
* Select the component Block: Configurable Reports and your Moodle version
 +
* Explain in the Description field your needs
 +
* If you have funding, you can contact me using the forum or the moodle internal messaging system, since I work for a Moodle Partner I can work on your request.
 +
* Vote and Watch the issue you have created
 +
 
 +
== Credits ==
 +
 
 +
Juan Leyva [http://moodle.org/user/view.php?id=49568&course=1 Moodle profile]
 +
 
 +
[http://twitter.com/jleyvadelgado Follow me in Twitter]
 +
 
 +
== Screenshots ==
 +
 
 +
=== Users report ===
 
[[Image:block_custom_reports_sample_user_report.png|600px]]
 
[[Image:block_custom_reports_sample_user_report.png|600px]]
  
=== Informe SQL ===
+
 
 +
=== SQL report ===
 
[[Image:block_custom_reports_sample_sql_report.png|600px]]
 
[[Image:block_custom_reports_sample_sql_report.png|600px]]
  
[[en:blocks/configurable_reports]]
+
 
 +
== See Also ==
 +
 
 +
* CONTRIB-2386
 +
* [https://tracker.moodle.org/issues/?jql=project%20%3D%20CONTRIB%20AND%20component%20%3D%20%22Block%3A%20Configurable%20report%22 Block: Configurable reports] Tracker component
 +
* [http://moodle.org/plugins/view.php?plugin=block_configurable_reports Modules & Plugins] database entry
 +
* [http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]
 +
* [[ad-hoc_contributed_reports|contributed reports]] (in plain SQL)
 +
* [https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]
 +
* [https://www.youtube.com/watch?v=lF6CuY2Qiw0 Configurable Reports as a Learning Analytics Tool] - iMoot 2015 presentation by Elizabeth Dalton
 +
* [http://opensourceelearning.blogspot.co.za/2015/08/moodle-configurable-reports-plugin-all.html All Variables and Filters] - Lists the Variables and Filters you can use in a report
 +
 
 +
[[Category:Report]]
 +
[[Category:Contributed_code]]
 +
 
 +
[[es:blocks/configurable_reports/]]

Latest revision as of 07:35, 7 August 2019

Installation

  1. Download the Configurable Reports installation file and unzip it to the \blocks directory in your Moodle folder.
  2. Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports
  3. 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 its also connected to a public repository of sample reports (only plugin version 2.3 and above)

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

Adding a calculation

  1. Go to Calculations Tab
  2. Add a Sum calculation, choose the hits column

Adding a Plot

  1. Go to Plot
  2. 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.

Note: Bar charts are currently not displaying on systems using PHP 7: https://github.com/jleyva/moodle-block_configurablereports/issues/101

Filters

Filters add a control to the report that allows the user to select a subset of data when the report runs. Filters require two steps:

  1. Select the filter you want to use on the "Filters" tab
  2. Add SQL code to make the filter affect the output.

These are the filters that can be used to constrain your report:

%%FILTER_CATEGORIES:
%%FILTER_COURSEMODULEID:
%%FILTER_COURSEMODULEFIELDS:
%%FILTER_COURSEMODULE:
%%FILTER_COURSES:
%%FILTER_COURSEENROLLEDSTUDENTS:
%%FILTER_USERS:
%%FILTER_ROLE:
%%FILTER_SEARCHTEXT:
%%FILTER_SEMESTER:
%%FILTER_STARTTIME:
%%FILTER_ENDTIME:
%%FILTER_SUBCATEGORIES:
%%FILTER_COURSEUSER:
%%FILTER_SYSTEMUSER:
%%FILTER_YEARHEBREW:
%%FILTER_YEARNUMERIC:

Using Filters

When using a filter you need at least one static WHERE condition, followed by one or more filters. For example

WHERE 1
%%FILTER_COURSES:c.id%%

You can technically add multiple filters, but once a user applies one filter to a report all filters for report are applied. So it can be a little tricky to have multiple filters on the same report. For example if you add a course and date filter to a report, then if you just want to filter by course you have to make sure your date filters are set to date range that covers all courses.

Many of the filters are hard coded to be drop down menus which are sorted by database id number instead of alphabetically. This can be problematic if you have a large number of users, courses, or categories. However, you can use one search text filter per report, which can be used to work around the issue in some cases.

Many filters require a logical operator to specify how the filter works. For example

%%FILTER_STARTTIME:l.TIME:>%% %%FILTER_ENDTIME:l.TIME:<%%

You can add a Course filter; it's very easy.

  1. Go to filters, choose Courses
  2. 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

  1. Go to filters, choose Start / End date filter
  2. 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


If you want to filter text (for example, lastname)

  1. Go to filters, choose Search Text filter
  2. Go to Custom SQL tab and type your query. Here is an example for querying the user table:
SELECT u.firstname, u.lastname
FROM prefix_user u
WHERE 1=1
%%FILTER_SEARCHTEXT:u.lastname:~%%
ORDER BY u.lastname

Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.

One more example (for filtering a group of courses by category)

SELECT COUNT(l.id) hits, c.fullname AS Course,c.id AS CourseID
,(SELECT COUNT( ra.userid ) AS Users FROM prefix_role_assignments AS ra
JOIN prefix_context AS ctx ON ra.contextid = ctx.id
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id
%%FILTER_CATEGORIES:c.category%% 
GROUP BY l.course
ORDER BY hits DESC

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

SQL variables

If you place one of these strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url), etc.)

%%CATEGORYID%%
%%COURSEID%%
%%CURRENTUSER%%
%%DEBUG%%
%%FILTER_VAR%%
%%STARTTIME%%','%%ENDTIME%%
%%USERID%%
%%WWWROOT%%

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

Export and import of reports

Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the "Other report field" column.

Reports that uses the user module outline column can't be exported either

Use the same report in different courses

(Available only in Configurable Report version 2.3 and above)

In order to use the same report in different courses you have to check the "Global report" option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to "Display global reports".

If you don't want to display global reports in a certain block instance you can always edit the instance settings for selecting "No" in the "Display global reports" block setting.

Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed

Reports can run on a different DB then the current (production) DB

(Available only in Configurable Report version 2.3 and above)

This functionality is for using a copy of the same moodle database, not for queries to other database sources.

Go to Admin -> Plugins -> Blocks -> Configurable Report settings

DataTables for the report table

(Available only in Configurable Report version 2.3 and above)

Go to Admin -> Plugins -> Blocks -> Configurable Report settings to enable this functionality

CodeMirror.js for highlighting SQL query code

(Available only in Configurable Report version 2.3 and above)

Go to Admin -> Plugins -> Blocks -> Configurable Report settings to disable this functionality

Using GITHUB as a repository to distribute and manage sharable SQL queries

(Available only in Configurable Report version 2.3 and above)

Go to Admin -> Plugins -> Blocks -> Configurable Report settings to point to your own repository

Cron SQL queries

(Available only in Configurable Report version 2.3 and above)

Settings to control security of SQL Queries

(Available only in Configurable Report version 2.3 and above)

Go to Admin -> Plugins -> Blocks -> Configurable Report settings to change the security level

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:

<p align="center"><b>##reportname##</b></p>
<table width="60%" align="center">
<tr>
<td>

Record:

<table width="100%">
<tr>
<td><img src="http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg"></td>
<td><h2>[[Firstname]] [[Lastname]]</h2>
City: [[City]]
</td>
</tr>
</table>
<br>

Footer:

</td>
<td valign="top">
##graphs## 
<br /><br />
##exportoptions##
</td>
</table>

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.

Reports repository

Configurable Reports is connected to two different repositories:

You can use your custom repository following this instructions:

  • First, you need a github account (free)
  • Fork any of the previous repositorys, using the GITHUB fork tool
  • Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)
  • Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name
  • If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)


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.

How to request a new feature

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