Step 55 – Delaying Loading of the SCO

In the past, I’ve had some intermittent problems with a SCO loading but showing a Javascript error. Although I couldn’t pin it down conclusively, it seemed to result from an incomplete download of some kind. Since forcing a reload with CTRL-R or CTRL-F5 usually solved the problem, I just put it down to something that I had to live with because SCORM forces us to use Javascript which can be very fickle.

But, recently, reader ‘deighvan’ reported a similar problem and, even better, came up with a simple solution. So I’ve incorporated a slightly modified form of this solution in a new version of the rte.php file.

Here it is:

<?php 

/*

VS SCORM 1.2 RTE - rte.php
Rev XXXXXXXXXXX was 2009-11-30-01
Copyright (C) 2010, Addison Robson LLC

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

*/

// read SCOInstanceID from the GET parameters
$SCOInstanceID = $_GET['SCOInstanceID'] * 1;

?>
<html>
<head>
  <title>VS SCORM</title>
  <script language="javascript">

    var started = false;

    function loadSCO() {
      if (! started) {
        SCO.location.href = '... location of the SCO ...';
      }
      started = true;
    }

    function unloadSCO() {
      setTimeout('API.LMSFinish("");',2000);
    }

  </script>
</head>
<frameset frameborder="0" framespacing="0" border="0" rows="50,*" cols="*" onbeforeunload="unloadSCO();" onunload="unloadSCO();">
  <frame src="api.php?SCOInstanceID=<?php print $SCOInstanceID; ?>" name="API" id="API" noresize onload="loadSCO();">
  <frame src="blank.html" name="SCO" id="SCO">
</frameset>
</html>

And here are the changes … line-by-line:

  • Line 35 – I define a Javascript variable called ‘started’ and set it to false. This will be used to prevent the SCO being started twice.
     
  • Lines 37 to 42 – I’ve added a new Javascript function that, when called, will load the SCO into the ‘SCO’ frame.
     
  • Line 51 – I’ve added an ‘onload’ action. When the api.php code has completely loaded into the frame, this will call loadSCO() which will start the SCO.
     
  • Line 52 – When the frameset starts, I’m going to load a blank document into the ‘SCO’ frame. Why not just start with an empty frame (i.e. src=”)? Because, if I’m going to be running over an SSL connection, Internet Explorer considers an empty frame to be an insecure document and will pop up a warning message that’s annoying, and also worrying to many students.
     

So I try it out, and it seems to work much more smoothly than before. Once again, thanks to reader ‘deighvan’ for the suggestion.

Be Sociable, Share!
This entry was posted in Run Time Environment. Bookmark the permalink.

4 Responses to Step 55 – Delaying Loading of the SCO

  1. Steve Addison says:

    Even better, replace ‘blank.html’ with an HTML file that displays a “Loading … Please Wait” message!

  2. deighvan says:

    Good call! Doing that now…

  3. Good stuff Steve, just stumbled across your site. I’ve been working on LMSs for almost 10 years, and SCORM quirks certainly trip us up a lot. A nice project you have here – any progress since the summer?

    Tony

  4. Steve Addison says:

    Just starting up again – moving on to errors codes and logging, and a test harness to make it easier to diagnose SCO/LMS communication problems. A new post should be out later today to start things rolling.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>