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 = 2024100710 in version.php).

  • The CI pipeline (.github/workflows/ci.yml) tests the plugin against MOODLE_405_STABLE, MOODLE_500_STABLE and MOODLE_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.php uses get_config('local_suap', 'default_auth') (falling back to manual) and get_config('local_suap', 'default_user_preferences') when creating a user on demand (JIT provisioning β€” see HTTP API).

  • classes/group_helper.php reads the profile field campus_sigla, which is created by the auth_suap plugin (not by tool_painelava) β€” if that field does not exist, grouping by campus simply falls back to the default value SEM_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).