Documentation

xAPI

This export allows creating offline zip packages with a selected lesson. It contains only the required files to launch the latest icplayer version from mAuthor and additional scripts in the index.html file.

Additionally to HTML5/offline format, it has scripts accessing the xAPI communication, which sends statements to the xAPI server. It is required to access xAPI server.

Package structure

/
    icplayer/ - folder with newest icplayer
    javascript/ - folder containing scripts required to launch addons from icplayer and mAuthor additional scripts for index.html file
    javascript/tincan - folder containing xAPI script for communicating with xAPI server and tincan library
    pages/ - folder containing main.xml file describing whole content and lesson pages xmls
    resources/ - folder containing media files used by lesson
    index.html - initial launching file for lesson
    metadata.xml - xml file with lesson metadata

index.html

This is a main initial file to boot the exported package. It contains a portion of scripts required by the player to launch a lesson and some mAuthor additional scripts' functionalities.

<script type="text/javascript" src="javascript/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="icplayer/icplayer.nocache.js"></script>
<script type="text/javascript" src="javascript/semi-responsive-layout-chooser.js"></script>
<script type="text/javascript" src="javascript/screen.js"></script>

Scripts included in the mAuthor export packages:

jquery-1.7.1.min.js - jQuery script for addons
semi-respoinsive-layout-chooser.js & screen.js - additional mAuthor scripts for changing lesson layout depending on device screen.
icplayer.nocache.js - boot file for player application to load icplayer

You can download these scripts here: Scripts

Booting script

xAPI requires initialization of communication between a lesson and the xAPI server. Configuration JSON is created but it requires manual addition of the endpoint and courseIRI keys by a user. xAPI object is created at the lesson's start after the icplayer application loading is finished.

var player;
var start;
var xapi;
var semiResponsiveLayoutChooser;
var userAgent = window.navigator.userAgent;
var viewPort = document.querySelector("meta[name=viewport]");

var tincanCfg = {
    entry : "ab-initio",
    lessonIRI: "5772986137968640",
    lessonTitle: "Copy of Copy of NG 2. poglavlje",
    lessonDescription: "",
    actor: {
        account:{
            homePage:"http://example.lms.com/",
            name:"Anonymous"
        }
    }

    // endpoint: ...
    // courseIRI: ...
};


function icOnAppLoaded(){
    player = icCreatePlayer('_icplayer');
    try{
        cfg = xAPI.configFromParams(tincanCfg);
        xapi = new xAPI(cfg);
    }catch(err){
        $('#_icplayer').html('xAPI initialization returned the following error:</br>' + err +
                '</br>Please refer to /doc/page/Content-output for more details');
        return
    }
    var location = "0";
    if (cfg.entry === "resume"){
        xapi.resumeAttempt();
        try{
            var result = xapi.getAttemptState();
            var state = result.state.contents;
            player.setState(atob(state.state_string));
            location = state.location;
        }catch(err){
            console.log("State not available for this attempt:" + err );
        }
    }else {
        xapi.initializeAttempt();
    }
    player.load('pages/main.xml', parseInt(location));
}