Skip to main content
maximilianf46353140
Known Participant
August 11, 2017
Question

xAPI version in Captivate 9, running XML statements?

  • August 11, 2017
  • 0 replies
  • 391 views

Hi Guys,

I set up my LRS and am able to send some xAPI statements in Legacy mode (I mean

the old kind of communicating with xAPI, explained here: TinCanJS by Rustici Software )

For example, this code works:

var tincan = new TinCan ({url: window.location.href});

tincan.sendStatement(

{

verb: {

id: "http://www.cosimatp4/simulation0808/clicked.htm",

display: {"en-US": "clicked"}

},

object: {

id: "http://www.cosimatp4/simulation0808/question1_button_2.htm",

definition: {

name: {"en-US": "question_1_button_2"},

description: {"en-US": "Button 2 on Question 1"}

}

}

}

);

However, has anyone of you guys got to run xAPI with regular xml statements, like this (which was described in the xAPI recipy section)?
In the first part I just setup the lrs, then I create and save a statement, code was copied from TinCanJS by Rustici Software

And does anyone know the xAPI version compatable out of the box without xapiwrapper etc?

var lrs;

try {

    lrs = new TinCan.LRS(

        {

            endpoint: "bla",

            username: "bla",

            password: "bla",

            allowFail: false

        }

    );

}

catch (ex) {

    console.log("Failed to setup LRS object: " + ex);

    // TODO: do something with error, can't communicate with LRS

}

var statement = new TinCan.Statement(

{

    "actor": {

        "objectType": "Agent"

    },

    "verb": {

        "id": "http://adlnet.gov/expapi/verbs/answered",

        "display": {

            "en-US": "answered"

        }

    },

    "object": {

        "id": "http://adlnet.gov/expapi/activities/example",

        "definition": {

            "name": {

                "en-US": "Button1"

            },

            "description": {

                "en-US": "Button 1"

            },

            "type": "http://adlnet.gov/expapi/activities/cmi.interaction",

            "interactionType": "choice"

        },

        "objectType": "Activity"

    },

    "result": {

        "response": "variable"

    }

}

);

lrs.saveStatement(

    statement,

    {

        callback: function (err, xhr) {

            if (err !== null) {

                if (xhr !== null) {

                    console.log("Failed to save statement: " + xhr.responseText + " (" + xhr.status + ")");

                    // TODO: do something with error, didn't save statement

                    return;

                }

                console.log("Failed to save statement: " + err);

                // TODO: do something with error, didn't save statement

                return;

            }

            console.log("Statement saved");

            // TOOO: do something with success (possibly ignore)

        }

    }

);

This topic has been closed for replies.