From: Vincent Vanwaelscappel Date: Fri, 30 Jul 2021 17:27:43 +0000 (+0200) Subject: try #4631 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=5ec0ae66b63c010e135652fbb19fc743dac0d255;p=fluidbook-toolbox.git try #4631 @1 --- diff --git a/resources/quiz/js/libs/scorm/apiwrapper.js b/resources/quiz/js/libs/scorm/apiwrapper.js index 8adfc0179..7d2f216fc 100644 --- a/resources/quiz/js/libs/scorm/apiwrapper.js +++ b/resources/quiz/js/libs/scorm/apiwrapper.js @@ -15,8 +15,8 @@ ** var result = doLMSInitialize(); ** if (result != true) ** { -** // handle error -** } + ** // handle error + ** } ** *******************************************************************************/ @@ -95,8 +95,7 @@ function doLMSFinish() { if (api == null) { console.error("Unable to locate the LMS's API Implementation.\nLMSFinish was not successful."); return "false"; - } - else { + } else { // call the LMSFinish function that should be implemented by the API var result = api.LMSFinish(""); @@ -127,8 +126,7 @@ function doLMSGetValue(name) { if (api == null) { console.error("Unable to locate the LMS's API Implementation.\nLMSGetValue was not successful."); return ""; - } - else { + } else { var value = api.LMSGetValue(name); var errCode = api.LMSGetLastError().toString(); if (errCode != _NoError) { @@ -136,8 +134,7 @@ function doLMSGetValue(name) { var errDescription = api.LMSGetErrorString(errCode); console.error("LMSGetValue(" + name + ") failed. \n" + errDescription); return ""; - } - else { + } else { return value.toString(); } @@ -161,8 +158,7 @@ function doLMSSetValue(name, value) { if (api == null) { console.error("Unable to locate the LMS's API Implementation.\nLMSSetValue was not successful."); return; - } - else { + } else { var result = api.LMSSetValue(name, value); if (result.toString() != "true") { var err = ErrorHandler(); @@ -187,8 +183,7 @@ function doLMSCommit() { if (api == null) { console.error("Unable to locate the LMS's API Implementation.\nLMSCommit was not successful."); return "false"; - } - else { + } else { var result = api.LMSCommit(""); if (result != "true") { var err = ErrorHandler(); @@ -277,14 +272,12 @@ function LMSIsInitialized() { if (api == null) { console.error("Unable to locate the LMS's API Implementation.\nLMSIsInitialized() failed."); return false; - } - else { + } else { var value = api.LMSGetValue("cmi.core.student_name"); var errCode = api.LMSGetLastError().toString(); if (errCode == _NotInitialized) { return false; - } - else { + } else { return true; } } @@ -362,6 +355,10 @@ function findAPI(win) { try { while ((win.API == null) && (win.parent != null) && (win.parent != win)) { findAPITries++; + if (win.fluidbook !== undefined || win.parent.fluidbook !== undefined) { + console.error('quiz is embeded in a fluidbook -- we do not want quiz interact with fluidbook scorm'); + return null; + } // Note: 7 is an arbitrary number, but should be more than sufficient if (findAPITries > 7) { console.error("Error finding API -- too deeply nested."); @@ -392,7 +389,7 @@ function findAPI(win) { *******************************************************************************/ function getAPI() { var theAPI = findAPI(window); - if ((theAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined")) { + if ((theAPI == null) && (window.opener != null) && (typeof (window.opener) != "undefined")) { theAPI = findAPI(window.opener); } if (theAPI == null) { @@ -400,6 +397,7 @@ function getAPI() { } return theAPI } + var startTime; function startTimer() {