From 874d3d48c4fd1e167730f251d99a2ade5197e75b Mon Sep 17 00:00:00 2001 From: tom creighton Date: Thu, 28 Jan 2016 13:30:57 -0500 Subject: [PATCH] Release v1.9.0 --- dist/xapiwrapper.min.js | 4 ++-- doc/index.html | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/xapiwrapper.min.js b/dist/xapiwrapper.min.js index 7f0a6c1..46f8812 100644 --- a/dist/xapiwrapper.min.js +++ b/dist/xapiwrapper.min.js @@ -1,2 +1,2 @@ -/*! xAPIWrapper v 1.7.0 | Built on 2016-01-08 12:53:55-0500 */ -function toBase64(a){return CryptoJS&&CryptoJS.enc.Base64?CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a)):Base64.encode(a)}function toSHA1(a){return CryptoJS&&CryptoJS.SHA1?CryptoJS.SHA1(a).toString():Crypto.util.bytesToHex(Crypto.SHA1(a,{asBytes:!0}))}function isDate(a){if("[object Date]"===Object.prototype.toString.call(a))var b=a;else var b=new Date(a);return"[object Date]"===Object.prototype.toString.call(b)?isNaN(b.valueOf())?(ADL.XAPIWrapper.log("Invalid date String passed"),null):b:(ADL.XAPIWrapper.log("Invalid date object"),null)}var CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=d.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;return b&&c.mixIn(b),c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)}),c.init.prototype=c,c.$super=this,c},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),f=d.WordArray=e.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,e=a.sigBytes;if(this.clamp(),d%4)for(var f=0;e>f;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=(g.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,c=this._map,d=c.charAt(64);if(d){var e=a.indexOf(d);-1!=e&&(b=e)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=c.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return f.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0})),l=d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}}),m=c.algo={},n=[],o=m.SHA1=l.extend({_doReset:function(){this._hash=new f.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=0;80>i;i++){if(16>i)n[i]=0|a[b+i];else{var j=n[i-3]^n[i-8]^n[i-14]^n[i-16];n[i]=j<<1|j>>>31}var k=(d<<5|d>>>27)+h+n[i];k+=20>i?(e&f|~e&g)+1518500249:40>i?(e^f^g)+1859775393:60>i?(e&f|e&g|f&g)-1894007588:(e^f^g)-899497514,h=g,g=f,f=e<<30|e>>>2,e=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|0,c[4]=c[4]+h|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=l.clone.call(this);return a._hash=this._hash.clone(),a}});return c.SHA1=l._createHelper(o),c.HmacSHA1=l._createHmacHelper(o),c}(Math);!function(a){a.verbs={abandoned:{id:"http://purl.org/xapi/adl/verbs/abandoned",display:{"en-US":"abandoned"}},answered:{id:"http://adlnet.gov/expapi/verbs/answered",display:{"de-DE":"beantwortete","en-US":"answered","fr-FR":"a répondu","es-ES":"contestó"}},asked:{id:"http://adlnet.gov/expapi/verbs/asked",display:{"de-DE":"fragte","en-US":"asked","fr-FR":"a demandé","es-ES":"preguntó"}},attempted:{id:"http://adlnet.gov/expapi/verbs/attempted",display:{"de-DE":"versuchte","en-US":"attempted","fr-FR":"a essayé","es-ES":"intentó"}},attended:{id:"http://adlnet.gov/expapi/verbs/attended",display:{"de-DE":"nahm teil an","en-US":"attended","fr-FR":"a suivi","es-ES":"asistió"}},commented:{id:"http://adlnet.gov/expapi/verbs/commented",display:{"de-DE":"kommentierte","en-US":"commented","fr-FR":"a commenté","es-ES":"comentó"}},completed:{id:"http://adlnet.gov/expapi/verbs/completed",display:{"de-DE":"beendete","en-US":"completed","fr-FR":"a terminé","es-ES":"completó"}},exited:{id:"http://adlnet.gov/expapi/verbs/exited",display:{"de-DE":"verließ","en-US":"exited","fr-FR":"a quitté","es-ES":"salió"}},experienced:{id:"http://adlnet.gov/expapi/verbs/experienced",display:{"de-DE":"erlebte","en-US":"experienced","fr-FR":"a éprouvé","es-ES":"experimentó"}},failed:{id:"http://adlnet.gov/expapi/verbs/failed",display:{"de-DE":"verfehlte","en-US":"failed","fr-FR":"a échoué","es-ES":"fracasó"}},imported:{id:"http://adlnet.gov/expapi/verbs/imported",display:{"de-DE":"importierte","en-US":"imported","fr-FR":"a importé","es-ES":"importó"}},initialized:{id:"http://adlnet.gov/expapi/verbs/initialized",display:{"de-DE":"initialisierte","en-US":"initialized","fr-FR":"a initialisé","es-ES":"inicializó"}},interacted:{id:"http://adlnet.gov/expapi/verbs/interacted",display:{"de-DE":"interagierte","en-US":"interacted","fr-FR":"a interagi","es-ES":"interactuó"}},launched:{id:"http://adlnet.gov/expapi/verbs/launched",display:{"de-DE":"startete","en-US":"launched","fr-FR":"a lancé","es-ES":"lanzó"}},mastered:{id:"http://adlnet.gov/expapi/verbs/mastered",display:{"de-DE":"meisterte","en-US":"mastered","fr-FR":"a maîtrisé","es-ES":"dominó"}},passed:{id:"http://adlnet.gov/expapi/verbs/passed",display:{"de-DE":"bestand","en-US":"passed","fr-FR":"a réussi","es-ES":"aprobó"}},preferred:{id:"http://adlnet.gov/expapi/verbs/preferred",display:{"de-DE":"bevorzugte","en-US":"preferred","fr-FR":"a préféré","es-ES":"prefirió"}},progressed:{id:"http://adlnet.gov/expapi/verbs/progressed",display:{"de-DE":"machte Fortschritt mit","en-US":"progressed","fr-FR":"a progressé","es-ES":"progresó"}},registered:{id:"http://adlnet.gov/expapi/verbs/registered",display:{"de-DE":"registrierte","en-US":"registered","fr-FR":"a enregistré","es-ES":"registró"}},responded:{id:"http://adlnet.gov/expapi/verbs/responded",display:{"de-DE":"reagierte","en-US":"responded","fr-FR":"a répondu","es-ES":"respondió"}},resumed:{id:"http://adlnet.gov/expapi/verbs/resumed",display:{"de-DE":"setzte fort","en-US":"resumed","fr-FR":"a repris","es-ES":"continuó"}},satisfied:{id:"http://purl.org/xapi/adl/verbs/satisfied",display:{"en-US":"satisfied"}},scored:{id:"http://adlnet.gov/expapi/verbs/scored",display:{"de-DE":"erreichte","en-US":"scored","fr-FR":"a marqué","es-ES":"anotó"}},shared:{id:"http://adlnet.gov/expapi/verbs/shared",display:{"de-DE":"teilte","en-US":"shared","fr-FR":"a partagé","es-ES":"compartió"}},suspended:{id:"http://adlnet.gov/expapi/verbs/suspended",display:{"de-DE":"pausierte","en-US":"suspended","fr-FR":"a suspendu","es-ES":"aplazó"}},terminated:{id:"http://adlnet.gov/expapi/verbs/terminated",display:{"de-DE":"beendete","en-US":"terminated","fr-FR":"a terminé","es-ES":"terminó"}},voided:{id:"http://adlnet.gov/expapi/verbs/voided",display:{"de-DE":"entwertete","en-US":"voided","fr-FR":"a annulé","es-ES":"anuló"}},waived:{id:"http://purl.org/xapi/adl/verbs/waived",display:{"en-US":"waived"}}}}(window.ADL=window.ADL||{}),Date.prototype.toISOString||!function(){function a(a){var b=String(a);return 1===b.length&&(b="0"+b),b}Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}}(),function(a){function b(){try{return void 0!=this.lrs.endpoint&&""!=this.lrs.endpoint}catch(a){return!1}}function c(a){if(!c.debug)return!1;try{return console.log(a),!0}catch(b){return!1}}function d(a,b){for(var e in b){prop=b[e],c(e+" : "+prop);try{b[e].constructor==Object?a[e]=d(a[e],b[e]):(void 0==a&&(a=new Object),a[e]=b[e])}catch(f){void 0==a&&(a=new Object),a[e]=b[e]}}return a}function e(a){var b,c,e=["endpoint","auth","actor","registration","activity_id","grouping","activity_platform"],g=new Object;if(b=f(),void 0!==b&&0!==Object.keys(b).length){for(var h=0;h0&&(f.push(e.substr(g+1)),e=e.substr(0,g)),e=e+"?method="+a,null!==c)for(var h in c)f.push(h+"="+encodeURIComponent(c[h]));return null!==d&&f.push("content="+encodeURIComponent(d)),{method:"POST",url:e,headers:{},data:f.join("&")}}c.debug=!1;var i=function(){var a={};a.endpoint="http://localhost:8000/xapi/";try{a.auth="Basic "+toBase64("tom:1234")}catch(b){c("Exception in Config trying to encode auth: "+b)}return a}();XAPIWrapper=function(c,f){function g(b){var c=document.createElement("a");return c.href=b,c.protocol&&c.host?c.protocol+"//"+c.host:void a.XAPIWrapper.log("Couldn't create base url from endpoint: "+this.lrs.endpoint)}function h(a,b,c){a.auth="Basic "+toBase64(b+":"+c)}this.lrs=e(c||{}),this.lrs.user&&this.lrs.password&&h(this.lrs,this.lrs.user,this.lrs.password),this.base=g(this.lrs.endpoint),f&&b.call(this)&&window.ADL.XHR_request(this.lrs,this.lrs.endpoint+"about","GET",null,null,function(b){if(200==b.status)try{var c=JSON.parse(b.response),d=!1;for(var e in c.version)if(c.version[e]==a.XAPIWrapper.xapiVersion){d=!0;break}d||a.XAPIWrapper.log("The lrs version ["+c.version+"] does not match this wrapper's XAPI version ["+a.XAPIWrapper.xapiVersion+"]")}catch(f){a.XAPIWrapper.log("The response was not an about object")}else a.XAPIWrapper.log("The request to get information about the LRS failed: "+b)}),this.searchParams=function(){var a={format:"exact"};return a},this.hash=function(b){if(!b)return null;try{return toSHA1(b)}catch(c){return a.XAPIWrapper.log("Error trying to hash -- "+c),null}},this.changeConfig=function(b){try{a.XAPIWrapper.log("updating lrs object with new configuration"),this.lrs=d(this.lrs,b),b.user&&b.password&&this.updateAuth(this.lrs,b.user,b.password),this.base=g(this.lrs.endpoint)}catch(c){a.XAPIWrapper.log("error while changing configuration -- "+c)}},this.updateAuth=h},XAPIWrapper.prototype.xapiVersion="1.0.1",XAPIWrapper.prototype.prepareStatement=function(a){void 0===a.actor?a.actor=JSON.parse(this.lrs.actor):"string"==typeof a.actor&&(a.actor=JSON.parse(a.actor)),(this.lrs.grouping||this.lrs.registration||this.lrs.activity_platform)&&(a.context||(a.context={})),this.lrs.grouping&&(a.context.contextActivities||(a.context.contextActivities={}),a.context.contextActivities.grouping=[{id:this.lrs.grouping}]),this.lrs.registration&&(a.context.registration=this.lrs.registration),this.lrs.activity_platform&&(a.context.platform=this.lrs.activity_platform)},XAPIWrapper.prototype.testConfig=b,XAPIWrapper.prototype.log=c,XAPIWrapper.prototype.sendStatement=function(b,c){if(this.testConfig()){this.prepareStatement(b);var d;b.id?d=b.id:(d=a.ruuid(),b.id=d);var e=a.XHR_request(this.lrs,this.lrs.endpoint+"statements","POST",JSON.stringify(b),this.lrs.auth,c,{id:d});if(!c)return{xhr:e,id:d}}},XAPIWrapper.prototype.sendStatements=function(b,c){if(this.testConfig()){for(var d in b)this.prepareStatement(b[d]);var e=a.XHR_request(this.lrs,this.lrs.endpoint+"statements","POST",JSON.stringify(b),this.lrs.auth,c);if(!c)return e}},XAPIWrapper.prototype.getStatements=function(b,c,d){if(this.testConfig()){var e=this.lrs.endpoint+"statements";if(c)e=this.base+c;else{var f=new Array;for(s in b)if("until"==s||"since"==s){var g=new Date(b[s]);f.push(s+"="+encodeURIComponent(g.toISOString()))}else f.push(s+"="+encodeURIComponent(b[s]));f.length>0&&(e=e+"?"+f.join("&"))}var h=a.XHR_request(this.lrs,e,"GET",null,this.lrs.auth,d);if(void 0===h||404==h.status)return null;try{return JSON.parse(h.response)}catch(i){return h.response}}},XAPIWrapper.prototype.getActivities=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"activities?activityId=";d=d.replace("",encodeURIComponent(b));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},XAPIWrapper.prototype.sendState=function(b,d,e,f,g,h,i,j){if(this.testConfig()){var k=this.lrs.endpoint+"activities/state?activityId=&agent=&stateId=";k=k.replace("",encodeURIComponent(b)),k=k.replace("",encodeURIComponent(JSON.stringify(d))),k=k.replace("",encodeURIComponent(e)),f&&(k+="®istration="+encodeURIComponent(f));var l=null;h&&i?c("Can't have both If-Match and If-None-Match"):h?l={"If-Match":'"'+h+'"'}:i&&(l={"If-None-Match":'"'+i+'"'});var m="PUT";if(!g)return this.log("No activity state was included."),!1;g instanceof Array?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json"):g instanceof Object?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json",m="POST"):(l=l||{},l["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,k,m,g,this.lrs.auth,j,null,null,l)}},XAPIWrapper.prototype.getState=function(b,c,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"activities/state?activityId=&agent=";h=h.replace("",encodeURIComponent(b)),h=h.replace("",encodeURIComponent(JSON.stringify(c))),d&&(h+="&stateId="+encodeURIComponent(d)),e&&(h+="®istration="+encodeURIComponent(e)),f&&(f=isDate(f),null!=f&&(h+="&since="+encodeURIComponent(f.toISOString())));var i=a.XHR_request(this.lrs,h,"GET",null,this.lrs.auth,g,null,!0);if(void 0===i||404==i.status)return null;try{return JSON.parse(i.response)}catch(j){return i.response}}},XAPIWrapper.prototype.deleteState=function(b,d,e,f,g,h,i){if(this.testConfig()){var j=this.lrs.endpoint+"activities/state?activityId=&agent=&stateId=";j=j.replace("",encodeURIComponent(b)),j=j.replace("",encodeURIComponent(JSON.stringify(d))),j=j.replace("",encodeURIComponent(e)),f&&(j+="®istration="+encodeURIComponent(f));var k=null;g&&h?c("Can't have both If-Match and If-None-Match"):g?k={"If-Match":'"'+g+'"'}:h&&(k={"If-None-Match":'"'+h+'"'});var l=a.XHR_request(this.lrs,j,"DELETE",null,this.lrs.auth,i,null,k);if(void 0===l||404==l.status)return null;try{return JSON.parse(l.response)}catch(m){return l}}},XAPIWrapper.prototype.sendActivityProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"activities/profile?activityId=&profileId=";i=i.replace("",encodeURIComponent(b)),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":'"'+f+'"'}:g&&(j={"If-None-Match":'"'+g+'"'});var k="PUT";if(!e)return this.log("No activity profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j)}},XAPIWrapper.prototype.getActivityProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"activities/profile?activityId=";f=f.replace("",encodeURIComponent(b)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(d=isDate(d),null!=d&&(f+="&since="+encodeURIComponent(d.toISOString())));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},XAPIWrapper.prototype.deleteActivityProfile=function(b,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"activities/profile?activityId=&profileId=";h=h.replace("",encodeURIComponent(b)),h=h.replace("",encodeURIComponent(d));var i=null;e&&f?c("Can't have both If-Match and If-None-Match"):e?i={"If-Match":'"'+e+'"'}:f&&(i={"If-None-Match":'"'+f+'"'});var j=a.XHR_request(this.lrs,h,"DELETE",null,this.lrs.auth,g,null,i);if(void 0===j||404==j.status)return null;try{return JSON.parse(j.response)}catch(k){return j}}},XAPIWrapper.prototype.getAgents=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"agents?agent=";d=d.replace("",encodeURIComponent(JSON.stringify(b)));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},XAPIWrapper.prototype.sendAgentProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"agents/profile?agent=&profileId=";i=i.replace("",encodeURIComponent(JSON.stringify(b))),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":'"'+f+'"'}:g&&(j={"If-None-Match":'"'+g+'"'});var k="PUT";if(!e)return this.log("No agent profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j)}},XAPIWrapper.prototype.getAgentProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"agents/profile?agent=";f=f.replace("",encodeURIComponent(JSON.stringify(b))),f=f.replace("",encodeURIComponent(c)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(d=isDate(d),null!=d&&(f+="&since="+encodeURIComponent(d.toISOString())));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},XAPIWrapper.prototype.deleteAgentProfile=function(b,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"agents/profile?agent=&profileId=";h=h.replace("",encodeURIComponent(JSON.stringify(b))),h=h.replace("",encodeURIComponent(d));var i=null;e&&f?c("Can't have both If-Match and If-None-Match"):e?i={"If-Match":'"'+e+'"'}:f&&(i={"If-None-Match":'"'+f+'"'});var j=a.XHR_request(this.lrs,h,"DELETE",null,this.lrs.auth,g,null,i);if(void 0===j||404==j.status)return null;try{return JSON.parse(j.response)}catch(k){return j}}},a.ruuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},a.dateFromISOString=function(a){var b="([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T| ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?",c=a.match(new RegExp(b)),d=0,e=new Date(c[1],0,1);c[3]&&e.setMonth(c[3]-1),c[5]&&e.setDate(c[5]),c[7]&&e.setHours(c[7]),c[8]&&e.setMinutes(c[8]),c[10]&&e.setSeconds(c[10]),c[12]&&e.setMilliseconds(1e3*Number("0."+c[12])),c[14]&&(d=60*Number(c[16])+Number(c[17]),d*="-"==c[15]?1:-1),d-=e.getTimezoneOffset(),time=Number(e)+60*d*1e3;var f=new Date;return f.setTime(Number(time)),f},a.XHR_request=function(b,c,d,e,f,i,j,k,l){"use strict";function m(){if(s)return q;s=!0;var b=k&&404===n.status;if(!(void 0===n.status||n.status>=200&&n.status<400||b)){var e;try{e="There was a problem communicating with the Learning Record Store. ( "+n.status+" | "+n.response+" )"+c}catch(f){e=f.toString()}return a.XAPIWrapper.log(e),a.xhrRequestOnError(n,d,c,i,j),q=n,n}if(!i)return q=n,n;if(j)i(n,j);else try{var g=JSON.parse(n.responseText);i(n,g)}catch(h){i(n,n.responseText)}}var n,o,p,q,r,s=!1,t=!1,u=!1,v=c.toLowerCase().match(/^(.+):\/\/([^:\/]*):?(\d+)?(\/.*)?$/),w=window.location,x={};if(x["Content-Type"]="application/json",x.Authorization=f,x["X-Experience-API-Version"]=a.XAPIWrapper.xapiVersion,null!==l)for(var y in l)x[y]=l[y];t=w.protocol.toLowerCase()!==v[1]||w.hostname.toLowerCase()!==v[2],t||(p=null===v[3]?"http"===v[1]?"80":"443":v[3],t=p===w.port);var z=window.XDomainRequest&&window.XMLHttpRequest&&void 0===(new XMLHttpRequest).responseType;if(t&&void 0!==z&&z!==!1)u=!0,o=h(d,c,x,e),n=new XDomainRequest,n.open(o.method,o.url);else{n=new XMLHttpRequest,n.open(d,c,null!=i);for(var y in x)n.setRequestHeader(y,x[y])}if(n.onreadystatechange=function(){return 4===n.readyState?m():void 0},n.onload=m,n.onerror=m,n.send(u?o.data:e),!i){if(u)for(r=1e3+new Date;new Datef;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=(g.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,c=this._map,d=c.charAt(64);if(d){var e=a.indexOf(d);-1!=e&&(b=e)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=c.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return f.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0})),l=d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}}),m=c.algo={},n=[],o=m.SHA1=l.extend({_doReset:function(){this._hash=new f.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=0;80>i;i++){if(16>i)n[i]=0|a[b+i];else{var j=n[i-3]^n[i-8]^n[i-14]^n[i-16];n[i]=j<<1|j>>>31}var k=(d<<5|d>>>27)+h+n[i];k+=20>i?(e&f|~e&g)+1518500249:40>i?(e^f^g)+1859775393:60>i?(e&f|e&g|f&g)-1894007588:(e^f^g)-899497514,h=g,g=f,f=e<<30|e>>>2,e=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|0,c[4]=c[4]+h|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=l.clone.call(this);return a._hash=this._hash.clone(),a}});return c.SHA1=l._createHelper(o),c.HmacSHA1=l._createHmacHelper(o),c}(Math);!function(a){a.verbs={abandoned:{id:"http://purl.org/xapi/adl/verbs/abandoned",display:{"en-US":"abandoned"}},answered:{id:"http://adlnet.gov/expapi/verbs/answered",display:{"de-DE":"beantwortete","en-US":"answered","fr-FR":"a répondu","es-ES":"contestó"}},asked:{id:"http://adlnet.gov/expapi/verbs/asked",display:{"de-DE":"fragte","en-US":"asked","fr-FR":"a demandé","es-ES":"preguntó"}},attempted:{id:"http://adlnet.gov/expapi/verbs/attempted",display:{"de-DE":"versuchte","en-US":"attempted","fr-FR":"a essayé","es-ES":"intentó"}},attended:{id:"http://adlnet.gov/expapi/verbs/attended",display:{"de-DE":"nahm teil an","en-US":"attended","fr-FR":"a suivi","es-ES":"asistió"}},commented:{id:"http://adlnet.gov/expapi/verbs/commented",display:{"de-DE":"kommentierte","en-US":"commented","fr-FR":"a commenté","es-ES":"comentó"}},completed:{id:"http://adlnet.gov/expapi/verbs/completed",display:{"de-DE":"beendete","en-US":"completed","fr-FR":"a terminé","es-ES":"completó"}},exited:{id:"http://adlnet.gov/expapi/verbs/exited",display:{"de-DE":"verließ","en-US":"exited","fr-FR":"a quitté","es-ES":"salió"}},experienced:{id:"http://adlnet.gov/expapi/verbs/experienced",display:{"de-DE":"erlebte","en-US":"experienced","fr-FR":"a éprouvé","es-ES":"experimentó"}},failed:{id:"http://adlnet.gov/expapi/verbs/failed",display:{"de-DE":"verfehlte","en-US":"failed","fr-FR":"a échoué","es-ES":"fracasó"}},imported:{id:"http://adlnet.gov/expapi/verbs/imported",display:{"de-DE":"importierte","en-US":"imported","fr-FR":"a importé","es-ES":"importó"}},initialized:{id:"http://adlnet.gov/expapi/verbs/initialized",display:{"de-DE":"initialisierte","en-US":"initialized","fr-FR":"a initialisé","es-ES":"inicializó"}},interacted:{id:"http://adlnet.gov/expapi/verbs/interacted",display:{"de-DE":"interagierte","en-US":"interacted","fr-FR":"a interagi","es-ES":"interactuó"}},launched:{id:"http://adlnet.gov/expapi/verbs/launched",display:{"de-DE":"startete","en-US":"launched","fr-FR":"a lancé","es-ES":"lanzó"}},mastered:{id:"http://adlnet.gov/expapi/verbs/mastered",display:{"de-DE":"meisterte","en-US":"mastered","fr-FR":"a maîtrisé","es-ES":"dominó"}},passed:{id:"http://adlnet.gov/expapi/verbs/passed",display:{"de-DE":"bestand","en-US":"passed","fr-FR":"a réussi","es-ES":"aprobó"}},preferred:{id:"http://adlnet.gov/expapi/verbs/preferred",display:{"de-DE":"bevorzugte","en-US":"preferred","fr-FR":"a préféré","es-ES":"prefirió"}},progressed:{id:"http://adlnet.gov/expapi/verbs/progressed",display:{"de-DE":"machte Fortschritt mit","en-US":"progressed","fr-FR":"a progressé","es-ES":"progresó"}},registered:{id:"http://adlnet.gov/expapi/verbs/registered",display:{"de-DE":"registrierte","en-US":"registered","fr-FR":"a enregistré","es-ES":"registró"}},responded:{id:"http://adlnet.gov/expapi/verbs/responded",display:{"de-DE":"reagierte","en-US":"responded","fr-FR":"a répondu","es-ES":"respondió"}},resumed:{id:"http://adlnet.gov/expapi/verbs/resumed",display:{"de-DE":"setzte fort","en-US":"resumed","fr-FR":"a repris","es-ES":"continuó"}},satisfied:{id:"http://purl.org/xapi/adl/verbs/satisfied",display:{"en-US":"satisfied"}},scored:{id:"http://adlnet.gov/expapi/verbs/scored",display:{"de-DE":"erreichte","en-US":"scored","fr-FR":"a marqué","es-ES":"anotó"}},shared:{id:"http://adlnet.gov/expapi/verbs/shared",display:{"de-DE":"teilte","en-US":"shared","fr-FR":"a partagé","es-ES":"compartió"}},suspended:{id:"http://adlnet.gov/expapi/verbs/suspended",display:{"de-DE":"pausierte","en-US":"suspended","fr-FR":"a suspendu","es-ES":"aplazó"}},terminated:{id:"http://adlnet.gov/expapi/verbs/terminated",display:{"de-DE":"beendete","en-US":"terminated","fr-FR":"a terminé","es-ES":"terminó"}},voided:{id:"http://adlnet.gov/expapi/verbs/voided",display:{"de-DE":"entwertete","en-US":"voided","fr-FR":"a annulé","es-ES":"anuló"}},waived:{id:"http://purl.org/xapi/adl/verbs/waived",display:{"en-US":"waived"}}}}(window.ADL=window.ADL||{}),Date.prototype.toISOString||!function(){function a(a){var b=String(a);return 1===b.length&&(b="0"+b),b}Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}}(),function(a){function b(){try{return void 0!=this.lrs.endpoint&&""!=this.lrs.endpoint}catch(a){return!1}}function c(a){if(!c.debug)return!1;try{return console.log(a),!0}catch(b){return!1}}function d(a,b){for(var e in b){prop=b[e],c(e+" : "+prop);try{b[e].constructor==Object?a[e]=d(a[e],b[e]):(void 0==a&&(a=new Object),a[e]=b[e])}catch(f){void 0==a&&(a=new Object),a[e]=b[e]}}return a}function e(a){var b,c,e=["endpoint","auth","actor","registration","activity_id","grouping","activity_platform"],g=new Object;if(b=f(),void 0!==b&&0!==Object.keys(b).length){for(var h=0;h0&&(f.push(e.substr(g+1)),e=e.substr(0,g)),e=e+"?method="+a,null!==c)for(var h in c)f.push(h+"="+encodeURIComponent(c[h]));return null!==d&&f.push("content="+encodeURIComponent(d)),{method:"POST",url:e,headers:{},data:f.join("&")}}c.debug=!1;var i=function(){var a={};a.endpoint="http://localhost:8000/xapi/";try{a.auth="Basic "+toBase64("tom:1234")}catch(b){c("Exception in Config trying to encode auth: "+b)}return a}();XAPIWrapper=function(c,f){function g(b){var c=document.createElement("a");return c.href=b,c.protocol&&c.host?c.protocol+"//"+c.host:void a.XAPIWrapper.log("Couldn't create base url from endpoint: "+this.lrs.endpoint)}function h(a,b,c){a.auth="Basic "+toBase64(b+":"+c)}this.lrs=e(c||{}),this.lrs.user&&this.lrs.password&&h(this.lrs,this.lrs.user,this.lrs.password),this.base=g(this.lrs.endpoint),f&&b.call(this)&&window.ADL.XHR_request(this.lrs,this.lrs.endpoint+"about","GET",null,null,function(b){if(200==b.status)try{var c=JSON.parse(b.response),d=!1;for(var e in c.version)if(c.version[e]==a.XAPIWrapper.xapiVersion){d=!0;break}d||a.XAPIWrapper.log("The lrs version ["+c.version+"] does not match this wrapper's XAPI version ["+a.XAPIWrapper.xapiVersion+"]")}catch(f){a.XAPIWrapper.log("The response was not an about object")}else a.XAPIWrapper.log("The request to get information about the LRS failed: "+b)}),this.searchParams=function(){var a={format:"exact"};return a},this.hash=function(b){if(!b)return null;try{return toSHA1(b)}catch(c){return a.XAPIWrapper.log("Error trying to hash -- "+c),null}},this.changeConfig=function(b){try{a.XAPIWrapper.log("updating lrs object with new configuration"),this.lrs=d(this.lrs,b),b.user&&b.password&&this.updateAuth(this.lrs,b.user,b.password),this.base=g(this.lrs.endpoint)}catch(c){a.XAPIWrapper.log("error while changing configuration -- "+c)}},this.updateAuth=h},XAPIWrapper.prototype.xapiVersion="1.0.1",XAPIWrapper.prototype.prepareStatement=function(a){void 0===a.actor?a.actor=JSON.parse(this.lrs.actor):"string"==typeof a.actor&&(a.actor=JSON.parse(a.actor)),(this.lrs.grouping||this.lrs.registration||this.lrs.activity_platform)&&(a.context||(a.context={})),this.lrs.grouping&&(a.context.contextActivities||(a.context.contextActivities={}),a.context.contextActivities.grouping=[{id:this.lrs.grouping}]),this.lrs.registration&&(a.context.registration=this.lrs.registration),this.lrs.activity_platform&&(a.context.platform=this.lrs.activity_platform)},XAPIWrapper.prototype.testConfig=b,XAPIWrapper.prototype.log=c,XAPIWrapper.prototype.sendStatement=function(b,c){if(this.testConfig()){this.prepareStatement(b);var d;b.id?d=b.id:(d=a.ruuid(),b.id=d);var e=a.XHR_request(this.lrs,this.lrs.endpoint+"statements","POST",JSON.stringify(b),this.lrs.auth,c,{id:d});if(!c)return{xhr:e,id:d}}},XAPIWrapper.prototype.sendStatements=function(b,c){if(this.testConfig()){for(var d in b)this.prepareStatement(b[d]);var e=a.XHR_request(this.lrs,this.lrs.endpoint+"statements","POST",JSON.stringify(b),this.lrs.auth,c);if(!c)return e}},XAPIWrapper.prototype.getStatements=function(b,c,d){if(this.testConfig()){var e=this.lrs.endpoint+"statements";if(c)e=this.base+c;else{var f=new Array;for(s in b)if("until"==s||"since"==s){var g=new Date(b[s]);f.push(s+"="+encodeURIComponent(g.toISOString()))}else f.push(s+"="+encodeURIComponent(b[s]));f.length>0&&(e=e+"?"+f.join("&"))}var h=a.XHR_request(this.lrs,e,"GET",null,this.lrs.auth,d);if(void 0===h||404==h.status)return null;try{return JSON.parse(h.response)}catch(i){return h.response}}},XAPIWrapper.prototype.getActivities=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"activities?activityId=";d=d.replace("",encodeURIComponent(b));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},XAPIWrapper.prototype.sendState=function(b,d,e,f,g,h,i,j){if(this.testConfig()){var k=this.lrs.endpoint+"activities/state?activityId=&agent=&stateId=";k=k.replace("",encodeURIComponent(b)),k=k.replace("",encodeURIComponent(JSON.stringify(d))),k=k.replace("",encodeURIComponent(e)),f&&(k+="®istration="+encodeURIComponent(f));var l=null;h&&i?c("Can't have both If-Match and If-None-Match"):h?l={"If-Match":'"'+h+'"'}:i&&(l={"If-None-Match":'"'+i+'"'});var m="PUT";if(!g)return this.log("No activity state was included."),!1;g instanceof Array?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json"):g instanceof Object?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json",m="POST"):(l=l||{},l["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,k,m,g,this.lrs.auth,j,null,null,l)}},XAPIWrapper.prototype.getState=function(b,c,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"activities/state?activityId=&agent=";h=h.replace("",encodeURIComponent(b)),h=h.replace("",encodeURIComponent(JSON.stringify(c))),d&&(h+="&stateId="+encodeURIComponent(d)),e&&(h+="®istration="+encodeURIComponent(e)),f&&(f=isDate(f),null!=f&&(h+="&since="+encodeURIComponent(f.toISOString())));var i=a.XHR_request(this.lrs,h,"GET",null,this.lrs.auth,g,null,!0);if(void 0===i||404==i.status)return null;try{return JSON.parse(i.response)}catch(j){return i.response}}},XAPIWrapper.prototype.deleteState=function(b,d,e,f,g,h,i){if(this.testConfig()){var j=this.lrs.endpoint+"activities/state?activityId=&agent=&stateId=";j=j.replace("",encodeURIComponent(b)),j=j.replace("",encodeURIComponent(JSON.stringify(d))),j=j.replace("",encodeURIComponent(e)),f&&(j+="®istration="+encodeURIComponent(f));var k=null;g&&h?c("Can't have both If-Match and If-None-Match"):g?k={"If-Match":'"'+g+'"'}:h&&(k={"If-None-Match":'"'+h+'"'});var l=a.XHR_request(this.lrs,j,"DELETE",null,this.lrs.auth,i,null,k);if(void 0===l||404==l.status)return null;try{return JSON.parse(l.response)}catch(m){return l}}},XAPIWrapper.prototype.sendActivityProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"activities/profile?activityId=&profileId=";i=i.replace("",encodeURIComponent(b)),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":'"'+f+'"'}:g&&(j={"If-None-Match":'"'+g+'"'});var k="PUT";if(!e)return this.log("No activity profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j)}},XAPIWrapper.prototype.getActivityProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"activities/profile?activityId=";f=f.replace("",encodeURIComponent(b)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(d=isDate(d),null!=d&&(f+="&since="+encodeURIComponent(d.toISOString())));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},XAPIWrapper.prototype.deleteActivityProfile=function(b,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"activities/profile?activityId=&profileId=";h=h.replace("",encodeURIComponent(b)),h=h.replace("",encodeURIComponent(d));var i=null;e&&f?c("Can't have both If-Match and If-None-Match"):e?i={"If-Match":'"'+e+'"'}:f&&(i={"If-None-Match":'"'+f+'"'});var j=a.XHR_request(this.lrs,h,"DELETE",null,this.lrs.auth,g,null,i);if(void 0===j||404==j.status)return null;try{return JSON.parse(j.response)}catch(k){return j}}},XAPIWrapper.prototype.getAgents=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"agents?agent=";d=d.replace("",encodeURIComponent(JSON.stringify(b)));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},XAPIWrapper.prototype.sendAgentProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"agents/profile?agent=&profileId=";i=i.replace("",encodeURIComponent(JSON.stringify(b))),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":'"'+f+'"'}:g&&(j={"If-None-Match":'"'+g+'"'});var k="PUT";if(!e)return this.log("No agent profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j)}},XAPIWrapper.prototype.getAgentProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"agents/profile?agent=";f=f.replace("",encodeURIComponent(JSON.stringify(b))),f=f.replace("",encodeURIComponent(c)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(d=isDate(d),null!=d&&(f+="&since="+encodeURIComponent(d.toISOString())));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},XAPIWrapper.prototype.deleteAgentProfile=function(b,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"agents/profile?agent=&profileId=";h=h.replace("",encodeURIComponent(JSON.stringify(b))),h=h.replace("",encodeURIComponent(d));var i=null;e&&f?c("Can't have both If-Match and If-None-Match"):e?i={"If-Match":'"'+e+'"'}:f&&(i={"If-None-Match":'"'+f+'"'});var j=a.XHR_request(this.lrs,h,"DELETE",null,this.lrs.auth,g,null,i);if(void 0===j||404==j.status)return null;try{return JSON.parse(j.response)}catch(k){return j}}},a.ruuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},a.dateFromISOString=function(a){var b="([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T| ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?",c=a.match(new RegExp(b)),d=0,e=new Date(c[1],0,1);c[3]&&e.setMonth(c[3]-1),c[5]&&e.setDate(c[5]),c[7]&&e.setHours(c[7]),c[8]&&e.setMinutes(c[8]),c[10]&&e.setSeconds(c[10]),c[12]&&e.setMilliseconds(1e3*Number("0."+c[12])),c[14]&&(d=60*Number(c[16])+Number(c[17]),d*="-"==c[15]?1:-1),d-=e.getTimezoneOffset(),time=Number(e)+60*d*1e3;var f=new Date;return f.setTime(Number(time)),f},a.XHR_request=function(b,c,d,e,f,i,j,k,l){"use strict";function m(){if(s)return q;s=!0;var b=k&&404===n.status;if(!(void 0===n.status||n.status>=200&&n.status<400||b)){var e;try{e="There was a problem communicating with the Learning Record Store. ( "+n.status+" | "+n.response+" )"+c}catch(f){e=f.toString()}return a.XAPIWrapper.log(e),a.xhrRequestOnError(n,d,c,i,j),q=n,n}if(!i)return q=n,n;if(j)i(n,j);else try{var g=JSON.parse(n.responseText);i(n,g)}catch(h){i(n,n.responseText)}}var n,o,p,q,r,s=!1,t=!1,u=!1,v=c.toLowerCase().match(/^(.+):\/\/([^:\/]*):?(\d+)?(\/.*)?$/),w=window.location,x={};if(x["Content-Type"]="application/json",x.Authorization=f,x["X-Experience-API-Version"]=a.XAPIWrapper.xapiVersion,null!==l)for(var y in l)x[y]=l[y];t=w.protocol.toLowerCase()!==v[1]||w.hostname.toLowerCase()!==v[2],t||(p=null===v[3]?"http"===v[1]?"80":"443":v[3],t=p===w.port);var z=window.XDomainRequest&&window.XMLHttpRequest&&void 0===(new XMLHttpRequest).responseType;if(t&&void 0!==z&&z!==!1)u=!0,o=h(d,c,x,e),n=new XDomainRequest,n.open(o.method,o.url);else{n=new XMLHttpRequest,n.open(d,c,null!=i);for(var y in x)n.setRequestHeader(y,x[y])}if(n.onreadystatechange=function(){return 4===n.readyState?m():void 0},n.onload=m,n.onerror=m,n.send(u?o.data:e),!i){if(u)for(r=1e3+new Date;new Date - xAPIWrapper 1.7.0 Reference + xAPIWrapper 1.9.0 Reference @@ -178,7 +178,7 @@ -

xAPIWrapper 1.7.0 Reference

+

xAPIWrapper 1.9.0 Reference

diff --git a/package.json b/package.json index 8913cc2..ada83c4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xAPIWrapper", "description": "An easier way to build, send, and retrieve xAPI statements", - "version": "1.7.0", + "version": "1.9.0", "repository": { "type": "git", "url": "https://github.com/adlnet/xAPIWrapper.git"