Compare commits

..

1 Commits

Author SHA1 Message Date
2ac29a6d89 feat: support exporting Canvas group members with group info (#7)
Some checks failed
build / trigger-build-image (push) Has been cancelled
## Summary

Add an optional `--group` argument to `export-users`.

When `--group` is not provided, the command keeps the original behavior and exports all Canvas users as:

`name,sis_id,login_id`

When `--group <group_set_prefix>` is provided, the command looks up the corresponding Canvas group set, exports only users in that group set, and appends the normalized group name as the fourth column:

`name,sis_id,login_id,group_name`

For example, if the group set is `p2team`, the exported group names will be formatted as `p2team01`, `p2team02`, `p2team10`, etc.

## Changes

- Add optional `--group` support to `export-users`
- Look up Canvas group sets by exact name first, then by prefix
- Export only members in the matched group set when `--group` is used
- Append the user's group name as the fourth CSV column
- Normalize Canvas group names like `p1team 1` and `p1team10` into `p1team01` and `p1team10`
- Sort exported rows by group number in ascending order
- Handle invalid input more gracefully:
  - if no matching group set is found, exit cleanly with an error log
  - if a Canvas group name does not follow the expected `group_set_name + number` pattern, exit cleanly with an error log

## Behavior

### Default

`joint-teapot export-users students.csv`

Output format:

`name,sis_id,login_id`

### With group export

`joint-teapot export-users p2.csv --group p2team`

Output format:

`name,sis_id,login_id,p2team01`

## Notes

This change keeps the original export behavior unchanged unless `--group` is explicitly provided.

Reviewed-on: #7
Reviewed-by: 张泊明518370910136 <bomingzh@sjtu.edu.cn>
Co-authored-by: egghead_yao <egghead_yao@sjtu.edu.cn>
Co-committed-by: egghead_yao <egghead_yao@sjtu.edu.cn>
2026-06-22 18:10:04 +08:00

Diff Content Not Available