Moodle-Claw Skill
This skill allows you to interact with a Moodle learning management system (LMS) to help users with their courses, assignments, and learning materials.
Setup
If
moodle-claw binary is missing, download it:
URL="https://github.com/4strium/moodle-claw/releases/download/v1.0/moodle-claw"
SHA256="0ce9e6ad4e42c626ebe2c4ce79bde23da3386dc8e4b54a87da0a345a1a0252aa"
curl -L -o moodle-claw "$URL"
echo "$SHA256 moodle-claw" | sha256sum -c -
chmod +x moodle-claw
Configuration
Before using moodle-claw commands, the user needs to configure their Moodle connection:
CODEBLOCK0
This will interactively prompt for:
- 1. Moodle server URL - e.g., INLINECODE1
- Authentication method - Token (direct), SSO (redirect URL), or Username/Password
- Download path - Where to save downloaded files
Authentication Methods
Option 1: Direct Token
If you already have a 32-character hex token:
CODEBLOCK1
Option 2: SSO Authentication (recommended for universities)
For institutions using SSO (Single Sign-On):
- 1. Log into your Moodle account in a web browser
- Open the developer console (press F12) and go to the Network tab
- Visit this URL in the same browser tab (replace with your Moodle URL):
https://YOUR_MOODLE_URL/admin/tool/mobile/launch.php?service=moodle_mobile_app&passport=12345&urlscheme=moodlemobile
- 4. The page will fail to load - this is expected! An error will occur.
- In the Network tab, find the failed request (it should be red/failed)
- Right-click on the failed request > Copy > Copy link address
- The URL looks like:
moodlemobile://token=BASE64_ENCODED_STRING
- 7. Use the copied URL:
CODEBLOCK3
Or use interactive mode and select "SSO (redirect URL)":
CODEBLOCK4
Option 3: Username/Password
For institutions allowing direct login:
CODEBLOCK5
Available Commands
Check Status
moodle-claw status [--output json]
Shows current configuration and connection status.
List Courses
moodle-claw courses [--filter "math"] [--refresh] [--output json]
Lists all enrolled courses. Use
--refresh to fetch latest from server.
View Course Content
moodle-claw content "Course Name" [--section "TD2"] [--output json]
moodle-claw content 12345 # by course ID
Shows the structure of a course (sections, modules, files).
Search Content
moodle-claw search "exercise" [--course "Physics"] [--type file] [--output json]
Searches for content across courses.
Download Files
moodle-claw get "Course/Section/file.pdf" [--course "Math"] [--dest /tmp]
moodle-claw get --url "https://moodle.../pluginfile.php/..." [--dest /tmp]
# Extract text from PDF files (recommended for reading content)
moodle-claw get "file.pdf" --text --output json
Downloads a file and returns its local path. Use
--text (
-t) to automatically extract text content from PDF files.
Sync Course
moodle-claw sync "Course Name" [--dest ~/Courses] [--no-confirm]
moodle-claw sync # syncs all enabled courses
Downloads all files from a course.
Usage Patterns
When user asks about a course
- 1. First, list courses to find the right one: INLINECODE6
- Then get its content: INLINECODE7
- If needed, download specific files: INLINECODE8
When user asks about specific content (e.g., "TD2", "exercise 3")
- 1. Search for the content: INLINECODE9
- Download and extract text from PDF: INLINECODE10
- The extracted text will be included in the output for you to analyze
When user wants to work offline
- 1. Sync the entire course: INLINECODE11
- Files will be available locally for reading
Output Formats
All commands support --output json for structured output, or the default markdown format for human readability.
Example Interactions
User: "Explique-moi le cours de mécanique"
CODEBLOCK12
User: "Quel est l'exercice 3 du TD2 en maths?"
CODEBLOCK13
User: "Télécharge tous les fichiers du cours de physique"
CODEBLOCK14
Notes
- - Files are cached locally after first download
- Use
--refresh on moodle-claw courses to update the course list from server - Course names support fuzzy matching (partial names work)
- The
--output json flag is useful for parsing structured data - Use
--text with moodle-claw get to extract text from PDF files directly
Security / Vetting
- - Source code fully open-source
- SHA256 checksum verified before execution
- Token, credentials and configuration saved locally on this machine
Moodle-Claw 技能
该技能允许您与Moodle学习管理系统(LMS)进行交互,帮助用户处理课程、作业和学习材料。
设置
如果缺少 moodle-claw 二进制文件,请下载:
URL=https://github.com/4strium/moodle-claw/releases/download/v1.0/moodle-claw
SHA256=0ce9e6ad4e42c626ebe2c4ce79bde23da3386dc8e4b54a87da0a345a1a0252aa
curl -L -o moodle-claw $URL
echo $SHA256 moodle-claw | sha256sum -c -
chmod +x moodle-claw
配置
在使用 moodle-claw 命令之前,用户需要配置其 Moodle 连接:
bash
moodle-claw configure
这将交互式地提示输入:
- 1. Moodle 服务器 URL - 例如 https://moodle.university.edu
- 认证方式 - 令牌(直接)、SSO(重定向 URL)或用户名/密码
- 下载路径 - 保存下载文件的位置
认证方式
选项 1:直接令牌
如果您已有 32 字符的十六进制令牌:
bash
moodle-claw configure --url https://moodle.example.com --token 您的32字符令牌 --path ~/Documents/Moodle
选项 2:SSO 认证(推荐用于大学)
对于使用 SSO(单点登录)的机构:
- 1. 在网页浏览器中登录您的 Moodle 账户
- 打开开发者控制台(按 F12)并转到 网络 选项卡
- 在同一浏览器标签页中访问此 URL(替换为您的 Moodle URL):
https://您的MoodleURL/admin/tool/mobile/launch.php?service=moodlemobileapp&passport=12345&urlscheme=moodlemobile
- 4. 页面将无法加载 - 这是预期行为!会出现错误。
- 在网络选项卡中,找到失败的请求(应为红色/失败状态)
- 右键点击失败的请求 > 复制 > 复制链接地址
- URL 看起来像:moodlemobile://token=BASE64编码的字符串
- 7. 使用复制的 URL:
bash
moodle-claw configure --url https://moodle.example.com --sso-url moodlemobile://token=... --path ~/Documents/Moodle
或者使用交互模式并选择SSO(重定向 URL):
bash
moodle-claw configure
选项 3:用户名/密码
对于允许直接登录的机构:
bash
moodle-claw configure --url https://moodle.example.com --username 您的用户名 --password 您的密码 --path ~/Documents/Moodle
可用命令
检查状态
bash
moodle-claw status [--output json]
显示当前配置和连接状态。
列出课程
bash
moodle-claw courses [--filter 数学] [--refresh] [--output json]
列出所有已注册的课程。使用 --refresh 从服务器获取最新数据。
查看课程内容
bash
moodle-claw content 课程名称 [--section TD2] [--output json]
moodle-claw content 12345 # 按课程 ID
显示课程的结构(章节、模块、文件)。
搜索内容
bash
moodle-claw search 练习 [--course 物理] [--type file] [--output json]
跨课程搜索内容。
下载文件
bash
moodle-claw get 课程/章节/文件.pdf [--course 数学] [--dest /tmp]
moodle-claw get --url https://moodle.../pluginfile.php/... [--dest /tmp]
从 PDF 文件中提取文本(推荐用于阅读内容)
moodle-claw get 文件.pdf --text --output json
下载文件并返回其本地路径。使用 --text(-t)自动从 PDF 文件中提取文本内容。
同步课程
bash
moodle-claw sync 课程名称 [--dest ~/Courses] [--no-confirm]
moodle-claw sync # 同步所有已启用的课程
下载课程中的所有文件。
使用模式
当用户询问课程时
- 1. 首先,列出课程以找到正确的课程:moodle-claw courses --filter 关键词
- 然后获取其内容:moodle-claw content 课程名称
- 如果需要,下载特定文件:moodle-claw get 路径/到/文件.pdf
当用户询问特定内容时(例如TD2、练习 3)
- 1. 搜索内容:moodle-claw search TD2 --course 课程名称
- 下载并从 PDF 中提取文本:moodle-claw get 路径/到/文件.pdf --text
- 提取的文本将包含在输出中供您分析
当用户想离线工作时
- 1. 同步整个课程:moodle-claw sync 课程名称 --no-confirm
- 文件将在本地可用以供阅读
输出格式
所有命令支持 --output json 用于结构化输出,或默认的 markdown 格式以提高可读性。
交互示例
用户:解释一下力学课程
bash
1. 查找课程
moodle-claw courses --filter 力学 --output json
2. 获取课程结构
moodle-claw content 力学 --output json
3. 下载相关材料并解释
moodle-claw get 力学/第1章/课程.pdf --output json
用户:数学课 TD2 的练习 3 是什么?
bash
1. 在数学课程中搜索 TD2
moodle-claw search TD2 --course 数学 --output json
2. 下载 TD2 文件并提取文本
moodle-claw get TD2.pdf --course 数学 --text --output json
文本内容将包含在 JSON 输出中供您分析
用户:下载物理课的所有文件
bash
moodle-claw sync 物理 --no-confirm
注意事项
- - 文件在首次下载后会在本地缓存
- 在 moodle-claw courses 上使用 --refresh 从服务器更新课程列表
- 课程名称支持模糊匹配(部分名称也可用)
- --output json 标志对于解析结构化数据很有用
- 使用 moodle-claw get 的 --text 选项直接从 PDF 文件中提取文本
安全/审查
- - 源代码完全开源
- 执行前验证 SHA256 校验和
- 令牌、凭据和配置保存在本机