cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
matt_borja
Community Participant

Bulk Delete Enrollments From a Section (with no SIS ID)

Jump to solution

Hi all,

I understand that you cannot delete a section if there are enrollments. But if a course has a section that was added in Canvas directly (no SIS ID) and we wanted that section removed, yet that section has multiple enrollments, is there not a way to delete enrollments in bulk vs. one at a time?

Matt

Labels (1)
Tags (2)
1 Solution

Accepted Solutions
matt_borja
Community Participant

Hi Brian,

Thanks for your response. I guess I should have provided a little more context: this is meant to be done over the API as it is actually a maintenance tool we've created that is meant to serve as a one-click "Fix It" for our administrators so they probably aren't going to want to go into each individual section to assign missing SIS IDs. Basically the policy is: instructors shouldn't be adding their own sections since they will be imported directly from source and those are the ones they should be using.

However, this does bring up one viable workaround to mind (I emphasize on workaround because this really ought to be part of the API):

To [Programmatically] Delete Section Enrollments in Bulk:

  1. Use the Sections API to Edit a Section and set the SIS ID (i.e. "SIS_PREFIX_<SECTIONID>") if it doesn't have one already. (Cost: 1 API call)
  2. Retrieve a list of Enrollments for the section. This can be wrapped into the same call used to get the section by passing the include[]=enrollments parameter. (Cost: 0-1 API calls)
  3. Format this [optionally filtered] list of Enrollments as a new SIS Import for Enrollments and set the status column to "deleted." (Cost: 1 API call)

Total cost: 2-3 API calls to delete some or all enrollments (using SIS) in a section.

Alternatively, if you have no need to filter which enrollments you are deleting in bulk and are essentially deleting ALL enrollments, you might also argue this could be easier done in two easier steps, but still costing 2 API calls:

  1. Set the SIS ID of a section
  2. Delete the section itself via SIS (while it has enrollments)

So I guess there you have it, deleting enrollments in bulk Smiley Happy

View solution in original post

5 Replies
bneporadny
Community Champion

Matt,

From what I know there is no way to delete bulk enrollments via the Canvas interface.

On thing you can try is to go into the section and give it a SIS ID manually and by doing so would allow you to remove the enrollments in bulk.

To add a section SIS ID manually click on Setting--> Sections --> Click on the section and on the right hand side of the page you should see "Edit Section"  once in the screen you should see SIS ID with a blank text box beside it. You can type in the SIS ID you would like to use.

Brian

matt_borja
Community Participant

Hi Brian,

Thanks for your response. I guess I should have provided a little more context: this is meant to be done over the API as it is actually a maintenance tool we've created that is meant to serve as a one-click "Fix It" for our administrators so they probably aren't going to want to go into each individual section to assign missing SIS IDs. Basically the policy is: instructors shouldn't be adding their own sections since they will be imported directly from source and those are the ones they should be using.

However, this does bring up one viable workaround to mind (I emphasize on workaround because this really ought to be part of the API):

To [Programmatically] Delete Section Enrollments in Bulk:

  1. Use the Sections API to Edit a Section and set the SIS ID (i.e. "SIS_PREFIX_<SECTIONID>") if it doesn't have one already. (Cost: 1 API call)
  2. Retrieve a list of Enrollments for the section. This can be wrapped into the same call used to get the section by passing the include[]=enrollments parameter. (Cost: 0-1 API calls)
  3. Format this [optionally filtered] list of Enrollments as a new SIS Import for Enrollments and set the status column to "deleted." (Cost: 1 API call)

Total cost: 2-3 API calls to delete some or all enrollments (using SIS) in a section.

Alternatively, if you have no need to filter which enrollments you are deleting in bulk and are essentially deleting ALL enrollments, you might also argue this could be easier done in two easier steps, but still costing 2 API calls:

  1. Set the SIS ID of a section
  2. Delete the section itself via SIS (while it has enrollments)

So I guess there you have it, deleting enrollments in bulk Smiley Happy

View solution in original post

N_YOUNG
Community Participant

Matt --

I realize that you already posted an answer, but i wanted to ask why you're needing to add a SIS ID in the first place? You shouldn't need to set a SIS ID in order to retrieve any enrollments from a section.

When dealing with Canvas via the API, you can use either the canvas internal ID to specify which object you're working with... or you can use the SIS ID that you've set yourself.

For example, this is the endpoint when getting a section:

Using the internal Canvas-assigned ID:

     $endpoint = $canvasUrl . '/api/v1/sections/' . $id;

Using the SIS SECTION ID assigned by us:

     $endpoint = $canvasUrl. '/api/v1/sections/sis_section_id:' . $id;

So, you should be able to eliminate the first step where you're assigning a SIS ID. Just grab the enrollments from the section directly, and then do your operations like before.

(Unless im missing a reason for why you need a SIS ID in the first place, then ignore this whole reply 🙂 )

matt_borja
Community Participant

Hi Nicholas,

Going the SIS Import route (requiring a SIS ID) allows us to leverage the enrollments.csv which enables us to bulk-delete enrollments whereas if you look at the Enrollments API, or at least per the documentation, you can only delete 1 enrollment ID at a time (SIS ID not required).

Matt

N_YOUNG
Community Participant

Gotcha. Makes sense.

I just wanted to check to make sure you weren't saying that you can't delete/alter something unless it has a SIS ID.

I've written some things before that iterated through using the Canvas ID via API.... Of course it always depends on the amount of data you're churning through. Just make sure you're not causing issues for yourself in future by treating things as SIS events, when they might not be. IE: If you upload something or take some action with a SIS CSV, then it won't always allow you to override that in the UI.