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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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.
热度
- GitHub 星标
- 48k
- 排名
- #5251
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。