Last active
January 26, 2018 21:42
-
-
Save gabriel4649/080eba11880b9b82b85602a110b88bdd to your computer and use it in GitHub Desktop.
Get list of Canvas sortable names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from canvasapi import Canvas | |
CANVAS_API_URL = '' | |
CANVAS_TOKEN = '' | |
COURSE_ID = 9999 # int class id | |
def get_canvas_client(): | |
return Canvas(CANVAS_API_URL, | |
CANVAS_TOKEN) | |
def export_student_data(): | |
canvas = get_canvas_client() | |
course = canvas.get_course(COURSE_ID) | |
students = course.get_users(enrollment_type=['student'], include=['email'], per_page=500) | |
for student in students: | |
sortable_name = student.sortable_name.replace(',', '') # Remove names | |
sortable_name = sortable_name.replace(' ', '') # Remove spaces | |
sortable_name = sortable_name.replace('-', '') # Remove hyphens | |
print(sortable_name.lower() + ', ' + student.login_id + '@gatech.edu') | |
export_student_data() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment