#include "as_scripts/clx_MORPHX.as" // ****************************** // CLX_xml_communicator Class // // @author: Andy Häberli // @version: 1.0 / 23.12.2005 // ****************************** // // // ------------------------------ // CLX_xml_communicator: Constructor // // @param: objRef -> Referenz zum aufrufenden Objekt // communicationDebugMode -> Debug Modus // ------------------------------ CLX_xml_communicator = function (objRef, communicationDebugMode) { // objRef ist eine Referenz zum CLX_Translator bzw. zum aufrufenden Object this.refTranslator = objRef; this.communicationDebugMode = communicationDebugMode; this.version = "v2005-12-23-001_clx"; this.comVersion = '1.1'; }; //--------------------------- // CLX_xml_communicator getVersion //--------------------------- CLX_xml_communicator.prototype.getVersion = function() { return ("CLX XML Communicator Class Version: "+this.version); }; //--------------------------- // CLX_xml_communicator init //--------------------------- CLX_xml_communicator.prototype.init = function() { // Help: Schnittstelle if (this.communicationDebugMode == true) { commtrace("Schnittstelle XML gefunden"); } // URL aus FlashVars this.url = unescape(_root.url); // this.xml_session_id = ""; this.xml_version = 1.0; this.xml_url = ""; this.parseURL(); this.xmlData = new CLX_MORPHX(); this.userData = new Object(); this.userData.error = "noValue"; this.userData.error_text = "noValue"; 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.core_lesson = "noValue"; if (this.xml_session_id == 0 || this.xml_url == 0) { // Help: Parameter aus URL if (this.communicationDebugMode == true) { commtrace("Keine oder nicht alle URL-Parameter geparst"); } this.refTranslator.initCallback(1); } else { // Help: Parameter aus URL if (this.communicationDebugMode == true) { commtrace("URL-Parameter geparst"); } this.refTranslator.initCallback(0); } }; //--------------------------- // CLX_xml_communicator parseURL //--------------------------- CLX_xml_communicator.prototype.parseURL = function() { var tURL_array = this.url.split("?"); var tParam_array = tURL_array[1].split("&"); for (var i = 0; i'; xmlstr += ''+this.xml_version+''; xmlstr += ''; this.communication_xml = new XML(xmlstr); this.communication_xml.contentType = "text/xml"; this.communication_xml.objRef = this; this.communication_xml.sendAndLoad(this.xml_url, this.communication_xml); this.communication_xml.onData = this.userDataLoaded; // Help: Get-XML-Ausgabe (Aufbau und Inhalt) if (this.communicationDebugMode == true) { commtrace("Folgendes XML an das LMS gesendet:"); commtrace(xmlstr); } }; //--------------------------- // CLX_xml_communicator setUserData //--------------------------- CLX_xml_communicator.prototype.setUserData = function() { var xmlstr = ''; xmlstr += ''; xmlstr += ''; xmlstr += 'LMSSetValues'; xmlstr += ''+this.xml_session_id+''; xmlstr += ''+this.xml_version+''; xmlstr += ''; xmlstr += ''; xmlstr += ''+this.userData.lesson_location+''; xmlstr += ''+this.userData.lesson_status+''; xmlstr += ''+this.userData.time+''; xmlstr += ''; xmlstr += ''+this.userData.score+''; xmlstr += ''; xmlstr += ''+this.userData.attempt+''; xmlstr += ''; xmlstr += ''+escape(this.userData.core_lesson)+''; xmlstr += ''; xmlstr += ''; this.communication_xml = new XML(xmlstr); this.communication_xml.contentType = "text/xml"; this.communication_xml.objRef = this; this.communication_xml.sendAndLoad(this.xml_url, this.communication_xml); this.communication_xml.onData = this.userDataLoaded; // Help: Set-XML-Ausgabe (Aufbau und Inhalt) if (this.communicationDebugMode == true) { commtrace("Folgendes XML an das LMS gesendet:"); commtrace(xmlstr); } }; //--------------------------- // CLX_xml_communicator exitUserData //--------------------------- CLX_xml_communicator.prototype.connectionExit = function() { this.refTranslator.connectionExitCallback(0); }; //--------------------------- // CLX_xml_communicator userDataLoaded //--------------------------- CLX_xml_communicator.prototype.userDataLoaded = function(result) { if (result != "") { // Help: Result-Ausgabe if (this.objRef.communicationDebugMode == true) { commtrace("Folgende Daten vom LMS erhalten:"); commtrace(result); } this.objRef.xmlData.objRef = this.objRef; this.objRef.xmlData.onLoad = function() { this.objRef.parseUserData(); }; this.objRef.xmlData.xmlLoadString(result); } else { // Help: Fehler-Ausgabe if (this.objRef.communicationDebugMode == true) { commtrace("Ladevorgang fehlerhaft"); } this.objRef.refTranslator.errorCallback(); } }; //--------------------------- // CLX_xml_communicator parseUserData //--------------------------- CLX_xml_communicator.prototype.parseUserData = function() { // error if (this.xmlData.structure.clx[0].error[0]._value != undefined) { this.userData.error = this.xmlData.structure.clx[0].error[0]._value; } // error_text if (this.xmlData.structure.clx[0].error_text[0]._value != undefined) { this.userData.error_text = this.xmlData.structure.clx[0].error_text[0]._value; } // studend_id if (this.xmlData.structure.clx[0].cmi[0].core[0].student_id[0]._value != undefined) { this.userData.student_id = this.xmlData.structure.clx[0].cmi[0].core[0].student_id[0]._value; } // student_name if (this.xmlData.structure.clx[0].cmi[0].core[0].student_name[0]._value != undefined) { this.userData.student_name = this.xmlData.structure.clx[0].cmi[0].core[0].student_name[0]._value; } // lesson_location if (this.xmlData.structure.clx[0].cmi[0].core[0].lesson_location[0]._value != undefined) { this.userData.lesson_location = this.xmlData.structure.clx[0].cmi[0].core[0].lesson_location[0]._value; } // lesson_status if (this.xmlData.structure.clx[0].cmi[0].core[0].lesson_status[0]._value != undefined) { this.userData.lesson_status = this.xmlData.structure.clx[0].cmi[0].core[0].lesson_status[0]._value; } // attempt if (this.xmlData.structure.clx[0].cmi[0].student_data[0].attempt_number[0]._value != undefined) { this.userData.attempt = this.xmlData.structure.clx[0].cmi[0].student_data[0].attempt_number[0]._value; } // score if (this.xmlData.structure.clx[0].cmi[0].core[0].score[0].raw[0]._value != undefined) { this.userData.score = this.xmlData.structure.clx[0].cmi[0].core[0].score[0].raw[0]._value; } // time if (this.xmlData.structure.clx[0].cmi[0].core[0].total_time[0]._value != undefined) { this.userData.time = this.xmlData.structure.clx[0].cmi[0].core[0].total_time[0]._value; } // core_lesson if (this.xmlData.structure.clx[0].cmi[0].suspend_data[0]._value != undefined) { this.userData.core_lesson = unescape(this.xmlData.structure.clx[0].cmi[0].suspend_data[0]._value); } // Help: Get-Parameter-Ausgabe if (this.communicationDebugMode == true) { commtrace("Folgende Daten vom LMS geparst:"); commtrace("Error: "+this.userData.error); commtrace("Errortext: "+this.userData.error_text); commtrace("Student-ID: "+this.userData.student_id); commtrace("Student Name: "+this.userData.student_name); commtrace("Lesson Location: "+this.userData.lesson_location); commtrace("Lesson Status: "+this.userData.lesson_status); commtrace("Attempt: "+this.userData.attempt); commtrace("Score: "+this.userData.score); commtrace("Time: "+this.userData.time); commtrace("Core Lesson: "+this.userData.core_lesson); } // if (this.xmlData.structure.clx[0].command[0]._value == "LMSGetValues") { this.refTranslator.getUserDataCallback(this.userData.error); } else if (this.xmlData.structure.clx[0].command[0]._value == "LMSSetValues") { this.refTranslator.setUserDataCallback(this.userData.error); } else { this.refTranslator.errorCallback(); } }; // //--------------------------- // CLX_xml_communicator getError //--------------------------- CLX_xml_communicator.prototype.getError = function() { return this.userData.error; }; //--------------------------- // CLX_xml_communicator getError_text //--------------------------- CLX_xml_communicator.prototype.getError_text = function() { return this.userData.error_text; }; //--------------------------- // CLX_xml_communicator getStudent_id //--------------------------- CLX_xml_communicator.prototype.getStudent_id = function() { return this.userData.student_id; }; //--------------------------- // CLX_xml_communicator getStudent_name //--------------------------- CLX_xml_communicator.prototype.getStudent_name = function() { return this.userData.student_name; }; //--------------------------- // CLX_xml_communicator setLesson_location //--------------------------- CLX_xml_communicator.prototype.setLesson_location = function(whichValue) { this.userData.lesson_location = whichValue; }; //--------------------------- // CLX_xml_communicator getLesson_location //--------------------------- CLX_xml_communicator.prototype.getLesson_location = function() { return this.userData.lesson_location; }; //--------------------------- // CLX_xml_communicator setLesson_status //--------------------------- CLX_xml_communicator.prototype.setLesson_status = function(whichValue) { this.userData.lesson_status = whichValue; }; //--------------------------- // CLX_xml_communicator getLesson_status //--------------------------- CLX_xml_communicator.prototype.getLesson_status = function() { return this.userData.lesson_status; }; //--------------------------- // CLX_xml_communicator setAttempt //--------------------------- CLX_xml_communicator.prototype.setAttempt = function(whichValue) { this.userData.attempt = whichValue; }; //--------------------------- // CLX_xml_communicator getAttempt //--------------------------- CLX_xml_communicator.prototype.getAttempt = function() { return this.userData.attempt; }; //--------------------------- // CLX_xml_communicator setScore //--------------------------- CLX_xml_communicator.prototype.setScore = function(whichValue) { this.userData.score = whichValue; }; //--------------------------- // CLX_xml_communicator getScore //--------------------------- CLX_xml_communicator.prototype.getScore = function() { return this.userData.score; }; //--------------------------- // CLX_xml_communicator setTime //--------------------------- CLX_xml_communicator.prototype.setTime = function(whichValue) { this.userData.time = whichValue; }; //--------------------------- // CLX_xml_communicator getTime //--------------------------- CLX_xml_communicator.prototype.getTime = function() { return this.userData.time; }; //--------------------------- // CLX_xml_communicator setLesson_data //--------------------------- CLX_xml_communicator.prototype.setLesson_data = function(whichValue) { this.userData.core_lesson = whichValue; }; //--------------------------- // CLX_xml_communicator getCore_lesson //--------------------------- CLX_xml_communicator.prototype.getLesson_data = function() { return this.userData.core_lesson; }; this.communicator = new CLX_xml_communicator(this, false); this.communicator.init();