cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rwest
Community Member

Deleting an enrollment on a section

Jump to solution

When enrolling a student onto a course, you can specify if you are enrolling onto the course or a section in the course by using:

POST /api/v1/courses/:course_id/enrollments

or

POST /api/v1/sections/:section_id/enrollments

We have teachers that are enrolled on multiple sections of a course, but there doesn't appear to be a way of removing them just from a single section, only from the entire course:

DELETE /api/v1/courses/:course_id/enrollments/:id

I can't just delete them from the course as we would then lose all of their settings, so how do I do this?

1 Solution

Accepted Solutions
nr2522
Community Champion

Hello,  @rwest ‌.

I'm not an API expert, but I'll take a stab at this. Wouldn't the enrollment ID be unique for each section that the student is enrolled in? I think that if you delete the enrollment for one section, any other section enrollments in that course for the user would remain. It's worth testing on your Canvas test environment.

Alternatively, you might consider using SIS Import CSV to achieve this. See SIS Import Format Documentation - Canvas LMS REST API Documentation.

Best,

Nelson Ricardo

Columbia Business School

(I don't usually include that in my posts, but I see that you're from LBS, our EMBA-Global partner school.)

View solution in original post

6 Replies
chofer
Community Coach
Community Coach

Hello there,  @rwest ...

While I do not necessarily have an answer for you, I wanted to let you know that I have shared your question with the Canvas Developers‌ group here in the Canvas Community in hopes that your question will get some additional exposure.  If you are not yet following this group, please use the link that I have provided, and then click the "Follow" button located at the top right corner of that page.  There is also an "Actions" button next to "Follow".  Click "Actions" and then "Join group" to join the group.  I hope this will be of help to you, Robert.  Good luck!

mzimmerman
Community Champion

Hello Robert,

Are you strictly looking at doing this via the API?  It is possible to remove a user from one section via the GUI from within the section page (the "X" says "Remove the user from the course", but it really just removes them from the section), but I'm not seeing an API documented to do the same thing.  

Mike

nr2522
Community Champion

Hello,  @rwest ‌.

I'm not an API expert, but I'll take a stab at this. Wouldn't the enrollment ID be unique for each section that the student is enrolled in? I think that if you delete the enrollment for one section, any other section enrollments in that course for the user would remain. It's worth testing on your Canvas test environment.

Alternatively, you might consider using SIS Import CSV to achieve this. See SIS Import Format Documentation - Canvas LMS REST API Documentation.

Best,

Nelson Ricardo

Columbia Business School

(I don't usually include that in my posts, but I see that you're from LBS, our EMBA-Global partner school.)

View solution in original post

mzimmerman
Community Champion

Good point, Nelson!   Yes, each section enrollment has its own ID...

James
Community Champion

 @mzimmerman   @nr2522  gave you the answer, I just wanted to clarify a common misconception of people who may not be familiar with the API.

You need to look at where the parameters in the route appear

DELETE /api/v1/courses/:course_id/enrollments/:id

The :id is after the /enrollments, so it's most likely an enrollment ID. If it were after /submissions, then it would be a submission ID. Many people get confused and think it's the user ID. If that were the case, it would appear after /users or possible /students and would be labeled as :user_id.


Certain IDs have names, such as :account_id, :course_id, :section_id, and :user_id, while others just show up as :id. It's when that :id appears that you have to be more cautious to make sure you're giving it the correct ID.

rwest
Community Member

Hi  @nr2522 ‌

Thank you for the suggestion, as  @James ‌ mentions I had mixed up my Course & Session id fields in my code. We originally coded my application to work with a single session per course, so everything was working. And then the users changed the sepecification (surprise) after we went live. This is one bit of code that hadn't been updated and I was still unenrolling the faculty from all sections by mistake, I've modified it now and it is working as expected.

Cheers

Robert West

...and 'hi' from all at London Business School