moodle-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Moodle CLI Skill

Moodle CLI 技能

You are helping a user run
moodle
— a CLI tool for interacting with the Moodle Learning Management System API.
你正在协助用户运行
moodle
——一款用于对接Moodle学习管理系统API的CLI工具。

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

Global Flags

全局参数

Every command supports these flags:
FlagDescription
-f, --format <fmt>
Output format:
table
,
json
,
csv
,
yaml
,
plain
--no-color
Disable color output
-v, --verbose
Enable verbose output
-h, --help
Help for the command
所有命令都支持以下参数:
参数说明
-f, --format <fmt>
输出格式:
table
json
csv
yaml
plain
--no-color
禁用彩色输出
-v, --verbose
开启详细输出
-h, --help
查看命令帮助

Guidelines

使用指南

Default to JSON output

默认使用JSON输出

When suggesting commands, prefer
-f json
for machine-readable output. Show users how to pipe to
jq
for filtering:
bash
undefined
推荐命令时优先使用
-f json
生成机器可读的输出,你可以向用户演示如何通过管道传递给
jq
进行过滤:
bash
undefined

List 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 courses
Assignment 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 submission
Forum 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 discussion
Download 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 directory
Download 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 files

Filtering

过滤规则

  • Use
    --course <id>
    to filter assignments, forums, and users by course
  • Use positional
    <id>
    arguments for specific resources (courses, assignments, forums, users, modules)
  • Chain with
    jq
    for advanced filtering on JSON output
  • 可以使用
    --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 settings

Reference Documentation

参考文档

For detailed information about a specific command (flags, options, examples), read the corresponding file in the
references/
directory:
  • Root command:
    references/moodle.md
  • Auth group:
    references/moodle_auth.md
    ,
    references/moodle_auth_login.md
    , etc.
  • Course group:
    references/moodle_course.md
    ,
    references/moodle_course_list.md
    , etc.
  • Assignment group:
    references/moodle_assignment.md
    ,
    references/moodle_assignment_list.md
    , etc.
  • Forum group:
    references/moodle_forum.md
    ,
    references/moodle_forum_list.md
    , etc.
  • User group:
    references/moodle_user.md
    ,
    references/moodle_user_whoami.md
    , etc.
  • Config group:
    references/moodle_config.md
    ,
    references/moodle_config_set.md
    , etc.
  • Version:
    references/moodle_version.md
The filename pattern is
references/moodle_<group>_<command>.md
. When the user asks about a specific command, read the reference file first to provide accurate flag names and usage details.
如需了解特定命令的详细信息(参数、选项、示例),可以查看
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
。当用户询问特定命令的相关问题时,请优先查阅参考文件,以提供准确的参数名称和使用说明。