]> _ Git - fluidbook-toolbox.git/commitdiff
try #4631 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 30 Jul 2021 17:27:43 +0000 (19:27 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 30 Jul 2021 17:27:43 +0000 (19:27 +0200)
resources/quiz/js/libs/scorm/apiwrapper.js

index 8adfc0179653de529a73e334635ddaab34eba14c..7d2f216fcf46e0beea2c8e559b8ed1e3b52f1ea2 100644 (file)
@@ -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() {