}
SCORMFacade.prototype = {
+ LMSInitialize: function () {
+ return this.Initialize();
+ },
Initialize: function () {
this._log('Init');
return true;
},
+ LMSFinish: function () {
+ return this.Terminate();
+ },
Terminate: function () {
this._log('Terminate');
- return finishScorm();
+ closeSubSCO();
+ return true;
+ },
+ LMSGetValue: function (key) {
+ return this.GetValue(key);
},
GetValue: function (key) {
- this._log('Get value ' + key);
var d = savedState[currentModule.id];
-
+ var res;
if (key === 'cmi.core.lesson_status' || key === 'cmi.completion_status') {
- return d.completion_status;
+ res = d.completion_status;
} else if (key === 'cmi.location' || key === 'cmi.core.lesson_location') {
- return JSON.stringify(d.location);
+ if (typeof d.location === 'string' || typeof d.location === 'number') {
+ res = d.location;
+ } else {
+ res = JSON.stringify(d.location);
+ }
} else if (key === 'cmi.success_status') {
- return d.success_status;
+ res = d.success_status;
+ } else {
+ res = d.cmi[key] === null ? '' : d.cmi[key];
}
- return d.cmi[key] === null ? 'null' : d.cmi[key];
+ this._log('Get value ' + key + ' :: ' + res);
+ return res;
+ },
+ LMSSetValue: function (key, value) {
+ return this.SetValue(key, value);
},
SetValue: function (key, value) {
this._log('Set value ' + key + ' :: ' + value);
setModuleState(currentModule.id, data);
return true;
},
+ LMSCommit: function (d) {
+ return this.Commit(d);
+ },
Commit: function (d) {
- this._log('Commit');
return true;
},
+ LMSGetLastError: function () {
+ return this.GetLastError();
+ },
GetLastError: function () {
return 0;
},
- GetErrorString: function () {
+ LMSGetErrorString: function (code) {
+ return this.GetErrorString(code);
+ },
+ GetErrorString: function (code) {
return '';
},
- GetDiagnostic: function () {
+ LMSGetDiagnostic: function (code) {
+ return this.GetDiagnostic(code);
+ },
+ GetDiagnostic: function (code) {
return '';
},
_log: function (log) {
initState();
setContents();
initEvents();
- window.API = null;
- window.API_1484_11 = new SCORMFacade();
+ window.API = window.API_1484_11 = new SCORMFacade();
return SCORM_OK;
}
$.each(DATA.modules, function (k, v) {
- var defaultState = {completion_status: 'incomplete', success_status: 'unknown', score: 0, location: {}, cmi: {}};
+ var defaultState = {completion_status: 'incomplete', success_status: 'unknown', score: 0, location: '', cmi: {}};
if (window.savedState[v.id] === undefined || window.savedState[v.id] === null) {
window.savedState[v.id] = defaultState;
} else {
$("#sco").attr('src', path);
if (!module.scorm) {
- setModuleState(module.id, {completion_status: 'completed', success_status: 'passed', score: 100});
+ setModuleState(module.id, {completion_status: 'completed', success_status: 'passed'});
}
}
function setModuleState(id, data) {
- console.log('setModuleState', id, JSON.stringify(data));
- console.log(JSON.stringify(window.savedState));
$.extend(true, window.savedState[id], data);
- console.log(window.savedState[id]);
- console.log(JSON.stringify(window.savedState));
saveStatus();
setContents();
}
$.each(DATA.modules, function (k, v) {
var s = window.savedState[v.id];
+ var score = calcScore(s);
var tr = $('<tr data-type="' + v.type + '" data-id="' + v.id + '"><td class="i">' + getSpriteIcon('icon-' + v.type) + '</td></tr>');
$('tbody').append(tr);
tr.append('<td class="t">' + v.title + '</td>');
tr.append('<td class="y">' + types[v.type] + '</td>');
tr.append('<td class="c">' + (v.mandatory ? vcheck : xcheck) + '</td>');
tr.append('<td class="c">' + (s.completion_status === 'completed' ? vcheck : xcheck) + '</td>');
- tr.append('<td class="score c" data-score="' + s.score + '"><div>' + s.score + ' %</div></td>');
+ tr.append('<td class="score c" data-score="' + score + '"><div>' + (score === 0 ? '-' : score + ' %') + '</div></td>');
});
}
+function calcScore(s) {
+ var raw = doubleQuestionMark(s.cmi['cmi.core.score.raw'], s.cmi['cmi.score.raw'], 0);
+ var max = doubleQuestionMark(s.cmi['cmi.core.score.max'], s.cmi['cmi.score.max'], 100);
+ var min = doubleQuestionMark(s.cmi['cmi.core.score.min'], s.cmi['cmi.score.min'], 0);
+ var scale = max - min;
+ var norm = raw - min;
+ return 100 * (norm / scale);
+}
+
+function doubleQuestionMark() {
+ for (var i = 0; i < arguments.length; i++) {
+ if (arguments[i] === undefined || arguments[i]===null) {
+ continue;
+ }
+ return arguments[i];
+ }
+}
+
(function (global) {
'use strict';
if (!global.console) {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest
+ xmlns="http://www.imsproject.org/xsd/imscp_rootv1p1p2"
+ xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_rootv1p2p1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_rootv1p2"
+ identifier="MANIFEST-90878C16-EB60-D648-94ED-9651972B5F38"
+ xsi:schemaLocation="http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd
+ http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd
+ http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd">
+ <metadata>
+ <schema>ADL SCORM</schema>
+ <schemaversion>1.2</schemaversion>
+ </metadata>
+ <organizations default="ACME-ORG-1350650111249">
+ <organization identifier="ACME-ORG-1350650111249" structure="hierarchical">
+ <title>HF SCORM Multiple Package</title>
+ <item identifier="HF_SCORM_PACKAGE" identifierref="HF_SCORM_PACKAGE" isvisible="true">
+ <title>HF SCORM Multiple Package</title>
+ </item>
+ </organization>
+ </organizations>
+ <resources>
+ <resource type="webcontent" adlcp:scormtype="sco" identifier="HF_SCORM_PACKAGE" href="index.html">
+ <file href="index.html"/>
+ </resource>
+ </resources>
+</manifest>
\ No newline at end of file
$("main").append(results);
$(document).on('quizinit', function (event, state) {
+ console.log(state);
init(state)
});
initScormEvents();
}
#wrapper main table tbody td.score div {
white-space: nowrap;
- width: 60px;
+ width: 70px;
padding: 5px;
margin: 0 auto;
background-color: #e4ff19;
&.score
div
white-space: nowrap
- width: 60px
+ width: 70px
padding: 5px
margin: 0 auto
background-color: #e4ff19