A powerful Moodle plugin that emits xAPI (Experience API) statements using the Moodle Logstore framework, enabling comprehensive learning analytics and interoperability with Learning Record Stores (LRS).
- Overview
- Key Features
- Requirements
- Installation
- Configuration
- Usage
- Architecture
- Development
- Testing
- Documentation
- Contributing
- Credits
- License
The Moodle Logstore xAPI Plugin transforms Moodle events into standardized xAPI statements and sends them to a Learning Record Store (LRS). This enables:
- Learning Analytics: Track and analyze learner interactions across your Moodle platform
- Interoperability: Share learning data with other xAPI-compliant systems
- Reporting: Generate comprehensive reports using your LRS of choice
- Compliance: Follow international standards for learning experience data
This plugin captures a wide range of Moodle activities including course completions, module interactions, assessments, and more, converting them into xAPI statements that provide detailed insights into the learning process.
- Comprehensive Event Coverage: Supports numerous Moodle events across core and activity modules
- Background Processing: Runs in background mode via cron to avoid blocking page responses
- Batch Processing: Efficiently processes events in configurable batches
- Error Handling: Robust error logging and retry mechanisms for failed events
- Historical Events: Process past events from your Moodle logs
- Flexible Configuration: Customize LRS endpoints, authentication, and processing parameters
- Standard Compliance: Generates valid xAPI 1.0.3 statements
- Extensible: Easy to add support for new events and custom statements
The plugin supports events from numerous Moodle modules including:
- Core (course completion, user enrollment, etc.)
- Assignments
- BigBlueButton
- Books
- Chat
- Choice
- Database
- Feedback
- Forum
- Glossary
- H5P
- Page
- Quiz
- SCORM
- Survey
- Wiki
- Workshop
- And many more...
- Moodle: Version 3.9 or later (tested up to 4.0.x)
- PHP: Version 7.2 or later
- PHP Extensions: json
- Composer: For dependency management
- Learning Record Store: Any xAPI-compliant LRS
| Moodle Version | Plugin Version | Status |
|---|---|---|
| 3.9+ | 2022101804 | β Stable |
| 4.0.x | 2022101804 | β Supported |
The plugin can be installed in three ways:
If you want to contribute to the plugin or need the latest development version:
-
Navigate to your Moodle installation directory:
cd /path/to/moodle/admin/tool/log/store -
Clone the repository:
git clone https://github.com/HASKI-RAK/Moodle-xAPI-Plugin.git xapi cd xapi -
Install dependencies:
php -r "readfile('https://getcomposer.org/installer');" | php rm -rf vendor php composer.phar install --prefer-source
-
Navigate to your Moodle site as an administrator to complete the installation
π Detailed Git Installation Guide
For production deployments:
- Download the latest release ZIP file from the releases page
- Extract and prepare dependencies:
unzip moodle-logstore_xapi.zip cd moodle-logstore_xapi php -r "readfile('https://getcomposer.org/installer');" | php php composer.phar install --no-dev
- Navigate to:
Site administration β Plugins β Install plugins - Upload the ZIP file and follow the installation wizard
π Detailed ZIP Installation Guide
- Download the plugin from the Moodle plugins directory
- Extract to
moodle/admin/tool/log/store/xapi - Complete the installation through the Moodle interface
π Detailed Download Installation Guide
After installation, configure the plugin to connect to your LRS:
-
Navigate to
Site administration β Plugins β Logging β Logstore xAPI -
Configure the following settings:
LRS Connection:
- Endpoint: Your LRS endpoint URL (e.g.,
http://your.lrs/xAPI) - Username: Your LRS basic auth key/username
- Password: Your LRS basic auth secret/password
- API Key Auth: Enable if using API key authentication
- Auth: API key value (if applicable)
Processing Options:
- Background Mode: Enable to process events via cron (recommended, enabled by default)
- Max Batch Size: Number of events to process per batch (default: 30)
- Endpoint: Your LRS endpoint URL (e.g.,
-
Click "Save changes"
- Navigate to
Site administration β Plugins β Logging β Manage log stores - Enable the "Logstore xAPI" plugin
π Detailed Configuration Guide | Enable Plugin Guide
Once enabled, the plugin automatically:
- Captures Moodle events as they occur
- Queues them for processing (in background mode)
- Transforms events into xAPI statements via scheduled cron tasks
- Sends statements to your configured LRS
To process events that occurred before the plugin was installed:
-- Move events from standard log to xAPI log table
INSERT INTO mdl_logstore_xapi_log
SELECT * FROM mdl_logstore_standard_log
WHERE timecreated BETWEEN [start_timestamp] AND [end_timestamp]The plugin will process these events during the next cron run.
Monitor plugin activity through:
- Error Logs: Check
classes/log/error_log.txtfor transformation or transmission errors - Reports: Navigate to the plugin's report page to view event processing status
- LRS Dashboard: View statements in your LRS interface
moodle-logstore_xapi/
βββ src/
β βββ transformer/ # Event-to-xAPI transformation logic
β β βββ events/ # Event handlers by module
β β βββ utils/ # Utility functions
β β βββ handler.php # Main transformer handler
β βββ loader/ # LRS communication layer
β βββ utils/ # Loading utilities
β βββ handler.php # Main loader handler
βββ classes/
β βββ log/ # Log store implementation
β βββ task/ # Scheduled tasks
β βββ form/ # Admin forms
β βββ privacy/ # GDPR compliance
βββ tests/ # PHPUnit tests
βββ docs/ # Documentation
βββ lang/ # Language strings
- Event Capture: Moodle events are captured by the logstore
- Queueing: Events are stored in
mdl_logstore_xapi_logtable - Transformation: Cron task transforms events to xAPI statements
- Loading: Statements are sent to the LRS in batches
- Cleanup: Successfully processed events are removed from the queue
The plugin follows a layered architecture:
- Data Layer (Repository): Reads/writes data from database, LRS, or external APIs
- Business Layer (Service): Transforms and processes data
- Presentation Layer: Admin interfaces and reports
- Fork and clone the repository
- Install dependencies:
composer install
- Create a new branch for your feature:
git checkout -b feature/your-feature-name
To add support for a new Moodle event:
-
Create Transformer Function: Add a new file in
src/transformer/events/[module]/[event_name].php -
Map the Event: Update
src/transformer/get_event_function_map.phpto map the event to your transformer -
Create Tests: Add test cases in
tests/[module]/[event_name]/with:test.php- Test runnerdata.json- Mocked database dataevent.json- Mocked event datastatements.json- Expected output
-
Run Tests: Verify your implementation:
./vendor/bin/phpunit
π New Events Guide | New Statements Guide
- Follow Moodle coding standards
- Write comprehensive tests for new features
- Document public functions and complex logic
- Ensure backward compatibility
Execute all tests:
./vendor/bin/phpunitRun specific test suite:
./vendor/bin/phpunit tests/mod_assign/Each test consists of four files:
test.php- Executes the testdata.json- Mocks Moodle databaseevent.json- Mocks logstore eventstatements.json- Expected xAPI statements
π Testing Guide
The plugin uses GitHub Actions for automated testing across multiple Moodle and PHP versions. See .github/workflows/moodle-plugin-ci.yml for details.
Comprehensive documentation is available in the docs/ directory:
We welcome contributions! Here's how you can help:
- Fork the Repository: Create your own fork on GitHub
- Create a Branch: Make your changes in a feature branch
- Follow Guidelines: Adhere to coding standards and include tests
- Submit a Pull Request: Use our PR template
- Code Review: Respond to feedback from maintainers
Found a bug or have a feature request? Please use our issue tracker and follow the issue template.
- Original Repository: xAPI-vle/moodle-logstore_xapi
- Full-Event Extension: PR #841
- Jerret Fowler - jerrett.fowler@gmail.com
- Ryan Smith
- David Pesce - david.pesce@exputo.com
This fork is maintained by the HASKI-RAK team with additional features and enhancements.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- Documentation: Check the docs directory
- Issues: GitHub Issue Tracker
- Community: Join discussions in the issue tracker
Note: Before creating a Moodle Plugin ZIP for distribution, ensure dependencies are installed:
composer install --no-devFor development:
composer install --prefer-source