Leading through Chaos - Insights and Actions • Browse the resources from the keynote presented by the Academic Strategy Team.
Found this content helpful? Log in or sign up to leave a like!
I use the endpoint below to get all submissions from a specific course
https://myconpany.instructure.com/api/v1/courses/:course_id/quizzes/:quiz_id/submissions
For each answer, I have a html_url, for example
https://mycompany.instructure.com/courses/8718/quizzes/58321/submissions/1409414
that is converted to
https://mycompany.instructure.com/courses/8718/quizzes/58321/history?user_id=3341
I was able to see the user_id by the URL and all answers from that user on the HTML page.
Is there an API endpoint that I was able to see the answers from the student(including the answer that students write).
There is an documented switch that has the undocumented side effect of giving you the quiz responses.
Get the submissions (not quiz submissions) for the corresponding assignment and be sure to add the query parameter: include[]=submission_history.
Let's say that I have a quiz at /courses/896851/quizzes/3986251. If I GET /api/v1/courses/896851/quizzes/3986251, I see that the assignment_id is 13300109.
Then I GET /api/v1/courses/896851/assignments/13300109/submissions?include[]=submission_history.
It returns an array of users, and each user that has taken the quiz has a submission_history.submission_data array. That array contains an object for each question.
Here is an example (just the submission_data portion) from a quiz I gave.
{
"submission_data":[
{
"correct":true,
"points":1,
"question_id":73065717,
"answer_id":5521,
"text":"5521",
"more_comments":""
},
{
"correct":"defined",
"points":0,
"question_id":73065719,
"text":"<p>An ancient Egyptian casket.</p>",
"more_comments":""
}
]
}
The response to the essay question (question 2) was "An ancient Egyptian casket."
To make sense out of the first question, you need to get the information about the question from somewhere else.
I can do that with GET /api/v1/courses/896851/quizzes/3986251/questions
The first question had question_id=73065717 and was "What is the teacher's favorite color?". From the answers object, you can tell what response 5521 is. Do NOT look at the text property here, they didn't type 5521.
For the second question, id=73065719, the question_type was "essay_question" and the text was "Explain sarcasm." The text in this case is what the student typed.
See the appendix of question answer formats at the bottom of the Quiz Submission Questions API documentation for additional information.
Hi @fabiocunha ,
Did you tried to get all submissions for all assignments? And after that search for your quiz_id?
I had a similar issue in the past and @jamesjonespa kindly helped me with excellent explanations on that post: https://community.canvaslms.com/thread/44434-is-there-an-api-call-that-get-a-list-of-all-submissions...
Hope it helps!
Is your quiz a practice quiz or ungraded survey? They may not have assignments associated with them. One thing you could do (untested) is to go to your beta instance, change it to be a graded assignment, and then get the results out of it as I described earlier.
Quizzes that don't have an associated gradebook entry will not return an assignment_id. I would assume there is no way to get submission_history for them.
Hi James, I tried this but it didn't work. Can you verify that it's still working on your end? I am not seeing the submission_data portion in the response
Sorry for the delay. Anymore, if people aren't at-tagging me, I'm not getting the message and may miss stuff.
Yes, this still works. I just created a brand new classic quiz, added an essay question to it, took it, and then retrieved the text of the essay answer.
The query I used was
GET /api/v1/courses/:courseId/assignments/:assignmentId/submissions?include[]=submission_history
Make sure you're using the assignment ID and not the quiz ID.
The submission_data is under submission_history.
Hi @James
Thanks for sharing these details. I used to use Quiz Report API to fetch this information but what you shared here seems way better way to get it. Now I need to get student submissions(answers and grades) for each question for another use case using the new quizzes API. I am curious do you know how can we achieve the same results with the new quizzes API?
No.
I try to avoid New Quizzes as much as possible. The API is not developed as much as for Classic Quizzes. That said, I'm not using a [Classic] Quiz API to get the answers, I'm using the Submissions API. You could check the Submissions API with the include[]=submission_history, but since New Quizzes is separate from Canvas, while Classic Quizzes was a core part, I would not expect it to be there.
I'm not sure that I ever saw it officially documented that you could get student answers from the submissions, which means it may not be supported.
I thought it might be better to append my question to this topic, instead of opening a new one...
@James thank you for your very clear answers! Do you know if there is a way to get the quiz answers through GraphQL as well? I found the SubmissionHistoriesConnection, but it doesn't output the text field, like the REST API .../submissions?include[]=submission_history does. (In your initial reply, this is the text field with value "<p>An ancient Egyptian casket.</p>".)
We're using (Classic) quizes and I couldn't find a way to get it. If you know a way to get it with New Quizzes, it would be much appreciated too!
Information about Classic Quizzes is almost non-existent through GraphQL. You can determine whether an assignment is a quiz, discern the type of quiz, get the quiz ID and any module placements through GraphQL, but that's about it.
GraphQL was pushed as Canvas rolled out new functionality. It was for quick but limited responses. Classic Quizzes were already on the way out at that point and they weren't going to waste the effort to rewrite it in GraphQL.
New Quizzes is another thing all together. I try to use it as little as possible.
It's an LTI and limited support through the API was developed. Through the REST API, they have New Quizzes, New Quizzes Items, and New Quizzes Reports. Compare that to Classic Quizzes, which had extensions, IP filters, question groups, questions, reports, statistics, submission events, submission files, submission questions, submission user list, submissions, and just the regular old quizzes. It's not that they rolled all the functionality into just three APIs, either.
The Instructure Developer Documentation Portal has documentation that includes other services than the REST API documentation, but the documentation for the Quiz API is pretty poorly structured. They don't give names like "Get a single quiz", just the names of the functions, so "create" is there three times, "index" is there four times.
That documentation does include (as one of the "index" endpoints) the ability to get session_item_responses. But you have to know the quiz_session_id to get that information. There is another "index" to get the quiz_sessions, but you have to know the quiz_id. There's another "index" endpoint for that.
I don't know what any of this returns. Unlike the REST API document that we're used to, the only thing the response documents is error and errors. Path and query parameters have a name but no explanation of what they are.
In short, I still don't know how to do this, or if it's even possible, with New Quizzes.
@James thank you very much for your elaboration. I didn't know the documentation portal link yet, but after looking around a bit, I wonder if it'll be of any added value...
I was hoping you would bring more love for New Quizzes; I already found your 2023 / 2024 posts with little enthousiasm for them haha. Then I suppose there is nothing to do currently, except use the (undocumented) REST API functionality to retrieve quiz answers, and wait for New Quizzes or GraphQL to be developed further and offer a good alternative in this use case. (If I were a better programmer, I would check if I could help the open source parts in this regards, but alas...)
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in