Advanced Moodle Platform
Boost productivity using this create, custom, external, service. Includes structured workflows, validation checks, and reusable patterns for development.
Moodle LMS Development Skill
A Claude Code skill for developing and customizing the Moodle learning management system — covering plugin development, theme customization, web services API, database schema, and Moodle coding standards.
When to Use This Skill
Choose this skill when:
- Developing Moodle plugins (activities, blocks, local plugins)
- Customizing Moodle themes and layouts
- Integrating external services with Moodle's web services API
- Working with Moodle's database layer and form API
- Setting up Moodle development environments
- Debugging Moodle performance or functionality issues
Consider alternatives when:
- You need a simple course website (use a static site generator)
- You need real-time collaboration features (use Canvas or Google Classroom)
- You need a non-PHP LMS (use Open edX for Python)
Quick Start
# Set up Moodle development environment git clone https://github.com/moodle/moodle.git cd moodle php admin/cli/install.php --dbtype=pgsql --dbname=moodle --dbuser=moodle --dbpass=password # Create a new plugin php admin/tool/pluginskel/cli/generate.php --name=my_plugin --component=local_myplugin
// local/myplugin/version.php defined('MOODLE_INTERNAL') || die(); $plugin->component = 'local_myplugin'; $plugin->version = 2026031300; $plugin->requires = 2024042200; // Moodle 4.4 $plugin->maturity = MATURITY_STABLE; $plugin->release = '1.0.0';
Core Concepts
Plugin Types
| Type | Directory | Purpose |
|---|---|---|
| Activity Module | mod/ | Course activities (quiz, assignment) |
| Block | blocks/ | Sidebar content blocks |
| Local Plugin | local/ | Custom functionality, integrations |
| Authentication | auth/ | Custom login methods |
| Enrolment | enrol/ | Course enrolment methods |
| Theme | theme/ | UI customization |
| Report | report/ | Custom reports |
| Web Service | local/ | External API endpoints |
Database Layer
// Using Moodle's $DB API global $DB; // Insert a record $record = new stdClass(); $record->name = 'Test Item'; $record->timecreated = time(); $id = $DB->insert_record('local_myplugin_items', $record); // Query records $items = $DB->get_records('local_myplugin_items', ['userid' => $USER->id]); // Complex query with SQL $sql = "SELECT u.id, u.firstname, u.lastname, COUNT(s.id) as submissions FROM {user} u LEFT JOIN {assign_submission} s ON s.userid = u.id WHERE u.deleted = 0 GROUP BY u.id, u.firstname, u.lastname ORDER BY submissions DESC"; $results = $DB->get_records_sql($sql, [], 0, 10);
Web Services API
// Define web service functions // local/myplugin/db/services.php $functions = [ 'local_myplugin_get_items' => [ 'classname' => 'local_myplugin\external\get_items', 'description' => 'Get items for the current user', 'type' => 'read', 'ajax' => true, 'capabilities' => 'local/myplugin:view', ], ];
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
moodle_version | string | "4.4" | Target Moodle version |
php_version | string | "8.1" | Minimum PHP version |
db_type | string | "pgsql" | Database: pgsql, mysqli, mariadb |
debug_mode | boolean | true | Enable developer debugging |
plugin_type | string | "local" | Plugin type: local, mod, block, auth |
coding_standard | string | "moodle" | PHP coding standard for linting |
Best Practices
-
Follow Moodle coding standards strictly — Moodle has specific PHP coding standards enforced by automated checks; run
php admin/tool/phpunit/cli/util.php --buildcomponentconfigsand fix all issues before submitting plugins. -
Use the
$DBAPI, never raw SQL connections — Moodle's database API handles cross-database compatibility, parameter binding, and query logging; raw PDO/mysqli calls bypass security and logging. -
Define capabilities for all access control — every action in a Moodle plugin should check a capability with
has_capability(); this integrates with Moodle's role-based access control system. -
Use Moodle's form API for all user input —
moodleformhandles CSRF protection, validation, and accessibility; building custom HTML forms bypasses these protections. -
Test plugins across Moodle versions — Moodle deprecates APIs across versions; test your plugin against the minimum required version and the latest release to ensure compatibility.
Common Issues
Plugin not appearing after installation — Purge caches with php admin/cli/purge_caches.php. Check that version.php exists with the correct $plugin->component value matching the directory structure.
Database upgrade fails on existing installations — Schema changes require upgrade steps in db/upgrade.php. Never modify db/install.xml after initial release; always use upgrade steps with version checks.
Web service returns "Access denied" — Ensure the web service function is added to an external service, the user has a token for that service, and the user has the required capability assigned through their role.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Full-Stack Code Reviewer
Comprehensive code review skill that checks for security vulnerabilities, performance issues, accessibility, and best practices across frontend and backend code.
Test Suite Generator
Generates comprehensive test suites with unit tests, integration tests, and edge cases. Supports Jest, Vitest, Pytest, and Go testing.
Pro Architecture Workspace
Battle-tested skill for architectural, decision, making, framework. Includes structured workflows, validation checks, and reusable patterns for development.