desire2learn Valence: Course Getting orgUnitID from Offering Code - desire2learn

I'm doing some work with grades and the desire2learn Valence API. In the context I'm operating in, there is no way for us to get the orgUnitID directly. We are currently getting the Offering Code for each course but not the orgUnitID. Since the API requires the orgUnitID for any interactions with a course, is there any way to look up the orgUnitID using the offering Code for the course?
Thanks,
George

There is no call to search for a course by offering code, but, the offering code is set in the OrgUnitInfo structure. So I have seen people retrieve that structure as an indirection to get the actual ID. (For example when trying to retrieve grades)
If you have a user id for example you could get enrollments and go from there.
To answer further I would need a sense of how you wanted to walk the courses? Globally or for a specific user or something else?

Related

Asana API: organization_exports

How do I get organization ID? I tried this:
https://app.asana.com/api/1.0/organization_exports
But it returns
{"errors":[{"message":"Not Found","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}
Of course I'm logged in, or use an access token, and other API calls work fine.
My final goal is to make use of the organization ID in https://github.com/Asana/export_importer.
sorry for the delay - the system that was supposed to alert us to your question didn't pick this one up.
The easiest way to get the organization ID is to query our API for your user to see what organizations you're a member of, rather than use the organization_exports endpoint - that's for exporting a full organization data dump for backup or reporting purposes.
If you look at our API documentation for getting your user at app.asana.com/api/1.0/users/me, you'll see that your user record returns a list of workspaces which have ID and name information. This is probably the most straightforward way to get your organization ID from our API.

Getting List of All Instructor Enrollments

I've been using /d2l/api/lp/1.4/enrollments/myenrollments/ to get a list of enrollments for the current user. Now, I want to just get the enrollments where the user is in an instructor role. So, I'm trying to use:
/d2l/api/lp/1.4/enrollments/users/{userId}/orgUnits/?roleId=105
When I use that, I get an empty list of Items back, with or without the roleId specified.
My expectation is that just calling it without the roleId would return the same list as /d2l/api/lp/1.4/enrollments/myenrollments/. But, I always get an empty list, except when I log in as a system administrator. Only in that case do I get anything back.
Does anyone have any suggestions on what I might be doing wrong?
The various my* API calls specifically exist to provide end users to fetch back details about the system that they should know, but segregated from information they shouldn't (that's available through the more general routes for a particular area). Enrollments is a good example of this. And end-user should be able to see their own enrollments, but they should not have generalized access to enrollment records. In particular, the D2L system treats the D2L user role belonging to an enrollment as fairly privileged information, and a side effect of this is that it's not generally visible to end users.
One way that applications and services can cope with achieving goals that the end-user cannot themselves perform is to have set up a "service account" that the app can use to make calls of an administrative nature, to fetch back data that they can use in the business logic around presenting information to end users. In this particular case, you could, for example use the service account to make calls about a user's enrollments, and then present the user with logic that could filter the list of their enrollments by "these are the student ones, and these are the ones where you're a teacher, and a tutor, and so forth".
But you'd also need to carefully consider the implications of this type of activity in balance against the intentions of the client LMS's policies and administration. Even this level of information may be giving away too much to end users, in the eyes of a client LMS administrator.
Using a service account to let an app make administrative level calls must always be done with great care around the issue of information/functional leakage to end users.

What are the permissions required in desire2learn (D2L) Valence PUT call for .../courses?

I continue to get a "HTTP/1.1 403 Forbidden" response from a PUT request to /d2l/api/lp/1.2/courses/7917 . This may be a permission problem with the user/role that I'm using, but I can't figure out what specific permissions may be required. Can anyone point me to a list or matrix of valence routes and required permissions? Or, answer for this specific one?
The same appid/userid/username works for the GETs associated with the same path.
confused...
cwt
The permissions associated with API calls should mirror the permissions you'd have to have if you were to perform the relevant function through the Learning Envrionment's web UI. You can think about this problem in two ways:
Frame the question in terms of a user role: identify the class of users you'd reserve this ability for in your existing configuration, and ensure that a user of that role can make the call through the API as you'd expect.
Frame the question in terms of an abstract single user: start with a role that has no privileges and add permissions until you arrive at only the ones required for the API call. This is not a trivial exercise, and the first way is far more useful in the long run.
In this particular case, because the API requires you provide a complete course offering set of properties when you want to update it, you have to have permission to alter all the properties in the set (under the Manage Courses tool). You also need to be able to see the course info in the first place, so you need to have Course Management Console > See Course Info as well.
You're probably safest to look at the permissions array in the Manage Courses and Course Management Console tools for the user roles that would do this thing in the web UI and make sure that the users employing your app also have a similar permissions array specified in those tools.

D2L - User clicks on URL link, how to get User's current course

I know I can get the courses the user has, but I want to know where the user is at this moment - clicking the link to our external application. I'm building on the Getting Started example in PHP, from the valence/desire2learn.com website. We're using d2l for many of the course materials but want to produce some tracking and graphs for students to see. It would involve getting grade info (which I think I can do), having students enter hours of study (in our application), storing that information and returning a graph comparing course grade and study hours over the course. It would be much better to automatically pick the right course than to have the student pick the right course.
Can it be done (obtain which course the student's in at the time the link is clicked)? In addition to the annoyance of having to pick which course, it's possible that students are taking more than one course at a time where the teacher is using this tool.
Thanks in advance for your assistance.
If you use LTI v1.0 (Basic LTI) to build the link to launch from D2L to your external application, then the LTI context passed to your application will contain a context_id property: the value of this property will be the org unit ID that identifies the D2L organizational unit for the launch point's context (in this case, the ID of the course offering). Note that until LE v10.2.0 SP1, D2L won't send along the context_id for the top org level, but if the user launches an LTI link from a course offering context, you should get the org unit ID for the course offering.

How do I use the Desire2learn Valence API to enroll a student in a course?

In trying to automate a workflow, how do I use the D2L REST API to enroll a student in a course?
D2L works on enrollments that are a tuple of the user, the role and the course or org structure (orgunitid represents course or a structural element like a department or faculty). The call to create these enrollments allows you to specify all these values, and other calls allow retreival of the ids for users or courses.
Most often developers need to search by course code, but that is not possible directly on version 9.4.1 or version 10.0 so you will want to locate the d2lid from the course code in the calling code (this course code search is covered in other questions as well).

Resources