Showing Questions

Interactive questions can be initialized with the question function of a JSAV instance.

.question(qtype, questionText, [options])

This is a method of the AV object. It initializes an interactive question of the given type (qtype). The type can be:

The questionText parameter is the actual question shown to a student. For the question type TF, options parameter can contain following options.

An example of initializing a true-false question is below.

var q = av.question("TF", "JSAV supports questions now?",
{correct: true,
falseLabel: "No",
trueLabel: "Yes"});

The function returns an instance of a question. Answer choices can be added to this instance using the following methods.

q.addChoice(label, [options])

This adds an answer choice to question q. Parameter label is the label shown for this answer choice. The only option at the moment is correct which indicates the correctness of this choice. Default value for it is false. Note, that this method does nothing for the true-false type question.

q.show()

This function will show the question in the current step in the algorithm. This way, the initialization, addition of answers, and displaying the question can happen in different steps in the animation. It helps when the goal is to show students questions that require prediction of the algorithm’s behavior. A complete example of a multiple-select question:

var q = av.question("MS", "Life is good?");
q.addChoice("Of course", {correct: true});
q.addChoice("Certainly", {correct: true});
q.addChoice("No way!");
q.show();