moodle-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMoodle CLI Skill
Moodle CLI 技能
You are helping a user run — a CLI tool for interacting with the Moodle Learning Management System API.
moodle你正在协助用户运行——一款用于对接Moodle学习管理系统API的CLI工具。
moodleCommand Tree
命令树
moodle
├── auth # Manage authentication
│ ├── login # Log in to a Moodle instance
│ ├── logout # Log out of the Moodle instance
│ ├── status # Show authentication status
│ └── token # Print the authentication token
├── course # Manage courses
│ ├── list # List enrolled courses
│ ├── get <id> # Get course details
│ ├── search <query> # Search courses
│ ├── content <id> # Get course contents (sections, modules)
│ ├── module <id> # Get course module details
│ ├── grades <id> # View your course grades
│ └── download <id> # Download module files
├── assignment # Manage assignments
│ ├── list # List assignments (--course to filter)
│ ├── get <id> # Get assignment details
│ ├── status <id> # Check submission status
│ ├── upload <id> <file> # Upload files to an assignment
│ ├── submit <id> # Submit assignment for grading
│ ├── text <id> # View or update online text submission
│ └── download <id> # Download submission files (-R for resources)
├── forum # Manage forums
│ ├── list # List forums in a course (--course)
│ ├── discussions <id> # List discussions in a forum
│ ├── read <id> # Read a discussion thread
│ ├── post <id> # Create a new discussion
│ ├── reply <id> # Reply to a post
│ ├── edit <id> # Edit a post
│ └── delete <id> # Delete a post
├── user # Manage users
│ ├── whoami # Show current user info
│ ├── list # List users enrolled in a course (--course)
│ └── get <id> # Get user by ID
├── config # Manage configuration
│ ├── list # List all configuration settings
│ ├── get <key> # Get a configuration value
│ └── set <key> <value> # Set a configuration value
└── version # Print the versionmoodle
├── auth # Manage authentication
│ ├── login # Log in to a Moodle instance
│ ├── logout # Log out of the Moodle instance
│ ├── status # Show authentication status
│ └── token # Print the authentication token
├── course # Manage courses
│ ├── list # List enrolled courses
│ ├── get <id> # Get course details
│ ├── search <query> # Search courses
│ ├── content <id> # Get course contents (sections, modules)
│ ├── module <id> # Get course module details
│ ├── grades <id> # View your course grades
│ └── download <id> # Download module files
├── assignment # Manage assignments
│ ├── list # List assignments (--course to filter)
│ ├── get <id> # Get assignment details
│ ├── status <id> # Check submission status
│ ├── upload <id> <file> # Upload files to an assignment
│ ├── submit <id> # Submit assignment for grading
│ ├── text <id> # View or update online text submission
│ └── download <id> # Download submission files (-R for resources)
├── forum # Manage forums
│ ├── list # List forums in a course (--course)
│ ├── discussions <id> # List discussions in a forum
│ ├── read <id> # Read a discussion thread
│ ├── post <id> # Create a new discussion
│ ├── reply <id> # Reply to a post
│ ├── edit <id> # Edit a post
│ └── delete <id> # Delete a post
├── user # Manage users
│ ├── whoami # Show current user info
│ ├── list # List users enrolled in a course (--course)
│ └── get <id> # Get user by ID
├── config # Manage configuration
│ ├── list # List all configuration settings
│ ├── get <key> # Get a configuration value
│ └── set <key> <value> # Set a configuration value
└── version # Print the versionGlobal Flags
全局参数
Every command supports these flags:
| Flag | Description |
|---|---|
| Output format: |
| Disable color output |
| Enable verbose output |
| Help for the command |
所有命令都支持以下参数:
| 参数 | 说明 |
|---|---|
| 输出格式: |
| 禁用彩色输出 |
| 开启详细输出 |
| 查看命令帮助 |
Guidelines
使用指南
Default to JSON output
默认使用JSON输出
When suggesting commands, prefer for machine-readable output. Show users how to pipe to for filtering:
-f jsonjqbash
undefined推荐命令时优先使用生成机器可读的输出,你可以向用户演示如何通过管道传递给进行过滤:
-f jsonjqbash
undefinedList courses as JSON
List courses as JSON
moodle course list -f json
moodle course list -f json
Get a specific field
Get a specific field
moodle course list -f json | jq '.[].fullname'
moodle course list -f json | jq '.[].fullname'
Filter assignments by course
Filter assignments by course
moodle assignment list --course 42 -f json | jq '.[] | {id, name, duedate}'
For quick human-readable output, the default `table` format works well — no flag needed.moodle assignment list --course 42 -f json | jq '.[] | {id, name, duedate}'
如果需要方便人阅读的输出,默认的`table`格式就足够用了,不需要加额外参数。Common Workflows
常用工作流
First-time setup:
bash
moodle auth login --url https://moodle.example.com
moodle auth status # verify login
moodle course list # see enrolled coursesAssignment workflow:
bash
moodle assignment list --course 42 # find assignment ID
moodle assignment get 101 # check details and due date
moodle assignment upload 101 report.pdf # upload file
moodle assignment submit 101 --accept-statement # submit for grading
moodle assignment status 101 # verify submissionForum workflow:
bash
moodle forum list --course 42 # find forum ID
moodle forum discussions 5 # list discussions
moodle forum read 100 # read a thread
moodle forum reply 200 --message "Thanks!" # reply to a post
moodle forum post 5 --subject "Question" --message "Hello" # new discussionDownload assignment resources:
bash
moodle assignment get 101 # see attached resources
moodle assignment download 101 --resources # download instructor-attached files
moodle assignment download 101 -R -o ./resources # download to a directoryDownload course files:
bash
moodle course content 42 # browse course sections
moodle course download 500 # download a module's files首次配置:
bash
moodle auth login --url https://moodle.example.com
moodle auth status # verify login
moodle course list # see enrolled courses作业处理工作流:
bash
moodle assignment list --course 42 # find assignment ID
moodle assignment get 101 # check details and due date
moodle assignment upload 101 report.pdf # upload file
moodle assignment submit 101 --accept-statement # submit for grading
moodle assignment status 101 # verify submission论坛操作工作流:
bash
moodle forum list --course 42 # find forum ID
moodle forum discussions 5 # list discussions
moodle forum read 100 # read a thread
moodle forum reply 200 --message "Thanks!" # reply to a post
moodle forum post 5 --subject "Question" --message "Hello" # new discussion下载作业资源:
bash
moodle assignment get 101 # see attached resources
moodle assignment download 101 --resources # download instructor-attached files
moodle assignment download 101 -R -o ./resources # download to a directory下载课程文件:
bash
moodle course content 42 # browse course sections
moodle course download 500 # download a module's filesFiltering
过滤规则
- Use to filter assignments, forums, and users by course
--course <id> - Use positional arguments for specific resources (courses, assignments, forums, users, modules)
<id> - Chain with for advanced filtering on JSON output
jq
- 可以使用参数按课程过滤作业、论坛和用户
--course <id> - 针对特定资源(课程、作业、论坛、用户、模块)使用位置参数指定
<id> - 输出JSON格式时可以结合实现高级过滤
jq
Configuration
配置
Users can set defaults to avoid repeating flags:
bash
moodle config set format json # always output JSON
moodle config list # see current settings用户可以设置默认值避免重复输入参数:
bash
moodle config set format json # always output JSON
moodle config list # see current settingsReference Documentation
参考文档
For detailed information about a specific command (flags, options, examples), read the corresponding file in the directory:
references/- Root command:
references/moodle.md - Auth group: ,
references/moodle_auth.md, etc.references/moodle_auth_login.md - Course group: ,
references/moodle_course.md, etc.references/moodle_course_list.md - Assignment group: ,
references/moodle_assignment.md, etc.references/moodle_assignment_list.md - Forum group: ,
references/moodle_forum.md, etc.references/moodle_forum_list.md - User group: ,
references/moodle_user.md, etc.references/moodle_user_whoami.md - Config group: ,
references/moodle_config.md, etc.references/moodle_config_set.md - Version:
references/moodle_version.md
The filename pattern is . When the user asks about a specific command, read the reference file first to provide accurate flag names and usage details.
references/moodle_<group>_<command>.md如需了解特定命令的详细信息(参数、选项、示例),可以查看目录下的对应文件:
references/- 根命令:
references/moodle.md - 认证分组: 、
references/moodle_auth.md等references/moodle_auth_login.md - 课程分组: 、
references/moodle_course.md等references/moodle_course_list.md - 作业分组: 、
references/moodle_assignment.md等references/moodle_assignment_list.md - 论坛分组: 、
references/moodle_forum.md等references/moodle_forum_list.md - 用户分组: 、
references/moodle_user.md等references/moodle_user_whoami.md - 配置分组: 、
references/moodle_config.md等references/moodle_config_set.md - 版本查询:
references/moodle_version.md
文件命名规则为。当用户询问特定命令的相关问题时,请优先查阅参考文件,以提供准确的参数名称和使用说明。
references/moodle_<group>_<command>.md