API /courses enhancements

0 Likes

Currently, getting course cross-listing via API is at best cumbersome, at worst is extremely inefficient, resulting in O(n^2) time complexity. Unless I'm missing something, the worst case scenario may look as follows:

1. Get my courses with the user token @ /courses
2. For each course, get sections @ /course/{id}/sections
3. Filter sections, where nonxlist_course_id is null (default parent course section)
4. For each filtered nonxlist_course_id, get the xlisted course @ /course/{id} 

steps 2/3 are easily optimized by running your API requests via async mode, however, for the unfortunate ones (php) the execution is synchronous and will result in the exact worst case scenario time complexity.

Proposal:

There already exists include[]=section parameter within /courses endpoint, which provides a list of section objects. It would make absolute and total sense to have nonxlist_course_id included in the object as follows:

 

"sections": [
    {
        "id": 74998,
    --> "nonxlist_course_id": 34567,
        "name": "2195-POKE-1301-001-INTRO TO POKEMONISM",
        "start_at": null,
        "end_at": null
    }
],

 

Moreover, /course/{id}/enrollments could benefit from the same as well, as there are use-cases where you may need to grab all users with teacher roles or students in xlisted courses via type[]=TeacherEnrollment&role[]=TeacherEnrollment etc parameters. The process to get xlisted courses in this case has pretty much the number of roundtrips to the API.

 

[
    {
        "id": 788753,
        "user_id": 883,
        "course_id": 45801,
    --> "nonxlist_course_id": 34567,
        "type": "TeacherEnrollment",
        ...
        "user": {
            ...
        }
    }
]

 

If nonxlist_course_id is added to both responses, it would completely eliminate step 2 and 3.

 

2 Comments
Stef_retired
Instructure Alumni
Instructure Alumni
Status changed to: Open
 
ProductPanda
Instructure
Instructure
Status changed to: Archived
Comments from Instructure

As part of the new Ideas & Themes process, all ideas in Idea Conversations were reviewed by the Product Team. Any Idea that was associated with an identified theme was moved to the new Idea & Themes space. Any Idea that was not part of the move is being marked as Archived. This will preserve the history of the conversations while also letting Community members know that Instructure will not explore the request at this time.