I'm trying to figure out if it's possible to add a file to a file upload question in quizzes.
I tested with assignments first (because it was a lot easier!) and the process requires many steps, with the last being that after the file was uploaded to the user's files, sending the file id in the assignment submission.
For quizzes, I've done the file upload and it's in the user's files, then I attempted to actually "take" the quiz through the api. I got as far as /api/v1/courses/:course_id/quizzes/:quiz_id/submissions/questions.
I have found all the other question types and what to add to the json body except for the file upload question:
I was hoping I could just add the ID for the file as I did in assignments, but that doesn't work.
Has anyone been successful at adding a file (as the student) from the user's files to a quiz file upload question?
Update: There are actually a couple of issues with the quiz file upload process and I've filed a couple of tickets.
If you test assignments, the folder_id is returned for the user's files -> submissions folder. The assignments upload file is there.
If you upload a file for quizzes, no folder_id is returned, (displays null), and while you can use the URL returned to view/download the file , it is not found in any of the user's folders. I would have expected it to be in the submissions folder also.
The next problem is that there is no documentation on the file_upload question type, so even if the file were uploaded correctly, it still could not be used if trying to take the quiz through the API.
After getting through to Level 2 support I finally got an answer on this: post the Id of the file as the answer to the question.
In more detail...
I've confirmed this works fine. It's important to note that the Canvas API does not do any file type validation so that will need to be handled by your application.