// Includes #include "as_scripts/MLAB_flash_setvariables.as" //----------------------- // CLX SCORM Communicator Class // by Andy Haeberli // www.crealogix.com // Version 1.0 2005-11-07 // ---------------------- // //--------------------------- // CLX_scorm_communicator Constructor //--------------------------- CLX_scorm_communicator = function (objRef, communicationDebugMode) { // objRef ist eine Referenz zum CLX_Translator bzw. zum aufrufenden Object this.refTranslator = objRef; this.communicationDebugMode = communicationDebugMode; this.version = "v2005-11-09-001_clx"; // _root._ComStatus = "true"; // xtrace("setze ComStatus auf true") _root._ComResult; _root._ComError; _root._ComValue; // this._Value = new Array(); this._ValueID = 0; this._CommunicationTimer; this._MaxChar = 250; this._Command = new Array(); this._CommandID = 0; this.userData = new Object(); this.userData.student_id = "noValue"; this.userData.student_name = "noValue"; this.userData.lesson_location = "noValue"; this.userData.lesson_status = "noValue"; this.userData.score = "noValue"; this.userData.time = "noValue"; this.userData.suspend_data = "noValue"; }; //--------------------------- // CLX_scorm_communicator getVersion //--------------------------- CLX_scorm_communicator.prototype.getVersion = function() { return ("CLX SCORM Communicator Class Version: "+this.version); }; //--------------------------- // CLX_scorm_communicator init //--------------------------- CLX_scorm_communicator.prototype.init = function() { this._Command = new Array(); this._CommandID = 0; this.setCommand("LMSInitialize", "", "", ""); this.setCommand("Callback", "", "init", ""); this.startCommand(0); }; //--------------------------- // CLX_scorm_communicator connectionExit //--------------------------- CLX_scorm_communicator.prototype.connectionExit = function() { this._Command = new Array(); this._CommandID = 0; this.setCommand("LMSSetValue", "", "cmi.core.exit", "logout"); this.setCommand("LMSCommit", "", "", ""); this.setCommand("LMSFinish", "", "", ""); this.setCommand("Callback", "", "exit", ""); this.startCommand(0); }; //--------------------------- // CLX_scorm_communicator getUserData //--------------------------- CLX_scorm_communicator.prototype.getUserData = function() { this._Command = new Array(); this._CommandID = 0; this.setCommand("LMSGetValue", "student_id", "cmi.core.student_id", ""); this.setCommand("LMSGetValue", "student_name", "cmi.core.student_name", ""); this.setCommand("LMSGetValue", "lesson_location", "cmi.core.lesson_location", ""); this.setCommand("LMSGetValue", "lesson_status", "cmi.core.lesson_status", ""); this.setCommand("LMSGetValue", "score", "cmi.core.score.raw", ""); this.setCommand("LMSGetValue", "time", "cmi.core.total_time", ""); this.setCommand("LMSGetValue", "suspend_data", "cmi.suspend_data", ""); // this.setCommand("LMSCommit", "", "", ""); this.setCommand("Callback", "", "get", ""); this.startCommand(0); }; //--------------------------- // CLX_scorm_communicator setUserData //--------------------------- CLX_scorm_communicator.prototype.setUserData = function() { this._Command = new Array(); this._CommandID = 0; this.setCommand("LMSSetValue", "", "cmi.core.lesson_location", this.userData.lesson_location.toString()); this.setCommand("LMSSetValue", "", "cmi.core.lesson_status", this.userData.lesson_status.toString()); this.setCommand("LMSSetValue", "", "cmi.core.score.raw", this.userData.score.toString()); this.setCommand("LMSSetValue", "", "cmi.core.session_time", this.userData.time.toString()); this.setCommand("LMSSetValue", "", "cmi.suspend_data", this.userData.suspend_data.toString()); this.setCommand("LMSCommit", "", "", ""); this.setCommand("Callback", "", "set", ""); this.startCommand(0); }; //--------------------------- // CLX_scorm_communicator startCommand //--------------------------- CLX_scorm_communicator.prototype.startCommand = function(whichID) { this._CommandID = whichID; if (this.communicationDebugMode == true) { commtrace("Comand (Start): "+this._Command[this._CommandID].command+" / "+this._Command[this._CommandID].name+" / "+this._Command[this._CommandID].value); } switch (this._Command[this._CommandID].command) { case "LMSInitialize" : this.Initialize(); break; case "LMSFinish" : this.Finish(); break; case "LMSCommit" : this.Commit(); break; case "LMSGetValue" : this.GetValue(this._Command[this._CommandID].name); break; case "LMSSetValue" : this.SetValue(this._Command[this._CommandID].name, this._Command[this._CommandID].value); break; case "Callback" : this.Callback(this._Command[this._CommandID].name, 0); break; } }; //--------------------------- // CLX_scorm_communicator endCommand //--------------------------- CLX_scorm_communicator.prototype.endCommand = function() { if (this.getComStatus()) { if (this.communicationDebugMode == true) { commtrace("Comand (End): "+this._Command[this._CommandID].command+" / "+this.getComResult()+" / "+this.getComError()+" / "+this.getComValue()); } clearInterval(this._CommunicationTimer); switch (this._Command[this._CommandID].command) { case "LMSGetValue" : if (this.getComResult()) { this.userData[this._Command[this._CommandID].variable] = this.getComValue(); this.startCommand(this._CommandID+1); } else { this.Callback(this._Command[this._Command.length-1].name, this.getComResult()); } break; default : if (this.getComResult()) { this.startCommand(this._CommandID+1); } else { this.Callback(this._Command[this._Command.length-1].name, this.getComError()); } } } }; //--------------------------- // CLX_scorm_communicator Callback //--------------------------- CLX_scorm_communicator.prototype.Callback = function(whichName, whichValue) { switch (whichName) { case "init" : this.refTranslator.initCallback(whichValue); break; case "exit" : this.refTranslator.connectionExitCallback(0); break; case "get" : this.refTranslator.getUserDataCallback(whichValue); break; case "set" : this.refTranslator.setUserDataCallback(whichValue); break; } }; // //=========================== // SCORM Functions //=========================== // //--------------------------- // CLX_scorm_communicator Initialize //--------------------------- CLX_scorm_communicator.prototype.Initialize = function() { this.JSLMSInitialize(); }; //--------------------------- // CLX_scorm_communicator JSLMSInitialize //--------------------------- CLX_scorm_communicator.prototype.JSLMSInitialize = function() { this.setComStatus(false); getURL("javascript:JSLMSInitialize();"); this._CommunicationTimer = setInterval(this, "endCommand", 50); }; // //=========================== // //--------------------------- // CLX_scorm_communicator Finish //--------------------------- CLX_scorm_communicator.prototype.Finish = function() { this.JSLMSFinish(); }; CLX_scorm_communicator.prototype.JSLMSFinish = function() { this.setComStatus(false); getURL("javascript:JSLMSFinish();"); this._CommunicationTimer = setInterval(this, "endCommand", 50); }; // //=========================== // //--------------------------- // CLX_scorm_communicator Commit //--------------------------- CLX_scorm_communicator.prototype.Commit = function() { this.JSLMSCommit(); }; CLX_scorm_communicator.prototype.JSLMSCommit = function() { this.setComStatus(false); getURL("javascript:JSLMSCommit();"); this._CommunicationTimer = setInterval(this, "endCommand", 50); }; // //=========================== // //--------------------------- // CLX_scorm_communicator GetValue //--------------------------- CLX_scorm_communicator.prototype.GetValue = function(whichName) { this.JSLMSGetValue(whichName); }; //--------------------------- // CLX_scorm_communicator JSLMSGetValue //--------------------------- CLX_scorm_communicator.prototype.JSLMSGetValue = function(whichName) { this.setComStatus(false); getURL("javascript:JSLMSGetValue('"+whichName+"');"); this._CommunicationTimer = setInterval(this, "endCommand", 50); }; // //=========================== // //--------------------------- // CLX_scorm_communicator SetValue //--------------------------- CLX_scorm_communicator.prototype.SetValue = function(whichName, whichValue) { this._Value = new Array(); var tCountIndex = Math.ceil(whichValue.length/this._MaxChar); for (i=0; i