Skip to content

Commit

Permalink
Remove call to Submission.edit() in Submission.upload_comment().
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
cnuahs committed Apr 23, 2024
1 parent 02d42cb commit 40bac66
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions canvasapi/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def upload_comment(self, file: FileOrPathLike, **kwargs):
**kwargs
).start()

if response[0]:
self.edit(comment={"file_ids": [response[1]["id"]]})
# if response[0]:
# self.edit(comment={"file_ids": [response[1]["id"]]})
return response


Expand Down

0 comments on commit 40bac66

Please sign in to comment.