Moodle

LMSFinish cannot be correctly fired when the user tries to browse within the parent (= Moodle) window

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.8, 1.9.9, 1.9.10
  • Fix Version/s: 2.0.5, 2.1.2
  • Component/s: SCORM
  • Labels:
    None
  • Database:
    Any
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE, MOODLE_21_STABLE

Description

When the content is configured to be displayed in a new window, it is possible for the user to get back into the parent window and navigate away from it.
Such a behavior correctly fires a close command against the SCORM content window but... this will happen when the SCORM RTE (API) has been already removed from the parent window and the content - which usually "close" the session using code called in body@unonload - is not able to correctly "finish" the tracking session being LMSFinish() no more available.

The same applies with SCORM 2004 and potentially with 2.0.x.

Issue Links

Activity

Hide
Matteo Scaramuccia added a comment -

A possible solution is to delay the browser "someway" in unloading the parent window, to let the content close its session correctly.
It seems that the patch proposal below does the trick:

Index: /trunk/src/moodle/mod/scorm/player.php
===================================================================
--- /trunk/src/moodle/mod/scorm/player.php (revision original)
+++ /trunk/src/moodle/mod/scorm/player.php (revision proposal)
@@ -63,4 +63,5 @@
     $strscorms = get_string('modulenameplural', 'scorm');
     $strscorm  = get_string('modulename', 'scorm');
+    $straltpopup = get_string('altpopup', 'scorm');
     $strpopup = get_string('popup','scorm');
     $strexit = get_string('exitactivity','scorm');
@@ -147,5 +148,5 @@
     $bodyscript = '';
     if ($scorm->popup == 1) {
-        $bodyscript = 'onunload="main.close();"';
+        $bodyscript = 'onunload="closepopup();"';
     }
 
@@ -166,4 +167,13 @@
             scorm_resize(<?php echo $scorm->width.", ".$scorm->height; ?>);
         };
+        
+        function closepopup() {
+            // check if popup is still opened
+            if (!main.closed) {
+                main.close();
+                alert('<?php echo addslashes($straltpopup) ?>');
+                return false;
+            }
+        }
     -->  
     </script>
Index: /trunk/src/moodle/lang/en_utf8/scorm.php
===================================================================
--- /trunk/src/moodle/lang/en_utf8/scorm.php (revision original)
+++ /trunk/src/moodle/lang/en_utf8/scorm.php (revision proposal)
@@ -5,4 +5,5 @@
 $string['activation'] = 'Activation';
 $string['advanced'] = 'Parameters';
+$string['altpopup'] = 'Please close the course popup window before navigating away from here, thank you.';
 $string['asset'] = 'Asset';
 $string['assetlaunched'] = 'Asset - Viewed';
Show
Matteo Scaramuccia added a comment - A possible solution is to delay the browser "someway" in unloading the parent window, to let the content close its session correctly. It seems that the patch proposal below does the trick:
Index: /trunk/src/moodle/mod/scorm/player.php
===================================================================
--- /trunk/src/moodle/mod/scorm/player.php (revision original)
+++ /trunk/src/moodle/mod/scorm/player.php (revision proposal)
@@ -63,4 +63,5 @@
     $strscorms = get_string('modulenameplural', 'scorm');
     $strscorm  = get_string('modulename', 'scorm');
+    $straltpopup = get_string('altpopup', 'scorm');
     $strpopup = get_string('popup','scorm');
     $strexit = get_string('exitactivity','scorm');
@@ -147,5 +148,5 @@
     $bodyscript = '';
     if ($scorm->popup == 1) {
-        $bodyscript = 'onunload="main.close();"';
+        $bodyscript = 'onunload="closepopup();"';
     }
 
@@ -166,4 +167,13 @@
             scorm_resize(<?php echo $scorm->width.", ".$scorm->height; ?>);
         };
+        
+        function closepopup() {
+            // check if popup is still opened
+            if (!main.closed) {
+                main.close();
+                alert('<?php echo addslashes($straltpopup) ?>');
+                return false;
+            }
+        }
     -->  
     </script>
Index: /trunk/src/moodle/lang/en_utf8/scorm.php
===================================================================
--- /trunk/src/moodle/lang/en_utf8/scorm.php (revision original)
+++ /trunk/src/moodle/lang/en_utf8/scorm.php (revision proposal)
@@ -5,4 +5,5 @@
 $string['activation'] = 'Activation';
 $string['advanced'] = 'Parameters';
+$string['altpopup'] = 'Please close the course popup window before navigating away from here, thank you.';
 $string['asset'] = 'Asset';
 $string['assetlaunched'] = 'Asset - Viewed';
Hide
Dan Marsden added a comment -

I'm thinking about modifying the way the parent/child window works so that pop-up windows load the SCORM API rather than using the parent/child method - see attached bug for the plan.

Show
Dan Marsden added a comment - I'm thinking about modifying the way the parent/child window works so that pop-up windows load the SCORM API rather than using the parent/child method - see attached bug for the plan.
Hide
Dan Marsden added a comment -

this shouldn't be an issue in the 2.0 branches anymore - please see MDL-28295 for details - thanks!

Show
Dan Marsden added a comment - this shouldn't be an issue in the 2.0 branches anymore - please see MDL-28295 for details - thanks!

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: