Skip to content
Skillpedia
APIs & servers (backend)48k · #3637

moodle-external-api-development

Guides the creation of external web APIs for Moodle. Follows platform standards to ensure correct integration.

What it does

This tool helps you create new connections (APIs) for Moodle, an online learning system. It follows Moodle's rules and standards to ensure everything works correctly.

When to use it

  • ✓When you need to add custom features to Moodle.
  • ✓When building an app that connects to Moodle to manage courses.
  • ✓To have Moodle send information to other systems.

Example of what to ask your AI

“How can I create an API to get a student's quiz attempt count for a specific course?”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/moodle-external-api-development/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/moodle-external-api-development/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool uses a detailed guide that explains step-by-step how to build these connections. It ensures you follow Moodle's best practices and security standards.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add sickn33/agentic-awesome-skills --skill moodle-external-api-development

Or download just the file:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/moodle-external-api-development/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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

Examples from Real Implementation

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;

        self::validate_parameters(self::execute_parameters(), [
            'userid' => $userid,
            'courseid' => $courseid
        ]);

        $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' => $userid,
            'courseid' => $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)

See attached create_quiz_from_categories.php for a comprehensive example including:

  • Multiple database insertions
  • Course module creation
  • Quiz instance configuration
  • Random question selection with tags
  • Group-based access restrictions
  • Extensive error logging
  • Transaction management

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

What is an external API?

It's a way for different computer programs to talk to each other. For Moodle, it allows other systems to request or send information to it.

Do I need to be an expert programmer to use this?

Some basic programming knowledge is recommended, as the tool involves creating code. The detailed guide helps explain the steps.

What are Moodle's 'coding standards'?

These are rules that Moodle developers follow to write code in an organized, secure, and easy-to-understand way for other developers.

Details

Original description by the author

This skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#3637
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills