API /courses enhancements
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.