-
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
Add support for parameters to Submission.edit when using Submission.upload_file #554
Comments
I see the potential value, but the rest of the library only accepts When a file is uploaded successfully, it returns the attachment data that has to be posted to the submission endpoint anyways. The comment goes on the submission, not on the file. |
I might be misreading/misunderstanding the code, but bear with me. canvasapi/canvasapi/submission.py Line 180 in 2859820
Submission.edit is called.
If I understand it correctly, this will create a new comment on the submission, with the attached file. Can/Should I then use the returned response-object to obtain a reference to the posted submission comment, so I can edit the parameters of the comment after it has been posted? |
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().
When using
canvasapi.submission.Submission.upload_file
, the file is first uploaded, then attached to a comment withcanvasapi.submission.Submission.edit
.Is it possible to extend
upload_file
such that it accepts an optional**kwargs
, that can be passed toedit
in case the upload succeeded?This would allow for uploading a file setting the
text_comment
parameter for uploaded files, as well as setting thegroup_comment
parameter when uploading files as comments on a submission as a grader.The text was updated successfully, but these errors were encountered: