Avendoo® online documentation

Avendoo® API

Interactive knowledge test questions

Experienced authors (with appropriate HTML/CSS and JavaScript knowledge) can use Avendoo® API (application programming interface) for creating an interactive question. Thus they can transfer certain parameters to a self created design.

The following table contains the appropriate command and the appropriate description:

CommandDescription

window.top.

Because the content of the interactive question is embedded in an Iframe, this has to be before each function, in order to open from the Iframe the function of the Avendoo-API.

fn_setInteractiveQuestionState(percent,
useranswer)

The function transfers the following paramters of the interactive question to Avendoo®:

percent = Achieved Points
useranswer = Selected answer of the user

Via the parameter percent the author defines the achievable points per answer.
The number of points can be a fixed defined value or can be calculated via the function
fn_getPoints()

proportionately from the maximum achievable number of points of the question.

The parameter useranswer designates the different answers and is an alphanumeric designation, freely allocable by the author (for example: “opt1”, “opt2”, “opt3”).

Note:

The designations “opt1”, “opt2” etc. have to be signed by double quote top.

fn_getReshow()

The function detects, if it is a redisplay of the question.

true = Question is redisplayed
false = Question is displayed for the first time

Example:
If the question of the final page of a knowledge test is redisplayed, the question should be displayed in the way how the user it has given off after editing the question. Via this function the redisplay will be read out.

Example for source code:

if(window.top.fn_getReshow()) {
var useranswer = window.top.fn_getUserAnswer();
    //Via the variable useranswer now the answer should be displayed. 
For example the setting of the selected radio button of a single choice question  }

fn_getDissolve()

The function detects on basis of the settings in the Knowledge test wizard, if the answer should be displayed or not.

true = Answer should be displayed
false = Answer should not be displayed

Interactive question API navigation

Example:
When the user has answered the question incorrect, the correct answer can be displayed.

fn_getPoints()

The function calculates the maximum possible points, which were configured in the Question wizard of the interactive question.

Interactive question API possible points

fn_getReachedPoints()

The function calculates the achieved points for this question, which are achieved by the real answer of the user.

Note:
It is the number of points, which were transferred via the function
fn_setInteractiveQuestionState
to Avendoo®; so the points defined by the author per answer.

fn_getUseranswer()

The function detects the question selected by the user.

Note:
It is the answer, which is transferred via the function fn_setInteractiveQuestionState
to Avendoo®; this means it is the alphanumeric desgination per answer defined by the author.

Example:
If the question of the final page of a knowledge test is redisplayed, the question should be displayed as if the user has “given” it after editing the question.

fn_getParameter()

The function detects the parameters, which were entered in the Question wizard of the interactive question under “Question parameters”.
Interactive question API question paramters

Example:

You can define for example the texts of the question and the answers in the question parameters. The paramters are read and dynamically written into the interactive question. Thus the flexibility increases and you can create a question template, which is filled by the question parameters always different every time.

Consecutively you see the instructions, with which you can fill the texts of the interactive question via the question parameter:
Question parameters (in the interaktice question of Avendoo®):

{"question": "What weekday was on June 30th 2015?",
"answer1": "Monday",
"answer2": "Tuesday",
"answer3": "Wednesday"}

The characteristic names “answer1”, “answer2” etc. have to be noted in double quotes.

  • The corresponding values are also written as text or string in double quotes. Numerical values and boolean (true/false) are written without quotes.


JavaScript (in the content of the interactive question):

var parameter = window.top.fn_getParameter();
var json = JSON.parse(parameter);
// Via the designations json-question, json.answer1, json.answer2, json.answer3 you can use the defined question parameters in the interactive question.