-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The course.quiz.listSubmissions(options) method doesn't return any results when visitEndpoint returns multi-page results. This happens because, with multi-page result sets, visitEndpoint() returns an array of objects and not an object that contains a quiz_submissions key.
See code at line:
caccl-api/endpoints/API/Course/Quiz.js
Line 587 in 08b290f
| return Promise.resolve(response.quiz_submissions); |
I haven't checked other methods that check multi-page results return results properly, but suspect the listSubmissions() method is not the only one.
The root of the problem is that genVisitEndpoint() doesn't return an array if there is only one page of results. This is unfortunate as it complicates how to handle its return value by calling code.
See code starting at line:
| const allData = ( |
If genVisitEndpoint() always returned an array, calling code could easily flatten single or multi-page results (e.g.: [].concat(...response.map(({ quiz_submissions }) => quiz_submissions))) or unwrap when a single result is expected (e.g.: response[0].key).