Open a specific content page in Brightspace depending on which course offering student is enrolled

I apologise upfront if my question comes across very basic but I've never used API calls before so unsure if want I want to do is even possible and if it is, what API call I should be using.
I have been asked to create a button in a course offering, that when pressed, will route the student to another content page depending on their enrollment in another course offering.
Here's my example.
A student can be enrolled in 1 out of 4 possible Schools within our institution. Each School has it's own course offering page. Let's call these A, B, C and D
I've been asked to create a button that when clicked will figure out which of of these school course offerings the student is enrolled in and then route them to a specific school related content page in another course offering.
So if a student is enrolled in A they then see content page related to A in the other course offering.
Firstly is there an API call that can retrieve this information?
Secondly, can that information then be used in a Javascript if, else, else if query?
Answers
-
You might be over thinking this - enrolment in another OrgUnit is an option on release conditions.
So, make four copies of the content topic which contains the button. Link each button to the relevant piece of content.
Use release conditions to release the appropriate topic based on their enrolment on the course you are linking to.
-
You could probably use the API call to retrieve the user's list of Org Unit Enrolments here:
(note: you'll need to know the user's LMS User ID to use this route)From there you'd have the list of the user's enrolments which you could filter to see which of the 4 Orgs they belong to and then redirect them to the appropriate page from there.
-
Hi Scott,
/d2l/api/lp/(version)/enrollments/myenrollments/ (
) will give you a list of all enrollments for the user. Then you can loop the response to see if the user is enrolled in any of the school course offerings. If yes, redirect the user to that course page or content.Or, multiple calls of /d2l/api/lp/(version)/enrollments/myenrollments/(orgUnitId) (
) if there are not many schools.You can place the button as a custom widget on the user's home page.
-
Hey Scott,
I wouldn't use the API to do what you described.
@Steve.B.446 's design is the best, after reading over your description.
If there is a definite requirement for a button, you can do this…
The following assumes you have the course cut up in sections and students enrolled into sections properly.
Create four New announcements in the News Widget with a Button on it. Each with a release condition linked to the section.
Now, only those student in those sections can see this announcement, the button link to the content area of your choice.
However, I would also put a release condition on the content, limiting it by section only. The problem you may run into is, if a student need to be in multiple sections at the same time.
Now, to do this in API, I would avoid using direct JS. The last thing you need is your OAuth 2.0 code being accessible via a View Source. Also, the code has a time limit on it. You'd need something on the backend to ensure it is updated constantly. Since you are building all of that, might as well create a custom Widget, which is an iframe to an external (self hosted) webapp, where you can pass the student's D2L ID and Course ID, and you can look it up via PHP/Java/Python on the backend to generate a new button to link them to a specific content area.
Hopes this help.
-
The suggestion above with Release Conditions sounds like the most efficient method.
Otherwise, look into Login Logic - think it only applies to Organizational homepages (e.g. not a course specific one). I believe it's a feature that D2L has to configure for you.