Step 2 – Adding the API Functions

OK – I’ve got the basic frameset in place, so I now need to create the HTML page that will hold the SCORM RTE API calls. Just to remind you, there are 8 JavaScript functions that the LMS must provide so that the course can communicate with it.

This is pretty easy – I’ll create the HTML file called api.html as I’ve defined it in the RTE frameset. Then I’ll add the following code:

<html>
<head>

<title>VS SCORM - RTE API</title>

<script language="javascript">

/*

VS SCORM - RTE API FOR SCORM 1.2 
Rev 1.0 - Sunday, May 31, 2009
Copyright (C) 2009, 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.

*/

var debug = true;

// ------------------------------------------
//   SCORM RTE Functions - Initialization
// ------------------------------------------
function LMSInitialize(dummyString) { 
  if (debug) { alert('*** LMSInitialize ***'); }
  return "true";
}

// ------------------------------------------
//   SCORM RTE Functions - Getting and Setting Values
// ------------------------------------------
function LMSGetValue(varname) {
  if (debug) { 
    alert('*** LMSGetValue varname='+varname
                          +' varvalue=value ***');
  }
  return "value";
}

function LMSSetValue(varname,varvalue) {
  if (debug) { 
    alert('*** LMSSetValue varname='+varname
                          +' varvalue='+varvalue+' ***');
  }
  return "true";
}

function LMSCommit(dummyString) {
  if (debug) { alert('*** LMSCommit ***'); }
  return "true";
}

// ------------------------------------------
//   SCORM RTE Functions - Closing The Session
// ------------------------------------------
function LMSFinish(dummyString) {
  if (debug) { alert('*** LMSFinish ***'); }
  return "true";
}

// ------------------------------------------
//   SCORM RTE Functions - Error Handling
// ------------------------------------------
function LMSGetLastError() {
  if (debug) { alert('*** LMSGetLastError ***'); }
  return 0;
}

function LMSGetDiagnostic(errorCode) {
  if (debug) { 
    alert('*** LMSGetDiagnostic errorCode='+errorCode+' ***');
  }
  return "diagnostic string";
}

function LMSGetErrorString(errorCode) {
  if (debug) { 
    alert('*** LMSGetErrorString errorCode='+errorCode+' ***'); 
  }
  return "error string";
}

</script>

</head>
<body>

<p> 

</body>
</html>

In this file, I’m defining 8 (almost) empty JavaScript functions that can be called by the course. The only things that are included in the functions are a debugging/monitoring statement that will create a JavaScript alert each time the course calls that particular function, and a statement that returns a value that’s consistent with the SCORM 1.2 RTE specification.

Now that I’ve got my API calls in place, I’m going to look for a sample SCORM course, and run some initial tests.

This entry was posted in Run Time Environment. Bookmark the permalink.

1 Response to Step 2 – Adding the API Functions

  1. Abhi says:

    Hello,
    LMSFinish() is not getting called. We are calling some web-services in this function in later steps.
    What is the issue?
    LMSCommit() is the last function which is calling.
    Thanks for this excellent post!
    Waiting for response…
    Abhi

Leave a Reply

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