This panel lets you enter the query and make certain global choices about the behaviour of the dashboard.
While the usual data source is generally Moodle's own database, it is possible to use an additional source (PostgreSQL only) to display data coming from another application.
You can choose to display or not to display:
Optionally, you can choose to display, for debugging purposes:
You will enter a query in the text editing area. You must comply with the following writing rules:
This option is only available in the pro version
Because an SQL query result cannot have a variable number of output columns, this data querying mode is not suited to querying matrix data. Data pivoting is a way of transforming a “flat” record output into a dynamically sized matrix. This technique is useful, for example, when you want to feed several distinct curve series into a graph from the results of a simple query. Pivoting uses a “dimension” column, called the “pivot” column, to arrange the data of the other columns in a grid that keeps the other dimensions, but whose other dimension is formed by the distinct values of the pivot.
Consider a table listing the number of users per authentication method and per country, according to the query:
SELECT
CONCAT(country, '-', auth) as pkey,
country as cn,
auth as auth,
COUNT(*) as num
FROM
{user}
GROUP BY
CONCAT(country, '-', auth)
This query is supposed to output a linear table:
| pkey | cn | auth | num |
|---|---|---|---|
| FR-manual | FR | manual | 45 |
| FR-mnet | FR | mnet | 4 |
| FR-cas | FR | cas | 1754 |
| EN-manual | EN | manual | 22 |
| EN-mnet | EN | mnet | 23 |
| EN-cas | EN | cas | 98 |
| CH-manual | CH | manual | 12 |
| CH-mnet | CH | mnet | 5 |
| CH-cas | CH | cas | 302 |
In order to display a bar graph on a data series per country, it is necessary, to feed the graph input, to produce a table transformed from the direct query output. The table to obtain is:
| pkey | auth | FR | EN | CH |
|---|---|---|---|---|
| manual | manual | 45 | 22 | 12 |
| mnet | mnet | 4 | 23 | 5 |
| cas | cas | 1754 | 98 | 302 |
which allows us to provide series “per authentication method” on the country entries.
We can then express the pivot method as:
“ pivot the column cn (country) around the pivot “auth” to distribute the data of the column num ”.
The pivot requires reprocessing the primary keys so that they match the new organisation of the output table.
Back to the configuration guide index - Back to the component index - Go to the generic query catalog - Back to the plugin index - Back to the catalog