I manage a large class (hundreds of students) and it is divided into sections based on days of the week. Some students change days from the "Monday" section to the "Tuesday" section, for example.
I can create sections mechanically using the API but I cannot find in the documentation of the API how to delete or add a student to the section. Obviously it can be done manually through the course "people" tab but for a large class that becomes impractical when frequent changes are made.
I know I can add a student to a section by using (Python syntax - but could be anything really):
#POST /api/v1/sections/:section_id/enrollments
url = "{0}/sections/{1}/enrollments".format(baseUrl,section_id)
extra_parameters={
'enrollment[user_id]': user_id,
'enrollment[type]': 'StudentEnrollment',
'enrollment[enrollment_state]': 'active'
}
But this just add the student to an additional section, so I needed to have removed the previous section first.
I tried guessing at the syntax:
# Use the Canvas API to get the remove a member from a named section in a course
#DELETE /api/v1/section/:section_id/enrollments
url = "{0}/sections/{1}/enrollments".format(baseUrl,section_id)
extra_parameters={
'enrollment[user_id]': user_id
}
But that does not work and gives me a 404. I could delete the whole section, but it would take many hundreds of enrollments to put everyone back who had not changed!
Is there a syntax for the API section access I need to know?