Skip to content

Commit

Permalink
Merge pull request #114 from adaptlearning/ABU-1130
Browse files Browse the repository at this point in the history
allow the authoring tool to suppress SCORM errors when previewing
  • Loading branch information
Himanshu Rajotia committed Nov 17, 2015
2 parents bac9f16 + 9b5b232 commit eedaf08
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 68 deletions.
137 changes: 71 additions & 66 deletions js/adapt-contrib-spoor.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,103 @@
define([
'coreJS/adapt',
'./scorm',
'./adapt-stateful-session',
'./adapt-offlineStorage-scorm'
'coreJS/adapt',
'./scorm',
'./adapt-stateful-session',
'./adapt-offlineStorage-scorm'
], function(Adapt, scorm, adaptStatefulSession) {

//SCORM session manager
//SCORM session manager

var Spoor = _.extend({
var Spoor = _.extend({

_config: null,
_config: null,

//Session Begin
//Session Begin

initialize: function() {
this.listenToOnce(Adapt, "configModel:dataLoaded", this.onConfigLoaded);
this.listenToOnce(Adapt, "app:dataReady", this.onDataReady);
},
initialize: function() {
this.listenToOnce(Adapt, "configModel:dataLoaded", this.onConfigLoaded);
this.listenToOnce(Adapt, "app:dataReady", this.onDataReady);
},

onConfigLoaded: function() {
if (!this.checkConfig()) return;
onConfigLoaded: function() {
if (!this.checkConfig()) return;

this.configureAdvancedSettings();
this.configureAdvancedSettings();

scorm.initialize();
scorm.initialize();

this.setupEventListeners();
},
this.setupEventListeners();
},

onDataReady: function() {
adaptStatefulSession.initialize();
},
onDataReady: function() {
adaptStatefulSession.initialize();
},

checkConfig: function() {
this._config = Adapt.config.has('_spoor')
? Adapt.config.get('_spoor')
: false;
checkConfig: function() {
this._config = Adapt.config.has('_spoor')
? Adapt.config.get('_spoor')
: false;

if (this._config && this._config._isEnabled !== false) return true;
return false;
},
if (this._config && this._config._isEnabled !== false) return true;
return false;
},

configureAdvancedSettings: function() {
if(this._config._advancedSettings) {
var settings = this._config._advancedSettings;
configureAdvancedSettings: function() {
if(this._config._advancedSettings) {
var settings = this._config._advancedSettings;

if(settings._showDebugWindow) scorm.showDebugWindow();
if(settings._showDebugWindow) scorm.showDebugWindow();

scorm.setVersion(settings._scormVersion || "1.2");
scorm.setVersion(settings._scormVersion || "1.2");

if(settings.hasOwnProperty("_suppressErrors")) {
scorm.suppressErrors = settings._suppressErrors;
}
if(settings.hasOwnProperty("_suppressErrors")) {
scorm.suppressErrors = settings._suppressErrors;
}

if(settings.hasOwnProperty("_commitOnStatusChange")) {
scorm.commitOnStatusChange = settings._commitOnStatusChange;
}
if(settings.hasOwnProperty("_commitOnStatusChange")) {
scorm.commitOnStatusChange = settings._commitOnStatusChange;
}

if(settings.hasOwnProperty("_timedCommitFrequency")) {
scorm.timedCommitFrequency = settings._timedCommitFrequency;
}
if(settings.hasOwnProperty("_timedCommitFrequency")) {
scorm.timedCommitFrequency = settings._timedCommitFrequency;
}

if(settings.hasOwnProperty("_maxCommitRetries")) {
scorm.maxCommitRetries = settings._maxCommitRetries;
}
if(settings.hasOwnProperty("_maxCommitRetries")) {
scorm.maxCommitRetries = settings._maxCommitRetries;
}

if(settings.hasOwnProperty("_commitRetryDelay")) {
scorm.commitRetryDelay = settings._commitRetryDelay;
}
} else {
/**
if(settings.hasOwnProperty("_commitRetryDelay")) {
scorm.commitRetryDelay = settings._commitRetryDelay;
}
} else {
/**
* force use of SCORM 1.2 by default - some LMSes (SABA/Kallidus for instance) present both APIs to the SCO and, if given the choice,
* the pipwerks code will automatically select the SCORM 2004 API - which can lead to unexpected behaviour.
*/
scorm.setVersion("1.2");
}
},
scorm.setVersion("1.2");
}

setupEventListeners: function() {
this._onWindowUnload = _.bind(this.onWindowUnload, this);
$(window).on('unload', this._onWindowUnload);
},
/**
* suppress SCORM errors if 'nolmserrors' is found in the querystring
*/
if(window.location.search.indexOf('nolmserrors') != -1) scorm.suppressErrors = true;
},

//Session End
setupEventListeners: function() {
this._onWindowUnload = _.bind(this.onWindowUnload, this);
$(window).on('unload', this._onWindowUnload);
},

onWindowUnload: function() {
scorm.finish();
//Session End

$(window).off('unload', this._onWindowUnload);
}

}, Backbone.Events);
onWindowUnload: function() {
scorm.finish();

Spoor.initialize();
$(window).off('unload', this._onWindowUnload);
}

}, Backbone.Events);

Spoor.initialize();

});
4 changes: 2 additions & 2 deletions required/imsmanifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</organization>
</organizations>
<resources>
<resource identifier="res1" type="webcontent" href="index.html" adlcp:scormtype="sco">
<file href="index.html"/>
<resource identifier="res1" type="webcontent" href="index_lms.html" adlcp:scormtype="sco">
<file href="index_lms.html"/>
</resource>
</resources>
</manifest>
File renamed without changes.
24 changes: 24 additions & 0 deletions required/index_lms.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--[if IE]><![endif]-->
<!doctype html>
<!--[if IE 7 ]><html id="adapt" class="ie ie7 no-js" lang="en"><![endif]-->
<!--[if IE 8 ]><html id="adapt" class="ie ie8 no-js" lang="en"><![endif]-->
<!--[if IE 9 ]><html id="adapt" class="ie ie9 no-js" lang="en"><![endif]-->
<!--[if gt IE 9]><!--><html id="adapt" class="no-js" lang="en"><!--<![endif]-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link href="adapt/css/adapt.css" type="text/css" rel="stylesheet"/>
<script src="libraries/modernizr.js" type="text/javascript" language="javascript"></script>
<script src="adapt/js/scriptLoader.js" type="text/javascript" language="javascript"></script>
</head>

<body>
<button id="accessibility-toggle" class="base button a11y-ignore-focus" role="button" ></button>
<span id="accessibility-instructions" class="aria-label" role="region" tabindex="0"></span>
<div id="wrapper">
</div>
</body>
</html>

0 comments on commit eedaf08

Please sign in to comment.