Skip to content

Commit

Permalink
Makes groups output CSV format consistent with other CSV outputs
Browse files Browse the repository at this point in the history
The course code is used instead of the Canvas ID.
  • Loading branch information
dbosk committed Mar 26, 2024
1 parent 809d303 commit 8d7cbdb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/canvaslms/cli/users.nw
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def add_groups_command(subp):
groups_parser = subp.add_parser("groups",
help="Lists groups of a course",
description="Lists groups of a course(s). Output, CSV-format: "
"<Canvas ID> <group category> <group name> <#members>")
"<course code> <group category> <group name> <#members>")
groups_parser.set_defaults(func=groups_command)
courses.add_course_option(groups_parser)
<<add groups specific options>>
Expand Down Expand Up @@ -298,7 +298,10 @@ else:

for category in categories:
for group in filter_groups([category], args.regex):
row = [group.id, category.name, group.name, group.members_count]
row = [
category.course.course_code, category.name,
group.name, group.members_count
]
output.writerow(row)
@

Expand All @@ -313,8 +316,10 @@ we can filter out groups; or filter out groups directly from courses.
We want to filter out the group categories from a list of courses.
<<functions>>=
def filter_group_categories(course_list, regex):
"""Filters out the group categories whose names match regex
in the courses in course_list"""
"""
Filters out the group categories whose names match regex
in the courses in course_list
"""

name = re.compile(regex or ".*")

Expand All @@ -334,9 +339,11 @@ method [[.get_groups()]], so thanks to Python's duck typing we can write short
code.
<<functions>>=
def filter_groups(items, regex):
"""Items is a list of either courses or group categories,
"""
Items is a list of either courses or group categories,
regex is a regular expression.
Returns all groups whose name match regex."""
Returns all groups whose name match regex.
"""

name = re.compile(regex or ".*")

Expand Down

0 comments on commit 8d7cbdb

Please sign in to comment.