Getting the current user role in a course offering

71 views
Skip to first unread message

Paul Bonenfant

unread,
Jun 5, 2014, 7:34:33 PM6/5/14
to valenc...@googlegroups.com
Hi I am trying to access what my user's role is given a course offering. I'm writing an app geared towards profs and I would like to get a listing of their current course offerings in which they are an instructor only.

I can get all course offerings by calling:
/d2l/api/lp/1.4/enrollments/myenrollments/?orgUnitTypeId=3

However this returns all courses; even those courses for which the user is registered as student by the institution (i.e. WHMIS training). I do not want to have these course offerings in their list of courses, but cannot find a way of filtering them out.The data structure returned simply does not have the role information.

I tried /d2l/api/lp/1.4/enrollments/orgUnits/(orgUnitId)/users/(userId) but a "Not authorized to perform this operation. (HTTP status 403)" was returned.  Is there a way of getting the role information for an org unit to which the user is enrolled (i.e. an org unit returned from myenrollments) without giving global permissions?

Thanks,

Paul


Desire2Learn Staff: Sarah-Beth

unread,
Jun 9, 2014, 9:28:42 AM6/9/14
to valenc...@googlegroups.com
Hi Paul

This is a good question - I'm speaking to some developers to help get you an answer. I'll get back to you as soon as I have all the details.

~S-BB

Desire2Learn Staff: Viktor

unread,
Jun 11, 2014, 3:45:28 PM6/11/14
to valenc...@googlegroups.com
Hi Paul,

Unfortunately, the answer is that role-for-enrollment information is typically treated as privileged information by clients, and the LMS configurations are set up this way -- typically "end user" type roles (like students, instructors, tutors, and so forth) are not given the permission to make the calls they need to inspect the role bound to an enrollment.

The call you want to use for your use case is the "get all enrollments for a user" call, but on most client systems those general enrollment calls are reserved for administrative-role users. You really only have two options here:

* The LMS admins can extend the permissions for these calls to your target user role types -- I can well understand that they may not want to do this

* You can design a hosted service that uses a service user account with specific, elevated permissions, and controls the kinds of data sent back to your end-user-owned applications to help get the information you'd like to present and then massage it carefully; this is a potential workaround that could meet your use case, but is obviously potentially open to abuse, and again, your LMS admins may well object to this technique

I'd recommend that you request some enhancement around the enrollments APIs through your partner or account manager, or post it on D2L's Products Idea Exchange. Other clients have also asked for this enhancement, but this was an intentional design decision built into the API (so it's not a defect, it's "working as designed").

There are several potential solutions that could help meet your use-case and still preserve some of the privacy around assigned LMS roles that our clients have required, but none of them are on the immediate road-map to implement: requesting the enhancement through official business channels between your LMS admins and D2L (i.e. through an approved support contact, or an account or partner manager) can help increase the priority towards getting this done.

Thomas Hawkins

unread,
Sep 9, 2014, 10:47:46 AM9/9/14
to valenc...@googlegroups.com
I just ran into this very problem, and happy to have found the answer.  But not happy to have no built in solution.  Building a whole other webservice for handling this seems a bit overkill, but we may have to do this.

Thanks for the information.

Desire2Learn Staff: Sarah-Beth

unread,
Sep 9, 2014, 2:40:39 PM9/9/14
to valenc...@googlegroups.com
Glad that you found your answer, Thomas... Even if it's not ideal.

If you do move forward with the solution you have in mind, it would be great to hear how it works for you and any lessons learned along the way. If you can, come back and share your knowledge on the forums.

Paul Bonenfant

unread,
Sep 9, 2014, 3:18:01 PM9/9/14
to valenc...@googlegroups.com
I ended up giving my users the ability to remove those courses which they don't teach from a cached list of courses in the app. That way they don't have to see courses for which the app doesn't apply; but it does rely on their input.

Hopefully a future release will support being to query the role for a course offering given that the offering is returned by the myenrollments. I can see my role as Student in those courses when I log in to the LMS and view the Classlist.

Paul
Reply all
Reply to author
Forward
0 new messages