Skip navigation
All Places > Canvas Developers > Blog > 2017 > July

The current quiz API seems to be missing functionality to insert HTML answers, as one can only set an answer_text and not an answer_html.  This is despite the fact that the actual answers support an html element, as can be seen below:

"answers": [ { "id": 3603, "text": "answer1", "html": "", "comments": "", "comments_html": "", "weight": 0 }, { "id": 3070, "text": "answer2", "html": "", "comments": "", "comments_html": "", "weight": 100 }, ... ]


It is possible via the RCE GUI to cut the text and then switch to HTML mode and past it in. As shown in the example below:

[{'text': '', 'id': 2400, 'html': '<pre>sum(5,10)</pre>', 'weight': 0.0, 'comments_html': '', 'comments': ''}, {'text': '', 'id': 7243, 'html': '<pre>from math import *<br>sum(5,10,0)</pre>', 'weight': 0.0, 'comments_html': '', 'comments': ''}, {'text': '', 'id': 7766, 'html': '<pre>from math import<br>sum(5,10)</pre>', 'weight': 0.0, 'comments_html': '', 'comments': ''}, {'text': '', 'id': 5120, 'html': '<pre>from math import *<br>sum(5,10)</pre>', 'weight': 100.0, 'comments_html': '', 'comments': ''}]


I think that it should always be possible to set values via the API as opposed to having to use the GUI.  While it might take only a few minutes to do this for a single question, when there are large numbers of questions - this is when it should be possible to apply power tools.


[I am aware that there will be a new quiz engine, but as I do not have it - I have to work with what I have.]

I am a big fan of sections and have found that they are useful in a number of contexts. However, I really hate to use point and click user interfaces, so I decided it was time to make some programs to do the work for me.

This lead to a series of programs:

1. to list the existing section information (produces a spreadsheet with two pages: Sections and Students)

2. to create new sections by name

3. to remove sections that I no longer want

4. the real goal, it takes a course_id, spreadsheet file (such as an augmented version of the one produced by the first program), and a column name in this spreadsheet and adds then each student to the named section.


See Sections in courses: Chip sandbox 


An obvious extension is to randomly assign students to a set of N sections (with balancing over the set of sections). For example, this could be used to form sections for the purpose of assigning each section a different version of a quiz.