Avendoo® online documentation

Avendoo® API

Main page of a course

Avendoo® API Version 1

Create main page of a course

CommandDescription

window.top.

If the content of the course main page is integrated via an IFrame, you have to enter this command before each function for accessing from the IFrame to the function in the Avendoo-API.

fn_openCourseObject(Typ, Id, Kursfreigabe Id, Sprache)

The function opens a course object with the following parameters:

  1. Type of the learning object
  2. Instructional material has the type ID 21, knowledge test has the type ID 90, event has the type ID 22, assessment has the type ID 120, forum has the type ID 47, e-payment has the type ID 51, flashcard file has the type ID 98, web-based training has the type ID 53, section has the type ID 164, hurdle has the type ID 130, checkpoint has the type ID 131, task hurdle has the type ID 132 and time obstacle has the type ID 148.

  3. Id of the learning object
  4. Id of the course activation
  5. Language

fn_getTypes()[X]

The function detects the type of the learning object regarding position [X] on the learning path.

Important note:
The count starts at zero!
This means that the first learning object on the learning path is addressed via [0], the second learning object is addressed via [1] and so on.

Further learning objects , which are included in the course, can be addressed with the same function. Thus you have to adjust the position in the square brackets.

fn_getIds()[X]

The function detects the Id of the learning object regarding position [X] on the learning path.

fn_getAssignmentId()

The function detects the Id of the current course activation.

fn_getUserLanguage()

The functions detects the language which is selected by the user.

function fn_isTutorMode()

Via this function you can detect, if you are in the user or the author mode. If you are in the author mode, the function gives the value “true” back. Otherwise the value “false” will be given back.

function fn_getObjectData(index, apiDataKey)

Reads the data.
Example:
fn_getObjectData(0, “objectType”), at which apiDataKey = objectType.

Example

You use for the second learning object on the learning path for example  [1] , for the third learning object you use for example [2]

fn_openCourseObject(fn_getTypes()[1],fn_getIds()[1], fn_getAssignmentId(),fn_getUserLanguage());

Avendoo® API Version 2

CommandDescription

function fn_getLearnpath()

The function „fn_getLearnpath()“ is used for getting certain information of ojects on the learning path. The function transmits an Array with all elements of the learning path.

Note:

The count starts at Arrays always with 0!

Informations of the learning path for the main page of the course can be used in combination with the Array and different methods. You get an overview of all methods and their descriptions here.

Example

In the following example an alert is done to each learning object, which contains the title of the learning object.

In a loop, which operates in „one-steps“ from„0“ to the„number of elements on the learning path“, all values are written in each run into the variable LPE (Learn Path Element). By adding the method “title“ (methods are arbitrarily replaceable; depending on need on this position can be also teaser, mandatory, objectId, state, … and so on) the appropriate value is shown.

$(function () {
        for (var index = 0; index < fn_getLearnpath().length; index++) {
            var LPE = fn_getLearnpath()[index];
            alert(LPE.title);
        }
    });

Example of use

A knowledge test is placed on the third position on the learning path. It can be opened via an additional button in the text. The button turns green, once the test is completed.

Avendoo API course main page function fn_getLearnpath()

var LPE = fn_getLearnpath()[2];
// into the variable LPE the values to the appropriate LearningPathElement are written.
if(LPE.state == "completed") {
 $("#idOfButton").css("background", "green");
}
// if the value for LPE.state is „completed“, the button is searched via 
jQuery regarding the ID and gets the CSS property „background: green;“ assigned.

Methods regarding the function fn_getLearnpath()

In both examples above several values are assigned to the variable. The values are then restricted by the method. Via a direct assignment you can write only one value into a variable.

Though the variable var 3LPEtitle = fn_getLearnpath()[2].title contains for example only the title of the learning object at third position.

Below the different methods are shown. Though “x” stands always for a number (position of the learning object on the learning path).

DesignationDescription

title

fn_getLearnpath()[x].title
contains the title of the learning object.

teaser

fn_getLearnpath()[x].teaser
contains the teaser of the learning object.

mandatory

fn_getLearnpath()[x].mandatory
transmits the value “true“ or “false“, depending on the learning object is “mandatory” or “optional”.

objectTypeId

fn_getLearnpath()[x].objectTypeId
transmits a numerical value.Though instructional materials have the objectTypeId 21, a task hurdle has the objectTypeId 132 and a knowledge test has the objectTypeId 22.

objectTitle

fn_getLearnpath()[x].objectTitle
specifies the type of the learning object. Thus acts like objectTypeId. Though the type of the learning object is expressed as word, for example instructional material, knowledge test, event and so on.

objectId

fn_getLearnpath()[x].objectId
transmits the objectId of the appropriate learning object. This definite 13-digit number looks like “1437638469552_1“. Two different elements on the learning path have never the same objectId.

state

fn_getLearnpath()[x].state
transmits the status of the appropriate learning object.
There are the following status:
• „none“ (still not processed),
• „incomplete“ (started, but still not completed),
• „completed“ (completely processed)
• „failed“ (not passed)

estimatedTimeMinutes

fn_getLearnpath()[x].estimatedTimeMinutes
shows the number of minutes of the estimated learning duration of the learning object (for example: 30, 10, 15, 150).

estimatedTimeFormated

fn_getLearnpath()[x].estimatedTimeFormated
shows the number of minutes of the estimated learning duration of the learning object in time format (for example: 00:30, 00:10, 00:15, 02:30).

imageSrc

fn_getLearnpath()[x].imageSrc
If an optional learning path image has been added, this method can read the path to this file.

buttonTitle

fn_getLearnpath()[x].buttonTitle
shows the changed designation of the selection button. If the designation is not changed, the value “zero” is transmitted.

certificateTitle

fn_getLearnpath()[x].certificateTitle
shows the title of the certificate.

available

fn_getLearnpath()[x].available
Learning objects can be deactivated by different causes (see the following methods). If the learning object is deactivated by any cause, the method transmits the value “false”. Otherwise the value “true” is transmitted.

blockedByHurdle

fn_getLearnpath()[x].blockedByHurdle
transmits the value “true” for all learning objects, which are deactivated by a hurdle. For all objects, which are before a hurdle, are optional or placed after a passed hurdle the value is “false”.

blockedCourseObject

fn_getLearnpath()[x].blockedCourseObject
Learning objects, which deactivated by the author, get the value “true”. If the learning objects are activated, the method transmits the value “false”.

hasNoTranslation

fn_getLearnpath()[x].hasNoTranslation
transmits the value “true”, if a learning object is deactivated because of no existing translation for a language, which is chosen in the course.

Further functions of the new course-API

BefehlErklärung

function fn_openLearnpathElement (jsonLearnpathElement) {

Each button on the learning path contains several information (objectTypeId, assignmentId, objectId, language), to open always the correct learning object. This information is in the function outlined above fn_getLearnpath() contained.

If you transmit the function fn_openLearnpathElement data of the function fn_getLearnpath(), you can open any learning object.

To open a learning object at the learning path position “X”, you would use the following function call:

fn_openLearnpathElement (fn_getLearnpath()[x])

Example of use

There is a knowledge test at the third position on the learning path. This knowledge test can be opened by an additional button in the text.
Code-Zeile

fn_hasCourseCertificate()

This function detects, if a course certificate is linked with a course.

fn_getCourseCertificateTitle()

This function transmits the title of the course certificate, if a short certificate is linked with the course.

fn_isCourseCertificateAccessable()

This function detects, if a course certificate can be downloaded.
There have to be fulfilled two conditions: The participant has to be achieved the course certificate and the download in the course have to activated (option “Allow downloading in the course” on the tab “Parameters” in the Course wizard).

Function for saving variables

BefehlErklärung

fn_setData()

The learning progress of the user and many other information of the learning objects are saved on the learning path and can be queried via the methods outlined above.
For further more individual variables we can access to the functions
“fn_setData()“.

These saved values are dependent on the user. This means, despite in which browser or operation system the learner is, the set value will be accessed.

Example of use
There is a welcome text on the course main page. Once the user clicks the button “Start course”, the welcome text will not be shown anymore.

Input-Button

$(window).load(function () {
        /* Initialization and IE-Fallback for fn_getData()/ fn_setData() */
        try {
            api = jQuery.parseJSON(fn_getData());
        } catch (e) {
            api = new Object();
            api.HintSeen = "false";
        }
        if (api == null) {
            api = new Object();
            api.HintSeen = "false";
        }
        /* Is the variable = true the div with the class "Hinweistext" is hidden per CSS. */
        if (api.HintSeen === "true") {
            $(".Hinttext").css("display", "none");
        }
        alert("The button 'Start course' is pressed = " + api.HintSeen);
    });

    /* Via click on the button the function is executed, which changes the variable and writes the variable into the database. */
    function fn_Startcourse() {
        api.HintSeen = "true";
        document.getElementById("apiData").value = JSON.stringify(api);  
        fn_setData(JSON.stringify(api), true);
    };

fn_getData()

The function fn_getData() transmits all name value pairs, which were set via the function fn_setData().

If you save all values in a variable in the example above and if you show these, you get {“HintSeen“:“true“}.

var WerteInAPI = fn_getData();
alert(WerteInAPI);

Further options

Hide learning path

The standard learning path is not necessary anymore if applicable. Therefore it can be hidden. This is processed via the following CSS data:

Code-Zeile 2