//Dummy SCORM 2004 Run-Time Environment
//Copyright Intrallect Ltd 2005

//create SCORM 2004 RTE API Object 
// (must be called "API_1484_11")
var API_1484_11 = new scorm2004API();


// ********** objects and methods ********* //

      function scorm2004API()
      {
      this.checkState = true;
      objScorm2004API = this;

      this.cmiData=new Hashtable();

      }

      scorm2004API.prototype.Initialize = function (parameter) {

	// using sensible defaults for properties in the CMI Data Model

	// Former Core fields 
	objScorm2004API.cmiData.put("cmi.completion_status","incomplete");
	objScorm2004API.cmiData.put("cmi.credit","no-credit");
	objScorm2004API.cmiData.put("cmi.entry","");
	objScorm2004API.cmiData.put("cmi.learner_id","urn:intrallect://user0");
	objScorm2004API.cmiData.put("cmi.learner_name","Unknown User");
	objScorm2004API.cmiData.put("cmi.location","");
	objScorm2004API.cmiData.put("cmi.mode","browse");
	objScorm2004API.cmiData.put("cmi.score._children","raw");
	objScorm2004API.cmiData.put("cmi.score.raw","");
	objScorm2004API.cmiData.put("cmi.success_status","unknown");
	objScorm2004API.cmiData.put("cmi.total_time","PT0H0M0S"); // should accumulate

	// Data fields
	objScorm2004API.cmiData.put("cmi.launch_data",""); // should get from "adlcp:datafromlms"
	objScorm2004API.cmiData.put("cmi.suspend_data",""); // should store for user

	// Objectives
	objScorm2004API.cmiData.put("cmi.objectives._count","0");
	
	//Former Student Data
	objScorm2004API.cmiData.put("cmi.scaled_passing_score","");
	objScorm2004API.cmiData.put("cmi.max_time_allowed","");

	//Learner Preferences
	objScorm2004API.cmiData.put("cmi.learner_preference.delivery_speed","1");

	//Interactions
	objScorm2004API.cmiData.put("cmi.interactions._count","0");

	//New top level elements
	objScorm2004API.cmiData.put("cmi._version","1.0"); // should be read-only

        return "true";
      }

      scorm2004API.prototype.GetValue = function (element) {
	//just get the value (if any) stored in the hash table
	var value=objScorm2004API.cmiData.get(element);
	value=value+''; // cast value object to string
	return value;
      }

      scorm2004API.prototype.SetValue = function (element, value) {
	//just set the value in the hash table
	objScorm2004API.cmiData.put(element,value);
        return "true";
      }

      scorm2004API.prototype.Commit = function (parameter) {
        return true;
      }

      scorm2004API.prototype.Terminate = function (parameter) {
        return "true";
      }

      scorm2004API.prototype.GetLastError = function () {
        return "0";
      }

      scorm2004API.prototype.GetErrorString = function (errorCode) {
        return "No error";
      }

      scorm2004API.prototype.GetDiagnostic = function (errorCode) {
        return "IntraLibrary includes only a dummy implementation of the SCORM 2004 Run-Time Environment";
      }


