A

Advanced Moodle Platform

Boost productivity using this create, custom, external, service. Includes structured workflows, validation checks, and reusable patterns for development.

SkillClipticsdevelopmentv1.0.0MIT
0 views0 copies

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

TypeDirectoryPurpose
Activity Modulemod/Course activities (quiz, assignment)
Blockblocks/Sidebar content blocks
Local Pluginlocal/Custom functionality, integrations
Authenticationauth/Custom login methods
Enrolmentenrol/Course enrolment methods
Themetheme/UI customization
Reportreport/Custom reports
Web Servicelocal/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

ParameterTypeDefaultDescription
moodle_versionstring"4.4"Target Moodle version
php_versionstring"8.1"Minimum PHP version
db_typestring"pgsql"Database: pgsql, mysqli, mariadb
debug_modebooleantrueEnable developer debugging
plugin_typestring"local"Plugin type: local, mod, block, auth
coding_standardstring"moodle"PHP coding standard for linting

Best Practices

  1. Follow Moodle coding standards strictly — Moodle has specific PHP coding standards enforced by automated checks; run php admin/tool/phpunit/cli/util.php --buildcomponentconfigs and fix all issues before submitting plugins.

  2. Use the $DB API, 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.

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

  4. Use Moodle's form API for all user inputmoodleform handles CSRF protection, validation, and accessibility; building custom HTML forms bypasses these protections.

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

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates