Skip to content

Commit 930123e

Browse files
committed
added extra tests for verifying 403 on empty cmi.location. Certain content produced from other tools seems to rely on this error code in order to determine cmi.entry vs. using cmi.entry.
This added test will confirm LMS standardization if run against a platform. Also added console errors. When using the SCOBot Runtime API errors are generated, but on other platforms this was transparent. So the 'getvalue' and 'setvalue' triggers within SCOBot will now trace these events to the console for these QUnit tests.
1 parent e761fd0 commit 930123e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

QUnit-Tests/js/test/scobot-prod.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@ var $ = SCOBotUtil,
3838
$.addEvent(scorm, "setvalue", function (e) {
3939
"use strict";
4040
setvalue_calls += 1;
41+
// Hook for trapping SCORM errors.
42+
if (e.error.code !== 0) {
43+
SB.debug(e.n + " " + e.v + "\n" + e.error.code + "\n" + e.error.message + "\n" + e.error.diagnostic, 1);
44+
}
4145
});
4246
$.addEvent(scorm, "getvalue", function (e) {
4347
"use strict";
4448
getvalue_calls += 1;
49+
// Hook for trapping SCORM errors.
50+
if (e.error.code !== 0) {
51+
SB.debug(e.n + "\n" + e.error.code + "\n" + e.error.message + "\n" + e.error.diagnostic, 1);
52+
}
4553
});
4654
$.addEvent(scorm, "StoreData", function (e) {
4755
"use strict";
@@ -177,12 +185,20 @@ $.addEvent(SB, 'load', function (e) {
177185
test("Bookmarking", function () {
178186
if (local) {
179187
// There would be no bookmark unless one was manually set
188+
// This means a request to get Bookmark is cached by SCOBot. This test will work
189+
// with the SCOBotBase (scorm namespace) to directly verify the error code gets set.
190+
strictEqual(scorm.getvalue('cmi.location'), '', "Get empty Boomkark");
191+
strictEqual(scorm.getLastError().code, 403); // should be value not initialized
192+
180193
strictEqual(SB.setBookmark(2), 'true', 'Setting Bookmark to 2');
181194
strictEqual(SB.getBookmark(), '2', 'Getting Bookmark, should be 2');
182195
} else {
183196
if (SB.getEntry() === "resume") {
184197
strictEqual(SB.getBookmark(), '2', 'Getting Bookmark, should be 2');
185198
} else {
199+
strictEqual(scorm.getvalue('cmi.location'), '', "Get empty Boomkark");
200+
strictEqual(scorm.getLastError().code, 403); // should be value not initialized
201+
186202
strictEqual(SB.setBookmark(2), 'true', 'Setting Bookmark to 2');
187203
strictEqual(SB.getBookmark(), '2', 'Getting Bookmark, should be 2');
188204
}

QUnit-Tests/js/test/scobot.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@ var $ = SCOBotUtil,
3838
$.addEvent(scorm, "setvalue", function (e) {
3939
"use strict";
4040
setvalue_calls += 1;
41+
// Hook for trapping SCORM errors.
42+
if (e.error.code !== 0) {
43+
SB.debug(e.n + " " + e.v + "\n" + e.error.code + "\n" + e.error.message + "\n" + e.error.diagnostic, 1);
44+
}
4145
});
4246
$.addEvent(scorm, "getvalue", function (e) {
4347
"use strict";
4448
getvalue_calls += 1;
49+
// Hook for trapping SCORM errors.
50+
if (e.error.code !== 0) {
51+
SB.debug(e.n + "\n" + e.error.code + "\n" + e.error.message + "\n" + e.error.diagnostic, 1);
52+
}
4553
});
4654
$.addEvent(scorm, "StoreData", function (e) {
4755
"use strict";
@@ -172,13 +180,21 @@ $.addEvent(SB, 'load', function (e) {
172180

173181
test("Bookmarking", function () {
174182
if (local) {
183+
// SCOBot will not get a cmi.location unless its entry type is resume or blank
184+
// This means a request to get Bookmark is cached by SCOBot. This test will work
185+
// with the SCOBotBase (scorm namespace) to directly verify the error code gets set.
186+
strictEqual(scorm.getvalue('cmi.location'), '', "Get empty Boomkark");
187+
strictEqual(scorm.getLastError().code, 403); // should be value not initialized
175188
// There would be no bookmark unless one was manually set
176189
strictEqual(SB.setBookmark(2), 'true', 'Setting Bookmark to 2');
177190
strictEqual(SB.getBookmark(), '2', 'Getting Bookmark, should be 2');
178191
} else {
179192
if (SB.getEntry() === "resume") {
180193
strictEqual(SB.getBookmark(), '2', 'Getting Bookmark, should be 2');
181194
} else {
195+
strictEqual(scorm.getvalue('cmi.location'), '', "Get empty Boomkark");
196+
strictEqual(scorm.getLastError().code, 403); // should be value not initialized
197+
182198
strictEqual(SB.setBookmark(2), 'true', 'Setting Bookmark to 2');
183199
strictEqual(SB.getBookmark(), '2', 'Getting Bookmark, should be 2');
184200
}

0 commit comments

Comments
 (0)