instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.71k stars 2.52k forks source link

API: "answer" is missing from Quiz Submission Questions API #742

Closed rodogir closed 8 years ago

rodogir commented 8 years ago

Summary

Quiz Submission Questions API does not return the answers provided by the user. The answer property is missing from the quiz_submission_question objects.

Docs for the API: https://canvas.instructure.com/doc/api/quiz_submission_questions.html

Steps to reproduce

  1. Setup a quiz that allows students to see their answers (check "Let Students See Their Quiz Responses)
  2. Take the quiz as a student
  3. Retrieve submission questions through the API:
GET     /api/v1/quiz_submissions/:quiz_submission_id/questions

Expected behavior

The returned submission questions should contain the answer property as described by the API docs

{
  //The ID of the QuizQuestion this answer is for.
  "id": 1,

  //Whether this question is flagged.
  "flagged": "true",

  //The provided answer (if any) for this question. The format of this parameter
  //depends on the type of the question, see the Appendix for more information.
  "answer": "",

  //The possible answers for this question when those possible answers are
  //necessary.  The presence of this parameter is dependent on permissions.
  "answers": ""
}

Additional notes:

Possibly already known as I found this post talking about the same issue: https://community.canvaslms.com/thread/2716

Is the score per question available somewhere? I haven't found anything regarding this.

ryanmt commented 8 years ago

Hey,

So the quiz_submission_question endpoint doesn't expose the answer on a completed quiz submission. Once a QuizSubmission has been completed, it only provides "correct" and "flagged" fields.

I believe that the only per user scoring we are exposing via the API is a quiz level result, as accessible at the api/v1/assignment/:assignment_id/submission/:submission_id endpoint. But there isn't any way to get per item scoring from the quiz apis. We do provide comprehensive data around items/students via the quiz report API (i.e. the quiz statistics reports).

Cheers, Ryan

dahlbyk commented 8 years ago

Came to report this same issue.

At minimum, I would urge you to revise the documentation that states answer will be included in the payload. GET /api/v1/quiz_submissions/:quiz_submission_id/questions explicitly states its example response is { "quiz_submission_questions": [QuizSubmissionQuestion] }, but the actual quiz_submission_questions values are actually QuizQuestion objects with the extra correct and flagged fields (in which case, why support include=quiz_question?).

That said, it would be extremely useful for the API to respond as documented, and including raw score and comments would be even better. As James mentions on the referenced community thread, the student_analysis Quiz Report is very awkward to work with from an API perspective (polling for report to complete, denormalized CSV structure, etc) and doesn't include all the relevant information.

Is there a specific reason submission details are not available through the API?