Skip to content

HASKI-RAK/Moodle-xAPI-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Moodle Logstore xAPI Plugin

Moodle Plugin License: GPL v3

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).

πŸ“‹ Table of Contents

🎯 Overview

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.

✨ Key Features

  • 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

Supported Moodle Modules

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...

πŸ“¦ Requirements

  • 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

Compatibility

Moodle Version Plugin Version Status
3.9+ 2022101804 βœ… Stable
4.0.x 2022101804 βœ… Supported

πŸš€ Installation

The plugin can be installed in three ways:

Method 1: Install via Git (Recommended for Development)

If you want to contribute to the plugin or need the latest development version:

  1. Navigate to your Moodle installation directory:

    cd /path/to/moodle/admin/tool/log/store
  2. Clone the repository:

    git clone https://github.com/HASKI-RAK/Moodle-xAPI-Plugin.git xapi
    cd xapi
  3. Install dependencies:

    php -r "readfile('https://getcomposer.org/installer');" | php
    rm -rf vendor
    php composer.phar install --prefer-source
  4. Navigate to your Moodle site as an administrator to complete the installation

πŸ“– Detailed Git Installation Guide

Method 2: Install via ZIP File

For production deployments:

  1. Download the latest release ZIP file from the releases page
  2. 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
  3. Navigate to: Site administration β†’ Plugins β†’ Install plugins
  4. Upload the ZIP file and follow the installation wizard

πŸ“– Detailed ZIP Installation Guide

Method 3: Direct Download

  1. Download the plugin from the Moodle plugins directory
  2. Extract to moodle/admin/tool/log/store/xapi
  3. Complete the installation through the Moodle interface

πŸ“– Detailed Download Installation Guide

βš™οΈ Configuration

After installation, configure the plugin to connect to your LRS:

Basic Configuration

  1. Navigate to Site administration β†’ Plugins β†’ Logging β†’ Logstore xAPI

  2. 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)
  3. Click "Save changes"

Enable the Plugin

  1. Navigate to Site administration β†’ Plugins β†’ Logging β†’ Manage log stores
  2. Enable the "Logstore xAPI" plugin

πŸ“– Detailed Configuration Guide | Enable Plugin Guide

πŸ”§ Usage

Real-time Event Processing

Once enabled, the plugin automatically:

  1. Captures Moodle events as they occur
  2. Queues them for processing (in background mode)
  3. Transforms events into xAPI statements via scheduled cron tasks
  4. Sends statements to your configured LRS

Historical Events

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.

πŸ“– Historical Events Guide

Monitoring

Monitor plugin activity through:

  • Error Logs: Check classes/log/error_log.txt for 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

πŸ—οΈ Architecture

Component Overview

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

Data Flow

  1. Event Capture: Moodle events are captured by the logstore
  2. Queueing: Events are stored in mdl_logstore_xapi_log table
  3. Transformation: Cron task transforms events to xAPI statements
  4. Loading: Statements are sent to the LRS in batches
  5. Cleanup: Successfully processed events are removed from the queue

Code Structure

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

πŸ‘¨β€πŸ’» Development

Setting Up Development Environment

  1. Fork and clone the repository
  2. Install dependencies:
    composer install
  3. Create a new branch for your feature:
    git checkout -b feature/your-feature-name

Adding Support for New Events

To add support for a new Moodle event:

  1. Create Transformer Function: Add a new file in src/transformer/events/[module]/[event_name].php

  2. Map the Event: Update src/transformer/get_event_function_map.php to map the event to your transformer

  3. Create Tests: Add test cases in tests/[module]/[event_name]/ with:

    • test.php - Test runner
    • data.json - Mocked database data
    • event.json - Mocked event data
    • statements.json - Expected output
  4. Run Tests: Verify your implementation:

    ./vendor/bin/phpunit

πŸ“– New Events Guide | New Statements Guide

Code Standards

  • Follow Moodle coding standards
  • Write comprehensive tests for new features
  • Document public functions and complex logic
  • Ensure backward compatibility

πŸ§ͺ Testing

Running Tests

Execute all tests:

./vendor/bin/phpunit

Run specific test suite:

./vendor/bin/phpunit tests/mod_assign/

Test Structure

Each test consists of four files:

  • test.php - Executes the test
  • data.json - Mocks Moodle database
  • event.json - Mocks logstore event
  • statements.json - Expected xAPI statements

πŸ“– Testing Guide

Continuous Integration

The plugin uses GitHub Actions for automated testing across multiple Moodle and PHP versions. See .github/workflows/moodle-plugin-ci.yml for details.

πŸ“š Documentation

Comprehensive documentation is available in the docs/ directory:

Installation Guides

Configuration & Usage

Development

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the Repository: Create your own fork on GitHub
  2. Create a Branch: Make your changes in a feature branch
  3. Follow Guidelines: Adhere to coding standards and include tests
  4. Submit a Pull Request: Use our PR template
  5. Code Review: Respond to feedback from maintainers

Reporting Issues

Found a bug or have a feature request? Please use our issue tracker and follow the issue template.

πŸ“– Contributing Guidelines

πŸ‘ Credits

Original Plugin

Maintainers

HASKI Fork

This fork is maintained by the HASKI-RAK team with additional features and enhancements.

πŸ“„ License

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.

πŸ”— Links

πŸ†˜ Support


Note: Before creating a Moodle Plugin ZIP for distribution, ensure dependencies are installed:

composer install --no-dev

For development:

composer install --prefer-source

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages