//----------------------- // CLX AICC Communicator Class // by Caspar Noetzli / Andy Haeberli // www.crealogix.com // vs. 0.2 2004-09-28 // ---------------------- // //--------------------------- // CLX_aicc_communicator Constructor //--------------------------- CLX_aicc_communicator = function (objRef, communicationDebugMode) { // objRef ist eine Referenz zum CLX_Translator bzw. zum aufrufenden Object this.refTranslator = objRef; this.communicationDebugMode = communicationDebugMode; this.version = "v2004-03-04-001_clx"; }; //--------------------------- // CLX_aicc_communicator getVersion //--------------------------- CLX_aicc_communicator.prototype.getVersion = function() { return ("CLX AICC Communicator Class Version: "+this.version); }; //--------------------------- // CLX_aicc_communicator init //--------------------------- CLX_aicc_communicator.prototype.init = function() { // Help: Schnittstelle if (this.communicationDebugMode == true) { commtrace("Schnittstelle AICC gefunden"); } // URL aus FlashVars this.url = unescape(_root.url); commtrace("Diese URL wurde empfangen: "+this.url) // this.aicc_session_id = 0; this.aicc_version = 3.5; // wird vom LMS nicht geliefert (CMI Guidelines for AICC Rev. 3.5) this.aicc_catcher_uri = 0; this.parseURL(); 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.aicc_session_id == 0 || this.aicc_catcher_uri == 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_aicc_communicator parseURL //--------------------------- CLX_aicc_communicator.prototype.parseURL = function() { var tURL_array = this.url.split("?"); var tParam_array = tURL_array[1].split("&"); for (var i = 0; i < tParam_array.length; i++ ) { var tProp_array = tParam_array[i].split('='); if (tProp_array[0].toLowerCase() == 'aicc_sid' ) { this.aicc_session_id = tProp_array[1]; } if (tProp_array[0].toLowerCase() == 'aicc_url' ) { this.aicc_catcher_uri = tProp_array[1]; } } if (this.communicationDebugMode == true) { commtrace("AICC Session ID: "+this.aicc_session_id); commtrace("AICC Catcher URI: "+this.aicc_catcher_uri); commtrace("AICC Version: "+this.aicc_version); } }; //--------------------------- // CLX_aicc_communicator getUserData //--------------------------- CLX_aicc_communicator.prototype.getUserData = function() { /* // Alte Version requestUrl = this.aicc_catcher_uri; requestUrl += "?command=GetParam&version="+this.aicc_version+"&session_id="+this.aicc_session_id+"&AICC_Data="; loadVariablesNum(requestUrl, 0, "POST"); */ // ev. Reihenfolge wechseln this.communication_lv = new LoadVars(); this.communication_lv.refObj = this; // ev Probleme mit anderen LMS (TopClass) this.communication_lv.command = "GetParam"; this.communication_lv.version = this.aicc_version; this.communication_lv.session_id = this.aicc_session_id; this.communication_lv.AICC_Data = ""; this.communication_lv.onLoad = this.dataLoaded; this.communication_lv.sendAndLoad(this.aicc_catcher_uri, this.communication_lv, "Post"); // Help: Get-String-Ausgabe (Aufbau und Inhalt) if (this.communicationDebugMode == true) { commtrace("Folgender PutString (GetParam) an das LMS gesendet:") commtrace (unescape(this.communication_lv.toString())); } }; //--------------------------- // CLX_aicc_communicator setUserData //--------------------------- CLX_aicc_communicator.prototype.setUserData = function() { /* // Alte Version requestUrl = this.aicc_catcher_uri; requestUrl += "?command=GetParam&version="+this.aicc_version+"&session_id="+this.aicc_session_id+"&AICC_Data="; requestUrl += "%5BCore%5D"+"%0D%0A"+"Lesson_Location"+"%3D"+escape(this.userData.lesson_location)+"%0D%0A"+"Lesson_Status"+"%3D"+escape(this.userData.lesson_status)+"%0D%0A"+"Score"+"%3D"+escape(this.userData.score)+"%0D%0A"+"Time"+"%3D"+escape(this.userData.time); requestUrl += "%0D%0A"+"%5BCore_Lesson%5D"+"%0D%0A"+escape(this.userData.core_lesson); loadVariablesNum(requestUrl, 0, "POST"); */ // AICC_Data formatieren -> ev. Probleme mit der URL-kodierung var AICC_Data_str = "[core]\r\n"; AICC_Data_str += "lesson_location="+this.userData.lesson_location+"\r\n"; AICC_Data_str += "lesson_status="+this.userData.lesson_status+"\r\n"; AICC_Data_str += "score="+this.userData.score+"\r\n"; AICC_Data_str += "time="+this.userData.time+"\r\n"; AICC_Data_str += "[core_lesson]\r\n"; AICC_Data_str += this.userData.core_lesson; // // ev. Reihenfolge wechseln this.communication_lv = new LoadVars(); this.communication_lv.refObj = this; // ev Probleme mit anderen LMS (TopClass) this.communication_lv.command = "PutParam"; this.communication_lv.version = this.aicc_version; this.communication_lv.session_id = this.aicc_session_id; this.communication_lv.AICC_Data = AICC_Data_str; this.communication_lv.onLoad = this.dataLoaded; this.communication_lv.sendAndLoad(this.aicc_catcher_uri, this.communication_lv, "Post"); // Help: Get-String-Ausgabe (Aufbau und Inhalt) if (this.communicationDebugMode == true) { commtrace("An folgende URL wurden die Daten geschickt:") commtrace(this.aicc_catcher_uri) commtrace("Folgender PutString (PutParam) an das LMS gesendet:") commtrace (unescape(this.communication_lv.toString())); } }; //--------------------------- // CLX_aicc_communicator exitUserData //--------------------------- CLX_aicc_communicator.prototype.connectionExit = function() { /* // Alte Version requestUrl = this.aicc_catcher_uri; requestUrl += "?command=ExitAU&version="+this.aicc_version+"&session_id="+this.aicc_session_id+"&AICC_Data="; loadVariablesNum(requestUrl, 0, "POST"); */ // ev. Reihenfolge wechseln this.communication_lv = new LoadVars(); this.communication_lv.refObj = this; // ev Probleme mit anderen LMS (TopClass) this.communication_lv.command = "ExitAU"; this.communication_lv.version = this.aicc_version; this.communication_lv.session_id = this.aicc_session_id; this.communication_lv.AICC_Data = ""; this.communication_lv.onLoad = this.dataLoaded; this.communication_lv.sendAndLoad(this.aicc_catcher_uri, this.communication_lv, "Post"); // Help: Get-String-Ausgabe (Aufbau und Inhalt) if (this.communicationDebugMode == true) { commtrace("Folgender PutString (ExitAU) an das LMS gesendet:") commtrace (unescape(this.communication_lv.toString())); } }; //--------------------------- // CLX_aicc_communicator dataLoaded //--------------------------- CLX_aicc_communicator.prototype.dataLoaded = function(ok) { if(ok) { var result = "error="+this.error; // Help: Result-Ausgabe if (this.refObj.communicationDebugMode == true) { commtrace("Folgende Daten vom LMS erhalten:") commtrace (result); } // this.refObj.parseUserData(result); } else { // Help: Fehler-Ausgabe if (this.refObj.communicationDebugMode == true) { commtrace("Ladevorgang fehlerhaft"); } if (this.command == "GetParam") { this.refObj.refTranslator.getUserDataCallback(1); } else if (this.command == "PutParam") { this.refObj.refTranslator.setUserDataCallback(1); } else if (this.command == "ExitAU") { this.refObj.refTranslator.connectionExitCallback(1); } } }; //--------------------------- // CLX_aicc_communicator parseUserData //--------------------------- CLX_aicc_communicator.prototype.parseUserData = function(result) { // String vom LMS wird ev. codiert übermittelt -> Probleme mit dem Parsen var tResult = unescape(result); var tResult_array = tResult.split("\n"); for (i=0; i Probleme mit dem XML-parsen // Workaround: String wird am Anfang und Ende gekürzt var tStart = this.userData.core_lesson.indexOf(""); if (tStart > -1) { this.userData.core_lesson = this.userData.core_lesson.slice(tStart); commtrace("Core_Lesson: Start -> "+tStart+". Zeichen"); } var tEnd = this.userData.core_lesson.indexOf(""); if (tEnd > -1) { this.userData.core_lessont = this.userData.core_lesson.slice(0, tEnd+15); commtrace("Core_Lesson: Ende -> "+tEnd+15+". Zeichen"); } } else { var tResultRow_array = tResult_array[i].split("="); // error if (tResultRow_array[0].toLowerCase() == "error") { this.userData.error = tResultRow_array[1]; } // error_text if (tResultRow_array[0].toLowerCase() == "error_text") { this.userData.error_text = tResultRow_array[1]; } // studend_id if (tResultRow_array[0].toLowerCase() == "student_id") { this.userData.student_id = tResultRow_array[1]; } // student_name if (tResultRow_array[0].toLowerCase() == "student_name") { this.userData.student_name = tResultRow_array[1]; } // lesson_location if (tResultRow_array[0].toLowerCase() == "lesson_location") { this.userData.lesson_location = tResultRow_array[1]; } // lesson_status if (tResultRow_array[0].toLowerCase() == "lesson_status") { if(tResultRow_array[1] == "notattempted") { this.userData.lesson_status = "not attempted"; } else { this.userData.lesson_status = tResultRow_array[1]; } } // score if (tResultRow_array[0].toLowerCase() == "score") { this.userData.score = tResultRow_array[1]; } // time if (tResultRow_array[0].toLowerCase() == "time") { this.userData.time = tResultRow_array[1]; } } } // 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("Score: "+this.userData.score); commtrace("Time: "+this.userData.time); commtrace("Core Lesson: "+this.userData.core_lesson); } // if (this.communication_lv.command == "GetParam") { this.refTranslator.getUserDataCallback(this.userData.error); } else if (this.communication_lv.command == "PutParam") { this.refTranslator.setUserDataCallback(this.userData.error); } else if (this.communication_lv.command == "ExitAU") { this.refTranslator.connectionExitCallback(this.userData.error); } }; // //--------------------------- // CLX_aicc_communicator getError //--------------------------- CLX_aicc_communicator.prototype.getError = function() { return this.userData.error; }; //--------------------------- // CLX_aicc_communicator getError_text //--------------------------- CLX_aicc_communicator.prototype.getError_text = function() { return this.userData.error_text; }; //--------------------------- // CLX_aicc_communicator getStudent_id //--------------------------- CLX_aicc_communicator.prototype.getStudent_id = function() { return this.userData.student_id; }; //--------------------------- // CLX_aicc_communicator getStudent_name //--------------------------- CLX_aicc_communicator.prototype.getStudent_name = function() { return this.userData.student_name; }; //--------------------------- // CLX_aicc_communicator setLesson_location //--------------------------- CLX_aicc_communicator.prototype.setLesson_location = function(whichValue) { this.userData.lesson_location = whichValue; }; //--------------------------- // CLX_aicc_communicator getLesson_location //--------------------------- CLX_aicc_communicator.prototype.getLesson_location = function() { return this.userData.lesson_location; }; //--------------------------- // CLX_aicc_communicator setLesson_status //--------------------------- CLX_aicc_communicator.prototype.setLesson_status = function(whichValue) { this.userData.lesson_status = whichValue; }; //--------------------------- // CLX_aicc_communicator getLesson_status //--------------------------- CLX_aicc_communicator.prototype.getLesson_status = function() { return this.userData.lesson_status; }; //--------------------------- // CLX_aicc_communicator setScore //--------------------------- CLX_aicc_communicator.prototype.setScore = function(whichValue) { this.userData.score = whichValue; }; //--------------------------- // CLX_aicc_communicator getScore //--------------------------- CLX_aicc_communicator.prototype.getScore = function() { return this.userData.score; }; //--------------------------- // CLX_aicc_communicator setTime //--------------------------- CLX_aicc_communicator.prototype.setTime = function(whichValue) { this.userData.time = whichValue; }; //--------------------------- // CLX_aicc_communicator getTime //--------------------------- CLX_aicc_communicator.prototype.getTime = function() { return this.userData.time; }; //--------------------------- // CLX_aicc_communicator setLesson_data //--------------------------- CLX_aicc_communicator.prototype.setLesson_data = function(whichValue) { this.userData.core_lesson = whichValue; }; //--------------------------- // CLX_aicc_communicator getCore_lesson //--------------------------- CLX_aicc_communicator.prototype.getLesson_data = function() { return this.userData.core_lesson; };