moodle-external-api-development – Coding skill for AI agents
This skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.
Install the moodle-external-api-development skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/moodle-external-api-development-beacd.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /moodle-external-api-development – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/moodle-external-api-development-beacd.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $moodle-external-api-development – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/moodle-external-api-development-beacd.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /moodle-external-api-development – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/moodle-external-api-development-beacd.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /moodle-external-api-development – then describe the task you want done.
SKILL.md content
Moodle External API Development
This skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.
Detailed Guide
Read [the detailed guide](references/detailed-guide.md) before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.
When to Use This Skill
- Creating custom web services for Moodle plugins
- Implementing REST/AJAX endpoints for course management
- Building APIs for quiz operations, user tracking, or reporting
- Exposing Moodle functionality to external applications
- Developing mobile app backends using Moodle
Illustrative Implementation Fragments
Simple Read API (Get Quiz Attempts)
<?php
namespace local_userlog\external;
defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/externallib.php");
use external_api;
use external_function_parameters;
use external_single_structure;
use external_value;
class get_quiz_attempts extends external_api {
public static function execute_parameters() {
return new external_function_parameters([
'userid' => new external_value(PARAM_INT, 'User ID'),
'courseid' => new external_value(PARAM_INT, 'Course ID')
]);
}
public static function execute($userid, $courseid) {
global $DB;
$params = self::validate_parameters(self::execute_parameters(), [
'userid' => $userid,
'courseid' => $courseid
]);
$context = \context_course::instance($params['courseid']);
self::validate_context($context);
require_capability('mod/quiz:viewreports', $context);
// Instructor-report endpoint; add group/quiz-specific visibility restrictions as needed.
$sql = "SELECT COUNT(*) AS quiz_attempts
FROM {quiz_attempts} qa
JOIN {quiz} q ON qa.quiz = q.id
WHERE qa.userid = :userid AND q.course = :courseid";
$attempts = $DB->get_field_sql($sql, [
'userid' => $params['userid'],
'courseid' => $params['courseid']
]);
return ['quiz_attempts' => (int)$attempts];
}
public static function execute_returns() {
return new external_single_structure([
'quiz_attempts' => new external_value(PARAM_INT, 'Total number of quiz attempts')
]);
}
}Complex Write API (Create Quiz from Categories)
The referenced create_quiz_from_categories.php is not bundled. Do not claim it
was read, executed or transaction-tested. Use the installed Moodle release's
activity/question APIs with context/capability checks, group visibility, bounded
input and rollback tests; direct insertion fragments in the guide are historical
schema illustrations, not a complete quiz builder. Use least-privilege test roles
and synthetic learner data, never production admin tokens in shell arguments.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Related skills
- movie-coupon – Fetch movie ticket coupons from platforms like Taopiaopiao and Maoyan. Returns coupon…
- muapi-media – Generate images and videos with MuAPI's schema-driven asynchronous media API while…
- multi-platform-apps-multi-platform – Build and deploy the same feature consistently across web, mobile, and desktop platforms…
- multiplayer – Multiplayer game development principles. Architecture, networking, synchronization.
- n8n-code-javascript – Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using…
- n8n-code-python – Write Python code in n8n Code nodes. Use when writing Python in n8n, using…
- n8n-code-tool – Write and debug JavaScript or Python for the AI-callable n8n Custom Code Tool, including…
- n8n-node-configuration – Operation-aware node configuration guidance. Use when configuring nodes, understanding…