Duplicate attachment id's when filename is not unique

mpoell-acc
Community Novice

We have built an integration for our tool with Canvas.
A student submits a document through our tool.
Using the Canvas API, our tool uploads the file to a Canvas assignment.

Uploading according to:
https://canvas.instructure.com/doc/api/file.file_uploads.html#method.file_uploads.post

Then using the attachement_id from the previous API-respons submitting to the assignment according to:
https://canvas.instructure.com/doc/api/submissions.html#method.submissions.create
submission_type: 'online_upload'
file_id: from the API response of the upload
user_id: student's ID

Canvas sends the document to a plagiarism scanner, and we eventually receive the link to the plagiarism report via the API.

We use one course with one assignment where the student can make multiple attempts.
Submission and retrieving a report work well for standard cases.

However, during testing, we observe the following:

If the uploaded file name is unique, the file gets a unique attachment_id.
If the uploaded file name is the same as a previously submitted file, we sometimes see that the API returns an already existing attachment_id, and other times it returns a new attachment_id. This can be replicated consitently

In the Canvas interface, we see uploaded files listed as separate files.
If the file name already exists, Canvas sometimes adds a sequence number or a hash to the file, as described in this post:
https://community.canvaslms.com/t5/Canvas-Question-Forum/Resubmit-assignment-but-keep-original-filen...
We also see this modified name in the API under display_name. In both cases: if canvas added a number or a hash to file then the file also has a unique attachment_id.

We do not quite understand why a new attempt does not always get its own attachment_id or why an existing filename doesn't always get's added a number or a hash.
Does anyone recognize this issue or know where this inconsistency comes from?

 

Thanks for your help!

Labels (4)
0 Likes