javascriptlrs

Authorizing xAPI interactions through Javascript triggers against my LRS


I've constructed a course in Storyline2, and defined several triggers via javascript as xAPI (tincan) activities. I have an LRS endpoint link and authorization token, but I'm yet to understand where these credentials should be embedded in order for the whole thing to function properly.

I was given this at another message board:

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

Which of these needs to be replaced by one of the above mentioned? I'm guessing another should be added via "+" after "href".


Solution

  • That example code (which I guess you got from the article I wrote here: http://tincanapi.com/share-statements-between-courses/ ) is envisaging that you will launch the Storyline content from something like an LMS. In that case you will enter the endpoint and authorization details in the LMS settings, and the LMS will pass those to Storyline.

    See: http://tincanapi.com/share-statements-between-courses/

    If you want to put the details directly in the package, see the example code here: http://rusticisoftware.github.io/TinCanJS/

    (included below for convenience)

    var lrs;
    
    try {
        lrs = new TinCan.LRS(
            {
                endpoint: "https://cloud.scorm.com/tc/public/",
                username: "<Test User>",
                password: "<Test Password>",
                allowFail: false
            }
        );
    }
    catch (ex) {
        console.log("Failed to setup LRS object: " + ex);
        // TODO: do something with error, can't communicate with LRS
    }