OverviewΒΆ

What the plugin doesΒΆ

local_suap is a local type plugin for Moodle. It represents the Moodle-side integration between SUAP Edu (IFRN’s academic management system) and Moodle: via its HTTP API, it receives course structures, enrolments, cohorts, and grades from SUAP (typically through the Integrador AVA) and applies them to Moodle, creating or updating:

  • course categories (hierarchy: Logbooks/DiΓ‘rios β†’ Campus β†’ Course β†’ Term β†’ Class/Turma);

  • courses/rooms (logbooks/diΓ‘rios, coordination rooms, self-enrolment, practicals, and models);

  • users (students, teachers, and support staff) and dozens of custom profile fields;

  • cohorts (global groups) and their members;

  • enrolments and role assignments, including automatic suspension of students who leave official lists;

  • groups within each room (by entry year/term, class, campus hub, and program).

In addition to top-down synchronization (SUAP β†’ Moodle), the plugin exposes endpoints for the reverse direction: returning grades from Moodle’s gradebook back to SUAP (sync_down_grades) and synchronizing user preferences between Moodle and the AVA Panel (sync_user_preference/set_user_preference). See API & Services for the complete service list and SUAP β†’ Moodle Synchronization for the step-by-step enrolment synchronization process.

RequirementsΒΆ

  • $plugin->requires = 2021051700 in version.php (Moodle 3.11+).

  • The CI pipeline (.github/workflows/ci.yml) tests the plugin against MOODLE_401_STABLE, MOODLE_402_STABLE, and MOODLE_403_STABLE with PHP 8.3 on PostgreSQL and MariaDB.

Note

The requirement declared in version.php (Moodle 3.11+) is more permissive than the versions covered in CI (Moodle 4.1 to 4.3). Treat the CI matrix as the verified compatibility guarantee.

Integration with auth_suapΒΆ

local_suap does not depend on any other suite plugin to function, but it is consumed by auth_suap (SUAP OAuth2 authentication plugin): if local_suap is installed, auth_suap reads the default_user_preferences setting (configured in this plugin’s admin settings, see Installation) and applies those preferences upon initial account creation performed by OAuth2 login. local_suap also applies these preferences when creating a user via sync_up_enrolments (see SUAP β†’ Moodle Synchronization). This shared configuration via get_config('local_suap', 'default_user_preferences') is the direct interface between the two plugins.

Repository StructureΒΆ

local_suap/
β”œβ”€β”€ adminlib.php                  # Admin settings page definition (admin/settings.php)
β”œβ”€β”€ locallib.php                  # Generic helpers: get_or_create, create_or_update, custom fields
β”œβ”€β”€ login.php                     # Redirects to OAuth2 login (auth/oauth2)
β”œβ”€β”€ health.php                    # Raw diagnostic page (not the health API)
β”œβ”€β”€ healthcheck.php               # Simple endpoint: component/release/version in JSON
β”œβ”€β”€ settings.php                  # Registers admin page in Server menu
β”œβ”€β”€ version.php                   # Plugin version/release/maturity
β”œβ”€β”€ admin/
β”‚   β”œβ”€β”€ index.php                  # Lists received sync requests
β”‚   β”œβ”€β”€ view.php                   # Details a sync request (JSON payload, status, logs)
β”‚   └── tasklogs.php                # Scheduled task logs linked to a request
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ index.php                   # Dispatcher: validates requested service and delegates
β”‚   β”œβ”€β”€ servicelib.php               # Base service class: token authentication and response contract
β”‚   β”œβ”€β”€ health.php                   # "health" service: plugin/Moodle version without side effects
β”‚   β”œβ”€β”€ get_diarios.php               # Lists logbooks/coordinations/practicals of a user
β”‚   β”œβ”€β”€ get_atualizacoes_counts.php    # Unread messages/notifications count
β”‚   β”œβ”€β”€ set_favourite_course.php        # Favorite/unfavorite course
β”‚   β”œβ”€β”€ set_visible_course.php           # Change course visibility
β”‚   β”œβ”€β”€ set_user_preference.php           # Saves user preference from AVA Panel
β”‚   β”œβ”€β”€ sync_user_preference.php           # Forwards Moodle user preference to AVA Panel
β”‚   β”œβ”€β”€ sync_up_enrolments.php              # Main service: syncs categories/courses/users/enrolments
β”‚   └── sync_down_grades.php                 # Fetches grades and completion rates of a logbook for SUAP
β”œβ”€β”€ classes/
β”‚   β”œβ”€β”€ observer.php                 # User/enrolment event observers
β”‚   β”œβ”€β”€ Jsv4/                        # JSON Schema validation library (draft-04)
β”‚   β”œβ”€β”€ task/
β”‚   β”‚   β”œβ”€β”€ generate_report_task.php  # Scheduled task: self-instructional course report
β”‚   β”‚   └── sync_up_enrolments_task.php # Async adhoc task processing sync in background
β”‚   └── output/
β”‚       β”œβ”€β”€ renderer.php              # Plugin renderer
β”‚       └── relatorio_page.php        # Self-instructional course report page renderer
β”œβ”€β”€ cursos/relatorio.php             # Self-instructional course report page
β”œβ”€β”€ db/
β”‚   β”œβ”€β”€ install.php                   # Creates custom fields and tables on installation
β”‚   β”œβ”€β”€ install.xml                   # Table definitions
β”‚   β”œβ”€β”€ upgrade.php                    # Upgrade savepoints and field recreations
β”‚   β”œβ”€β”€ uninstall.php                   # Uninstallation hook
β”‚   β”œβ”€β”€ access.php                      # Capabilities: local/suap:adminview, local/suap:view_mooc_reports
β”‚   β”œβ”€β”€ events.php                       # Registered observers
β”‚   β”œβ”€β”€ tasks.php                        # Scheduling for generate_report_task
β”‚   └── migrate.php                      # Shared migration functions
β”œβ”€β”€ examples/                        # Sample JSON payloads accepted by API
β”œβ”€β”€ schemas/                         # Partial JSON schema for sync_up_enrolments payload
β”œβ”€β”€ templates/                        # Mustache templates: sync list/detail and reports
β”œβ”€β”€ lang/{en,es,fr,nl,pt_br,zh_cn}/local_suap.php # Language strings
β”œβ”€β”€ requests.http                     # API HTTP call examples
β”œβ”€β”€ docs/                             # Documentation (Sphinx)
└── .github/workflows/
    β”œβ”€β”€ ci.yml                        # moodle-plugin-ci workflow
    β”œβ”€β”€ release.yml                    # Generates installable ZIP on git tag
    └── docs.yml                       # Publishes documentation to GitHub Pages

OrganizationΒΆ

The repository lives under the suap-ava-suite organization as moodle-local_suap alongside other AVA/SUAP suite components used by IFRN β€” such as auth_suap and the AVA Panel.