// create the Mathdox.LMS namespace, if it doesn't already exist var Mathdox; if (!Mathdox) { Mathdox = {} } if (!Mathdox.LMS) { Mathdox.LMS = { // store all values in the 'values' attribute values : { userid : "", username : "", exerciseid : "", date : "", time : "", status : "", masteryscore : "", totaltime : "", score : "" }, // set an LMS value setValue : function(name, value) { this.values[name] = value }, // retrieve a previously set LMS value getValue : function(name) { return this.values[name] }, // submit the LMS values to the server submit : function() { // create an xml document containing the LMS values var xml = "<lms>" for (var x in this.values) { xml += "<" + x + ">" + this.getValue(x) + "</" + x + ">" } xml += "</lms>" // get an XMLHttpRequest object var request; try { request = new XMLHttpRequest() } catch(exception) { request = new ActiveXObject("Msxml2.XMLHTTP") } // open synchronous request to /mathdox-lms-submission url var url = "" request.open("POST", url, false) // send XML document containing the LMS values request.setRequestHeader("Content-Type","text/xml") request.send(xml) } } }