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
Original title was "Canvas.get_assignment_group should turn assignments into Assignment instances"
A call to Course.get_assignment_group can optionally include full details about the assignments in the group. That is a nice way to reduce round-trips if we already know that the details will be needed.
In version 0.6.0 of canvasapi, these assignment details are provided as a list of dict.
group=course.get_assignment_group(group.id, include='assignments')
forassignmentingroup.assignments:
print(assignment) # prints each assignment as a dict
I was expecting them to be a list of Assignment instances. Each dict seemingly has all of the details needed to build an Assignment, and I can do that conversion myself:
group=course.get_assignment_group(group.id, include='assignments')
assignments= [Assignment(group._requester, raw) forrawingroup.assignments]
forassignmentinassignments:
print(assignment) # prints each assignment as an Assignment
However, accessing group._requester directly seems like cheating. And I would have expected canvasapi to take care of such details behind the scenes. Can that be done? Can Course.get_assignment_group convert each dict into a proper Assignment for me? (Obviously it should only do so if assignment details are present; without include='assignments', no details are given, so there is nothing to convert.
The text was updated successfully, but these errors were encountered:
Still using canvasapi 0.6.0, calling Course.get_assignment_group with discussion_topic on the include[] list returns Assignment instances have discussion_topic attributes. The values of these attributes are simple Python dict instances but should be DiscussionTopic instances. So this is essentially the same problem, but in a new context. Should I file a new issue for this new context, or do you want to bundle that in with the issue I originally reported here?
I think bundling these issues together makes sense. This is essentially the issue for turning nested objects into actual objects instead of dict. I'll edit the title to reflect this.
Original title was "Canvas.get_assignment_group should turn assignments into Assignment instances"
A call to
Course.get_assignment_group
can optionally include full details about the assignments in the group. That is a nice way to reduce round-trips if we already know that the details will be needed.In version 0.6.0 of
canvasapi
, these assignment details are provided as alist
ofdict
.I was expecting them to be a
list
ofAssignment
instances. Eachdict
seemingly has all of the details needed to build anAssignment
, and I can do that conversion myself:However, accessing
group._requester
directly seems like cheating. And I would have expectedcanvasapi
to take care of such details behind the scenes. Can that be done? CanCourse.get_assignment_group
convert eachdict
into a properAssignment
for me? (Obviously it should only do so if assignment details are present; withoutinclude='assignments'
, no details are given, so there is nothing to convert.The text was updated successfully, but these errors were encountered: