cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
acbart
Community Participant

Using Canvas API to retrieve quiz answers for all submissions (fill_in_multiple_blanks_question)

Jump to solution

I am attempting to use the Canvas API to retrieve the quiz answers for all past submissions for all my students, in order to analyze their earlier responses. I am able to retrieve past quiz submissions for quizzes using the 'quiz/:quiz_id/submissions' endpoint, which gives me quiz_submission_ids, which I can then follow-up on with 'quiz_submissions/:quiz_submission_id/questions'. However, it appears that I'm unable to retrieve all of the students' answers from these results. Depending on the submission type, it doesn't appear that the "answer" field is always populated. In particular, the 'fill_in_multiple_blanks_question' type does not have results. According to this appendix, I would expect this field to be present as a hash of strings to strings, and yet the field is undefined.


Am I accessing this field incorrectly? Or is there some other way I can get access to the entire previous student submission? Ultimately, my goal is to analyze every answer from every past submission for every student in every quiz, so a way to just get the bulk data would be a suitable answer too. 

4 Solutions

Accepted Solutions
Robbie_Grant
Community Coach
Community Coach

 @acbart ,

Were you able to find an answer to your question? I am going to go ahead and mark this question as answered because there hasn't been any more activity in a while so I assume that you have the information that you need. If you still have a question about this or if you have information that you would like to share with the community, by all means, please do come back and leave a comment.  Also, if this question has been answered by one of the previous replies, please feel free to mark that answer as correct.

 

Robbie

View solution in original post

acbart
Community Participant

Yes, I discovered the answer! The solution is to use the Quiz Reports API: Quiz Reports - Canvas LMS REST API Documentation 

Quick algorithm:

Get all the quizzes (courses/:course_id/quizzes)

For each quiz,

    Post that quiz's report (courses/:course_id/quizzes/:quiz_id/reports) with the report_type 'student_analysis', include the 'file' and 'progress'

    If the 'file' key is not in the returned result, repeatedly request the progress URL (courses/:course_id/progress/:progress_id) until its workflow_state is 'completed' (or 'failed')

   Once the workflow_state is 'completed', you will be able to Post the quiz report again and download 'file' 'url'.

View solution in original post

z_dusatko
Community Participant

I am going through the same process trying to extract quiz questions and student answers by calling just one api and getting result as JSON. So far I see the only way is to POST report and download all student answers as CSV file. I am finding using CSV file report for quizzes awkward, is there really no other solution? I also found this submitted issue for adding answers to quest submission questions API: "answer" is missing from Quiz Submission Questions API · Issue #742 · instructure/canvas-lms · ... but I don't see any progress in this.

View solution in original post

0 Kudos
James
Community Champion

Last month, I discovered that if you fetch the submissions for an assignment and add a query parameter of include[]=submission_history that it returns quiz answers for quizzes. Unfortunately, I didn't need that but there doesn't appear to be a way to turn it off.

There is a submission_data property that is an array that contains one element for each question. It's going to some matching to quiz questions to figure out what's completely going on and I haven't dug that deeply into it, but it does have the answers for my questions (I haven't tested it with an essay question).

View solution in original post

9 Replies
acbart
Community Participant

Ah, I think I can get it by using the 'quizzes/:quiz_id/questions/:id' endpoint on each individual student quiz submission questions, and that will have the complete data. Perhaps this needs to be documented a little more? Haven't done exhaustive testing to confirm that this will work.

acbart
Community Participant

Nope, I was quite wrong. This retrieves the text of the actual answers, and not a students' submission. The hunt continues.

Robbie_Grant
Community Coach
Community Coach

 @acbart ,

Were you able to find an answer to your question? I am going to go ahead and mark this question as answered because there hasn't been any more activity in a while so I assume that you have the information that you need. If you still have a question about this or if you have information that you would like to share with the community, by all means, please do come back and leave a comment.  Also, if this question has been answered by one of the previous replies, please feel free to mark that answer as correct.

 

Robbie

View solution in original post

acbart
Community Participant

Yes, I discovered the answer! The solution is to use the Quiz Reports API: Quiz Reports - Canvas LMS REST API Documentation 

Quick algorithm:

Get all the quizzes (courses/:course_id/quizzes)

For each quiz,

    Post that quiz's report (courses/:course_id/quizzes/:quiz_id/reports) with the report_type 'student_analysis', include the 'file' and 'progress'

    If the 'file' key is not in the returned result, repeatedly request the progress URL (courses/:course_id/progress/:progress_id) until its workflow_state is 'completed' (or 'failed')

   Once the workflow_state is 'completed', you will be able to Post the quiz report again and download 'file' 'url'.

View solution in original post

dwillmore
Community Champion

 @acbart ‌

When I run the quiz reports API I get two URLs for the reports, but they fail on download.  I suspect it has something to do with our system permissions, but I was wondering if you ran into this yourself.  Do you have any ideas?

acbart
Community Participant

Hm, it doesn't ring a bell. Looking at my code, I have an IF statement that checks to make sure it worked, but just reports the failure.

As a first sanity check, I'd see if you can make the request in your browser. First, try using the built-in buttons to do so (and check the network request). Then, try making the same API call from the JS console. If that all works, it seems unlikely to be a permissions problem, and more likely an issue with the how you are forming the API call on command line version. I assume you've already tried checking more basic API calls to make sure they work. Is there any kind of error associated with the response, or is it just workflow_state == 'failed'?

z_dusatko
Community Participant

I am going through the same process trying to extract quiz questions and student answers by calling just one api and getting result as JSON. So far I see the only way is to POST report and download all student answers as CSV file. I am finding using CSV file report for quizzes awkward, is there really no other solution? I also found this submitted issue for adding answers to quest submission questions API: "answer" is missing from Quiz Submission Questions API · Issue #742 · instructure/canvas-lms · ... but I don't see any progress in this.

View solution in original post

0 Kudos
James
Community Champion

Last month, I discovered that if you fetch the submissions for an assignment and add a query parameter of include[]=submission_history that it returns quiz answers for quizzes. Unfortunately, I didn't need that but there doesn't appear to be a way to turn it off.

There is a submission_data property that is an array that contains one element for each question. It's going to some matching to quiz questions to figure out what's completely going on and I haven't dug that deeply into it, but it does have the answers for my questions (I haven't tested it with an essay question).

View solution in original post

gahs
Community Participant

This seems to me to be the best answer. It is the only way I could find to do this for quiz submissions. The only minor annoyance is that there doesn't seem to be a way to make it return submissions of the "Test" student, so it is difficult for a faculty member with just one account to debug on a test course.

James' observation about the effect of include[]=submission_history on fetching assignment submissions is interesting, but I could not find an equivalent functionality for quiz submissions. Maybe I'm missing something.