cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
learningsystems
Community Participant

Unable to edit answer for question within Question Bank

Hello,

lo,

There is a question answer that I am unable to edit within a question bank. Upon further investigation, I was able to find out that the answer object for the particular answer that I can not edit has a "html" property which the other answer objects do not have as shown in the screenshot attached. This was the only difference that I could see between the answers for that question that may be the problem. 

There are also values that are effecting the questions which are: question[correct_comments_html], question[incorrect_comments_html], question[neutral_comments_html], which don’t appear in the Canvas API doc.

However, I’ve been able to set these values to null through the API. Changing the ‘html’ values overrides the normal ‘comments’ values, so that when you edit the questions again in Canvas, they lose their comments.

Changing the correct_comments values through the API overrides whatever is set as the correct_comments_html, and that then makes the question comments uneditable in Canvas.

Has anyone encountered this issue before and was able to fix it? I've had to work around the issue by making a new question with the same content.

This question bank is a result of a quiz import from a Blackboard export.

5 Replies
James
Community Champion

This almost sounds too simplistic, given the details you've provided through the API, but I thought I'd mention it just in case you're missing something.

When you have an answer that required HTML, you cannot edit it directly in the plain-text box -- as you're seeing in the second box. However, when you hover over the question response, a little pencil should appear that allows you to edit the HTML version. 

In your picture, the pencil is on the first response, but it should show up if you move the mouse to the second question response, in the red highlight box, where you're having the issue.

I will also say I did not verify this with a question bank, just a regular question. I also have no way to test an import from another LMS.

The other thing that see is that you have some extra functionality in your editor that doesn't come stock from Canvas. It's possible that their HTML editor addins are messing with the ability to edit.

learningsystems
Community Participant

Hello James,

Thanks for your reply. Unfortunately the issue lies with the fact that clicking on the pencil does not allow me to edit the answer even though I can click on it. I have attached a video which demonstrates what I mean by how I am unable to edit the quiz answer.

On another note, we have found a way to recreate the disappearing quiz answer comments through the use of the Canvas API and the steps can be followed below:

  1.       Create a new quiz, with a single question, get the ID.
  2.      Add the correct_comment_html and incorrect_comment_html properties to the question through the api

 

(console script for browser)

var q_data = {

    "question[correct_comments_html]": "correct html",

    "question[incorrect_comments_html]": "incorrect html"

}

var course_id = 37;

var quiz_id = 6662;

var question_id = 65149;

 

$.ajax({

    type: "PUT",

    url: "/api/v1/courses/" + course_id + "/quizzes/" + quiz_id + "/questions/" + question_id,

    contentType: 'multipart/form-data',

    data: q_data,

    success: function (data, textStatus, xhr) {

        console.log(textStatus, xhr.status, data);

        $.getJSON("/api/v1/courses/" + course_id + "/quizzes/" + quiz_id + "/questions/" + question_id, function (d) { console.log(d) })

    },

    error: function (xhr, textStatus, errorThrown) {

        console.log(textStatus, errorThrown, xhr);

        console.log("FAIL")

    }

});

 

  1.       In Canvas, try and edit the correct and incorrect comments against the question. You’ll see the text is present, but will disappear when you try and edit the comment text.

I have also attached a video to demonstrate the issue at hand:

 @learningsystems  

Your videos didn't show up. Just a notice that they are encoding and will be available soon. That was 4 days ago, so I think something didn't transfer through properly.

I took your code, replaced it with my values, and tried to recreate the problem. 


What I discovered is that your correct_comments_html and incorrect_comments_html are getting saved, but when they are not valid HTML (there are no tags to them) and so they're getting scrubbed when you go to edit them.

var url = '/api/v1/courses/896851/quizzes/5283322/questions/94458388';
var q_data = {
  'question': {
    'correct_comments_html': 'correct_html',
    'incorrect_comments_html': 'incorrect_html'
  }
};
$.ajax({
  type: "PUT",
  url: url,
  contentType: 'multipart/form-data',
  data: q_data,
  success: function(data, textStatus, xhr) {
    console.log(textStatus, xhr.status, data);
    $.getJSON(url, function(d) {
      console.log(d)
    })
  },
  error: function(xhr, textStatus, errorThrown) {
    console.log(textStatus, errorThrown, xhr);
    console.log("FAIL")
  }
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

If I use this, then things work properly.

var q_data = {
  'question': {
    'correct_comments_html': '<p>correct_html</p>',
    'incorrect_comments_html': '<p>incorrect_html<p>'
  }
};‍‍‍‍‍‍

If I use this, it has the same problem as the original ... the text is scrubbed when I go to edit.

var q_data = {
  'question': {
    'correct_comments': 'correct_html',
    'incorrect_comments': 'incorrect_html'
  }
};‍‍‍‍‍‍

If I try this, it won't let me edit things ... there is no pencil icon

var q_data = {
  'question': {
    'correct_comments': '<p>correct_html</p>',
    'incorrect_comments': '<p>incorrect_html<p>'
  }
};‍‍‍‍‍‍

and here's what it looks like

300691_pastedImage_1.png

When I look at the console, I see that Canvas barfed on it when I click the pencil to do the edit.

300701_pastedImage_2.png

I would report it as a bug with Canvas. The API documentation says to use correct_comments not correct_comments_html but if you use correct_comments with plain text it gets scrubbed with the Rich Content Editor and if you use correct_comments with HTML, you cannot edit it because of the error. The error seems to be with invoking the Rich Content Editor, not the API, though.

In the meantime, it appears that the work-around is to use correct_comments_html and make sure that you're actually sending it HTML and not plain text.

If you need to immediately fix this before Canvas gets around to it, you could retrieve the value from the API, slap some html tags around it, and send it back through the API.

There might have been something I'm missing because I couldn't see your videos, but that's what I discovered when I looked at it.

learningsystems
Community Participant

Thank you for your help once again James. I've re-uploaded the videos, please excuse their low quality.

I've reported both issues as a bug with Canvas and am waiting for a response, in the meantime, I will try your workaround the next time I encounter the bug with the comments.

porterrh
Community Participant

Did Canvas ever fix this bug?  Or get back to you?  I'm having the same issue, but I don't have comments in the question; I just sometimes cannot edit my question and it is really annoying to have to rewrite this many questions.  Every time I click on the pencil, it takes me back to the start of the quiz.