Skip to content
Matt Leathes edited this page Oct 23, 2017 · 5 revisions

Spoor

Welcome to the adapt-contrib-spoor wiki.

Accessing the SCORM API

If you need to get access the SCORM API in your own code, /js/scorm/wrapper.js exposes a number of functions for your use (via a singleton object called ScormWrapper). Requiring /js/scorm/scorm.js will return the instanciated wrapper for you. Once you have this, you get access to a whole host of lovely utility functions. Here are a few of the most useful (you'll need to dig around in the js for the full list):

  • Lesson status:
    • getStatus
    • setStatus
    • setIncomplete
    • setCompleted
    • setPassed
    • setFailed
  • Scoring:
    • getScore
    • setScore
  • Bookmarking/lesson location:
    • getLessonLocation
    • setLessonLocation
  • Suspend Data:
    • getSuspendData
    • setSuspendData
  • Student data:
    • getStudentName
    • getStudentId
  • Misc:
    • isFirstSession -- whether the user has accessed the course/SCO before (more reliable than checking for 'incomplete' lesson status)

Code sample

See below for a working example.

Adapt.on("app:dataReady", function() {
  var spoorConfig = Adapt.config.get('_spoor');
  if(spoorConfig && spoorConfig._isEnabled) {
    try {
      var scormAPI = require('extensions/adapt-contrib-spoor/js/scorm');
    } catch(e) {
      console.log('Something went wrong', e);
    }
    console.log(scormAPI.getStudentName());
  }
});