Skip to content

Commit 40bac66

Browse files
committed
Remove call to Submission.edit() in Submission.upload_comment().
Lots of weirdness around how uploading files to a submission works. (see for example ucfopen#496 ucfopen#554 ucfopen#631). This isn't really a fix for any of those. This is just a quick hack to make it work for my use case. At present, a call to Submission.upload_comment() to upload a file to attach to a comment, includes an implicit call to Submission.edit() that creates an empty comment (i.e, no text) on the submission, or, attached the file to any previous comment. This doesn't seem to fit with the description in the Canvas API documentation and is never what you actually want. This change removes that implicit call to .edit(). To comment on a submission and attache a file, first call .upload_comment() to upload the file, and then call .edit() including your comment text, grade etc. as well as the file id returned by .upload_comment().
1 parent 02d42cb commit 40bac66

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

canvasapi/submission.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ def upload_comment(self, file: FileOrPathLike, **kwargs):
176176
**kwargs
177177
).start()
178178

179-
if response[0]:
180-
self.edit(comment={"file_ids": [response[1]["id"]]})
179+
# if response[0]:
180+
# self.edit(comment={"file_ids": [response[1]["id"]]})
181181
return response
182182

183183

0 commit comments

Comments
 (0)