Exercise API

The exercise API is used to create interactive, automatically assessed exercises.

.exercise(modelSolution, reset, options)

An exercise is initialized with a call to av.exercise(..). The parameters for the function are:

The function can also take several options, some of which are required. The full set of options are:

For example, assuming modelSolution and reset are functions, the following would initialize an exercise:

var exercise = av.exercise(modelSolution, reset, { css: "background-color" });
exercise.reset();

See also the tutorial on creating an exercise.

exercise.showGrade()

Shows the grade of the student’s current solution. The behaviour can be customized using the showGrade option when initializing the exercise.

exercise.reset()

Resets the exercise.

exercise.showModelAnswer()

Shows the model answer of the exercise.

exercise.gradeableStep()

Marks the current step in the student’s solution as a step used in grading.

Showing the Current Score and Maximum Score in Continuous Feedback Mode

If the exercise is in the continuous feedback mode, it is possible to have JSAV show the current score, current maximum score, and the total maximum score to student. This can be done by adding HTML elements inside the JSAV container elements. JSAV will search for elements with the following class attributes:

So you could use the following HTML:

<p>
Your current score is <span class="jsavcurrentscore"></span> of
<span class="jsavcurrentmaxscore"></span>. Maximum score in this exercise is
<span class="jsavmaxscore"></span>.
</p>

As a shorter convenience notation, you can use <p class="jsavscore"><p/> that will be replaced automatically by JSAV with the HTML above if the exercise is in continuous feedback mode. Note, that in both cases, the elements can be anything, the important thing is that they have the class attributes.