Search code examples
desire2learn

Student Roles in Desire2Learn


How can I get a list of students from D2L? I want to get the grades of the students and when I get the classlist, I get both instructors and student marks.


Solution

  • You can use /d2l/api/lp/{ver}/enrollments/orgUnits/{orgUnitId}/users/. This will fetch a paged result set of all the users enrolled in the course offering identified by orgUnitId. Note that you can filter the result set with the roleId query parameter; if you know the role ID for students, you can provide that to fetch back just the users in the course with a student role:

    https://your.lms/d2l/api/lp/1.0/enrollments/orgUnits/6784/users/?roleId=78&{all_auth_qparms}
    

    Note that the enrollments API calls require certain role permissions of the calling user context. The calling user account needs 'View User Enrollments' permission, and to have the 'Search for <rolename>' permission for the enrolled user roles visible in the output:

    • Without 'View User Enrollments', you won't have any permission to query enrollments at all, and you'll likely get a 403 back (no permission, or forbidden).

    • If you don't have the 'Search for Student' or 'Search for Instructor' permission (or whatever your local roles are), then although you can make the enrollments call, the list of enrolled users you get back will get filtered down to only the roles you can 'Search for'.


    Edit. I've fixed this answer; the default role ID for students was not 3 (that's the default OrgUnitID for course offerings, I think). On our test server the default student role ID is '78'.

    Edit 2. I've added more information about the permissions required to get useful information from the enrollments call.