Group Enrollment Data Issue (Valence API)
I am trying to resolve an issue with group enrollments. I have an internally-developed app that makes a call to get the enrollment for the groups that the calling user (i.e. student) is a member of using this route:
/d2l/api/lp/(version)/(orgUnitId)/groupcategories/(groupCategoryId)/groups/
When the enrollment data is returned, it gives me the user id numbers of each person enrolled in the group. However, my app needs to display the name(s) of those people, not their ID numbers.
To solve this, I make a call to get the classlist, and I essentially look up the ID from the group enrollment to match it with the correct name from the classlist. This has worked fine until now.
The problem now is that we have a class that is made up of multiple sections, with students from different sections being put together in groups. The group enrollment API call still works fine, returning the ID numbers for everyone in the group. However, the classlist call only returns students who are on the same classlist at the student in whose context the app is executing the calls. This results in not being able to look up names for some members of the group, as they don't appear on a classlist that the student can receive data for.
I have tried other API routes to get the name of the students enrolled in the groups, but they all return 403 when called from a student context.
So, my question(s):
- What routes should I be using to match id numbers to names?
- Should all the user routes (e.g. /d2l/api/lp/(version)/demographics/users/(userId) or /d2l/api/lp/(version)/users/(userId)) be returning 403?
Answers
-
Hi Jame,
For question 1: you don't need to perform two calls to join user attributes, you can call classlist or enrollment endpoints using groupID where endpoints documentation show orgUnitId:
/d2l/api/le/(version)/(orgUnitId)/classlist/
/d2l/api/le/(version)/(orgUnitId)/classlist/paged/
/d2l/api/lp/(version)/enrollments/orgUnits/(orgUnitId)/users/
this is because a group is a special organizational unit, a native one like course offering with all tools available (Content, Quizz, Surveys, Dropbox, etc..). Notice classlist attributes visibility depends on your environment configuration and API respects that configuration:
d2l.Tools.Classlist.DisplayEmail
d2l.Tools.Classlist.DisplayInactiveUsers
d2l.Tools.Classlist.DisplayLastAccessed
d2l.Tools.Classlist.DisplayOrgId
d2l.Tools.Classlist.DisplayProfileImage
d2l.Tools.Classlist.DisplayUsername
I hope it helps.
Best regards,
Sergio
-
Hi Sergio,
Thank you for the reply. When I try to use the groupID in place of the course ou in the classlist call (/d2l/api/le/(version)/(orgUnitId)/classlist/) I get a 403 error, both for my student account and my local admin account (not a top-level admin, but one with more access than a typical instructor account). The call works fine for both my student and local admin accounts with the course OU.
However, even if it returned data for the student account, would it only return data for other students on the same classlist?
The other route (/d2l/api/lp/(version)/enrollments/orgUnits/(orgUnitId)/users/) returns data for my local admin account, but is 403 for when executing in a student context.
-
Hi James,
403 means Forbidden, so I guess your application user is associated with a rol with no access to Classlist on group level, please check "Has Access to the Classlist" permission for your application rol:
There are Enrollment API and ClassList API because represents two things, here a brief summary:
Enrollment API:
- Associated to "User" menu in Admin GUI
- Associated to User Tool in "Roles and Permissions" Admin GUI
- Check "Search for 'xxxx'" permission under OU levels (CourseOffering, Groups, etc) to successfully call Enrollment API and retrieve information for users with role xxxx.
ClassList API:
- Associated to "Classlist" for a course
- Associated to ClassList Tool in "Roles and Permissions" Admin GUI
- Check for "Has Access to the Classlist" permission under OU levels to successfully call ClassList API and retrieve that list.
- Check "Edit Setting" for you learners rol and check those options under "Classlist Display Options" in order to be included in classlist . And, yes, /d2l/api/le/(version)/(orgUnitId)/classlist/ return data for all users which rol is included in ClassList.
So, when you enroll a user it doesn't imply they are included in classlist, it depends on your role configuration and role permission setting for User and ClassList tools, endpoints in valence respect yours environment configuration.
Best regards,
Sergio
-
Hi Sergio,
This setting does grant access to the data. Thanks for the help.