How do I get a list of users in a course that does not include folks who have completed the course?

PeterStromberg
Community Member

Using Powershell. I can get a list of 851 enrolled users in this course and section:

$result = Invoke-RestMethod -Method GET -uri "https://XXXX.instructure.com/api/v1//courses/508/sections/579" -header $headers -body @{include = "students";enrollment_role_id = 'StudentEnrollment'}
$result.students.count
851

This includes lots of students who have enrollment type "completed" when looking at the GUI for this section.

When I try to refine my search by adding enrollment_state = "completed" to the body, we still get 851 students.

$result = Invoke-RestMethod -Method GET -uri "https://XXXX.instructure.com/api/v1//courses/508/sections/579" -header $headers -body @{include = "students";enrollment_role_id = 'StudentEnrollment';enrollment_state = "active"}

$result.students.count
851

I think I'm missing something about how enrollments work in canvas or how the body works. Any one able to help out with a valid command for returning only active, enrolled users in a course's section?

Labels (2)
0 Likes