OverviewΒΆ
What the plugin doesΒΆ
tool_painelava is an Admin tool plugin (installed at admin/tool/painelava) that acts
as a bridge between Moodle and the Painel AVA (an external application, referred to in the
code as βthe Django panelβ). It offers two clearly distinct integration surfaces:
a native Moodle web service function (
tool_painelava_get_user_courses), registered in the core web services subsystem and protected by Moodleβs capability mechanism β see Web service API;a set of dedicated HTTP endpoints, outside the web services subsystem, authenticated by a simple token sent in an HTTP header, used for operations that the web service API does not cover (enrolment, suspension, progress, preferences, favourites, course visibility, etc.) β see HTTP API.
In addition, the plugin automatically creates course custom fields (category Painel AVA)
used to classify courses and control self-enrolment, registers its own call log table
(tool_painelava_logging) and provides a scheduled task β see Custom data and fields.
RequirementsΒΆ
Moodle 4.5.0+ (
$plugin->requires=2024100710inversion.php).The CI pipeline (
.github/workflows/ci.yml) tests the plugin againstMOODLE_405_STABLE,MOODLE_500_STABLEandMOODLE_501_STABLE, with PHP 8.1 to 8.4 (some combinations excluded due to incompatibility β PHP 8.4 is not tested with Moodle 4.5, PHP 8.1 is not tested with Moodle 5.0+).
Warning
The repositoryβs README.md states that the requirements are βMoodle 4.0 or higher
(requires = 2022041900)β and βPHP 7.4+β. These values are outdated: the current
version.php defines requires = 2024100710 (Moodle 4.5) and the CI matrix only tests
PHP 8.1 onwards. This documentation follows what is actually in the code.
Implicit (optional) dependenciesΒΆ
The plugin does not declare formal dependencies in version.php, but part of the code only
has its full effect if the local_suap plugin is installed:
api/enrol_course.phpusesget_config('local_suap', 'default_auth')(falling back tomanual) andget_config('local_suap', 'default_user_preferences')when creating a user on demand (JIT provisioning β see HTTP API).classes/group_helper.phpreads the profile fieldcampus_sigla, which is created by theauth_suapplugin (not bytool_painelava) β if that field does not exist, grouping by campus simply falls back to the default valueSEM_CAMPUS.
Repository structureΒΆ
tool_painelava/
βββ adminlib.php # Admin settings page class
βββ settings.php # Settings page registration
βββ locallib.php # Generic helpers (config, aget, get_or_create...)
βββ version.php # Plugin version/release/maturity
βββ api/ # Dedicated HTTP endpoints (token authentication)
β βββ index.php # v1 dispatcher (service whitelist)
β βββ servicelib.php # Base class tool_painelava\service
β βββ get_diarios.php # User course timeline, with filters/tabs
β βββ get_progresso.php # Completion percentage per course
β βββ get_atualizacoes_counts.php # Unread message/notification counts
β βββ get_course_info.php # Course details, teachers and workload
β βββ set_favourite_course.php # Marks/unmarks a course as favourite
β βββ set_visible_course.php # Changes course visibility
β βββ set_user_preference.php # Saves a user preference
β βββ sync_user_preference.php # Forwards a preference to the Painel AVA (Django)
β βββ enrol_course.php # Enrols (or creates and enrols) a user
β βββ suspend_enrol.php # Suspends a user's enrolment
β βββ v2/ # v2 dispatcher (endpoints still placeholder)
β βββ index.php # v2 dispatcher (own whitelist)
β βββ get_conversas.php, get_notificacoes.php, get_salas.php
β βββ patch_conversa.php, patch_notificacao.php
β βββ token_refresh.php, token_revoke.php
βββ classes/
β βββ external/get_user_courses.php # Web service function implementation
β βββ event/user_courses_requested.php # Event triggered by the web service function
β βββ task/sync_courses.php # Scheduled task (placeholder)
β βββ group_helper.php # Automatic campus grouping on self-enrolment
βββ db/
β βββ access.php # Capabilities (tool/painelava:view, :viewothercourses)
β βββ services.php # Web service function registration
β βββ tasks.php # Scheduled task registration
β βββ events.php # Event observers (currently empty)
β βββ install.php / upgrade.php # Both delegate to migrate.php
β βββ migrate.php # Creates the log table and course custom fields
β βββ install.xml # Schema for the tool_painelava_logging table
β βββ uninstall.php # Removes plugin settings
βββ lang/{en,pt_br}/tool_painelava.php # Language strings
βββ tests/external/external_test.php # PHPUnit tests for the web service function
βββ requests.http # Example calls to the HTTP endpoints (api/index.php)
βββ test_debug.php # CLI debugging script (not part of the API)
βββ docs/ # This documentation (Sphinx)
βββ .github/workflows/
βββ ci.yml # moodle-plugin-ci (lint, PHPCS, PHPUnit, Behat...)
βββ release.yml # Builds an installable ZIP on every tag
βββ docs.yml # Publishes this documentation to GitHub Pages
Note
test_debug.php, at the repository root, is a debugging script run via CLI
(CLI_SCRIPT) to manually inspect a userβs course timeline. It is not registered anywhere
in the plugin (it does not appear in db/services.php nor in api/index.php) and is not
part of the documented API surface β it is merely a development support tool.
OrganisationΒΆ
The repository lives in the suap-ava-suite organisation
as moodle-tool_painelava, alongside other components of the AVA/SUAP suite used by IFRN
(for example, auth_suap, referenced above as the source of the campus_sigla profile
field).