Unity-SCORM Integration Kit  1.0
Integrate Unity3d Projects with your LMS via SCORM
Classes | Public Member Functions | Public Attributes | List of all members
ScormAPIWrapper Class Reference

Scorm API wrapper. Forms the 'Bridge' between the Unity3D code and the scorm.js code that communicates with teh LMS. More...

Classes

class  APICallResult
 This holds the values of the result of the SCORM API Callback from scorm.js More...
 

Public Member Functions

 ScormAPIWrapper (string obj, string callback)
 Initializes a new instance of the ScormAPIWrapper class. More...
 
void Initialize ()
 Start up the SCORM API Wrapper. More...
 
void SetCallbackValue (string input)
 Add a response to a javascript call to the queue. More...
 
string GetValue (string identifier)
 Get a value from the javascript API More...
 
bool SetValue (string identifier, string value)
 Set a value on the javascript API More...
 
void Commit ()
 Call the commit function in the javascript layer More...
 
void Terminate ()
 Call the terminate function in the javascript layer More...
 
void Log (string text)
 Send a log command up to the parent GameObject. The actual implementation of the Log function is up to your own code. More...
 

Public Attributes

bool IsScorm2004
 Allows interoperability bewteen SCORM 2004 and 1.2 (Not yet implemented) More...
 

Detailed Description

Scorm API wrapper. Forms the 'Bridge' between the Unity3D code and the scorm.js code that communicates with teh LMS.

In order for Unity3D to communicate with the LMS, it needs to do so via the scorm.js code located in the HTML that 'wraps' the Unity3D webplayer. Unity allows us to run extrenal calls to the enclosing HTML wrapper via UnityEngine.Application.ExternalCall(). In turn, the HTML wrapper can call Unity3D function via GetUnity().SendMessage(). However, this kind of communication is asynchronous, which makes it difficult to get return values from a call to the HTML wrapper back into the calling Unity3D function. (E.g. if you call a GetValue() to the LMS via scorm.js, how do you get the result?

This ScormAPI wrapper class allows calls to scorm.js appear to be synchronous by doing the following:

  1. When sending a call to scorm.js in the HTML wrapper, you give it the following information: a. The CallbackObjectName - the name of the Unity3D object that the 'reply' to the call should be sent. This is set in the ScormManager class as the ScormManager object. b. The CallbackFunctionName - the name of the function in the ScormManager (CallbackObjectName) that responds to the the 'reply' from teh HTML wrapper. c. The key - a unique key that identifies the function that sent the call.
  2. The HTML wrapper (scorm.js) processes the call, and then sends the result to Unity3D (the callback function in ScormManager as defined by the CallbackObjectName and CallbackFunctionName). It also send the key back, which allows the ScormManager Callback Function to assign the return result back to the correct calling function.

Constructor & Destructor Documentation

ScormAPIWrapper.ScormAPIWrapper ( string  obj,
string  callback 
)

Initializes a new instance of the ScormAPIWrapper class.

Parameters
objCallback object name.
callbackCallback function name.

Member Function Documentation

void ScormAPIWrapper.Commit ( )

Call the commit function in the javascript layer

string ScormAPIWrapper.GetValue ( string  identifier)

Get a value from the javascript API

Implements the interface to the SCORM API, and looks syncronous to the caller. TODO: (This is where you would implement the 2004/1.2 conversion)

Returns
A string of the return value of the get command
Parameters
identifierThe dot notation identifier of the data model element to get
void ScormAPIWrapper.Initialize ( )

Start up the SCORM API Wrapper.

This will check with the Javascript layer to see if it's executing in a 1.2 or 2004 LMS

void ScormAPIWrapper.Log ( string  text)

Send a log command up to the parent GameObject. The actual implementation of the Log function is up to your own code.

Parameters
textthe text to log
void ScormAPIWrapper.SetCallbackValue ( string  input)

Add a response to a javascript call to the queue.

The ScormManager will add messages from the javascript layer to the queue, which will be processed by the other thread.

bool ScormAPIWrapper.SetValue ( string  identifier,
string  value 
)

Set a value on the javascript API

Implements the interface to the SCORM API, and looks syncronous to the caller.

Returns
Bool return value of the set command
Parameters
identifierThe dot notation identifier of the data model element to set.
valueValue to set
void ScormAPIWrapper.Terminate ( )

Call the terminate function in the javascript layer

Member Data Documentation

bool ScormAPIWrapper.IsScorm2004

Allows interoperability bewteen SCORM 2004 and 1.2 (Not yet implemented)


The documentation for this class was generated from the following file: