instructure / canvas-lms

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

Changing Quiz question type from multiple choice to essay leaves invalid answers #997

Open ToeBee opened 7 years ago

ToeBee commented 7 years ago

Summary:

Changing a question from multiple choice to essay should delete all the answers associated with the question but this does not happen. Initially the answers are left alone. However if you then delete one of the answers, the API starts spitting back outright invalid data for the quiz answers.

The answers returned after this is triggered have no ID. They are also represented in the JSON as a string instead of a number which breaks our attempt to parse it using the Gson library.

Steps to reproduce:

Here is a screencast of me reproducing this problem: screencast

  1. Create and save a multiple choice question.
  2. Query the API for the quiz questions. Everything is ok.
  3. Change the question from multiple choice to essay and save the question
  4. Query the API. Notice that it returned the multiple choice answers even though it is now an essay question.
  5. Edit the question again and this time delete one of the (blank) answers. Save the question
  6. Query the API for the quiz questions again. The call now returns invalid data.

Sample invalid data:

"answers": [
  {
    "answer_exact": "",
    "answer_error_margin": "",
    "answer_range_start": "",
    "answer_range_end": "",
    "answer_approximate": "",
    "answer_precision": "10",
    "answer_weight": "0",
    "numerical_answer_type": "exact_answer",
    "blank_id": "",
    "id": "",
    "match_id": "",
    "answer_text": "",
    "answer_match_left": "",
    "answer_match_right": "",
    "answer_comment": "",
    "answer_html": "",
    "answer_match_left_html": "",
    "answer_comment_html": ""
  },
...]

Expected behavior:

Changing the question from multiple choice to essay should immediately eliminate all of the associated answers. Also, the API should never return answer IDs as a string (even if blank) as this will break parsing in strictly typed languages.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ToeBee commented 5 years ago

I just reproduced this bug again. Nothing has changed.

ToeBee commented 2 years ago

Well, this issue still exists but Instructure has put off fixing it for long enough that they have closed our support case saying it "behaves as expected" and to switch to using the new quizzes feature... which isn't available via the REST API. So there you go.