home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 December
/
CMCD1203.ISO
/
Software
/
Shareware
/
Programare
/
toolkit
/
toolkitsetup.msi
/
Instal01.cab
/
_2DEA2F0175F14C6FB1A920254BD135C1
< prev
next >
Wrap
Text File
|
2003-08-21
|
5KB
|
181 lines
var apiHandle = null;
var _NoError = 0, _GeneralException = 101, _ServerBusy = 102, _InvalidArgumentError = 201, _CannotHaveChildren = 202, _NotAnArray = 203, _NotInitialized = 301, _NotImplementedError = 401, _InvalidSetTime = 402, _ReadOnly = 403, _WriteOnly = 404, _IncorrectDataType = 405;
//Function: LMSInitialize()
// Inputs: None
// Return: true if the initialization was successful
// false if the initialization failed
function LMSInitialize()
{
var api = getAPIHandle();
if(api == null)
{
alert("Unable to locate the LMS's API Implementation.\nLMSInitialize was not successful.");
return false;
}
var initResult = api.LMSInitialize("");
initResult = ConvertTF(initResult);
if(initResult != true)
alert("LMSInitialize was not successful.");
return initResult;
}
//Function LMSFinish()
// Inputs: None
// Return: None
function LMSFinish()
{
var api = getAPIHandle();
if(api == null)
alert("Unable to locate the LMS's API Implementation.\nLMSFinish was not successful.");
else
api.LMSFinish("");
return;
}
//Function LMSSetValue(theName, theValue)
// Inputs: theName - string representing the cmi data model element
// theValue - the value that the named element or category will be assigned
// Return: None
function LMSSetValue(theName, theValue)
{
var api = getAPIHandle();
if(api != null)
{
if(theName == "cmi.core.score")
theName = "cmi.core.score.raw";
api.LMSSetValue(theName, theValue);
}
return;
}
//Function LMSGetValue(theName)
// Inputs: theName - string representing the cmi data model defined category or element
// Return: Empty String
function LMSGetValue(theName)
{
return "";
}
//Function LMSCommit()
// Inputs: None
// Return: None
function LMSCommit()
{
var api = getAPIHandle();
if(api != null)
api.LMSCommit("");
return;
}
//Function LMSGetLastError()
// Inputs: None
// Return: The error code (integer format) that was set by the last LMS function call
function LMSGetLastError()
{
var api = getAPIHandle();
if(api == null)
return _GeneralException.toString();
return api.LMSGetLastError().toString();
}
//Function LMSGetErrorString(errorCode)
// Inputs: errorCode - Error Code(integer format)
// Return: The textual description that corresponds to the input error code
function LMSGetErrorString(errorCode)
{
var api = getAPIHandle();
return api.LMSGetErrorString(errorCode).toString();
}
//Function LMSGetDiagnostic(errorCode)
// Inputs: errorCode - Error Code(integer format), or null
// Return: The vendor specific textual description that corresponds to the input error code
function LMSGetDiagnostic(errorCode)
{
var api = getAPIHandle();
return api.LMSGetDiagnostic(errorCode).toString();
}
//Function ConvertTF()
// Inputs: a string or other data type representing a boolean value
// Return: a boolean value
function ConvertTF(booleanToken)
{
booleanStr = booleanToken.toString();
switch(booleanStr)
{
case "1":
case "true":
realBoolean = true;
break;
case "false":
case "0":
default:
realBoolean = false;
break;
}
return realBoolean;
}
//Function getAPIHandle()
// Inputs: None
// Return: value contained by APIHandle
function getAPIHandle()
{
if(apiHandle == null)
apiHandle = getAPI();
return apiHandle;
}
//Function findAPI(win)
// Inputs: win - a Window Object
// Return: If an API object is found, it is returned, otherwise null is returned
function findAPI(win)
{
if(win.API != null)
return win.API;
if(win.length > 0)
{
for(var i=0; i<win.length; i++)
{
var theAPI = findAPI(win.frames[i]);
if(theAPI != null)
return theAPI;
}
}
return null;
}
//Function getAPI()
// Inputs: none
// Return: If an API object is found, it is returned, otherwise null is returned
function getAPI()
{
var theAPI = findAPI(this.top);
if(theAPI == null)
if(typeof(this.top.opener) != "undefined")
if(this.top.opener != null)
theAPI = findAPI(this.top.opener.top);
return theAPI;
}
//Function LMSIsInitialized()
// Inputs: none
// Return: true if the LMS API is currently initialized, otherwise false
function LMSIsInitialized()
{
var api = getAPIHandle();
var theReturn = false;
if(api == null)
{
alert("Unable to locate the LMS's API Implementation.\nLMSIsInitialized() failed.");
}else{
var value = api.LMSGetValue("cmi.core.student_name");
var errCode = api.LMSGetLastError().toString();
if(errCode != _NotInitialized)
theReturn = true;
}
return theReturn;
}