Commit 051ecfd6 authored by Kevin Lin's avatar Kevin Lin
Browse files

Add get_groups_ohyay.py

parent 454ef84c
#!/usr/bin/env python3
import csv, os
import canvas_api
import os.path
import readline
if __name__ == "__main__":
token = os.getenv("TOKEN")
if not token:
token = input("Enter a Canvas token (https://canvas.uw.edu/profile/settings): ")
canvas = canvas_api.Canvas(token)
courses_taught = canvas.get_courses_taught()
if courses_taught is None:
print("Invalid Canvas token.")
exit(1)
course_id = os.getenv("COURSE_ID")
if not course_id:
course_id = input("Enter a Canvas course ID (URL slug): ")
course = canvas.get_course(course_id)
if course is None:
print("Invalid Canvas course.")
exit(1)
groups = course.get_groups()
print("Email,Tags")
for group in groups:
for student in groups[group]:
print(f"{student.uwnetid}@uw.edu,{group.lower()}")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment