Viewing results of quiz attempts

Jump to solution
mark14
Community Novice

Using the LMS REST API, is it possible to get a list of past quiz submissions with either the answers the user submitted for that attempt or whether the answer the user submitted was correct or not?

My use case is I want to the students to have unlimited attempts to get all the questions correct on a quiz. I want to show them which questions they got incorrect on their previous attempt.

I've been playing with the `Quiz Submission Questions` and `Quiz Submission` REST api's but it does not seem to return answers in JSON format, just a link to an HTML page with the answers.

Labels (1)
1 Solution
sendres
Community Participant

Yes, you can get the specific information you are looking for via the API. It's a bit convoluted to do so since a bit of it is undocumented.

  1. GET /api/v1/courses/:course_id/quizzes/:id 

    Start by getting the general information about the quiz. One of the attributes returned from this call will be an assignment_id (NOT the :quiz_id) corresponding to this quiz. Note that the REST API description of the Quiz object does not tell you that each quiz has a corresponding :assignment_id, but Canvas does send back this information in the response.

  2. GET /api/v1/courses/:course_id/assignments/:assignment_id/submissions?include[]=submission_history

    Next, get the submissions to the assignment (again, the assignment, NOT the quiz) and ask Canvas to include the submission history. This part actually is documented, but it's tucked away in the Submissions API instead of the Assignments API where I expected to find it.

    This response will give you a submission_history array containing a submission_data array with the information about all the individual questions and whether they answered correctly or not.

View solution in original post