跳到正文
Skillpedia
API 与服务器(后端)48k · #5251

moodle-external-api-development

它能做什么

这个工具可以帮你为在线学习系统 Moodle 创建新的连接方式(也就是 API)。它会遵循 Moodle 的规则和标准,确保一切都能正常工作。

适用场景

  • ✓当你需要为 Moodle 添加自定义功能时。
  • ✓当你要开发一个连接 Moodle 来管理课程的应用时。
  • ✓当你希望 Moodle 把信息发送给其他系统时。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/moodle-external-api-development/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“如何创建一个 API,用来获取某个学生在指定课程中的测验尝试次数?”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具使用了一份详细的指南,一步一步讲解如何搭建这些连接。它能确保你遵循 Moodle 的最佳实践和安全标准。

技术内容(原始 SKILL.md)

作者在 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.
常见问题

什么是外部 API?

它是让不同计算机程序之间互相通信的一种方式。对 Moodle 来说,它允许其他系统向它请求信息,或者向它发送信息。

我需要是编程高手才能用吗?

建议你具备一些基础编程知识,因为这个工具涉及编写代码。详细的指南会帮你讲清楚每个步骤。

Moodle 的“编码规范”是什么?

这是 Moodle 开发者需要遵守的一套规则,让代码写得有条理、更安全,并且便于其他开发者理解。

详情

作者的原始描述

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

热度

GitHub 星标
48k
排名
#5251
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能