AnsweredAssumed Answered

Embedded javascript into quizzes

Question asked by Gerald Q. Maguire on Jun 15, 2017
Latest reply on Aug 28, 2017 by

Some of my colleagues have a large collection (146,915) questions that use javascript in the question (and in some cases in the answers). I have been thinking about alternatives for how to port these to Canvas. The alternatives that seem to be relevant are:

  1. Move them to an external quiz engine;
  2. Create an HTML page for each of them and then instantiate this in the question using an iframe;
  3. Using LTI to talk to an external tool provider that would provide the javascript in a window, get the student's answer, check the answer, and return a score to Canvas via LTI; and
  4. Dynamically update the questions and answers via the Quizzes API.

Have I missed an alternative? Are there any insights about their advantages and disadvantages.


For further background, most of the JavaScripts seem to be quite short with a median of 186 lines of javascript and a maximum of 2036 lines. In fact, 19,664 of the questions have 57 lines of Javascript and 126,376 of them are less than 100 lines of Javascript. The JavaScript questions constitute 2.9% of the legacy questions from our former LMS.


A typical fill in the blank questions has the form:

<p>XXXXXX ${N} YYYY ?</p>

where N is computed by some JavaScript. I have looked into converting this to 

<p>XXXXXX <span id="N"></span>YYYY ?</p>
<script type="text/javascript">
var N = QQQQQ
document.getElementById("N").innerHTML = N


This seems to be able to work in Chrome.