You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Course.list_multiple_submissions method returns a paginated list of Submission instances. However, printing any of these instances using its default string conversion fails:
AttributeError: 'Submission' object has no attribute 'id'
If instead I print each submission’s __class__ and attribute dictionary, I see something rather strange. The class is indeed canvasapi.submission.Submission. However, the attributes are not those that a Submission should have. Ignoring the double-underscore internal attributes, each submission instance has:
_requester
attributes
integration_id
section_id
set_attributes
sis_user_id
submissions
to_json
user_id
The sis_user_id and user_id attributes tell me that this is some sort of person-identifying structure along the lines of a User or Enrollment object. But it does not have the complete set of attributes for either of those. The value of the submissions attribute is a list of dicts; I believe that each of these dicts corresponds to one Submission object.
The Course.list_multiple_submissions method produces a GET /api/v1/courses/:course_id/students/submissions request, and the documentation for that request shows that its response can take one of two forms depending on the grouped parameter. I can see that the Course.list_multiple_submissions implementation always hard-codes grouped=False, but the response coming back looks exactly like the Canvas API documentation example of a grouped response, complete with those submissions attributes giving lists of Submission objects.
So it seems that the grouped=False aspect of the request is not working as intended. I don’t know why; is this a Canvas bug or a canvasapi bug? Either way, the current behavior certainly is not working as intended. canvasapi should either request a non-grouped response in a way that works, or else it should process the grouped response in a way that respects the actual structure and meaning of the returned data.
For now I am working around this myself by building new Submission instances out of the dicts in each of the submissions attributes, like this:
This appears to be (in part) an issue with Canvas. The documentation for the grouped parameter indicates that despite being of type boolean, passing any value at all (even false, 0, etc) will act as if it were set to true
If this argument is present, the response will be grouped by student, rather than a flat array of submissions.
I can change our hardcoded grouped=False to grouped='' to patch this issue. The intention behind adding grouped=False in the first place was to prevent Canvas sending a response format (grouped) that we are currently incapable of parsing. However, this may alter user expectations, so adding some kind of warning to the user that setting grouped to another value isn't permitted seems appropriate.
Implemented a similar fix to what I mentioned above in PR #76. Instead of passing grouped='', we just remove the param entirely, and warn the user about what we did.
This fix directly resolves the issue you were having, but does not add functionality to handle results returned in the grouped format. I will create a separate issue for this.
The
Course.list_multiple_submissions
method returns a paginated list ofSubmission
instances. However, printing any of these instances using its default string conversion fails:If instead I print each submission’s
__class__
and attribute dictionary, I see something rather strange. The class is indeedcanvasapi.submission.Submission
. However, the attributes are not those that aSubmission
should have. Ignoring the double-underscore internal attributes, eachsubmission
instance has:_requester
attributes
integration_id
section_id
set_attributes
sis_user_id
submissions
to_json
user_id
The
sis_user_id
anduser_id
attributes tell me that this is some sort of person-identifying structure along the lines of aUser
orEnrollment
object. But it does not have the complete set of attributes for either of those. The value of thesubmissions
attribute is a list of dicts; I believe that each of these dicts corresponds to oneSubmission
object.The
Course.list_multiple_submissions
method produces aGET /api/v1/courses/:course_id/students/submissions
request, and the documentation for that request shows that its response can take one of two forms depending on thegrouped
parameter. I can see that theCourse.list_multiple_submissions
implementation always hard-codesgrouped=False
, but the response coming back looks exactly like the Canvas API documentation example of a grouped response, complete with thosesubmissions
attributes giving lists ofSubmission
objects.So it seems that the
grouped=False
aspect of the request is not working as intended. I don’t know why; is this a Canvas bug or acanvasapi
bug? Either way, the current behavior certainly is not working as intended.canvasapi
should either request a non-grouped response in a way that works, or else it should process the grouped response in a way that respects the actual structure and meaning of the returned data.For now I am working around this myself by building new
Submission
instances out of the dicts in each of thesubmissions
attributes, like this:But clearly that is not how the API is intended to be used.
The text was updated successfully, but these errors were encountered: