instructure / canvas-lms

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

POST Quiz Question answer_comments does not function #2045

Closed tomsant closed 2 years ago

tomsant commented 2 years ago

Summary:

Unable to POST quiz question with answer comments.

I have successfully built a script to create a quiz and quiz questions using python and the canvas API. I'm able to successfully create quiz questions and weights,

Steps to reproduce:

  1. POST quiz question including option parameter for answer_comments
  2. View quiz in canvas
  3. See everything else but the answer_comments

Expected behavior:

Answer comments should be attached to each quiz question answer

Actual behavior:

They do not appear

Additional notes:

Here is the json I'm sending through. Again, note answer_text and answer_weight are correctly handled by the API, but answer_comments is not.

question = { 'question[question_text]' : question_prompt, 'question[question_type]' : question_type, 'question[points_possible]' : 2, 'question[answers][0][answer_text]' : correct_answer, 'question[answers][0][answer_weight]' : 100, 'question[answers][0][answer_comments]' : '', 'question[answers][1][answer_text]' : wrong_answer_1, 'question[answers][1][answer_weight]' : 0, 'question[answers][1][answer_comments]' : wrong_answer_1_feedback, 'question[answers][2][answer_text]' : wrong_answer_2, 'question[answers][2][answer_weight]' : 0, 'question[answers][2][answer_comments]' : wrong_answer_2_feedback, 'question[answers][3][answer_text]' : wrong_answer_3, 'question[answers][3][answer_weight]' : 0, 'question[answers][3][answer_comments]' : wrong_answer_3_feedback }

tomsant commented 2 years ago

Solved! After updating the answer comment in the canvas ui and inspecting network traffic, I discovered the API documentation is incorrect here. The field is question[answers][#][answer_comment_html].