How to use SCORM API to retrieve data?

1.2k views Asked by At

I am developing a simple LMS for medical trainees. So far i have developed a PHP LMS. For the content i have prepared a SCORM course with quizzes created with Articulate Storyline software. To communicate with SCORM and to retrieve quiz result i tried to implement SCORM API.

this is my Run time environment file

<html>
<head>

<title>VS SCORM - RTE Frameset</title>
<!-- Rev 1.0 - Sunday, May 31, 2009 -->

</head>
<frameset 
  frameborder="0" framespacing="0" 
  border="0" rows="0,*" cols="*" >
    <frame src="api.html" name="API" noresize></frame>
    <frame src="/packadge/JStest/story.html" name="course"></frame>
</frameset>
</html>

this is the api.html

<html>
<head>

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

<script language="javascript">

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>

but I don't see these functions are being triggered at the initiation of the SCORM project.

how to get Quiz result and alert it? (my idea is if I can do so, I will be able to send that results via ajax post to the sever)

1

There are 1 answers

0
John On

In order for any course to find the API you need to declare window.API and the API itself contains all those LMSxxxxxxx() functions.

For example:

var SCORM = {}; // Create blank object

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

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

// repeat for other LMSxxxxx() functions then assign to window.API

window.API = SCORM;