Statboard API
Versions
Current version
v1.0.5 (2026062601)
v1.0.5
Plugin type: Local plugins
Frankenstyle component name: local_su_statboard_api
Version build number: 2026062601
Version release name: v1.0.5
Maturity: Stable
Supported Moodle versions: 4.2, 4.3, 4.4, 4.5, 5.0, 5.1, 5.2
Repository URL (Git): https://github.com/dev-capsule/moodle-local_su_statboard_api/
Repository branch:
Repository tag:
Issue/bug tracker URL: https://github.com/dev-capsule/moodle-local_su_statboard_api/issues
Changelog
All notable changes to the local_su_statboard_api plugin are documented in this file.
The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.
1.0.5 — 2026-06-26
Added
- Auto-accept site policies for the webservice user: when a Moodle admin
publishes a new privacy policy or terms of service, all users — including
machine accounts — are normally required to accept it before any further
action. Thewebservice_statboard_*account cannot click "I accept" in a
browser, which caused all API calls to fail with "Politique du site pas
acceptée" after each policy update.
db/install.phpnow auto-accepts all active policies for the dedicated
webservice user at install time.db/upgrade.phpdoes the same on upgrade for any existing
webservice_statboard_*users.- Compatible with both the legacy
{user}.policyagreedflag and the modern
tool_policy_acceptancesmechanism (Moodle 3.7+). - New helper
local_su_statboard_api_accept_all_policies($userid)in
locallib.php.
1.0.4 — 2026-06-26
Changed
- Issue #4 (HIGH): live
max_connections(today's count) no longer queries
{logstore_standard_log}. It now reads{user}.lastaccess(≤ 50k rows,
indexed), consistent with the existingusers_online_nowpattern. Zero
runtime queries on the logstore from the API endpoint. - Issue #4 (HIGH): hourly aggregation cron switched from
eventname NOT LIKE '%webservice%'to an exact
eventname = '\core\event\user_loggedin'filter (indexed), for
consistency with the daily cron and faster execution. - Issue #7 (LOW): external service implementation moved from legacy
externallib.phpto the modern namespaced
classes/external/get_statboard_stats.php
(\local_su_statboard_api\external\get_statboard_stats::execute()).
The web service function name remains
local_su_statboard_api_get_statboard_stats— no client change required.
Removed
externallib.php(replaced by the namespaced class above).
1.0.3 — 2026-06-17
Changed (breaking)
- Minimum Moodle version raised to 4.2 (
2023042400+). Moodle 4.1 LTS reached its
end-of-extended-support in December 2025; this release uses the modern
\core_external\utilAPI introduced in 4.2 which avoids PHPUnit isolation issues
during installation. Users on Moodle 4.1 should stay on plugin v1.0.2 or upgrade Moodle first.
Changed (breaking, fixed by automatic upgrade)
Tables renamed to follow the Frankenstyle convention (
plugintype_pluginname_tablename):
su_statboard_daily_stats'local_su_statboard_api_daysu_statboard_hourly_stats'local_su_statboard_api_hour
(Short suffixes used because Moodle's
sql_generatorenforces a 28-character table-name limit for Oracle compatibility.)
- Existing installations are migrated automatically by
db/upgrade.php— no manual action required.
Fixed
- Security (BLOCKER): added
self::validate_context()call inget_statboard_stats()(Moodle external service guideline). - Security: replaced two
PARAM_RAWbyPARAM_TEXTfor submit-button parameters intoken_settings.php. - Best practice: use
get_config()instead of direct DML on{config_plugins}in the uninstaller.
Removed
- Dead cache definition
statboard_hourlythat was declared but never used.hourly_connectionsreads directly from the aggregated summary table (≤ 24 rows per call, already instant).
Added
- GitHub Actions CI workflow (
.github/workflows/ci.yml) running Moodle Plugin CI across Moodle 4.2 ' 4.5, PHP 8.0 ' 8.3, PostgreSQL and MariaDB (12 jobs). db/upgrade.phpwith the v1.0.3 table-rename migration block.
1.0.2 — 2026-04-29
Changed
- Plugin renamed from
local_su_dashboard_apitolocal_su_statboard_api. - Documentation overhaul:
DEVELOPERS_fr.mdandDEVELOPERS_en.md,README.md,CHANGELOG.md,LICENSE(GPL v3). - Full Moodle CodeChecker compliance (0 errors, 0 warnings).
- PHPUnit test suite (external, privacy provider, daily aggregation task).
1.0.0 — 2026-04-29
Added
- Initial public release of the Statboard API plugin.
- Single REST web service
local_su_statboard_api_get_statboard_statsreturning a complete metric set in one call:
total_users— active users (not deleted, not suspended).total_courses— number of courses excluding the front page.users_online_now— real users active in the last 5 minutes (excludeswebserviceandnologinaccounts).max_connections— daily login peak over the last 30 days, with date.hourly_connections— hourly snapshot of distinct active users.quiz_completed_today— finished quiz attempts of the day.
- MUC cache strategy with per-metric TTL (
statboard_totals1 h,statboard_max15 min,statboard_quiz5 min);users_online_nowalways live;hourly_connectionsread directly from the summary table. - Two scheduled tasks (
blocking=1for cluster safety):
\local_su_statboard_api\task\aggregate_daily_stats— nightly login aggregation (00:05).\local_su_statboard_api\task\aggregate_hourly_stats— hourly snapshot aggregation (HH:01).
- Two custom tables
su_statboard_daily_stats(≤ 30 rows) andsu_statboard_hourly_stats(≤ 720 rows) populated by the cron, with automatic 30-day rolling purge. - Automated installer that creates the dedicated webservice user, attaches the manager role, registers the external service and generates a permanent token.
- Automated uninstaller that performs full cleanup of users, tokens, services and configuration.
- Token management UI (
token_settings.php) with regeneration, expiration toggle, automatic detection and correction of inconsistencies between configuration and database state. - Read-only token consultation page (
view_token.php). - Two capabilities:
local/su_statboard_api:viewandlocal/su_statboard_api:managetokensettings. - Full Privacy API implementation covering metadata declaration, user data export and deletion (single user, multiple users, all users in context).
- Custom event
\local_su_statboard_api\event\stats_viewedfired on every API call for audit purposes. - Multi-database support: PostgreSQL 12+, MySQL 5.7.33+, MariaDB 10.6+. Installation aborts with a clear error on unsupported databases (MSSQL, Oracle, SQLite).
- Localised in 7 languages: English (reference), French, German, Spanish, Italian, Portuguese (Portugal), Portuguese (Brazil).
- Portable SQL helpers (
local_su_statboard_api_get_db_compatible_sql) that branch between PostgreSQL and MySQL/MariaDB syntax for date and hour operations.
Compatibility
- Requires Moodle 4.1 or later (
2022112800+).
v1.0.5 (2026042902)
v1.0.5
Plugin type: Local plugins
Frankenstyle component name: local_su_statboard_api
Version build number: 2026042902
Version release name: v1.0.5
Maturity: Stable
Supported Moodle versions: 4.1, 4.2, 4.3, 4.4, 4.5, 5.0
Repository URL (Git):
Repository branch:
Repository tag:
Issue/bug tracker URL: https://github.com/dev-capsule/moodle-local_su_statboard_api/issues
Changelog
All notable changes to the local_su_statboard_api plugin are documented in this file.
The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.
1.0.5 — 2026-06-26
Added
- Auto-accept site policies for the webservice user: when a Moodle admin
publishes a new privacy policy or terms of service, all users — including
machine accounts — are normally required to accept it before any further
action. Thewebservice_statboard_*account cannot click "I accept" in a
browser, which caused all API calls to fail with "Politique du site pas
acceptée" after each policy update.
db/install.phpnow auto-accepts all active policies for the dedicated
webservice user at install time.db/upgrade.phpdoes the same on upgrade for any existing
webservice_statboard_*users.- Compatible with both the legacy
{user}.policyagreedflag and the modern
tool_policy_acceptancesmechanism (Moodle 3.7+). - New helper
local_su_statboard_api_accept_all_policies($userid)in
locallib.php.
1.0.4 — 2026-06-26
Changed
- Issue #4 (HIGH): live
max_connections(today's count) no longer queries
{logstore_standard_log}. It now reads{user}.lastaccess(≤ 50k rows,
indexed), consistent with the existingusers_online_nowpattern. Zero
runtime queries on the logstore from the API endpoint. - Issue #4 (HIGH): hourly aggregation cron switched from
eventname NOT LIKE '%webservice%'to an exact
eventname = '\core\event\user_loggedin'filter (indexed), for
consistency with the daily cron and faster execution. - Issue #7 (LOW): external service implementation moved from legacy
externallib.phpto the modern namespaced
classes/external/get_statboard_stats.php
(\local_su_statboard_api\external\get_statboard_stats::execute()).
The web service function name remains
local_su_statboard_api_get_statboard_stats— no client change required.
Removed
externallib.php(replaced by the namespaced class above).
1.0.3 — 2026-06-17
Changed (breaking)
- Minimum Moodle version raised to 4.2 (
2023042400+). Moodle 4.1 LTS reached its
end-of-extended-support in December 2025; this release uses the modern
\core_external\utilAPI introduced in 4.2 which avoids PHPUnit isolation issues
during installation. Users on Moodle 4.1 should stay on plugin v1.0.2 or upgrade Moodle first.
Changed (breaking, fixed by automatic upgrade)
Tables renamed to follow the Frankenstyle convention (
plugintype_pluginname_tablename):
su_statboard_daily_stats'local_su_statboard_api_daysu_statboard_hourly_stats'local_su_statboard_api_hour
(Short suffixes used because Moodle's
sql_generatorenforces a 28-character table-name limit for Oracle compatibility.)
- Existing installations are migrated automatically by
db/upgrade.php— no manual action required.
Fixed
- Security (BLOCKER): added
self::validate_context()call inget_statboard_stats()(Moodle external service guideline). - Security: replaced two
PARAM_RAWbyPARAM_TEXTfor submit-button parameters intoken_settings.php. - Best practice: use
get_config()instead of direct DML on{config_plugins}in the uninstaller.
Removed
- Dead cache definition
statboard_hourlythat was declared but never used.hourly_connectionsreads directly from the aggregated summary table (≤ 24 rows per call, already instant).
Added
- GitHub Actions CI workflow (
.github/workflows/ci.yml) running Moodle Plugin CI across Moodle 4.2 ' 4.5, PHP 8.0 ' 8.3, PostgreSQL and MariaDB (12 jobs). db/upgrade.phpwith the v1.0.3 table-rename migration block.
1.0.2 — 2026-04-29
Changed
- Plugin renamed from
local_su_dashboard_apitolocal_su_statboard_api. - Documentation overhaul:
DEVELOPERS_fr.mdandDEVELOPERS_en.md,README.md,CHANGELOG.md,LICENSE(GPL v3). - Full Moodle CodeChecker compliance (0 errors, 0 warnings).
- PHPUnit test suite (external, privacy provider, daily aggregation task).
1.0.0 — 2026-04-29
Added
- Initial public release of the Statboard API plugin.
- Single REST web service
local_su_statboard_api_get_statboard_statsreturning a complete metric set in one call:
total_users— active users (not deleted, not suspended).total_courses— number of courses excluding the front page.users_online_now— real users active in the last 5 minutes (excludeswebserviceandnologinaccounts).max_connections— daily login peak over the last 30 days, with date.hourly_connections— hourly snapshot of distinct active users.quiz_completed_today— finished quiz attempts of the day.
- MUC cache strategy with per-metric TTL (
statboard_totals1 h,statboard_max15 min,statboard_quiz5 min);users_online_nowalways live;hourly_connectionsread directly from the summary table. - Two scheduled tasks (
blocking=1for cluster safety):
\local_su_statboard_api\task\aggregate_daily_stats— nightly login aggregation (00:05).\local_su_statboard_api\task\aggregate_hourly_stats— hourly snapshot aggregation (HH:01).
- Two custom tables
su_statboard_daily_stats(≤ 30 rows) andsu_statboard_hourly_stats(≤ 720 rows) populated by the cron, with automatic 30-day rolling purge. - Automated installer that creates the dedicated webservice user, attaches the manager role, registers the external service and generates a permanent token.
- Automated uninstaller that performs full cleanup of users, tokens, services and configuration.
- Token management UI (
token_settings.php) with regeneration, expiration toggle, automatic detection and correction of inconsistencies between configuration and database state. - Read-only token consultation page (
view_token.php). - Two capabilities:
local/su_statboard_api:viewandlocal/su_statboard_api:managetokensettings. - Full Privacy API implementation covering metadata declaration, user data export and deletion (single user, multiple users, all users in context).
- Custom event
\local_su_statboard_api\event\stats_viewedfired on every API call for audit purposes. - Multi-database support: PostgreSQL 12+, MySQL 5.7.33+, MariaDB 10.6+. Installation aborts with a clear error on unsupported databases (MSSQL, Oracle, SQLite).
- Localised in 7 languages: English (reference), French, German, Spanish, Italian, Portuguese (Portugal), Portuguese (Brazil).
- Portable SQL helpers (
local_su_statboard_api_get_db_compatible_sql) that branch between PostgreSQL and MySQL/MariaDB syntax for date and hour operations.
Compatibility
- Requires Moodle 4.1 or later (
2022112800+).