-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boolean flags mismanaged during assignment creation and update #64
Comments
We've had issues in the past with Canvas being weird about what it accepts for boolean values. See this issue for example. It could be related. Or, it could be on our end. Will investigate. |
When attempting to replicate this issue, I ran into some odd behavior. For each test, I kept everything the same except First, I tried course = canvas.get_course(COURSE_ID)
assignment_template = {
'name': 'CanvasAPI Assignment',
'peer_reviews': False
}
assignment = course.create_assignment(assignment_template)
print(assignment.peer_reviews) @liblit: based on your report, I expected it would incorrectly set peer_reviews to When I tried
I was suspicious that boolean values were simply being ignored, so I created assignments that had assignment_template = {
'name': 'CanvasAPI Assignment',
'peer_reviews': 'true'
}
assignment = course.create_assignment(assignment_template)
# ensure peer_reviews starts as True
assert assignment.peer_reviews is True
# edit assignment to set it to False
assignment.edit(assignment={'peer_reviews': False})
# ensure it's not just the local object that's been changed
confirm_assignment = course.get_assignment(assignment.id)
assert confirm_assignment.peer_reviews == assignment.peer_reviews
print(assignment.peer_reviews) This correctly changed peer_reviews from
These results are identical to the creation results, which was very surprising to me. If booleans were being ignored/dropped, both So... I'm not entirely certain what's going on, especially since this seems to be opposite to behavior that you reported. Do you have example code that replicates the behavior you reported? |
From my own testing, I discovered that the string The requests library sends |
@Thetwam asked:
I do. In fact, the code you offered shows the bug when I run it: course = canvas.get_course(COURSE_ID)
assignment_template = {
'name': 'CanvasAPI Assignment',
'peer_reviews': False
}
assignment = course.create_assignment(assignment_template)
print(assignment.peer_reviews) You say that this prints Extending this to include assignment_template = {
'name': 'CanvasAPI Assignment',
'peer_reviews': False,
'omit_from_final_grade': False,
}
assignment = course.create_assignment(assignment_template)
print(assignment.peer_reviews, assignment.omit_from_final_grade) This prints Could the inconsistency between my and @Thetwam’s output be caused by a difference in some underlying supporting package? Here is my complete dependency stack as printed by
|
I speculated:
Or maybe @Thetwam and I are interacting with different installations of Canvas itself? I do not know how to ask a Canvas server for its version number, or whether that is even a meaningful thing. My Canvas server is |
@liblit We've figured that out. It looks like you can append Our universities are (at least now) running the same version of Canvas. Can you try running this again to see if it's still acting up? |
I reran the following bug-demonstrating code from my earlier comment: assignment_template = {
'name': 'CanvasAPI Assignment',
'peer_reviews': False,
'omit_from_final_grade': False,
}
assignment = course.create_assignment(assignment_template)
print(assignment.peer_reviews, assignment.omit_from_final_grade) This code prints |
I've reported this issue to Canvas: instructure/canvas-lms#1232 |
We’ve patched this in develop following the approach I outlined in my comment last September. See commit 65b7549. |
Working with
canvasapi
0.6.0, I recently usedCourse.create_assignment
to create a large number of assignments. Each assignment had bothpeer_reviews
andomit_from_final_grade
explicitly set toFalse
. (Granted, these are the defaults, but for unrelated reasons it was useful to be explicit.) I was surprised to find that the newly-generated courses had each of these settings turned on, rather than off.I then used
Assignment.edit
to correct the bad settings, again with bothpeer_reviews
andomit_from_final_grade
explicitly set toFalse
. The calls reported no errors, but these two settings remainedTrue
on subsequent queries or when viewed in the standard web interface.Next I used
Assignment.edit
to correct the bad settings again, but this time with bothpeer_reviews
andomit_from_final_grade
explicitly set to'false'
as a lower-case string. The calls reported no errors, and the two settings were indeed changed as desired.So it seems that
False
is either ignored or misinterpreted as true, whereas'false'
is interpreted as false. I can pass the'false'
string for now as a workaround, but surely it would be better forFalse
to have the expected interpretation. When getting results back from the server, Boolean settings come back asTrue
andFalse
, not'true'
and'false'
. Passing settings up to the server in creation and modification requests should behave the same.The text was updated successfully, but these errors were encountered: