How can I retrieve a list of users in an enrollment term
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Currently, I retrieve all courses with an enrollment term first, followed by all users enrolled in the list of courses. It works well, but given that 1 user may enroll into multiple courses, the amount of duplicated information seems to be a large overhead. If there's a more straightforward way that will be awesome.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
vicker,
That is a lot of duplication and it's slow. Is your data created by a SIS import? If so, it might be easier to get a list from your Student Information System than from Canvas using the API.
I generate an unduplicated count of students by getting a list of all the courses that are in the current term. Our system imports those into Canvas, so it's already part of my system and I don't need to fetch the list from Canvas. My system is separate from our SIS which doesn't know which courses are in Canvas.
I then grab a list of all the students in those courses from the SIS. There's a lot duplication, but it's pretty quick since it's all done locally -- no need to go across the internet like you would with the API.
Then I collate the data and generate the list, and because my system contains all the data that was imported into Canvas in the first place, it's all without making a single Canvas API call.
If you have to use Canvas to get the data, then one option is to use the Provisioning Report to generate the list. I explained how to combine the users, courses, and enrollments tables in Excel here: How to list teachers who have published/unpublished courses
That's specifically about finding teachers in courses, but it could easily be modified (change a filter) to find students.
If you don't need names and just want counts, then you could just use the enrollments table of the Provisioning Report. If you need a list of names but don't care about what courses they're in, you could use the enrollments and users tables of the report.
If you have to use the API, be sure to specify per_page=100 in the query string to minimize the number of calls. You may also want to store the results locally to make it faster in the future.
If you can get the data from the SIS, that's probably the easiest. If you only need it once a semester, the Provisioning Report method isn't too bad. If you need it often and can't get it from the SIS, then you're on the right track -- it's just slow.