Skip to content
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

Comments to submissions are always added to first attempt #631

Open
hokies9402 opened this issue Jul 7, 2023 · 1 comment · May be fixed by #639
Open

Comments to submissions are always added to first attempt #631

hokies9402 opened this issue Jul 7, 2023 · 1 comment · May be fixed by #639
Labels

Comments

@hokies9402
Copy link

When using upload_comment in the submission.py the files that are uploaded are always attached to attempt 1 regardless of which attempt the comment was meant for

To Reproduce

  1. Submit an assignment to canvas.
  2. Use upload_comment to attach a file as a comment to the submission attempt.
  3. Resubmit to the same assignment as the same student.
  4. Use upload_comment again to upload another file comment.
  5. See that both files are attached to attempt 1, not attempt 1 and then attempt 2.

Expected behavior

When you upload a file as a comment it is attached to the most recent attempt, not attempt 1 always

Environment information

  • Python version (python --version)

  • [@spruce ~]$ python --version
    Python 3.9.16

  • CanvasAPI version (pip show canvasapi)

  • [@spruce ~]$ pip show canvasapi
    Name: canvasapi
    Version: 3.1.0
    Summary: API wrapper for the Canvas LMS
    Home-page: https://github.com/ucfopen/canvasapi
    Author: University of Central Florida - Center for Distributed Learning
    Author-email: techrangers@ucf.edu
    License: MIT License
    Location: /home/staff/dmcphers/.local/lib/python3.9/site-packages
    Requires: arrow, pytz, requests
    Required-by:

Additional context

I already know how to fix this.
Line 180 change it from this:

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

Line 180 change it to this:

self.edit(comment={"file_ids": [response[1]["id"]], "attempt": self.attempt})

@hokies9402 hokies9402 added the bug label Jul 7, 2023
@StellaYHXXX
Copy link

Can I work on this issue?

bainco added a commit to bainco/canvasapi that referenced this issue Nov 17, 2023
@bainco bainco linked a pull request Nov 17, 2023 that will close this issue
cnuahs added a commit to cnuahs/canvasapi that referenced this issue Apr 23, 2024
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().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants