Skip to content

Moodle Plugin Integration

GamiBot uses two Moodle plugins. block_gamibot displays the chat; local_gamibot_manager provides configuration, Moodle AJAX services, usage data and course-file synchronisation. Both require Moodle 4.4 or later.

Chat request path

The Chat block's JavaScript calls the Manager's local_gamibot_manager/make_request module. That module uses Moodle's core/ajax API and the registered local_gamibot_manager_post_query external function (db/services.php and classes/external/submit_query.php). Requests include purpose, prompt, component, context ID and options. The Manager validates the Moodle context, applies its request permissions and routes the request to the configured Langflow purpose. Quiz scores and gamification statistics use separate registered external functions and the Gami API.

There is no /local/gamibot_manager/api/chat.php endpoint in this plugin. Integrations should use the Moodle service contract rather than constructing an unauthenticated URL.

The standard purposes are Clarify, Summarize and Quiz, with one site-administered Langflow API key. Their flow URLs and input IDs are maintained in classes/local/langflow_setup.php. See Langflow connections and Moodle setup.

Course-file synchronisation

The Manager observes Moodle course-module creation, update and deletion; Folder edits; course-section, course and category updates. The course settings hook also handles adding or removing GamiBot. Only File and Folder activities in a course with its own GamiBot block are eligible.

Observers and course saves queue work in local_gamibot_manager_queue; they do not send ingestion requests during the edit. The local_gamibot_manager\task\sync_resources scheduled task discovers availability changes and delivers bounded work. A database-backed gap and sender lock limit requests globally across courses and cron workers. Deletions precede replacement uploads. See Data ingestion for the payload, limits, retry behavior and inspection commands.

The webhook's secret is in the JSON body, not an HMAC header or signature. The receiver must authenticate it and process module deletions idempotently. Delivery success means HTTP 2xx from the receiver, not completion of remote indexing.

Administration and upgrades

The Manager's Basic settings page holds the shared Langflow key, separate Gami API and ingestion credentials, TLS verification, quiz length and ingestion pacing. Standard Langflow connections are provisioned automatically. An upgrade preserves existing records, tenant assignments and custom connections; conflicting legacy keys require an administrator to choose the shared key.

After deploying a new version, run Moodle's normal upgrade and ensure cron is active. The scheduled task Reset Gamibot manager user usage data remains separate from ingestion.

For the exact setup sequence, see Moodle setup.

Released under the MIT License.