From: Vincent Vanwaelscappel Date: Wed, 15 Dec 2021 15:02:34 +0000 (+0100) Subject: wip #4907 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=954ec845c82dd217167afa3dc2801b0bf8bfc90c;p=hf-scorm-package.git wip #4907 @1.5 --- diff --git a/js/libs/scorm/facade.js b/js/libs/scorm/facade.js index 78e60d9..eed23e5 100644 --- a/js/libs/scorm/facade.js +++ b/js/libs/scorm/facade.js @@ -2,26 +2,45 @@ function SCORMFacade() { } 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); @@ -42,17 +61,28 @@ SCORMFacade.prototype = { 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) { diff --git a/js/scormpackage.js b/js/scormpackage.js index 0cdc6d7..f23d400 100644 --- a/js/scormpackage.js +++ b/js/scormpackage.js @@ -89,8 +89,7 @@ function initScorm() { initState(); setContents(); initEvents(); - window.API = null; - window.API_1484_11 = new SCORMFacade(); + window.API = window.API_1484_11 = new SCORMFacade(); return SCORM_OK; } @@ -113,7 +112,7 @@ function initState() { $.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 { @@ -208,16 +207,12 @@ function openSubSCO(id) { $("#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(); } @@ -247,16 +242,35 @@ function setContents() { $.each(DATA.modules, function (k, v) { var s = window.savedState[v.id]; + var score = calcScore(s); var tr = $('' + getSpriteIcon('icon-' + v.type) + ''); $('tbody').append(tr); tr.append('' + v.title + ''); tr.append('' + types[v.type] + ''); tr.append('' + (v.mandatory ? vcheck : xcheck) + ''); tr.append('' + (s.completion_status === 'completed' ? vcheck : xcheck) + ''); - tr.append('
' + s.score + ' %
'); + tr.append('
' + (score === 0 ? '-' : score + ' %') + '
'); }); } +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) { diff --git a/packages/QZ/QZ.zip b/packages/QZ/QZ.zip new file mode 100644 index 0000000..cb2eeb2 Binary files /dev/null and b/packages/QZ/QZ.zip differ diff --git a/packages/QZ/imsmanifest.xml b/packages/QZ/imsmanifest.xml new file mode 100644 index 0000000..b5f65e3 --- /dev/null +++ b/packages/QZ/imsmanifest.xml @@ -0,0 +1,27 @@ + + + + ADL SCORM + 1.2 + + + + HF SCORM Multiple Package + + HF SCORM Multiple Package + + + + + + + + + \ No newline at end of file diff --git a/packages/QZ/js/main.js b/packages/QZ/js/main.js index c9a25f8..7092b4a 100644 --- a/packages/QZ/js/main.js +++ b/packages/QZ/js/main.js @@ -115,6 +115,7 @@ $("main").append(results); $(document).on('quizinit', function (event, state) { + console.log(state); init(state) }); initScormEvents(); diff --git a/style/style.css b/style/style.css index d253454..96cbb68 100644 --- a/style/style.css +++ b/style/style.css @@ -192,7 +192,7 @@ header h1 { } #wrapper main table tbody td.score div { white-space: nowrap; - width: 60px; + width: 70px; padding: 5px; margin: 0 auto; background-color: #e4ff19; diff --git a/style/style.sass b/style/style.sass index 7dbc73c..cd7e52a 100644 --- a/style/style.sass +++ b/style/style.sass @@ -153,7 +153,7 @@ header &.score div white-space: nowrap - width: 60px + width: 70px padding: 5px margin: 0 auto background-color: #e4ff19