Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample script of changing the enrollment statuses with canvasapi
from canvasapi import Canvas
# Instantiate the Canvas object
canvas = Canvas("your_url", "your_key")
# Get the course by it's ID
course = canvas.get_course(course_id)
# Get a list of Enrollment items
# Use the 'type' and 'state' kwargs to only get active students
enrollments = course.get_enrollments(type="StudentEnrollment", state="active")
# Loop each student and deactivate them
for stu in enrollments:
stu.deactivate(task="deactivate")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.