@didask/scol-r 2.5.2 → 2.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/HTMLGenerator.js +1 -1
- package/lib/ManifestGenerator.d.ts +10 -2
- package/lib/ManifestGenerator.js +22 -25
- package/lib/SCORMAdapter.js +17 -17
- package/lib/index.js +6 -2
- package/lib/loadContent.d.ts +1 -1
- package/lib/loadContent.js +14 -8
- package/package.json +8 -3
- package/lib/SCORMAdapter.test.d.ts +0 -1
- package/lib/SCORMAdapter.test.js +0 -14
package/lib/HTMLGenerator.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HTMLGenerator = void 0;
|
|
4
4
|
function HTMLGenerator(props) {
|
|
5
5
|
var dataSource = props.dataSource, _a = props.libPath, libPath = _a === void 0 ? "lib" : _a;
|
|
6
|
-
return "<!DOCTYPE html>\n <html>\n <head>\n <title>SCO local endpoint</title>\n <meta charset=\"UTF-8\"/>\n <script>var exports = {};</script>\n <script type=\"text/javascript\" src=\""
|
|
6
|
+
return "<!DOCTYPE html>\n <html>\n <head>\n <title>SCO local endpoint</title>\n <meta charset=\"UTF-8\"/>\n <script>var exports = {};</script>\n <script type=\"text/javascript\" src=\"".concat(libPath, "/SCORMAdapter.js\"></script>\n <script type=\"text/javascript\" src=\"").concat(libPath, "/MessageHandler.js\"></script>\n <script type=\"text/javascript\" src=\"").concat(libPath, "/loadContent.js\"></script>\n <style type=\"text/css\">\n html, body { margin: 0; padding:0; overflow:hidden; width: 100%; height: 100%; }\n body {\n font-size: 20px;\n font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n color: #1d1046;\n }\n #wrapper { display: flex; flex-direction: column; height: 100%; }\n .container { width: 80%; max-width: 1200px; padding: 15px; margin: auto; }\n #wrapper .header {\n padding-top: 20px; padding-bottom: 20px;\n background-color: #f3f4f5;\n }\n #wrapper .messages { flex-grow: 1; padding-top: 20px; padding-bottom: 20px; }\n #wrapper .messages p { color: red; }\n #title-error-messages { color: #1d1046; }\n #wrapper .footer {\n background-color: #1d1046; color: white;\n padding-top: 10px; padding-bottom: 10px;\n }\n #wrapper .footer a { color: white; }\n\n iframe { overflow: hidden; height: 100%; width: 100%; }\n iframe + #wrapper { display: none; }\n #runtime-error {\n position: fixed;\n left: 20px; bottom: 20px; padding: 15px;\n background-color: #f44a3d; color: white;\n font-size: 16px;\n }\n #runtime-error h6, #runtime-error p { margin: 0 0 10px;}\n #runtime-error p:last-child { margin: 0;}\n #runtime-error:empty { display: none; }\n </style>\n </head>\n <!-- Set the body's data-source attribute to the SCO's remote endpoint. -->\n <body onload=\"loadContent();\" data-source=\"").concat(dataSource, "\">\n <div id=\"wrapper\">\n <div class=\"header\"><div class=\"container\">\n <h1 id=\"title\">Your content is loading...</h1>\n <p id=\"subtitle\">Please wait, or if your content doesn't appear, try closing and opening this window again.</p>\n </div></div>\n <div class=\"messages container\">\n <h2 id=\"title-error-messages\">If the initialization fails, error messages will appear below:</h2>\n </div>\n <div class=\"footer\"><div class=\"container\" id=\"footer-content\">\n This content is loaded via <a href=\"https://github.com/Didask/scol-r\" target=\"_blank\">SCOL-R</a>, a cross-domain SCORM connector created by <a href=\"https://www.didask.com\" target=\"_blank\">Didask</a>.\n </div></div>\n </div>\n <div id=\"runtime-error\"></div>\n </body>\n </html>");
|
|
7
7
|
}
|
|
8
8
|
exports.HTMLGenerator = HTMLGenerator;
|
|
@@ -2,10 +2,18 @@ import { scormVersions } from ".";
|
|
|
2
2
|
export declare class Sco {
|
|
3
3
|
scoID: string;
|
|
4
4
|
scoTitle: string;
|
|
5
|
+
scoHref: `./${string}`;
|
|
5
6
|
author: string;
|
|
6
7
|
learningTime: number;
|
|
7
8
|
resources: string[];
|
|
8
|
-
constructor(
|
|
9
|
+
constructor(props: {
|
|
10
|
+
scoID: string;
|
|
11
|
+
scoTitle: string;
|
|
12
|
+
author: string;
|
|
13
|
+
learningTime: number;
|
|
14
|
+
scoHref: `./${string}`;
|
|
15
|
+
resources: string[];
|
|
16
|
+
});
|
|
9
17
|
}
|
|
10
18
|
export interface ManifestGeneratorProps {
|
|
11
19
|
courseId: string;
|
|
@@ -15,6 +23,6 @@ export interface ManifestGeneratorProps {
|
|
|
15
23
|
sharedResources?: string[];
|
|
16
24
|
totalLearningTime?: number;
|
|
17
25
|
dataFromLms?: string;
|
|
18
|
-
scormVersion?: typeof scormVersions[number];
|
|
26
|
+
scormVersion?: (typeof scormVersions)[number];
|
|
19
27
|
}
|
|
20
28
|
export declare function ManifestGenerator({ courseId, scoList, sharedResources, totalLearningTime, dataFromLms, scormVersion, ...props }: ManifestGeneratorProps): string;
|
package/lib/ManifestGenerator.js
CHANGED
|
@@ -24,22 +24,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.ManifestGenerator = exports.Sco = void 0;
|
|
26
26
|
var Sco = /** @class */ (function () {
|
|
27
|
-
function Sco(
|
|
28
|
-
this.scoID = scoID;
|
|
29
|
-
this.scoTitle = scoTitle;
|
|
30
|
-
this.author = author;
|
|
31
|
-
this.learningTime = learningTime;
|
|
32
|
-
this.resources = resources
|
|
27
|
+
function Sco(props) {
|
|
28
|
+
this.scoID = props.scoID;
|
|
29
|
+
this.scoTitle = props.scoTitle;
|
|
30
|
+
this.author = props.author;
|
|
31
|
+
this.learningTime = props.learningTime;
|
|
32
|
+
this.resources = props.resources;
|
|
33
|
+
this.scoHref = props.scoHref;
|
|
33
34
|
}
|
|
34
35
|
return Sco;
|
|
35
36
|
}());
|
|
36
37
|
exports.Sco = Sco;
|
|
37
38
|
var formatLearningTime = function (learningTime) {
|
|
38
39
|
var intHours = Math.floor(learningTime / 60);
|
|
39
|
-
var hours = intHours > 10 ? intHours : "0"
|
|
40
|
+
var hours = intHours > 10 ? intHours : "0".concat(intHours);
|
|
40
41
|
var intMinutes = intHours > 0 ? learningTime - intHours * 60 : learningTime;
|
|
41
|
-
var minutes = intMinutes > 10 ? intMinutes : "0"
|
|
42
|
-
return hours
|
|
42
|
+
var minutes = intMinutes > 10 ? intMinutes : "0".concat(intMinutes);
|
|
43
|
+
return "".concat(hours, ":").concat(minutes, ":00");
|
|
43
44
|
};
|
|
44
45
|
var removeSpecialChars = function (obj) {
|
|
45
46
|
return Object.entries(obj).reduce(function (acc, _a) {
|
|
@@ -54,28 +55,24 @@ function ManifestGenerator(_a) {
|
|
|
54
55
|
var courseGlobalLearningTime = scoList.length
|
|
55
56
|
? scoList.reduce(function (acc, sco) { return acc + sco.learningTime; }, 0)
|
|
56
57
|
: totalLearningTime;
|
|
57
|
-
return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n <manifest xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\" identifier=\""
|
|
58
|
+
return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n <manifest xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\" identifier=\"".concat(courseId, "\" version=\"1.0\" xmlns:imsmd=\"http://www.imsglobal.org/xsd/imsmd_rootv1p2p1\" xmlns:adlcp=\"http://www.adlnet.org/xsd/adlcp_rootv1p2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" 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\">\n <metadata>\n <schema>ADL SCORM</schema>\n <schemaversion>").concat(scormVersion, "</schemaversion>\n <imsmd:lom xmlns=\"http://ltsc.ieee.org/xsd/LOM\">\n <imsmd:general>\n <imsmd:identifier>").concat(courseId, "</imsmd:identifier>\n </imsmd:general>\n <imsmd:lifecycle>\n <imsmd:contribute>\n <imsmd:role>\n <imsmd:source>\n <imsmd:langstring xml:lang=\"fr\">LOMv1.0</imsmd:langstring>\n </imsmd:source>\n <imsmd:value>\n <imsmd:langstring xml:lang=\"fr\">Author</imsmd:langstring>\n </imsmd:value>\n </imsmd:role>\n <imsmd:centity>\n <imsmd:vcard>\n begin:vcard\n fn:").concat(courseAuthor, "\n end:vcard\n </imsmd:vcard>\n </imsmd:centity>\n </imsmd:contribute>\n </imsmd:lifecycle>\n <imsmd:educational>\n <imsmd:typicallearningtime>\n <imsmd:datetime>").concat(formatLearningTime(courseGlobalLearningTime), "</imsmd:datetime>\n </imsmd:typicallearningtime>\n </imsmd:educational>\n </imsmd:lom>\n </metadata>\n <organizations default=\"Org1\">\n <organization identifier=\"Org1\">\n <title>").concat(courseTitle, "</title>\n ").concat(scoList
|
|
58
59
|
.map(function (_a) {
|
|
59
60
|
var scoID = _a.scoID, learningTime = _a.learningTime, resources = _a.resources, props = __rest(_a, ["scoID", "learningTime", "resources"]);
|
|
60
61
|
var _b = removeSpecialChars(props), scoTitle = _b.scoTitle, author = _b.author;
|
|
61
|
-
return "<item identifier=\""
|
|
62
|
+
return "<item identifier=\"".concat(scoTitle, "\" identifierref=\"resource_").concat(scoID, "\" isvisible=\"true\">\n <title>").concat(scoTitle, "</title>\n <adlcp:dataFromLMS>").concat(dataFromLms !== null && dataFromLms !== void 0 ? dataFromLms : courseId + ":" + scoID, "</adlcp:dataFromLMS>\n <metadata>\n <imsmd:lom xmlns=\"http://ltsc.ieee.org/xsd/LOM\">\n <imsmd:general>\n <imsmd:identifier>").concat(scoID, "</imsmd:identifier>\n </imsmd:general>\n <imsmd:lifecycle>\n <imsmd:contribute>\n <imsmd:role>\n <imsmd:source>\n <imsmd:langstring xml:lang=\"fr\">LOMv1.0</imsmd:langstring>\n </imsmd:source>\n <imsmd:value>\n <imsmd:langstring xml:lang=\"fr\">Author</imsmd:langstring>\n </imsmd:value>\n </imsmd:role>\n <imsmd:centity>\n <imsmd:vcard>\n begin:vcard\n fn:").concat(author, "\n end:vcard\n </imsmd:vcard>\n </imsmd:centity>\n </imsmd:contribute>\n </imsmd:lifecycle>\n <imsmd:educational>\n <imsmd:typicallearningtime>\n <imsmd:datetime>").concat(formatLearningTime(learningTime), "</imsmd:datetime>\n </imsmd:typicallearningtime>\n </imsmd:educational>\n </imsmd:lom>\n </metadata>\n </item>");
|
|
62
63
|
})
|
|
63
|
-
.join("\n")
|
|
64
|
-
? "<resource adlcp:scormtype=\"asset\" type=\"webcontent\" identifier=\"shared_resources\">\n "
|
|
65
|
-
.map(function (resource) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.join("\n") + "\n </resource>"
|
|
69
|
-
: "") + "\n " + scoList
|
|
64
|
+
.join("\n"), "\n </organization>\n </organizations>\n <resources>\n ").concat((sharedResources === null || sharedResources === void 0 ? void 0 : sharedResources.length)
|
|
65
|
+
? "<resource adlcp:scormtype=\"asset\" type=\"webcontent\" identifier=\"shared_resources\">\n ".concat(sharedResources
|
|
66
|
+
.map(function (resource) { return "<file href=\"".concat(resource, "\"/>"); })
|
|
67
|
+
.join("\n"), "\n </resource>")
|
|
68
|
+
: "", "\n ").concat(scoList
|
|
70
69
|
.map(function (sco) {
|
|
71
|
-
return "<resource adlcp:scormtype=\"sco\" type=\"webcontent\" identifier=\"resource_"
|
|
70
|
+
return "<resource adlcp:scormtype=\"sco\" type=\"webcontent\" identifier=\"resource_".concat(sco.scoID, "\" href=\"").concat(sco.scoHref, "\">\n ").concat((sharedResources === null || sharedResources === void 0 ? void 0 : sharedResources.length)
|
|
72
71
|
? '<dependency identifierref="shared_resources"/>'
|
|
73
|
-
: ""
|
|
74
|
-
.map(function (resource) {
|
|
75
|
-
|
|
76
|
-
})
|
|
77
|
-
.join("\n") + "\n </resource>";
|
|
72
|
+
: "", "\n ").concat(sco.resources
|
|
73
|
+
.map(function (resource) { return "<file href=\"".concat(resource, "\"/>"); })
|
|
74
|
+
.join("\n"), "\n </resource>");
|
|
78
75
|
})
|
|
79
|
-
.join("\n")
|
|
76
|
+
.join("\n"), "\n </resources>\n </manifest>");
|
|
80
77
|
}
|
|
81
78
|
exports.ManifestGenerator = ManifestGenerator;
|
package/lib/SCORMAdapter.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.convertMsToCMITimespan = exports.convertToTimeInterval = exports.SCORMAdapter = void 0;
|
|
4
4
|
var SCORMAdapter = /** @class */ (function () {
|
|
5
5
|
function SCORMAdapter(errorCallback) {
|
|
6
|
-
var _this = this;
|
|
7
6
|
if (errorCallback === void 0) { errorCallback = function () { }; }
|
|
7
|
+
var _this = this;
|
|
8
8
|
this._ignorableErrorCodes = [
|
|
9
9
|
{ code: 0, getShouldBeIgnored: function () { return true; } },
|
|
10
10
|
{
|
|
@@ -134,7 +134,7 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
134
134
|
var code = _a.code, getShouldBeIgnored = _a.getShouldBeIgnored;
|
|
135
135
|
return code === lastErrorCode && getShouldBeIgnored();
|
|
136
136
|
})) {
|
|
137
|
-
console.warn(functionName, "An error occured on the SCORM API: code "
|
|
137
|
+
console.warn(functionName, "An error occured on the SCORM API: code ".concat(lastErrorCode, ", message: ").concat(lastErrorString), lastErrorDiagnostic);
|
|
138
138
|
this._errorCallback(lastErrorString, lastErrorDiagnostic && lastErrorDiagnostic != lastErrorCode
|
|
139
139
|
? lastErrorDiagnostic
|
|
140
140
|
: null);
|
|
@@ -168,14 +168,14 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
168
168
|
var functionName = "GetValue";
|
|
169
169
|
var value = this._callAPIFunction(functionName, [name]);
|
|
170
170
|
var success = this.LMSGetLastError() === 0;
|
|
171
|
-
return success ? value : this._handleError(functionName
|
|
171
|
+
return success ? value : this._handleError("".concat(functionName, ": ").concat(name));
|
|
172
172
|
};
|
|
173
173
|
SCORMAdapter.prototype.LMSSetValue = function (name, value) {
|
|
174
174
|
this._lastRequest = { method: "set", key: name };
|
|
175
175
|
var functionName = "SetValue";
|
|
176
176
|
var result = this._callAPIFunction(functionName, [name, value]);
|
|
177
177
|
var success = eval(result.toString());
|
|
178
|
-
return success || this._handleError(functionName
|
|
178
|
+
return success || this._handleError("".concat(functionName, ": {").concat(name, ": ").concat(value, "}"));
|
|
179
179
|
};
|
|
180
180
|
SCORMAdapter.prototype.LMSCommit = function () {
|
|
181
181
|
var result = this._callAPIFunction("Commit");
|
|
@@ -270,11 +270,11 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
270
270
|
};
|
|
271
271
|
SCORMAdapter.prototype.setSessionTime = function (msSessionTime) {
|
|
272
272
|
if (this._isSCORM2004) {
|
|
273
|
-
var duration = exports.convertToTimeInterval(msSessionTime);
|
|
273
|
+
var duration = (0, exports.convertToTimeInterval)(msSessionTime);
|
|
274
274
|
this.LMSSetValue("cmi.session_time", duration);
|
|
275
275
|
}
|
|
276
276
|
else {
|
|
277
|
-
var duration = exports.convertMsToCMITimespan(msSessionTime);
|
|
277
|
+
var duration = (0, exports.convertMsToCMITimespan)(msSessionTime);
|
|
278
278
|
this.LMSSetValue("cmi.core.session_time", duration);
|
|
279
279
|
}
|
|
280
280
|
};
|
|
@@ -289,7 +289,7 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
289
289
|
SCORMAdapter.prototype.setObjectives = function (objectivesIds) {
|
|
290
290
|
var _this = this;
|
|
291
291
|
objectivesIds.forEach(function (objectiveId, index) {
|
|
292
|
-
_this.LMSSetValue("cmi.objectives."
|
|
292
|
+
_this.LMSSetValue("cmi.objectives.".concat(index, ".id"), objectiveId);
|
|
293
293
|
});
|
|
294
294
|
};
|
|
295
295
|
Object.defineProperty(SCORMAdapter.prototype, "objectives", {
|
|
@@ -297,7 +297,7 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
297
297
|
var objectives = [];
|
|
298
298
|
var objectivesNbr = this.LMSGetValue("cmi.objectives._count");
|
|
299
299
|
for (var index = 0; index < objectivesNbr; index++) {
|
|
300
|
-
objectives.push(this.LMSGetValue("cmi.objectives."
|
|
300
|
+
objectives.push(this.LMSGetValue("cmi.objectives.".concat(index, ".id")));
|
|
301
301
|
}
|
|
302
302
|
return objectives;
|
|
303
303
|
},
|
|
@@ -307,9 +307,9 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
307
307
|
SCORMAdapter.prototype.setObjectiveScore = function (objectiveId, score) {
|
|
308
308
|
var objectivesNbr = this.LMSGetValue("cmi.objectives._count");
|
|
309
309
|
for (var index = 0; index < objectivesNbr; index++) {
|
|
310
|
-
var storedObjectiveId = this.LMSGetValue("cmi.objectives."
|
|
310
|
+
var storedObjectiveId = this.LMSGetValue("cmi.objectives.".concat(index, ".id"));
|
|
311
311
|
if (objectiveId === storedObjectiveId) {
|
|
312
|
-
this.LMSSetValue("cmi.objectives."
|
|
312
|
+
this.LMSSetValue("cmi.objectives.".concat(index, ".score.raw"), score);
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
315
|
}
|
|
@@ -317,14 +317,14 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
317
317
|
SCORMAdapter.prototype.setObjectiveStatus = function (objectiveId, status) {
|
|
318
318
|
var objectivesNbr = this.LMSGetValue("cmi.objectives._count");
|
|
319
319
|
for (var index = 0; index < objectivesNbr; index++) {
|
|
320
|
-
var storedObjectiveId = this.LMSGetValue("cmi.objectives."
|
|
320
|
+
var storedObjectiveId = this.LMSGetValue("cmi.objectives.".concat(index, ".id"));
|
|
321
321
|
if (objectiveId === storedObjectiveId) {
|
|
322
322
|
if (this._isSCORM2004) {
|
|
323
|
-
this.LMSSetValue("cmi.objectives."
|
|
324
|
-
this.LMSSetValue("cmi.objectives."
|
|
323
|
+
this.LMSSetValue("cmi.objectives.".concat(index, ".success_status"), status === "completed" ? "passed" : "unknown");
|
|
324
|
+
this.LMSSetValue("cmi.objectives.".concat(index, ".completion_status"), status === "completed" ? "completed" : "incomplete");
|
|
325
325
|
}
|
|
326
326
|
else {
|
|
327
|
-
this.LMSSetValue("cmi.objectives."
|
|
327
|
+
this.LMSSetValue("cmi.objectives.".concat(index, ".status"), status === "completed" ? "passed" : "incomplete");
|
|
328
328
|
}
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
@@ -333,9 +333,9 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
333
333
|
SCORMAdapter.prototype.getObjectiveScore = function (objectiveId) {
|
|
334
334
|
var objectivesNbr = this.LMSGetValue("cmi.objectives._count");
|
|
335
335
|
for (var index = 0; index < objectivesNbr; index++) {
|
|
336
|
-
var storedObjectiveId = this.LMSGetValue("cmi.objectives."
|
|
336
|
+
var storedObjectiveId = this.LMSGetValue("cmi.objectives.".concat(index, ".id"));
|
|
337
337
|
if (objectiveId === storedObjectiveId) {
|
|
338
|
-
return this.LMSGetValue("cmi.objectives."
|
|
338
|
+
return this.LMSGetValue("cmi.objectives.".concat(index, ".score.raw"));
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
};
|
|
@@ -375,7 +375,7 @@ var convertMsToCMITimespan = function (milliseconds) {
|
|
|
375
375
|
var m = pad(minutes % 60, 2);
|
|
376
376
|
var s = pad(seconds % 60, 2);
|
|
377
377
|
var c = pad(cents % 100, 2);
|
|
378
|
-
return h
|
|
378
|
+
return "".concat(h, ":").concat(m, ":").concat(s, ".").concat(c);
|
|
379
379
|
};
|
|
380
380
|
exports.convertMsToCMITimespan = convertMsToCMITimespan;
|
|
381
381
|
var getDurationData = function (milliseconds) {
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -34,4 +38,4 @@ var LessonStatus;
|
|
|
34
38
|
LessonStatus["Incomplete"] = "incomplete";
|
|
35
39
|
LessonStatus["NotAttempted"] = "not attempted";
|
|
36
40
|
LessonStatus["Browsed"] = "browsed";
|
|
37
|
-
})(LessonStatus
|
|
41
|
+
})(LessonStatus || (exports.LessonStatus = LessonStatus = {}));
|
package/lib/loadContent.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function loadContent(): void;
|
package/lib/loadContent.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadContent = void 0;
|
|
1
4
|
function loadContent() {
|
|
2
5
|
var messages = {
|
|
3
6
|
en: {
|
|
@@ -45,8 +48,10 @@ function loadContent() {
|
|
|
45
48
|
var displayInitError = function (message) {
|
|
46
49
|
var messagesContainer = document.getElementsByClassName("messages");
|
|
47
50
|
var newMessage = document.createElement("p");
|
|
48
|
-
|
|
51
|
+
var localizedMessage = localizeMessage(message);
|
|
52
|
+
newMessage.innerHTML = localizedMessage;
|
|
49
53
|
messagesContainer.length && messagesContainer[0].appendChild(newMessage);
|
|
54
|
+
console.error(localizedMessage);
|
|
50
55
|
};
|
|
51
56
|
var displayRuntimeError = function () {
|
|
52
57
|
var errorContainer = document.getElementById("runtime-error");
|
|
@@ -89,18 +94,18 @@ function loadContent() {
|
|
|
89
94
|
var sourceUrlParser = document.createElement("a");
|
|
90
95
|
sourceUrlParser.href = sourceUrl;
|
|
91
96
|
var learnerId = ADAPTER.getLearnerId();
|
|
97
|
+
var learnerName = ADAPTER.getLearnerName();
|
|
92
98
|
if (learnerId == null) {
|
|
93
99
|
displayInitError("learnerIdMissing");
|
|
94
100
|
return;
|
|
95
101
|
}
|
|
96
102
|
sourceUrlParser.search +=
|
|
97
|
-
(sourceUrlParser.search.
|
|
98
|
-
"scorm
|
|
99
|
-
learnerId +
|
|
100
|
-
"&
|
|
101
|
-
encodeURIComponent(location.origin) +
|
|
102
|
-
"&data_from_lms="
|
|
103
|
-
ADAPTER.getDataFromLMS();
|
|
103
|
+
(sourceUrlParser.search.startsWith("?") ? "&" : "?") +
|
|
104
|
+
"scorm" +
|
|
105
|
+
"&learner_id=".concat(learnerId) +
|
|
106
|
+
"&learner_name=".concat(learnerName) +
|
|
107
|
+
"&lms_origin=".concat(encodeURIComponent(location.origin)) +
|
|
108
|
+
"&data_from_lms=".concat(ADAPTER.getDataFromLMS());
|
|
104
109
|
var iframe = document.createElement("iframe");
|
|
105
110
|
iframe.setAttribute("src", sourceUrlParser.href);
|
|
106
111
|
iframe.setAttribute("frameborder", "0");
|
|
@@ -124,3 +129,4 @@ function loadContent() {
|
|
|
124
129
|
ADAPTER.LMSTerminate();
|
|
125
130
|
});
|
|
126
131
|
}
|
|
132
|
+
exports.loadContent = loadContent;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@didask/scol-r",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0-beta.1",
|
|
4
4
|
"description": "Shareable Cross-Origin Learning Resources",
|
|
5
5
|
"main": "index.html",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/"
|
|
9
|
+
],
|
|
8
10
|
"scripts": {
|
|
9
11
|
"build": "tsc",
|
|
10
12
|
"clean": "rm -rf node_modules lib",
|
|
@@ -14,7 +16,10 @@
|
|
|
14
16
|
"type": "git",
|
|
15
17
|
"url": "git+https://github.com/Didask/scol-r.git"
|
|
16
18
|
},
|
|
17
|
-
"keywords": [
|
|
19
|
+
"keywords": [
|
|
20
|
+
"SCORM",
|
|
21
|
+
"CORS"
|
|
22
|
+
],
|
|
18
23
|
"author": "Didask",
|
|
19
24
|
"license": "ISC",
|
|
20
25
|
"bugs": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/SCORMAdapter.test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var bun_test_1 = require("bun:test");
|
|
4
|
-
var SCORMAdapter_1 = require("./SCORMAdapter");
|
|
5
|
-
bun_test_1.test('convertMsToCMITimespan ("0000:00:00.00")', function () {
|
|
6
|
-
var milliseconds = (36 * 60 * 60 * 1000) + (6 * 60 * 1000) + (2 * 1000) + (23 * 10);
|
|
7
|
-
var CMITimespan = SCORMAdapter_1.convertMsToCMITimespan(milliseconds);
|
|
8
|
-
bun_test_1.expect(CMITimespan).toBe('0036:06:02.23');
|
|
9
|
-
});
|
|
10
|
-
bun_test_1.test('convertToTimeInterval', function () {
|
|
11
|
-
var milliseconds = (36 * 60 * 60 * 1000) + (6 * 60 * 1000) + (2 * 1000) + (23 * 10);
|
|
12
|
-
var timeInterval = SCORMAdapter_1.convertToTimeInterval(milliseconds);
|
|
13
|
-
bun_test_1.expect(timeInterval).toBe('P1DT12H6M2');
|
|
14
|
-
});
|