forked from Toonigy/prodigy-classic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquestion.min.js
38 lines (35 loc) · 79.6 KB
/
question.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };
if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } }
{
let window = _____WB$wombat$assign$function_____("window");
let self = _____WB$wombat$assign$function_____("self");
let document = _____WB$wombat$assign$function_____("document");
let location = _____WB$wombat$assign$function_____("location");
let top = _____WB$wombat$assign$function_____("top");
let parent = _____WB$wombat$assign$function_____("parent");
let frames = _____WB$wombat$assign$function_____("frames");
let opener = _____WB$wombat$assign$function_____("opener");
function Util(){}var QI=QI||{};QI._PS=function(){var t=function(){function t(){this._events={"setup-init":[],"ctrl-init":[],"ctrl-submit":[],"template-change":[],"teardown-init":[],"times-up":[],"force-close":[],"use-tool":[]}}return t.prototype=Object.create(Object.prototype),t.prototype.publish=function(t,e){var i=this._events;if(_.isUndefined(i[t]))return console.error("[QI:PS] Failed to publish to unidentified event "+t+"."),!1;var s=i[t];return s.forEach(function(t){t.handler(e)}),"teardown-init"!==t&&"force-close"!==t||this.unsubscribeAll(),this},t.prototype.subscribe=function(t,e){var i=this._events;return _.isUndefined(i[t])?(console.error("[QI:PS] Failed to subscribe to unidentified event "+t+"."),!1):void i[t].push({handler:e})},t.prototype.unsubscribeAll=function(){var t=this._events;for(var e in t)t[e]=[]},t}();return t}(),QI._loader=function(t){var e=function(){function t(){this._data={hasLoaded:!1,wasSuccessful:!1,response:void 0}}return t.prototype=Object.create(Object.prototype),t.prototype.load=function(t){this._startLoad(),this._setLoadFailure()},t.prototype._startLoad=function(){this._data.response=void 0,this._data.wasSuccessful=!1,this._data.hasLoaded=!1},t.prototype._setLoadSuccess=function(t){this._data.response=t,this._data.wasSuccessful=!0,this._data.hasLoaded=!0},t.prototype._setLoadFailure=function(t){this._data.response=t,this._data.wasSuccessful=!1,this._data.hasLoaded=!0},t.prototype.wasSuccessful=function(){return this._data.hasLoaded&&this._data.wasSuccessful},t.prototype.wasUnsuccessful=function(){return this._data.hasLoaded&&!this._data.wasSuccessful},t.prototype.getResponse=function(t){return this.wasSuccessful()?this._data.response:void 0},t}();return t.Loader=e,t}(QI._loader||{}),QI._loader=function(t){var e=function(){function e(e){t.Loader.call(this)}return e.prototype=Object.create(t.Loader.prototype),e.prototype.load=function(t){this._startLoad();var e=$("<img>").on("load",this._setLoadSuccess.bind(this,e)).on("error",this._setLoadFailure.bind(this)).attr("src",t)},e}();return t.ImageLoader=e,t}(QI._loader),QI._loader=function(t){var e=function(){function e(e){t.Loader.call(this)}return e.prototype=Object.create(t.Loader.prototype),e.prototype.load=function(t){this._startLoad(),$.getJSON(t).success(this._setLoadSuccess.bind(this)).error(this._setLoadFailure.bind(this))},e}();return t.JsonLoader=e,t}(QI._loader);var Prodigy=Prodigy||{};Prodigy["extends"]=function(t,e,i){t.prototype=Object.create(e.prototype);for(var s in i)t.prototype[s]=i[s]},Util.capitalize=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},Util.setCookie=function(t,e,i){var s=new Date;s.setTime(s.getTime()+24*i*60*60*1e3);var n="expires="+s.toUTCString();document.cookie=t+"="+e+"; "+n},Util.getDate=function(){var t=new Date,e=t.getDate(),i=t.getMonth()+1,s=t.getFullYear();return e<10&&(e="0"+e),i<10&&(i="0"+i),i+""+e+s},Util.getCookie=function(t){t+="=";for(var e=document.cookie.split(";"),i=0;i<e.length;i++){for(var s=e[i];" "==s.charAt(0);)s=s.substring(1);if(0==s.indexOf(t))return s.substring(t.length,s.length)}return""},Util.convertItemToIcon=function(t){return"gold"===t.type?"item/26":"pet"===t.type?"pets/"+t.ID.toString():"spell"===t.type?t.element:"boss"===t.type?"boss":"player"===t.type?"player":Util.isDefined(t.type)&&Util.isDefined(t.ID)?t.type+"/"+t.ID:Util.isDefined(t.tag)?t.tag:"empty"},Util.numberToString=function(t){t=""+t;for(var e="",i=1,s=t.length-1;s>=0;s--)e=t.charAt(s)+e,i%3===0&&i>0&&s>0&&(e=","+e),i++;return e},Util.isSchoolHours=function(){var t=new Date,e=t.getHours();return e>=8&&e<=15},Util.isDefined=function(t){return!("undefined"==typeof t||null===t||"null"===t)},Util.isString=function(t){return"string"==typeof t||t instanceof String},Util.getDateSeed=function(){var t=new Date,e=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDay()),i=e.getTime();return i},Util.highlightAll=function(t,e,i,s){for(var n=0;n<t.length;n++)Util.isDefined(t[n].highlight)&&t[n].highlight(e,i,s)},Util.getObject=function(t){return"null"===t?null:Util.isString(t)?JSON.parse(t):t},Util.copyObject=function(t){var e={};if(null==t||"object"!=typeof t)return t;if(t instanceof Array){e=[];for(var i=0,s=t.length;i<s;i++)e[i]=Util.copyObject(t[i])}if(t instanceof Object)for(var n in t)t.hasOwnProperty(n)&&(e[n]=Util.copyObject(t[n]));return e},Util.pseudoRandomNumber=function(t){return(9301*t+49297)%233280/233280},Util.randomArrayElement=function(t,e){return Util.isDefined(e)?t[Math.floor(this.pseudoRandomNumber(e)*t.length)]:t[Math.floor(Math.random()*t.length)]},Util.weightedArrayElement=function(t){for(var e=0,i=[],s=0;s<t.length;s++)Util.isDefined(t[s].weight)&&t[s].weight>0&&(e+=t[s].weight),i.push(e);for(var n=Math.random()*e,s=0;s<t.length;s++)if(n<i[s])return t[s];return null},Util.shuffleArray=function(t,e){for(var i,s=t.length;0!==s;){i=Math.floor(Util.pseudoRandomNumber(e+s)*s),s--;var n=t[i];t[i]=t[s],t[s]=n}},Util.isEmptyObject=function(t){if(!Util.isDefined(t))return!0;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0},Util.inArray=function(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return!0;return!1},Util.removeDuplicates=function(t){for(var e=[],i=0;i<t.length;i++)Util.inArray(e,t[i])||e.push(t[i]);return e},Util.equalArrays=function(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!=e.length)return!1;for(var i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0},Util.getUrlVariable=function(t){var e={};window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(t,i,s){e[i]=s});return e[t]},Util.removeFromArray=function(t,e){for(var i=0;i<e.length;i++)if(e[i]===t){e.splice(i,1);break}},Util.processTime=function(t){if(t<=0)return"00:00";var e=Math.floor(t/36e5),i=Math.floor((t-36e5*e)/6e4),s=Math.floor((t-36e5*e-6e4*i)/1e3);return 0===e?e="00":e<10&&(e="0"+e),0===i?i="00":i<10&&(i="0"+i),0===s?s="00":s<10&&(s="0"+s),"00"===e?i+":"+s:e<24?e+":"+i+":"+s:Math.floor(e/24)+" days"},Prodigy.SkillNode=function(t){this.ID=t.ID,this.difficulty=t.d,this.nFactor=t.n||0,this.topic=t.t||"",this.questions=t.q,this.grade=1,this.prereqs=[],this.next=[],this.correct=0,this.incorrect=0,this.time=0,this.theta=null,this.decay=0,this.lock=0,this.incorrectT=0,this.correctT=0,this.previous=[],this.localLock=[],this.marked=!1,this.lastTime=0},Prodigy.SkillNode.prototype={constructor:Prodigy.SkillNode,init:function(t,e,i,s){this.theta=t,this.decay=e,this.lock=i,this.lastTime=Util.isDefined(s)?s:9999,this.lock>0&&this.setLocalLock(this.ID,!0)},clear:function(){this.prereqs=[],this.next=[]},getData:function(){var t={};return t.ID=this.ID,t.decay=this.decay,t.theta=this.theta,t.correct=this.correct,t.incorrect=this.incorrect,t.time=this.time,t.lock=this.lock,this.time=this.correct=this.incorrect=0,t},getTheta:function(){var t=this.theta-Math.max(0,this.decay-3*.6);return t<-3&&(t=-3),t>3&&(t=3),t},getNormalizedTheta:function(){var t=this.getTheta()+3;return t/6},isMastered:function(){return Util.isDefined(this.theta)&&this.getTheta()>=3},isStruggling:function(){return Util.isDefined(this.theta)&&this.getTheta()<-1.8},isValid:function(){return!this.lock&&this.localLock.length<=0&&!this.isMastered()},isNew:function(){return!Util.isDefined(this.theta)},setLock:function(t){this.updated=!0,this.lock=t,this.setLocalLock(this.ID,t)},setLocalLock:function(t,e){for(var i=0;i<this.next.length;i++)this.next[i].setLocalLock(t,e);this.ID!==t&&(e&&!Util.inArray(this.localLock,t)?this.localLock.push(t):e||Util.removeFromArray(t,this.localLock))},decrementLock:function(){this.lock>0&&(this.lock--,0===this.lock&&(this.theta=-2,this.setLock(0)),this.updated=!0)},decaySkill:function(t,e){if(!(t<=0)){e||this.setDecay(t);for(var i=0;i<this.prereqs.length;i++)this.prereqs[i].decaySkill(e?t:t-.6)}},setDecay:function(t){this.updated=!0,Util.isDefined(this.theta)&&t>0&&this.decay<3*.6&&this.decay+t>=3*.6?this.decay+=t+3*.6:Util.isDefined(this.theta)&&t<0&&this.decay>=3*.6&&this.decay+t<=3*.6?this.decay=0:this.decay+=t,this.decay<0&&(this.decay=0),this.decay>9&&(this.decay=9),t>0&&console.log("DECAY "+this.ID+" BY "+t+": "+this.decay)},initNew:function(t){this.theta=t?1:-1,this.decay=0},answerQuestion:function(t,e,i,s){this.updated=!0,i>600&&(i=600),this.time+=i||0,e?(this.correct++,this.correctT++,this.setDecay(-.6),this.theta=Math.min(3,this.theta+.6+t)):(this.incorrect++,this.incorrectT++,this.decaySkill(this.isStruggling()?1.2:.6,!0),this.theta=Math.max(-3,this.theta-1.2-t)),!s&&(this.incorrectT>=3||this.theta<=-3)&&(this.incorrectT=0,this.setLock(20),this.decaySkill(1.2,!0))}},Prodigy.SkillTree=function(t){this.curriculumTreeID=t||1},Prodigy.SkillTree.prototype={constructor:Prodigy.SkillTree,processSkills:function(t){for(var e=0;e<t.length;e++)t[e].clear();var i=Prodigy.SkillTree.TREES[this.curriculumTreeID];for(var s in i){var n=Prodigy.EducationSystem.getSkill(t,s),o=i[s];if(Util.isDefined(n)&&Util.isDefined(o))for(var e=0;e<o.length;e++){var r=Prodigy.EducationSystem.getSkill(t,o[e]);Util.isDefined(r)&&(n.prereqs.push(r),r.next.push(n))}}}},$.ajax({dataType:"json",url:Controller.DEPLOY_PATH+"skillTrees.json",async:!1,success:function(t){Prodigy.SkillTree.TREES=t}}),Prodigy.SkillTree.convertToID=function(t,e){return t&&1!=t&&2==t?1==e?3:2==e?4:2:1},Prodigy.Curriculum=function(t,e){this.grade=t||1,this.curriculumTreeID=e||1},Prodigy.Curriculum.prototype={constructor:Prodigy.Curriculum,processSkills:function(t){for(var e=[],i=8;i>=0;i--)for(var s=this.getCurriculum(i,this.curriculumTreeID),n=0;n<s.skills.length;n++){var o=s.skills[n].ID,r=Prodigy.EducationSystem.getSkill(t,o);Util.inArray(e,r)||(r.grade=i,r.marked=!0,r.difficulty=s.skills[n].d,e.push(r))}return e},getCurriculum:function(t,e){var i=null;e=e||1,t=t||1;for(var s in Prodigy.Curriculum.DATA){var n=Prodigy.Curriculum.DATA[s];if(n.grade==t&&n.locationID==e){i=n;break}}return Util.isDefined(i)||(i=Prodigy.Curriculum.DATA[1]),i},isGradeComplete:function(t,e){if(e>=8)return!1;for(var i=0;i<t.length;i++)if(t[i].grade==e&&!t[i].isMastered())return!1;return!0}},Prodigy.Curriculum.getGrade=function(t){var e=Prodigy.Curriculum.DATA[t];return Util.isDefined(e)?e.grade:null},Prodigy.Curriculum.getMasterSkillList=function(){var t=[];for(var e in Prodigy.Curriculum.DATA){e=Prodigy.Curriculum.DATA[e];for(var i=0;i<e.skills.length;i++){var s=e.skills[i];Util.isDefined(Prodigy.EducationSystem.getSkill(t,s.ID))||t.push(new Prodigy.SkillNode(s))}}return t},$.ajax({dataType:"json",url:Controller.DEPLOY_PATH+"curricula.json",async:!1,success:function(t){Prodigy.Curriculum.DATA=t}}),Prodigy.EducationSystem=function(t){this.nullGrade=!0,this.isNew=!0,this.reporter=t,this.skills=Prodigy.Curriculum.getMasterSkillList(),Prodigy.EducationSystem.sortSkills(this.skills);var e={};this.init(e)},Prodigy.EducationSystem.prototype={constructor:Prodigy.EducationSystem,init:function(t){if(console.log(t),this.algorithms=[],this.algorithms.push(new Prodigy.SkillSelection(this)),Util.isDefined(t)){if(Util.isDefined(t.skills)&&t.skills.length>0){for(var e=0;e<t.skills.length;e++){var i=t.skills[e],s=Prodigy.EducationSystem.getSkill(this.skills,i.skillID);Util.isDefined(s)&&s.init(i.theta,i.decay,i.lock,i.last_updated)}this.isNew=!1}var n=t.grade||1,o=t.curriculumTreeID||1,r=t.chosenGrade||n,l=t.curriculumOverride;if(Util.isDefined(l)&&(n=Prodigy.Curriculum.getGrade(l)||n),Util.isDefined(t.placementTestID)&&!Util.isDefined(l)&&this.algorithms.push(new Prodigy.PlacementSkillSelection(this,r,o,t.placementTestID,t.currentSkill,t.momentum)),Util.isDefined(t.plans)&&t.plans.length>0){Prodigy.PlannerSkillSelection.sort(t.plans),console.log(t.plans);for(var e=0;e<t.plans.length;e++)this.algorithms.push(new Prodigy.PlannerSkillSelection(this,n,t.plans[e]))}if(Util.isDefined(t.homework)&&t.homework.length>0)for(var e=t.homework.length-1;e>=0;e--)this.algorithms.push(new Prodigy.HomeworkSkillSelection(this,t.homework[e]));t.grade&&(this.nullGrade=!1),this.setup(n,o,r,l)}},setup:function(t,e,i){this.inUSA=1!=e,this.algorithms[0].setState(e,t,i)},getUpdatedData:function(){for(var t=0;t<this.algorithms.length;t++)this.algorithms[t].updated&&this.algorithms[t].save();for(var e=[],t=0;t<this.skills.length;t++){var i=this.skills[t];i.updated&&i.marked&&(i.updated=!1,e.push(i.getData()))}return e},decrementLocks:function(){for(var t=0;t<this.skills.length;t++)this.skills[t].decrementLock()},selectSkill:function(){for(var t=this.algorithms[this.algorithms.length-1],e=t.selectSkill();t.isComplete()||!Util.isDefined(e);)this.algorithms.splice(this.algorithms.length-1,1),t=this.algorithms[this.algorithms.length-1],e=t.selectSkill();return e.isNew()&&e.initNew(t.fastTrack),e},selectQuestion:function(){return this.algorithms[this.algorithms.length-1].selectQuestion()},answerQuestion:function(t,e){console.log("\nANSWER QUESTION "+t),this.algorithms[this.algorithms.length-1].answerQuestion(t,e)},getMasteredSkills:function(){for(var t=0,e=0;e<this.skills.length;e++)this.skills[e].isMastered()&&t++;return t}},Prodigy.EducationSystem.getSkill=function(t,e){for(var i=0;i<t.length;i++)if(t[i].ID==e)return t[i];return null},Prodigy.EducationSystem.sortSkills=function(t){t.sort(function(t,e){return 1e3*(t.difficulty-e.difficulty)+t.topic.localeCompare(e.topic)})},Prodigy.SkillSelection=function(t){this.edu=t,this.exhaust=0,this.skills=[],this.setState(1,1,1)},Prodigy.SkillSelection.prototype={constructor:Prodigy.SkillSelection,setState:function(t,e,i){this.grade=e,this.selectedGrade=i,this.curriculumTreeID=t,this.fastTrack=e<i,Util.isDefined(this.edu.skills)&&(this.curriculum=new Prodigy.Curriculum(this.grade,this.curriculumTreeID),this.skillTree=new Prodigy.SkillTree(this.curriculumTreeID),this.skills=this.curriculum.processSkills(this.edu.skills),this.skillTree.processSkills(this.edu.skills),Prodigy.EducationSystem.sortSkills(this.skills)),this.type="BASIC "+this.grade+", "+t},save:function(){this.updated=!1},isComplete:function(){return!1},selectSkill:function(){console.log("-------------------------------------------\n"),console.log("\n------ "+this.type+" SKILL SELECTION ------"),this.current=null;for(var t=[],e=0;e<this.skills.length&&!Util.isDefined(this.current);e++){var i=this.skills[e],s="";i.isValid()?i.isNew()&&i.grade===this.grade?(s="NEW GRADE SKILL :",this.current=i):i.isNew()&&i.decay>=3*.6?(s="NEW AVAIL PREREQ :",this.current=i):!i.isNew()&&i.grade<=this.grade?(s="NON-MASTERED SKILL :",this.current=i):s="SKIPPED (OUTSIDE GRADE) :":(t.push(i),s=i.lock?"SKILL LOCKED :":i.localLock.length>0?"PREREQS LOCKED :":i.isMastered()?"SKILL MASTERED :":"SKIPPED ??? :"),console.log(s+" ID = "+i.ID+", decay = "+i.decay+", theta = "+i.theta+", grade = "+i.grade)}if(!Util.isDefined(this.current))if(this.curriculum.isGradeComplete(this.skills,this.grade))console.log("GRADE COMPLETE!"),this.edu.reporter.trigger("grade-complete",{grade:this.grade+1}),this.edu.reporter.trigger("update-user",{grade:this.grade+1}),this.setState(this.curriculumTreeID,this.grade+1,this.selectedGrade);else{console.log("STUCK OR FULL MASTERY --- RANDOM SELECT!");for(var n=0,e=0;n<5&&t.length>0;e++){var i=Util.randomArrayElement(t);i.grade==this.grade&&(i.setDecay(.6*3),this.current=i,n++),Util.removeFromArray(i,t)}}return Util.isDefined(this.current)||(this.current=this.skills[0]),this.current},selectQuestion:function(){for(var t=Math.max(0,Math.ceil(this.current.questions/20)),e=Math.floor(this.current.getNormalizedTheta()*this.current.questions),i=[],s=-.1,n=Math.max(0,e-t);n<this.current.questions&&n<e+t;n++)s+=.2/(2*t+1),Util.inArray(this.current.previous,n)||i.push({index:n,mod:s});if(i.length>0){var o=Util.randomArrayElement(i);e=o.index,this.mod=o.mod}else this.mod=0;return this.current.previous.push(e),this.current.previous.length>10&&this.current.previous.splice(0,1),console.log("QUESTION CHOSEN: index = "+e+", mod = "+this.mod),e<0&&(e=0),e>this.current.questions-1&&(e=this.current.questions-1),{index:e}},answerQuestion:function(t,e,i){this.current?(this.exhaust+=this.current.nFactor*(t?1:3),this.exhaust>=150&&(this.exhaust=0),this.edu.decrementLocks(),this.current.answerQuestion(this.mod,t,e,i)):console.warn("A skill and question must be selected before it can be answered")}},Prodigy.HomeworkSkillSelection=function(t,e){if(Util.isDefined(e)){this.skills=e.skills,this.homeworkID=e.homeworkID,this.edu=t,this.incorrect=0,this.correct=0;for(var i=0;i<this.skills.length;i++){var s=this.skills[i];0===i&&(this.skillID=s.skillID),Util.isDefined(s.incorrect)&&(this.incorrect+=s.incorrect),Util.isDefined(s.correct)&&(this.correct+=s.correct)}Util.isDefined(e.stats)&&Util.isDefined(e.stats.skills)&&e.stats.skills>1&&(this.isExtended=!0)}},Prodigy["extends"](Prodigy.HomeworkSkillSelection,Prodigy.SkillSelection,{constructor:Prodigy.HomeworkSkillSelection,isComplete:function(){if(!Util.isDefined(this.skills))return!0;for(var t=0;t<this.skills.length;t++)if(this.skills[t].questions.length>0)return!1;return!0},selectSkill:function(){if(!Util.isDefined(this.skills))return null;console.log("HOMEWORK SELECT!");for(var t=0;t<this.skills.length;t++){var e=this.skills[t];if(e.questions.length>0){var i=Prodigy.EducationSystem.getSkill(this.edu.skills,e.skillID);if(Util.isDefined(i))return this.currentSkill=e,this.currentQuestion=e.questions[0],this.current=i,this.current.marked=!0,console.log("HW ID = "+i.ID+", decay = "+i.decay+", theta = "+i.theta+", grade = "+i.grade),i;this.skills.splice(t,1),t--}else this.skills.splice(t,1),t--}return null},selectQuestion:function(){return this.mod=0,{ID:this.currentQuestion,homeworkID:this.homeworkID}},answerQuestion:function(t,e){if(this.currentSkill.questions.splice(0,1),t)this.correct++;else{this.incorrect++;var i=this.incorrect+this.correct;if(this.isExtended&&this.incorrect>=9){var i=this.incorrect+this.correct,s=Math.floor(i*(.6-.0055*(i-15)));(i<=15||this.incorrect>=s)&&(this.skills=null)}}Prodigy.SkillSelection.prototype.answerQuestion.call(this,t,e),this.isComplete()&&(console.log("ASSIGNMENT COMPLETE"),this.edu.reporter.trigger("assignment-complete",{assignmentID:this.homeworkID,skillID:this.skillID,grade:this.getGrade()}))},getGrade:function(){var t=this.correct+this.incorrect;return this.correct/t}}),Prodigy.PlacementSkillSelection=function(t,e,i,s,n,o){this.placementTestID=s,this.currentSkill=n,this.skills=[],this.momentum=o||0,this.newGrade=null,this.chosenGrade=e,this.edu=t,this.curriculumTreeID=i,this.testIDs=Prodigy.PlacementSkillSelection.TARGETS[i];for(var r=0,l=0;l<this.testIDs.length;l++)for(var a=0;a<this.testIDs[l].length;a++){var c=Prodigy.EducationSystem.getSkill(this.edu.skills,this.testIDs[l][a]);this.skills.push(c),c.marked=!0,(l===e-2||0===l&&e-2<0)&&0===a&&!Util.isDefined(n)&&(this.currentSkill=r),r++}},Prodigy["extends"](Prodigy.PlacementSkillSelection,Prodigy.SkillSelection,{constructor:Prodigy.PlacementSkillSelection,isComplete:function(){return 0===this.momentum&&!Util.isDefined(this.currentSkill)},save:function(){this.edu.reporter.trigger("update-user",{currentSkill:this.currentSkill,momentum:this.momentum}),this.updated=!1},selectSkill:function(){return this.isComplete()?null:(console.log("PLACEMENT ID "+this.placementTestID+" - "+this.currentSkill),this.current=this.skills[this.currentSkill],console.log("SKILL CHOSEN "+this.current.ID),this.current)},selectQuestion:function(){this.mod=0;var t=0;return t=0===this.current.correct?0+this.current.incorrect:1===this.current.correct?this.current.questions/2+Math.max(0,this.current.incorrect):this.current.questions-1-Math.max(0,this.current.incorrect),t=Math.floor(t),t<0&&(t=0),t>this.current.questions-1&&(t=this.current.questions-1),{index:t}},answerQuestion:function(t,e){if(this.updated=!0,Prodigy.SkillSelection.prototype.answerQuestion.call(this,t,e,!0),this.current.incorrectT>=2)0===this.momentum?this.momentum=-2:2===this.momentum?this.momentum=-1:1===this.momentum&&this.completeTest(this.currentSkill);else{if(!(this.current.correctT>=3))return;this.current.theta=3,0===this.momentum?this.momentum=2:this.momentum===-2?this.momentum=1:this.momentum===-1&&this.completeTest(this.currentSkill+1)}0!==this.momentum&&(this.currentSkill+=this.momentum,(this.currentSkill<=0||this.currentSkill>=this.skills.length-1)&&this.completeTest(this.currentSkill))},completeTest:function(t){t<0&&(t=0),t>this.skills.length-1&&(t=this.skills.length-1);for(var e=1,i=null,s=1,n=0,o=0;o<this.testIDs.length&&!Util.isDefined(i);o++){e=o+1;for(var r=0;r<this.testIDs[o].length;r++){if(n===t){i=r/this.testIDs[o].length;break}n++}}this.momentum=0,this.currentSkill=null,s=e===this.chosenGrade?this.chosenGrade:e===this.chosenGrade-1&&i>=.75?this.chosenGrade:i>=.15?e:e-1,s<1?s=1:s>8&&(s=8),this.completed=!0,this.newGrade=s,this.edu.setup(s,this.curriculumTreeID,this.grade),this.updated=!0,console.log("COMPLETE PLACEMENT TEST "+this.placementTestID+", grade = "+s+", percent = "+i),this.edu.reporter.trigger("placement-complete",{grade:this.newGrade});var l={currentSkill:"null",momentum:0};this.edu.reporter.trigger("update-user",{currentSkill:"null",placementTestID:"null",momentum:0,grade:this.newGrade}),console.log(l)}}),Prodigy.PlacementSkillSelection.TARGETS={1:[[94,95,148,49,3,196,482],[429,439,7,53,457,77,76],[176,186,240,243,249,27,38],[29,129,208,760,252,720,721],[51,223,258,825,922,117,1016],[309,359,966,328,341,322,894],[507,505,515,987,512,529,332],[534,535,540,688,533,609,525]],2:[[94,97,98,164,165,196,197],[166,110,243,154,186,185,458],[772,782,554,718,722,1102,1106],[788,163,325,844,162,901,925,892],[1076,65,385,609,876,918],[999,1059,509,506,1044,946],[387,861,541,902,979,898],[691,688,686,681,695,663,664]],3:[[94,97,98,164,165,196,197],[166,110,243,154,186,185,458],[772,782,554,718,722,1102,1106],[788,163,325,844,162,901,925,892],[1076,65,385,609,876,918],[999,1059,509,506,1044,946],[387,861,541,902,979,898],[691,688,686,681,695,663,664]],4:[[94,97,98,164,165,196,197],[166,110,243,154,186,185,458],[772,782,554,718,722,1102,1106],[788,163,325,844,162,901,925,892],[1076,65,385,609,876,918],[999,1059,509,506,1044,946],[387,861,541,902,979,898],[691,688,686,681,695,663,664]]},Prodigy.PlannerSkillSelection=function(t,e,i){this.edu=t,this.data=i,this.curriculum=new Prodigy.Curriculum(e,i.curriculumTreeID||1),this.skillTree=new Prodigy.SkillTree(i.curriculumTreeID||1);var s=this.curriculum.processSkills(this.edu.skills);this.skillTree.processSkills(this.edu.skills),this.skills=[];for(var n=0;n<s.length;n++){var o=s[n];if(!(o.grade>=e+2))if(Util.inArray(i.skill_list,o.ID)&&(i.active||i.diff<0))o.marked=!0,this.skills.push(o);else if(i.diff>=0&&!i.active)for(var r=0;r<o.next.length;r++){var l=o.next[r];Util.inArray(i.skill_list,l.ID)&&!Util.inArray(i.skill_list,o.ID)&&(o.marked=!0,this.skills.push(o))}}console.log("PLANNER SKILLS:"),console.log(this.skills),this.type="PLANNER "+e+", "+i.curriculumTreeID},Prodigy["extends"](Prodigy.PlannerSkillSelection,Prodigy.SkillSelection,{constructor:Prodigy.PlannerSkillSelection,isComplete:function(){for(var t=0;t<this.skills.length;t++){var e=this.skills[t];if(e.isMastered()&&e.lastTime>=14)return!1;if(!e.isValid()||e.isStruggling()&&e.lastTime<2&&Util.isSchoolHours());else if(e.isValid())return!1}return console.log("COMPLETE"),!0},selectSkill:function(t){t||(console.log("-------------------------------------------\n"),console.log("\n------ "+this.type+" SKILL SELECTION ------")),this.current=null;for(var e=0;e<this.skills.length&&!Util.isDefined(this.current);e++){var i=this.skills[e],s="";i.isMastered()&&i.lastTime>=14?(i.setDecay(4),i.lastTime=2,this.current=i,s="OLD MASTERY"):!i.isValid()||i.isStruggling()&&i.lastTime<2&&!Util.isSchoolHours()?(this.skills.splice(e,1),e--,s="LOCKED"):i.isValid()&&(i.lastTime=2,this.current=i,s="NORMAL"),t||console.log(s+" ID = "+i.ID+", decay = "+i.decay+", theta = "+i.theta+", last = "+i.lastTime+", diff = "+this.data.diff)}return this.current},answerQuestion:function(t,e,i){Prodigy.SkillSelection.prototype.answerQuestion.call(this,t,e,i)}}),Prodigy.PlannerSkillSelection.sort=function(t){t.sort(function(t,e){var i=t.active?-1e3:Math.abs(t.diff),s=e.active?-1e3:Math.abs(e.diff);return s-i})},QI._settings=function(t){function e(t){function e(t){_.isUndefined(t)||(a=t)}function i(t){r=t}function s(t){l=t?"teacher":"student"}e(t.volume),i(t.secondChance),s(t.isTeacher)}function i(){return a}function s(){return r}function n(){r=!1}function o(){return l}var r,l,a=.5;return t.set=e,t.getVolume=i,t.getSecChance=s,t.useSecChance=n,t.getUserType=o,t}(QI._settings||{});var QI=function(t,e,i){function s(){var t="2.2.10",e="Effectiveness Tracking";n(t,e),o(t,l)}function n(t,e){console.log("%c %c %c QI v"+t+" | "+e+" %c %c ","background: #CCC","background: #BBB","background: #AAA; color: #FFF","background: #BBB","background: #CCC")}function o(t,e){function i(t){$("<link>",{rel:"stylesheet",type:"text/css",href:(l?"../dist/assets/style":t)+"/question.css"}).appendTo("head")}function s(t,e){}function n(t,e){var i=document.createElement("audio");i.src=t+"/audio/sfx/sfx-main.mp3",i.load(),e.sfx=e.sfx||i}var o="https://web.archive.org/web/20161210015218/https://prodigy.blob.core.windows.net/",r="edu-question-interface-2-1-3",l=_.includes(window.location.href,"education-qi");i(o+r),s(o+r,e),n(o+r,e)}function r(){function t(){return"fixed"===$("html").css("position")&&e._isCssLoaded()}function i(){return!0}function s(){return!0}return t()&&i()&&s()}var l=t._assets||{};return t._areAssetsLoaded=r,t._playSfx=function(){if(l.sfx){var e=l.sfx;e.volume=i.getVolume(),e.currentTime=3.2,e.play(),clearTimeout(t._sfxTimeout),t._sfxTimeout=setTimeout(function(){e.pause(),e=null},200)}},t._playCorrectSfx=function(){clearTimeout(t._sfxTimeout),t._sfxTimeout=setTimeout(function(){if(l.sfx){var t=l.sfx;t.volume=i.getVolume(),t.currentTime=11,t.play(),setTimeout(function(){t.pause(),t=null},2e3)}},360)},t._pauseAudioSrc=function(){l.audio&&l.audio.pause()},t._playAudioSrc=function(t){if(l.audio){var e=l.audio;e.volume=i.getVolume(),e.pause(),e.src=t,e.play()}},s(),t}(QI||{},Controller,QI._settings);QI.TrackedFields=function(){function t(){return{skillId:0,questionId:0,homeworkId:0,classIds:[],submissions:[]}}function e(t,e){const i=0,s=Math.round((t-e)/1e3);return Math.max(i,s)}function i(t,i){const s=300,n=e(t,i);return Math.min(s,n)}var s=t(),n=new Date;return{reset:function(){s=t(),n=new Date},setQuestion:function(t){t&&(s.skillId=t.skillID,s.questionId=t.ID,s.homeworkId=t.homeworkID)},setClassIds:function(t){s.classIds=t},trackSubmit:function(t){s.submissions.push({answer:t.answer,isCorrect:t.isCorrect,time:new Date})},progressEducationSystem:function(t){var i=_.last(s.submissions),o=i?i.time:new Date;i&&t.answerQuestion(i.isCorrect,e(o,n))},invokeCallback:function(t){var e=_.last(s.submissions),o=e?e.time:new Date;t({skillID:s.skillId,questionID:s.questionId,hwID:s.homeworkId||0,ownerIDs:s.classIds,userAnswer:e?e.answer:[],wasCorrect:!!e&&e.isCorrect,respTime:i(o,n),chances:_.map(s.submissions,function(t,e){var o=s.submissions[e-1],r=o?o.time:n;return{chance:e+1,userAnswer:JSON.stringify(t.answer),wasCorrect:t.isCorrect,respTime:i(t.time,r)}}),hintID:-1})}}},QI._cb=function(t,e){function i(t){t.subscribe("setup-init",s),t.subscribe("ctrl-submit",n),t.subscribe("teardown-init",o),t.subscribe("force-close",o)}function s(t){r=t.callback,l=t.educationSystem,a.reset(),a.setClassIds(t.classIds),a.setQuestion(t.question)}function n(t){var e="correct"===t.outcome||"incorrect"===t.outcome||"second-chance"===t.outcome;e&&a.trackSubmit({answer:t.input,isCorrect:"correct"===t.outcome})}function o(){_.isFunction(r)&&(a.progressEducationSystem(l),a.invokeCallback(r)),r=void 0,l=void 0,a.reset()}var r,l,a=e();return t.init=i,t}(QI._cb||{},QI.TrackedFields),QI._ctrl=function(t,e){var i=function(){function t(t){this._controller,this._ps=t,this._data={userId:0,submittedInput:[],hasDisplayedHighlight:!1,shouldShowStudentError:!1,hasDisplayedResult:!1,hasDisplayedAnswer:!1,hasDisabledHintBubbles:!1},t.subscribe("setup-init",this._setCurrency.bind(this)),t.subscribe("ctrl-submit",this._handleOutcome.bind(this))}return t.prototype=Object.create(Object.prototype),t.prototype.initialize=function(t,e,i,s){var n=this._splitTestingFlags(),o=this._splitTestingOptions(n,i),r=function(){s();var t=this._controller,i=this._controller.getSkill(),r=i.getQuestion(e);this._ps.publish("ctrl-init",{ctrl:this,controller:t,skill:i,question:r,splitTestingFlags:n,splitTestingOptions:o}),this._publishTemplateChange()};this._controller=new Controller(".qi-container .qi-content"),this._controller.showQuestion(t,e,r.bind(this),o),this._data.submittedInput=this._controller.getInput()},t.prototype._splitTestingFlags=function(){return{isHintBubbleIconSplitTestEnabled:!0,isHintBubbleContentSplitTestEnabled:!0}},t.prototype._splitTestingOptions=function(t,e){var i={},s=t.isHintBubbleIconSplitTestEnabled||t.isHintBubbleContentSplitTestEnabled;if(s){i.splitTestingSignature=e}return{controls:i}},t.prototype._handleOutcome=function(t){var e=t.outcome;switch(e){case"correct":this.displayAnswer(),this.clearStudentError();break;case"second-chance":this.displayAnswerHighlight(),this.showStudentError(),this.swapTemplate("hint","second-chance");break;case"sc-invalid":this.displayAnswerHighlight();break;case"incorrect":this.displayResult(),this.clearStudentError();break;case"answer":this.swapTemplate("answer")}},t.prototype.publishSubmitState=function(){var t,i=this._data.hasDisplayedHighlight&&!this._controller.hasChangedIncorrect(this._data.submittedInput);if(this._controller.isValid())if(i)t="sc-invalid";else{if(this._controller.isCorrect())t="correct";else{var s=e.getSecChance(),n=this._controller.getSkill().isType("mc"),o=s&&!n;o?(t="second-chance",e.useSecChance()):t="incorrect"}this._data.submittedInput=this._controller.getInput()}else t="invalid";this._ps.publish("ctrl-submit",{outcome:t,input:this._data.submittedInput})},t.prototype.displayAnswerHighlight=function(){function t(){this._controller.displayUnchangedHighlights(this._data.submittedInput),this._data.hasDisplayedHighlight=!0,this._publishTemplateChange()}this._controller.isTemplate("question")?t.bind(this)():this._controller.swapTemplate("question",t.bind(this))},t.prototype.shouldShowStudentError=function(){return this._data.userId%2===0},t.prototype.showStudentError=function(){function t(){this._controller.showStudentErrorBubbles(this._data.submittedInput),this._data.shouldShowStudentError=!0,this._publishTemplateChange()}this.shouldShowStudentError()&&(this._controller.isTemplate("question")?t.bind(this)():this._controller.swapTemplate("question",t.bind(this)))},t.prototype.clearStudentError=function(){function t(){this._controller.clearStudentErrorBubbles(),this._data.shouldShowStudentError=!1,this._publishTemplateChange()}this.shouldShowStudentError()&&(this._controller.isTemplate("question")?t.bind(this)():this._controller.swapTemplate("question",t.bind(this)))},t.prototype.displayResult=function(){function t(){this._controller.displayResult(),this._controller.disableInput(),this._data.hasDisplayedResult=!0,this._publishTemplateChange()}this._controller.isTemplate("question")?t.bind(this)():this._controller.swapTemplate("question",t.bind(this))},t.prototype.displayAnswer=function(){function t(){this._controller.displayAnswer(),this._controller.disableInput(),this._data.hasDisplayedAnswer=!0,this._publishTemplateChange()}this._controller.isTemplate("question")?t.bind(this)():this._controller.swapTemplate("question",t.bind(this))},t.prototype._publishTemplateChange=function(t){var e=this._controller.getTemplateType(),i="";switch(e){case"question":this._data.hasDisplayedResult&&(i="display-result"),this._data.hasDisplayedAnswer&&(i="display-answer")}this._ps.publish("template-change",{template:e,templateState:t||i,controller:this._controller}),this._data.hasDisabledHintBubbles&&this._controller.removeHintBubbles()},t.prototype.getSkill=function(){return this._controller.getSkill()},t.prototype._restoreQuestionState=function(){this._controller.isTemplate("question")&&(this._data.hasDisplayedHighlight&&this.displayAnswerHighlight(),
this._data.shouldShowStudentError&&this.showStudentError(),this._data.shouldShowStudentError||this.clearStudentError(),this._data.hasDisplayedResult&&this.displayResult(),this._data.hasDisplayedAnswer&&this.displayAnswer())},t.prototype.showSolution=function(){var t=this._controller.getSkill().getAnswerTemplate();t.isEmpty()?this.displayAnswer():this.swapTemplate("answer")},t.prototype.swapTemplate=function(t,e){this._controller.swapTemplate(t,this._restoreQuestionState.bind(this)),this._publishTemplateChange(e)},t.prototype.swapLastTemplate=function(){this._controller.swapLastTemplate(this._restoreQuestionState.bind(this)),this._publishTemplateChange()},t.prototype.resize=function(){this._controller.resize()},t.prototype.clear=function(){this._controller.clear()},t.prototype.toggleHint=function(){this._controller.isTemplate("hint")?this.swapLastTemplate():this.swapTemplate("hint")},t.prototype._setCurrency=function(t){this._data.currency=t.currency},t.prototype.hasManipulatives=function(){return this.getSkill().hasManipulatives()},t.prototype.setManipulatives=function(t){var e={},i=t.replace(/\s+/g,"").toLowerCase();"coins"===i&&(i+="-"+this._data.currency),e[i]="*",this._controller.setMenuManipulatives(e),this._ps.publish("use-tool",{category:"tool",type:t})},t.prototype.eraseAllManipulatives=function(){this._controller.eraseAllManipulatives()},t.prototype.getTools=function(){return this.getSkill().getTools()},t.prototype.removeHintBubbles=function(){this._data.hasDisabledHintBubbles=!0,this._controller.removeHintBubbles()},t}();return t.Ctrl=i,t}(QI._ctrl||{},QI._settings),QI._ctrl.analytics=function(t){"use strict";function e(t){t.subscribe("ctrl-init",function(t){s=t.skill.getId()})}function i(t,e){if(_.isUndefined(s))return void console.error("[QI] The controller must be initialized before events can be tracked.");try{_.isUndefined(e)?_gaq.push(["_trackEvent","Questions",t,s+""]):_gaq.push(["_trackEvent","Questions",t,s+"",e])}catch(i){console.log("[Track Event] Skill:"+s+", Action:"+t+", Value:"+e)}}var s;return t.init=e,t._trackEvent=i,t}(QI._ctrl.analytics||{}),QI.HintTracker=function(){var t=function(t){this._trackEvent=t,this._trackerData={}};return t.prototype.reset=function(){this._trackerData={}},t.prototype._trackEventAction=function(t,e){this._trackEvent(t,e)},t.prototype.openHint=function(t){this._trackerData[t.identifier]?this._trackerData[t.identifier].count++:this._trackerData[t.identifier]={hintType:t.type,hintIcon:t.icon,hintContentNumber:t.contentNumber,count:1}},t.prototype._getCount=function(t){return this._trackerData[t]?this._trackerData[t].count:0},t.prototype._getTotalCount=function(){var t=0;for(var e in this._trackerData)t+=this._getCount(e);return t},t.prototype.trackEvents=function(t){this._trackOutcome(t),this._trackUsage(t),this._trackEffectiveness(t)},t.prototype._trackOutcome=function(t){var e=t.isCorrect?t.isSecChance?"CorrectHintSC":"CorrectHint":t.isSecChance?"IncorrectHintSC":"IncorrectHint";this._trackEventAction(e,this._getTotalCount())},t.prototype._trackUsage=function(){_.forEach(this._trackerData,function(t,e){if(t.hintType){var i="Open"+_.capitalize(t.hintType)+" "+e;this._trackEventAction(i,this._getCount(e))}if(t.hintIcon){var s="OpenHintBubble ("+t.hintIcon+")";this._trackEventAction(s,this._getCount(e))}}.bind(this))},t.prototype._trackEffectiveness=function(t){_.forEach(this._trackerData,function(e,i){var s=JSON.stringify({criteria:"hint-bubble-effectiveness",hintIdentifier:i,hintContentNumber:e.hintContentNumber,chanceNumber:t.isSecChance?2:1}),n=t.isCorrect?1:0;this._trackEventAction(s,n)}.bind(this))},t}(),QI._ctrl.analytics=function(t,e){"use strict";function i(t){t.subscribe("ctrl-init",s),t.subscribe("template-change",n),t.subscribe("ctrl-submit",o)}function s(i){r=new e(t._trackEvent),l=!1;var s=i.splitTestingFlags;a=s.isHintBubbleIconSplitTestEnabled,c=s.isHintBubbleContentSplitTestEnabled}function n(t){var e=(t.template,t.templateState,t.controller);e.trackHintBubbleUsage(r.openHint.bind(r))}function o(e){var i=e.outcome;switch("correct"!==i&&"incorrect"!==i&&"second-chance"!==i||(r.trackEvents({isCorrect:"correct"===i,isSecChance:l}),r.reset(),l=!0),i){case"correct":t._trackEvent("CorrectAnswer");break;case"incorrect":t._trackEvent("IncorrectAnswer")}}var r,l,a,c;return t.trackFlow=i,t}(QI._ctrl.analytics,QI.HintTracker),QI._ctrl.analytics=function(t,e){"use strict";function i(t){t.subscribe("ctrl-init",s),t.subscribe("use-tool",n)}function s(){o=[]}function n(e){var i=e.category,s=e.type;"tool"===i&&(_.includes(o,s)||(o.push(s),t._trackEvent("Tool"+s.replace(/\s+/g,""))))}var o;return t.trackTools=i,t}(QI._ctrl.analytics||{},QI._events),QI._ctrl.analytics=function(t,e){"use strict";function i(t){t.subscribe("use-tool",s)}function s(e){var i=e.category;"tts"===i&&t._trackEvent("TTS")}return t.trackTTS=i,t}(QI._ctrl.analytics||{},QI._events,QI._settings),QI._elements=function(t){function e(t){return new s({model:new i(t)})}var i=Backbone.Model.extend({defaults:{question:void 0,template:"question",audio:void 0},initialize:function(t){t.subscribe("ctrl-init",this._setQuestion.bind(this)),t.subscribe("template-change",this._setTemplate.bind(this)),t.subscribe("template-change",this.resetAudio.bind(this)),this.ps=t},_setQuestion:function(t){this.set("question",t.question)},_setTemplate:function(t){this.set("template",t.template)},resetAudio:function(){_.isUndefined(this.get("audio"))||(this.get("audio").pause(),$(this.get("audio")).off(),this.unset("audio"),this.trigger("audio-ended"))},loadAudio:function(){if(this.ps.publish("use-tool",{category:"tts",type:this.get("template")}),_.isUndefined(this.get("audio"))){var t=document.createElement("audio"),e=this.get("template"),i=this.get("question");t.src=i.getTtsSource(e),t.autoplay=!0,$(t).one("play",function(){this.trigger("audio-loaded")}.bind(this)).on("ended",function(){this.trigger("audio-ended")}.bind(this)),t.load(),this.set("audio",t)}else this.trigger("audio-loaded")},playAudio:function(){var t=this.get("audio");!_.isUndefined(t)&&t.paused&&t.play()},isAudioLoading:function(){var t=this.get("audio");return!_.isUndefined(t)&&t.paused},isAudioPlaying:function(){var t=this.get("audio");return!_.isUndefined(t)&&!t.paused}}),s=Backbone.View.extend({className:"button audio-button",template:_.template('<i class="fa fa-volume-off"></i>'),initialize:function(){this.listenTo(this.model,"audio-loaded",this.playAudio),this.listenTo(this.model,"audio-ended",this.stopAudio),this.render(),$(".qi-container .qi").append(this.$el)},events:{touchstart:"touchButton",mousedown:"pressButton"},touchStart:function(t){this.$el.addClass("active")},touchButton:function(t){this.$el.removeClass("active"),t.preventDefault(),this.pressButton(t)},pressButton:function(t){QI._playSfx(),this.model.isAudioPlaying()||this.model.isAudioLoading()?this.stopAudio():(this.changeIcon("fa-spinner qi-icon-pulse"),this.model.loadAudio())},changeIcon:function(t){t="fa "+t;var e=this.$("i");e[0].className!==t&&(this.timeout&&clearTimeout(this.timeout),e.css({"-webkit-transform":"perspective(1px) scale(0.8)",transform:"perspective(1px) scale(0.8)"}),this.timeout=setTimeout(function(){e.css({"-webkit-transform":"perspective(1px) scale(1)",transform:"perspective(1px) scale(1)"})[0].className=t},100))},render:function(){this.$el.html(this.template(this.model.attributes)).css({top:"15px"})},playAudio:function(){this.changeIcon("fa-volume-up"),this.model.playAudio()},stopAudio:function(){this.$el.removeClass("disabled"),this.changeIcon("fa-volume-off"),this.model.resetAudio()},clear:function(){this.model.resetAudio(),this.$el.empty().remove(),this.remove()}});return t.AudioButton=e,t}(QI._elements||{},QI._events),QI._elements=function(t){"use strict";function e(t,e){return new s({model:new i(t,e)})}var i=Backbone.Model.extend({defaults:{isHintEnabled:!1,isHintOpen:!1,ctrl:void 0},initialize:function(t,e){var i=e.secondChance;this.set({isHintEnabled:i}),t.subscribe("ctrl-init",this._setCtrl.bind(this)),i&&t.subscribe("template-change",this._setHintOpen.bind(this))},_setCtrl:function(t){this.set("ctrl",t.ctrl),t.controller.hasHintBubbles()&&(this.get("isHintEnabled")||t.ctrl.removeHintBubbles(),this.set("isHintEnabled",!1))},_setHintOpen:function(t){var e=t.template,i="hint"===e;this.set("isHintOpen",i)},toggleHint:function(){this.get("isHintEnabled")&&this.get("ctrl").toggleHint()}}),s=Backbone.View.extend({className:"button hint-button",template:_.template('<i class="fa fa-lightbulb-o"></i>'),initialize:function(){this.listenTo(this.model,"change:isHintEnabled",this.changeEnabled),this.model.get("isHintEnabled")?this.listenTo(this.model,"change:isHintOpen",this.changeIcon):this.$el.addClass("disabled"),this.render(),$(".qi-container .qi").append(this.$el)},events:{touchstart:"touchButton",mousedown:"pressButton"},changeEnabled:function(){this.model.get("isHintEnabled")||this.$el.addClass("disabled")},touchStart:function(t){this.$el.addClass("active")},touchButton:function(t){this.$el.removeClass("active"),t.preventDefault(),this.pressButton(t)},changeIcon:function(){var t="fa "+(this.model.get("isHintOpen")?"fa-remove":"fa-lightbulb-o"),e=this.$("i");e[0].className!==t&&(this.timeout&&clearTimeout(this.timeout),e.css({"-webkit-transform":"scale(0.8)",transform:"scale(0.8)"}),this.timeout=setTimeout(function(){e.css({"-webkit-transform":"scale(1)",transform:"scale(1)"})[0].className=t},100))},pressButton:function(){QI._playSfx(),this.model.toggleHint()},render:function(){this.$el.html(this.template(this.model.attributes)).css({top:"90px"})},clear:function(){this.$el.empty(),this.remove()}});return t.HintButton=e,t}(QI._elements||{}),QI._elements=function(t){var e=Backbone.Model.extend({defaults:{state:"default",template:"question",text:"GO",handler:void 0,className:""},initialize:function(t){function e(t){o=t.ctrl}function i(t){var e=t.outcome;switch(e){case"correct":case"incorrect":case"second-chance":n.call(this,e)}}function s(t){var e,i=t.template,s=t.templateState;switch(i){case"question":switch(s){case"display-answer":e="correct";break;case"display-result":e="incorrect";break;default:e="default"}break;case"hint":case"answer":e=i}n.call(this,e),this.set("template",i)}function n(t){var e,i;switch(t){case"correct":e="CLOSE",i=QI.teardown;break;case"incorrect":e="NEXT",i=o.showSolution.bind(o);break;case"default":e="GO",i=o.publishSubmitState.bind(o);break;case"second-chance":e="TRY AGAIN",i=o.toggleHint.bind(o);break;case"hint":e="CLOSE HINT",i=o.toggleHint.bind(o);break;case"answer":e="NEXT",i=o.displayAnswer.bind(o)}"hint"===t?this.set({text:e,handler:i}):this.set({state:t,text:e,handler:i})}t.subscribe("ctrl-init",e.bind(this)),t.subscribe("ctrl-submit",i.bind(this)),t.subscribe("template-change",s.bind(this));var o}}),i=Backbone.View.extend({changeText:function(){this.$("div").text(this.model.get("text"))},changeTemplate:function(){this.$el.attr("data-template",this.model.get("template"))},changeState:function(){this.$el.attr("data-state",this.model.get("state"))},changeHandler:function(){var t=this.model.get("handler");this.$el.off("touchend mouseup").on("touchend mouseup",function(e){e.preventDefault(),QI._playSfx(),_.isFunction(t)&&t()})},initialize:function(){this.listenTo(this.model,"change:text",this.changeText),this.listenTo(this.model,"change:template",this.changeTemplate),this.listenTo(this.model,"change:state",this.changeState),this.listenTo(this.model,"change:handler",this.changeHandler),this.render(),$(".qi-container .qi").append(this.$el)},className:"go-button",attributes:{"data-template":"question","data-state":"default"},template:_.template('<div style="position: relative; top: 50%; transform: translateY(-50%); -webkit-transform: translateY(-50%)">GO</div>'),render:function(){this.$el.html(this.template(this.model.attributes))},events:{touchend:"submit",mouseup:"submit"},clear:function(){this.$el.empty(),this.remove()}}),s=function(t){return new i({model:new e(t)})};return t.GoButton=s,t}(QI._elements||{}),QI._elements=function(t){function e(t){return new s({model:new i(t)})}var i=Backbone.Model.extend({initialize:function(t){t.subscribe("ctrl-submit",this._setBannerState.bind(this)),t.subscribe("times-up",this._setTimesUpState.bind(this))},_setBannerState:function(t){var e=t.outcome;switch(e){case"correct":QI._playCorrectSfx(),setTimeout(function(){QI.teardown()},3600),this.trigger("show-correct");break;case"second-chance":case"incorrect":this.trigger("show-incorrect")}},_setTimesUpState:function(t){this.trigger("show-timesup"),setTimeout(function(){t.ps.publish("force-close",{$container:t.$container})}.bind(this),3600)}}),s=Backbone.View.extend({initialize:function(){this.listenTo(this.model,"show-correct",this.showCorrectBanner),this.listenTo(this.model,"show-incorrect",this.showIncorrectBanner),this.listenTo(this.model,"show-timesup",this.showTimesUpBanner),this.render(),$(".qi-container .qi").append(this.$el)},className:"qi-banner",template:_.template('<div class="qi-banner-contents"><div class="qi-banner-inner-contents"></div></div>'),render:function(){this.$el.html(this.template(this.model.attributes))},showCorrectBanner:function(){this.$(".qi-banner-inner-contents").html('<i class="fa fa-star star"></i><i class="fa fa-star star bright"></i><i class="fa fa-star star bright"></i><i class="fa fa-star-o star bright"></i><i class="fa fa-star-o star"></i><i class="fa fa-star-o star"></i><img style="position:absolute;z-index: -1; bottom: 25px; left:260px" src="https://web.archive.org/web/20161210015218/https://prodigy.blob.core.windows.net/edu-question-interface-2-1-3/images/ed-correct.png"></img><div class="qi-check-mark"></div><div class="qi-banner-contents-message">CORRECT!</div>'),_.each(this.$(".star"),function(t){var e="translate("+Math.floor(800*(Math.random()-.9))+"px, "+Math.floor(250*(Math.random()-.5))+"px)",i="rotate("+Math.floor(360*Math.random())+"deg)",s=e+" "+i;$(t).css({"-webkit-transform":s,transform:s,"font-size":30+Math.floor(100*Math.random())+"px"})}),this.resetState("correct")},showIncorrectBanner:function(){this.$(".qi-banner-inner-contents").html('<div class="qi-banner-contents-message">Oops...</div>'),this.resetState("incorrect")},showTimesUpBanner:function(){this.$el.remove(),$(".qi-container .qi").append(this.$el),this.$(".qi-banner-inner-contents").html('<div class="qi-banner-contents-message">Sorry, Time\'s Up!</div>'),this.resetState("times-up")},resetState:function(t){this.$el.attr("data-state",t),"correct"!==t&&setTimeout(function(){this.$el.attr("data-state","")}.bind(this),3e3)},clear:function(){this.timedCallback&&(clearTimeout(this.timedCallback),this.timedCallback=void 0),this.$el.empty(),this.remove()}});return t.Banner=e,t}(QI._elements||{},QI._events),QI._elements=function(t){function e(t){return new s({model:new i(t)})}var i=Backbone.Model.extend({defaults:{message:"",status:""},initialize:function(t){t.subscribe("ctrl-init",this._setHelpMessage.bind(this)),t.subscribe("ctrl-submit",this._setNoticeByOutcome.bind(this)),t.subscribe("template-change",this._setNoticeByTemplate.bind(this))},_setHelpMessage:function(t){var e=t.skill.getHelpMessage();this.set("helpMessage",e)},_setNoticeByOutcome:function(t){var e,i=t.outcome;switch(i){case"incorrect":e="That answer was incorrect.";break;case"invalid":e=this.get("helpMessage");break;case"sc-invalid":e="Change your answer before casting your spell!",i="invalid";break;case"second-chance":e="That answer was incorrect. Let's look at the hint and try again!"}_.isUndefined(i)||this.set("status",i),_.isUndefined(e)||(this.set("message",e),this.trigger("change:message"))},_setNoticeByTemplate:function(t){var e,i,s=t.template,n=t.templateState;switch(s){case"question":switch(n){case"display-answer":e="correct",i="This is the correct answer!";break;case"display-result":e="incorrect",i="That answer was incorrect.";break;default:i=""}break;case"answer":e="correct",i="This is how you get the correct answer."}_.isUndefined(e)||this.set("status",e),_.isUndefined(i)||this.set("message",i)}}),s=Backbone.View.extend({initialize:function(t){this.render(),$(".qi-container .qi").append(this.$el),this.listenTo(this.model,"change:message",this.changeMessage),this.listenTo(this.model,"change:status",this.changeStatus)},className:"qi-notice",template:_.template('<i style="float:right; padding-top:3px" class="qi-notice-close fa fa-times"></i><div style="float:left; width:920px" class="message"></div>'),render:function(){this.$el.html(this.template(this.model.attributes))},events:{touchstart:"hideNotice",click:"hideNotice"},showNotice:function(){this.$el.addClass("pop-up")},hideNotice:function(){this.$el.removeClass("pop-up")},changeMessage:function(){var t=this.model.get("message");this.$(".message").html(t),_.isEmpty(t)?this.hideNotice():this.showNotice()},changeStatus:function(){this.$el.attr("data-status",this.model.get("status"))},clear:function(){this.$el.empty(),this.remove()}});return t.Notice=e,t}(QI._elements||{});var QI=QI||{};QI.Key=Backbone.Model.extend({}),QI.KeyView=Backbone.View.extend({className:"key",events:{touchstart:"touchStart",touchend:"touchKey",click:"pressKey"},touchStart:function(t){this.$el.addClass("active")},touchKey:function(t){this.$el.removeClass("active"),t.preventDefault(),this.pressKey(t)},pressKey:function(t){this.$el.hasClass("disabled")||(QI._playSfx(),$("textarea.control.focus").trigger("qi-input",this.model.get("symbol")))},render:function(){switch(this.model.get("symbol")){case"DEL":this.$el.html('<div class="qi-backspace">×</div>').css({"float":"right"});break;case" ":this.$el.text("SPACE").css({"float":"right","font-size":"18px","font-weight":"bold"});break;default:this.$el.text(this.model.get("symbol"))}}}),QI._elements=function(t){function e(t){return new s({collection:new i(t)})}var i=Backbone.Collection.extend({model:QI.Key,initialize:function(t){function e(e){function i(t){var e=t.template,i=t.templateState,s="question"===e&&"display-result"!==i&&"display-answer"!==i;s?this.trigger("enable-keyboard"):this.trigger("disable-keyboard")}var s=e.skill;s.isType("tb")?t.subscribe("template-change",i.bind(this)):this.trigger("disable-keyboard")}t.subscribe("ctrl-init",this._resetKeyboardCharacters.bind(this)),t.subscribe("ctrl-init",e.bind(this))},_resetKeyboardCharacters:function(t){var e=t.skill,i=t.question.getId(),s=e.getAnswerCharacters(),n=22;s.length>n-1&&(s=e.getAnswerCharacters(i)),s.push("DEL");for(var o=[" ","0123456789",".","/","+-×÷","<>=",":","%","√∛","xyzab",".","/"],r=0,l=s.length-1;r<l&&r<n;r++)_.find(o,function(t,e){if(_.includes(t,s[r]))return o.splice(e,1),s=s.concat(_.difference(t.split(""),s)),!0});for(var r=0;r<o.length&&s.length+o[r].length<=n;r++)s=s.concat(o[r].split(""));var a={1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,0:10,DEL:11,"+":20,"-":21,"×":22,"÷":23,".":24,"/":25,"<":30,">":31,"=":32,":":33,"%":34,"√":35,"∛":36,x:37,y:38,z:39,a:40,b:41," ":100};s=s.splice(0,n),s=_.sortBy(s,function(t){return a[t]||50});for(var c=[],r=0;r<s.length;r++)c.push({symbol:s[r]});this.reset(c)}}),s=Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"add",this.addKey),this.listenTo(this.collection,"disable-keyboard",this.disableKeyboard),this.listenTo(this.collection,"enable-keyboard",this.enableKeyboard),this.listenTo(this.collection,"reset",this.render),$(".qi-container .qi").append(this.$el)},className:"keyboard",render:function(){this.$el.empty().css({position:"absolute","background-color":"#cfd1d5",height:"200px",width:"1280px",top:"540px",padding:"5px 184px 5px 7px","box-shadow":"0 0 10px #999"}),this.collection.forEach(this.addKey.bind(this),this)},addKey:function(t){var e=new QI.KeyView({model:t});e.render(),this.$el.append(e.el)},disableKeyboard:function(){this.$(".key").addClass("disabled")},enableKeyboard:function(){this.$(".key.disabled").removeClass("disabled")},isEnabled:function(){return!this.$(".key").hasClass("disabled")},clear:function(){this.collection.reset(),this.$el.empty(),this.remove()}});return t.Keyboard=e,t}(QI._elements||{},QI._events,QI._ctrl);var QI=QI||{};QI.CalculatorKey=Backbone.Model.extend({}),QI.CalculatorKeyView=Backbone.View.extend({className:"key",events:{touchstart:"touchKey",touchend:"pressKey",click:"pressKey"},render:function(){var t=this.model.get("symbol");"⌫"===t&&(t='<i class="fa fa-arrow-circle-left"></i>'),this.$el.addClass(this.model.get("class")).html(t)},touchKey:function(t){this.$el.addClass("active"),t.preventDefault()},pressKey:function(){switch(this.$el.removeClass("active"),this.model.get("symbol")){case"=":this.model.collection.trigger("press-evaluate");default:this.model.collection.trigger("press-key",this.model.get("symbol"))}}});var QI=QI||{};QI.Calculator=Backbone.Collection.extend({model:QI.CalculatorKey,initialize:function(t,e){this.reset([{symbol:"±","class":"function"},{symbol:"√","class":"function"},{symbol:"^","class":"function"},{symbol:"π","class":"function"},{symbol:"CLEAR","class":"clear"},{symbol:"⌫","class":"backspace"},{symbol:"÷","class":"operation"},{symbol:"7"},{symbol:"8"},{symbol:"9"},{symbol:"×","class":"operation"},{symbol:"4"},{symbol:"5"},{symbol:"6"},{symbol:"−","class":"operation"},{symbol:"1"},{symbol:"2"},{symbol:"3"},{symbol:"+","class":"operation"},{symbol:"0"},{symbol:"."},{symbol:"=","class":"evaluate"}])},pressKey:function(t){this.trigger("select-color",color),this.isSelected=!0},deselectColor:function(){this.trigger("deselect-color"),this.isSelected=!1},open:function(){this.trigger("open")},close:function(){this.trigger("close")},erase:function(){this.trigger("erase")},_lex:function(t){var e,i=function(t){return/[\+\−\×\÷\-\√\^\(\)]/.test(t)},s=function(t){return/[0-9]/.test(t)},n=function(t){return/π/.test(t)},o=[],r=0;for(advanceChar=function(){return e=t[++r]};r<t.length;)if(e=t[r],i(e))o.push({type:e}),advanceChar();else{if(!s(e)&&!n(e))throw"Unrecognized token "+e;var l,a=1,c=1;if(s(e)){for(a=e;s(advanceChar());)a+=e;if("."===e)do a+=e;while(s(advanceChar()));a=parseFloat(a)}if(n(e)){switch(e){case"π":c=Math.PI}advanceChar()}if(l=a*c,_.isNaN(l)||!_.isFinite(l))throw"Error";o.push({type:"number",value:l})}return o.push({type:"EOL"}),o},_parse:function(t){var e={},i=function(t,i,s,n){var o=e[t]||{};e[t]={lbp:o.lbp||s,nud:o.nud||i,led:o.lef||n}},s=0,n=t[s],o=function(){return n=t[++s]},r=function(t){if("EOL"===n.type)throw"Unexpected EOL";if(!_.isFunction(e[n.type].nud))throw"Unexpected token: "+n.type;var i,s=n;for(o(),i=e[s.type].nud(s);t<e[n.type].lbp;){if(s=n,o(),!_.isFunction(e[s.type].led))throw"Unexpected token: "+s.type;i=e[s.type].led(i)}return i},l=function(t,e,s,n){s=s||e,i(t,null,e,n||function(e){return{type:t,left:e,right:r(s)}})},a=function(t,e){i(t,function(){return{type:t,right:r(e)}})};i(")"),i("EOL"),i("number",function(t){return t}),i("(",function(){var t=r(2);if(")"!==n.type)throw"Expected missing token";return o(),t}),a("-",7),a("√",7),l("^",6,5),l("×",4),l("÷",4),l("+",3),l("−",3);var c=r(0);if("EOL"!==n.type)throw"Expected EOL";return c},_evaluate:function(t,e){var i,s,n=function(t){if(_.isNaN(t)||!_.isFinite(t))throw"Error";return t},o=function(t){return _.includes(t,".")?t.indexOf("."):t.length};try{var r={"+":function(t,e){return n(t+e)},"−":function(t,e){return n(t-e)},"×":function(t,e){return n(t*e)},"÷":function(t,e){if(0===e)throw"Math error";return n(t/e)},"√":function(t){if(t<0)throw"Math error";return n(Math.sqrt(t))},"^":function(t,e){return n(Math.pow(t,e))},"-":function(t){return n(-t)}},l=function(t){if("number"===t.type)return t.value;if(_.isUndefined(r[t.type]))throw"Unexpected node "+t;return t.left?r[t.type](l(t.left),l(t.right)):r[t.type](l(t.right))};i=l(this._parse(this._lex(t))),s=i.toString()}catch(a){throw a}if(_.isNaN(i)||!_.isFinite(i))return"Error";if(_.includes(s,"e")){var c=s.split(/e(\+|\-)?/),u=parseFloat(c[0]).toString(),h=c[1],d=parseInt(c[2]);if("-"===h){var f=u.length-o(u),p=Math.max(f+d,u.length);if(p>20)throw"Underflow";s=i.toFixed(p)}else{var m=Math.max(u.replace(".","").length+d,u.length);if(m>21)throw"Overflow";s=i.toPrecision(m)}}if(s.length>e){var m=Math.max(0,e-o(s)-1);if(m>20)throw"Underflow";if(s=i.toFixed(m),o(s)>e)throw"Overflow";var g=s.search("[1-9]");if(g>e||g===-1)throw"Underflow"}return s},_isValid:function(t,e){try{return this._parse(this._lex(t)),!0}catch(i){return("Unexpected EOL"===i||"Expected missing token"===i)&&!e}}}),QI.CalculatorView=Backbone.View.extend({className:"calculator",template:_.template('<div class="side-panel"><div class="calculator"><div class="screen"><div class="answer"> </div><div class="input-wrapper"><div class="input">0</div></div></div><div class="keys"></div></div></div>'),initialize:function(){this.listenTo(this.collection,"press-key",this.pressKey),this.listenTo(this.collection,"press-evaluate",this.pressEvaluate),this.listenTo(this.collection,"close",this.close),this.listenTo(this.collection,"open",this.open)},addKey:function(t){var e=new QI.CalculatorKeyView({model:t});e.render(),this.$(".calculator .keys").append(e.el)},render:function(){this.$el.html(this.template(this.collection.attributes)),this.collection.forEach(this.addKey.bind(this),this)},pressKey:function(t){var e=this.$(".answer").hasClass("eqn"),i=this.$(".screen").hasClass("error");e&&this.$(".answer").html(i?"":"ANS = "+this.$(".input").html());var s=i||e&&!/[\+\−\×\÷\-\√\^\±\⌫CLEAR]/.test(t)?"0":this.$(".input").html();/^-/.test(s)&&(s="("+s+")"),this.$(".answer").removeClass("eqn");var n,o=s.split(/\+|\−|\×|\÷|\^/g),r=_.last(o),l=s.slice(0,-r.length),a=function(t){return/^\(-.*\)$/.test(t)},c=function(t){return/^\(√.*\)$/.test(t)};switch(t){case"⌫":n=a(r)||c(r)?l+r.slice(2,-1):s.slice(0,-1)||"0";break;case"CLEAR":n="0";break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":"0"===r&&(n=l+t);break;case"π":/\.$/g.test(r)?n=l+r+"0"+t:_.isEmpty(l)&&"0"===r&&(n=t);break;case"^":case"+":case"−":case"×":case"÷":/\.$/g.test(r)&&(n=l+r+"0"+t);break;case"±":_.isEmpty(r)||(n=/^0.?0*$/g.test(r)?s:a(r)?l+r.slice(2,-1):l+"(-"+(/\.$/g.test(r)?r+"0":r)+")");break;case"√":n=_.isEmpty(r)?s:l+"(√"+(/\.$/g.test(r)?r+"0":r)+")";break;case".":n=_.isEmpty(r)?s+"0.":s+"."}n=_.isUndefined(n)?s+t:n,this.collection._isValid(n)?(this.$(".screen").removeClass("error"),n!==s||n!==this.$(".input").text()?this.$(".input").html(n).parent().scrollLeft(20*n.length):(this.$(".screen").removeClass("invalid"),setTimeout(function(){this.$(".screen").addClass("invalid")}.bind(this),0))):(this.$(".screen").removeClass("invalid"),setTimeout(function(){this.$(".screen").addClass("invalid")}.bind(this),0))},pressEvaluate:function(){var t=this.$(".input").html();if(/\.$/g.test(t)&&(t+="0"),this.collection._isValid(t,!0)){this.$(".answer").removeClass("eqn"),setTimeout(function(){this.$(".answer").addClass("eqn").text(t.length>17?t.substring(0,14)+"... =":t+" =")}.bind(this),0);try{this.$(".input").text(this.collection._evaluate(t,12))}catch(e){this.$(".input").text(e),this.$(".screen").addClass("error")}}else this.$(".screen").removeClass("invalid"),setTimeout(function(){this.$(".screen").addClass("invalid")}.bind(this),0)},close:function(){this.$el.css({"pointer-events":"none",display:"none"})},open:function(){this.$el.css({"pointer-events":"none",display:"block"})},clear:function(){this.collection.reset(),this.$el.empty(),this.remove()}}),QI._elements=function(t){return t.ManipulativeIcon=Backbone.Model.extend({}),t.ManipulativeIconView=Backbone.View.extend({events:{touchstart:"touchIcon",mousedown:"selectIcon"},className:"manipulative-icon",template:_.template('<i class="fa fa-<%= icon %>"></i><span style=""><%= label %></span>'),render:function(){this.$el.html(this.template(this.model.attributes))},touchIcon:function(t){t.preventDefault(),this.selectIcon(t)},selectIcon:function(){this.model.collection.trigger("deselect-icons"),this.model.collection.ctrl.setManipulatives(this.model.get("label"))}}),t}(QI._elements||{}),QI._elements=function(t){return t.ManipulativeDrawer=Backbone.Collection.extend({model:t.ManipulativeIcon,initialize:function(t,e,i,s){this.ctrl=s.ctrl,this.reset([{label:"Counters",icon:"circle"},{label:"Base Blocks",icon:"cube"},{label:"Coins",icon:"usd"},{label:"Fractions",icon:"tasks"}])}}),t.ManipulativeDrawerView=Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"deselect-icons",this.deselectIcons)},events:{touchstart:"bindScroll","touchstart .fa-arrow-left":"startScrollLeft","touchend .fa-arrow-left":"endScrollLeft","click .fa-arrow-left":"scrollLeft","touchstart .fa-arrow-right":"startScrollRight","touchend .fa-arrow-right":"endScrollRight","click .fa-arrow-right":"scrollRight"},startScrollLeft:function(t){this.$(".fa-arrow-left").addClass("active")},endScrollLeft:function(t){this.$(".fa-arrow-left").removeClass("active"),t.preventDefault(),this.scrollLeft(t)},scrollLeft:function(){this.$(".manipulative-icons").scrollLeft(this.$(".manipulative-icons").scrollLeft()-80),this.checkScroll()},startScrollRight:function(t){this.$(".fa-arrow-right").addClass("active")},endScrollRight:function(t){this.$(".fa-arrow-right").removeClass("active"),t.preventDefault(),this.scrollRight(t)},scrollRight:function(){this.$(".manipulative-icons").scrollLeft(this.$(".manipulative-icons").scrollLeft()+80),this.checkScroll()},checkScroll:function(){var t=10*Math.round(this.$(".manipulative-icons").scrollLeft()/10);t>0?this.$(".fa-arrow-left").removeClass("disabled"):this.$(".fa-arrow-left").addClass("disabled"),t<80*(Math.ceil(this.collection.length/3)-3)?this.$(".fa-arrow-right").removeClass("disabled"):this.$(".fa-arrow-right").addClass("disabled")},className:"manipulative-drawer manipulative-icons",template:_.template('<div class="manipulative-icons" style="height:95%; margin:12px; overflow-x:auto;"><table style="width:100%; margin:0px"><tr style="display:-webkit-flex; display:flex"></tr><tr style="display:-webkit-flex; display:flex"></tr><tr style="display:-webkit-flex; display:flex"></tr></table></div><div style="height:12.5%; width:100%; border-top: 1px solid #999; bottom: 0px; position: absolute; border-bottom-right-radius:10px; border-bottom-left-radius:10px; background-color: #EDEDED"><i class="arrow fa fa-arrow-left" style="float:left; border-bottom-left-radius:10px"></i><span style="line-height:40px;"></span><i class="arrow fa fa-arrow-right" style="float:right; border-bottom-right-radius:10px"></i></div>'),render:function(){this.$el.html(this.template(this.collection.attributes)),this.$(".manipulative-icons").on("scroll",this.checkScroll.bind(this));for(var e,i=this.collection.models,s=0;s<i.length;s++)e=new t.ManipulativeIconView({model:i[s]}),e.render(),this.$(".manipulative-icons table tr:eq("+s%3+")").append(e.el);this.checkScroll()},addIcon:function(e){var i=new t.ManipulativeIconView({model:e});i.render(),this.$(".manipulative-icons").append(i.el)},deselectIcons:function(){this.$(".manipulative-icon.selected").removeClass("selected"),this.close()},toggle:function(){this.$el.toggleClass("open")},open:function(){this.$el.addClass("open")},close:function(){this.$el.removeClass("open")},clear:function(){this.collection.reset(),this.$el.empty(),this.remove()}}),t}(QI._elements||{});var QI=QI||{};QI.ColorSwatch=Backbone.Model.extend({selectColor:function(){this.collection.selectColor(this.get("color"))},deselectColor:function(){this.collection.deselectColor()}}),QI.ColorSwatchView=Backbone.View.extend({className:"drawing-tool",events:{touchstart:"touchColor",click:"toggleColor"},pencilTemplate:_.template('<div class="pencil" style="height:40px; float:right;"><div class="tip" style="float:left; height:40px"><div class="lead" style="border-right:20px solid <%= color %>"></div><div class="wood"></div></div><div class="body" style="background-color:<%= color %>"></div></div>'),eraserTemplate:_.template('<div class="eraser"></div>'),render:function(){this.model.get("color")?this.$el.html(this.pencilTemplate(this.model.attributes)):this.$el.html(this.eraserTemplate(this.model.attributes))},touchColor:function(t){t.preventDefault(),
this.toggleColor()},toggleColor:function(){this.$el.hasClass("selected")?this.model.deselectColor():this.model.selectColor(),this.$el.toggleClass("selected")}}),QI._elements=function(t){return t.SketchPad=Backbone.Collection.extend({model:QI.ColorSwatch,initialize:function(t,e,i,s){this.isSelected=!1,this._ps=i,this._skill=s.skill;var n=Controller.COLORS;this.reset([{color:n.navy},{color:n.blue},{color:n.teal},{color:n.darkgreen},{color:n.lightbrown},{color:n.red},{color:n.orange},{color:n.darkgrey},{color:n.black},{}])},selectColor:function(t){this.trigger("select-color",t),this.isSelected=!0},deselectColor:function(){this.trigger("deselect-color"),this.isSelected=!1},open:function(){this.trigger("open")},close:function(){this.trigger("close")},erase:function(){this.trigger("erase")}}),t.SketchPadView=Backbone.View.extend({className:"sketchpad",template:_.template('<canvas height="540px" width="960px"></canvas>'),initialize:function(){this.listenTo(this.collection,"select-color",this.setColor),this.listenTo(this.collection,"deselect-color",this.unsetColor),this.listenTo(this.collection,"clear",this.clear),this.listenTo(this.collection,"close",this.close),this.listenTo(this.collection,"erase",this.erase),this.listenTo(this.collection,"open",this.open),$(".qi-container .side-menu").prepend('<div class="side-panel"></div>')},setColor:function(t){t?(this.context.globalCompositeOperation="source-over",this.context.fillStyle=t,this.context.strokeStyle=t,this.context.lineWidth=5):(this.context.globalCompositeOperation="destination-out",this.context.fillStyle="white",this.context.strokeStyle="white",this.context.lineWidth=15),this.$("canvas").css({cursor:"crosshair"}),$(".drawing-tool.selected").removeClass("selected"),this.collection._ps.publish("use-tool",{category:"tool",type:"Draw"})},unsetColor:function(){this.$("canvas").css({cursor:"default"})},render:function(){this.$el.html(this.template(this.collection.attributes)),this.context=_.first(this.$("canvas")).getContext("2d"),this.context.lineCap="round",this.context.lineJoin="round",this.context.globalCompositeOperation="destination-out",this.unsetColor(),this.collection.forEach(this.addColorSwatch,this)},erase:function(){this.context.clearRect(0,0,960,540)},close:function(){this.$el.css({"pointer-events":"none"}),$(".drawing-tool").css({display:"none"})},open:function(){this.$el.css({"pointer-events":"all"}),$(".drawing-tool").css({display:""})},events:{"touchstart canvas":"touchPoint","touchmove canvas":"touchLine","touchend canvas":"touchUnset","mousedown canvas":"drawPoint","mousemove canvas":"drawLine","mouseup canvas":"unset","mouseleave canvas":"unset"},_isSelected:function(){return this.collection.isSelected},_simulateEvent:function(t,e,i){!this._isSelected()||this.collection._skill.hasManipulatives()?$("canvas.manipulatives").trigger(i||e):Controller.simulateEvent({event:e,type:t,selector:".qi-content",maxDistance:i?30:1})},touchPoint:function(t){t.preventDefault(),this.drawPoint(t.originalEvent.touches[0],t)},touchLine:function(t){t.preventDefault(),this.drawLine(t.originalEvent.touches[0],t)},touchUnset:function(t){t.preventDefault(),this.unset(t.originalEvent.touches[0]||t.originalEvent.changedTouches[0],t)},drawPoint:function(t,e){if(this._isSelected()){var i=this.el.getBoundingClientRect(),s=t.pageX/(i.width/this.el.offsetWidth),n=t.pageY/(i.height/this.el.offsetHeight);this._point={x:s,y:n},this.context.beginPath(),this.context.arc(s,n,this.context.lineWidth/2,0,2*Math.PI,!1),this.context.fill()}this._simulateEvent("mousedown",t,e)},drawLine:function(t,e){if(this._isSelected()&&this._point){var i=this.el.getBoundingClientRect(),s=t.pageX/(i.width/this.el.offsetWidth),n=t.pageY/(i.height/this.el.offsetHeight);this.context.beginPath(),this.context.moveTo(this._point.x,this._point.y),this.context.lineTo(s,n),this.context.closePath(),this.context.stroke(),this._point={x:s,y:n}}this._simulateEvent("mousemove",t,e)},unset:function(t,e){this._point=void 0,this._simulateEvent("mouseup",t,e)},addColorSwatch:function(t){var e=new QI.ColorSwatchView({model:t});e.render(),$(".qi .side-panel").append(e.el)},clear:function(){this.collection.reset(),this.$el.empty(),this.remove()}}),t}(QI._elements||{},QI._events);var QI=QI||{};QI.SideIcon=Backbone.Model.extend({defaults:{selectable:!0,selected:!1}}),QI.SideIconView=Backbone.View.extend({className:"side-icon",template:_.template('<i class="fa fa-<%= icon %>"></i>'),events:{touchstart:"touchIcon",click:"selectIcon"},initialize:function(){this.model.get("selected")&&this.selectIcon()},render:function(){this.$el.html(this.template(this.model.attributes)),"trash"===this.model.get("icon")&&this.$el.css({position:"absolute",bottom:"0px"})},touchIcon:function(t){t.preventDefault(),this.selectIcon(t)},selectIcon:function(t){t&&QI._playSfx(),this.model.get("selectable")&&(this.model.collection.trigger("deselect-icons"),this.$el.addClass("selected")),this.model.trigger(this.model.get("trigger")),this.model.set({selected:!1})},openManipulatives:function(){this.model.openManipulatives()},openDrawing:function(){this.model.open()},openCalculator:function(){this.model.open()}}),QI._elements=function(t){function e(t){return new s({collection:new i((void 0),(void 0),t)})}var i=Backbone.Collection.extend({model:QI.SideIcon,initialize:function(e,i,s){s.subscribe("ctrl-init",function(e){var i=e.ctrl;this.ctrl=i;var n=i.hasManipulatives();this.sketchPad=new t.SketchPad((void 0),(void 0),s,e),this.calculator=new QI.Calculator,n?this.listenTo(this,"open-manipulatives",this.openManipulatives):(this.manipulativeDrawer=new t.ManipulativeDrawer((void 0),(void 0),s,e),this.listenTo(this.manipulativeDrawer,"deselect-icons",this.openManipulatives)),this.listenTo(this,"open-sketchpad",this.openSketchPad),this.listenTo(this,"open-calculator",this.openCalculator),this.listenTo(this,"erase-all",this.eraseAll);var o=[{icon:"th",trigger:"open-manipulatives",selected:n},{icon:"pencil",trigger:"open-sketchpad",selected:!n},{icon:"trash",trigger:"erase-all",selectable:!1}],r=i.getTools();_.includes(r,"calculator")&&o.push({icon:"calculator",trigger:"open-calculator",selected:!1}),o.push({icon:"trash",trigger:"erase-all",selectable:!1}),this.reset(o)}.bind(this))},openManipulatives:function(){this._closeAll()},eraseAll:function(){this.ctrl.eraseAllManipulatives(),this.sketchPad.erase()},_closeAll:function(){this.sketchPad.close(),this.calculator.close()},openSketchPad:function(){this._closeAll(),this.sketchPad.open()},openCalculator:function(){this._closeAll(),this.calculator.open()}}),s=Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"add",this.addIcon),this.listenTo(this.collection,"deselect-icons",this.deselectIcons),this.listenTo(this.collection,"open-manipulatives",this.openManipulatives),this.listenTo(this.collection,"open-sketchpad",this.openSketchPad),this.listenTo(this.collection,"open-calculator",this.openCalculator),this.listenTo(this.collection,"reset",this.render),$(".qi-container .side-menu").append(this.$el)},className:"side-bar",render:function(){this.$el.css({"pointer-events":"all",position:"absolute","background-color":"#cfd1d5",height:"540px",width:"80px",top:"0px",left:"1200px"}),this.collection.forEach(this.addIcon.bind(this),this)},addIcon:function(t){var e=new QI.SideIconView({model:t});e.render(),this.$el.append(e.el)},deselectIcons:function(){this.$(".side-icon.selected").removeClass("selected")},_closePanels:function(){_.isUndefined(this.sketchPadView)||this.sketchPadView.close(),_.isUndefined(this.calculatorView)||this.calculatorView.close(),$(".qi .side-panel").css("display","block")},openManipulatives:function(){!_.isUndefined(this.collection.manipulativeDrawer)&&_.isUndefined(this.manipulativeDrawerView)&&(this.manipulativeDrawerView=new t.ManipulativeDrawerView({collection:this.collection.manipulativeDrawer}),this.manipulativeDrawerView.render(),$(".qi-container .qi").append(this.manipulativeDrawerView.$el)),setTimeout(function(){_.isUndefined(this.manipulativeDrawerView)||(this._closePanels(),this.manipulativeDrawerView.toggle()),$(".qi .side-panel").css("display","none")}.bind(this,0))},openSketchPad:function(){!_.isUndefined(this.collection.sketchPad)&&_.isUndefined(this.sketchPadView)&&(this.sketchPadView=new t.SketchPadView({collection:this.collection.sketchPad}),this.sketchPadView.render(),this.$el.before(this.sketchPadView.$el)),_.isUndefined(this.sketchPadView)||(this._closePanels(),this.sketchPadView.open(),this.manipulativeDrawerView&&this.manipulativeDrawerView.close())},openCalculator:function(){!_.isUndefined(this.collection.calculator)&&_.isUndefined(this.calculatorView)&&(this.calculatorView=new QI.CalculatorView({collection:this.collection.calculator}),this.calculatorView.render(),this.$el.before(this.calculatorView.$el)),_.isUndefined(this.calculatorView)||(this._closePanels(),this.calculatorView.open(),this.manipulativeDrawerView&&this.manipulativeDrawerView.close())},clear:function(){this.collection.reset(),this.sketchPadView&&this.sketchPadView.clear(),this.calculatorView&&this.calculatorView.clear(),this.manipulativeDrawerView&&this.manipulativeDrawerView.clear(),this.$el.empty(),this.remove()}});return t.SideBar=e,t}(QI._elements||{}),QI._setup=function(t){"use strict";var e=function(){function t(t){function e(t){if(s||n)throw"[QI] Cannot add multiple loading screens.";s=t.$container,n=$(document.createElement("div")),n.text("LOADING...").css({position:"relative",top:"50%","text-align":"center","font-family":"Roboto","font-size":"50px","letter-spacing":"1px",color:"white","text-shadow":"-1px -1px 0 black, 1px -1px 0 black, -1px 1px 0 black, 1px 1px 0 black","-webkit-transform":"translateY(-50%)",transform:"translateY(-50%)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"}),s.css({display:"none"}).before(n)}function i(){s&&n&&(s.css("display","block"),n.remove()),s=void 0,n=void 0}t.subscribe("setup-init",e),t.subscribe("ctrl-init",i),t.subscribe("teardown-init",i),t.subscribe("force-close",i);var s,n}return t}();return t.LoadingScreen=e,t}(QI._setup||{}),QI._setup=function(t){"use strict";var e=function(){function t(t){function e(t){o=t.$container,o.is("#qi-test")||o.css("width","100%"),o.css({"pointer-events":"all",display:"block",position:"absolute",height:"100%","min-height":"100%",top:"0px",left:"0px"})}function i(){_.isUndefined(o)||(o.css({"pointer-events":"none",display:"none"}),o=void 0)}function s(t){"correct"===t.outcome&&n()}function n(){_.isUndefined(o)||o.addClass("fade-out")}t.subscribe("setup-init",e),t.subscribe("teardown-init",i),t.subscribe("force-close",i),t.subscribe("ctrl-submit",s),t.subscribe("times-up",n);var o}return t}();return t.Transitions=e,t}(QI._setup||{},QI._events),QI._setup=function(t,e){"use strict";var i=function(){function t(t){function i(i){function s(){n.addClass("qi-container").html('<div class="qi-overlay"></div><div class="qi-content"></div><div class="qi"><div class="side-menu"></div></div>')}function r(){o=[new e.Notice(t),new e.AudioButton(t),new e.Keyboard(t),new e.SideBar(t),new e.HintButton(t,i),new e.Banner(t),new e.GoButton(t)]}!n&&_.isUndefined(o)&&(n=i.$container,s(),r())}function s(){function t(){for(;!_.isEmpty(o);){var t=o.pop();t.clear(),t=null}}function e(){n.removeClass("qi-container loaded fade-out").empty()}n&&!_.isUndefined(o)&&(t(),e()),n=void 0,o=void 0}t.subscribe("setup-init",i),t.subscribe("teardown-init",s),t.subscribe("force-close",s);var n,o}return t}();return t.Elements=i,t}(QI._setup||{},QI._elements),QI._setup=function(t){"use strict";function e(t){t.subscribe("ctrl-init",i),t.subscribe("teardown-init",s),t.subscribe("force-close",s)}function i(t){function e(){var t=$(".qi-container"),e=t.outerWidth()||window.innerWidth,s=t.height()||window.innerHeight,n=t.offset()||{top:0,left:0},o="scale("+e/1280+","+s/720+")";t.find(".qi").css({top:n.top||0,left:n.left||0,"-webkit-transform":o,transform:o}),i.resize()}var i=t.controller;$(window).off("resize.qi").on("resize.qi",e).trigger("resize")}function s(){$(window).off("resize.qi")}return t.fullscreenResize=e,t}(QI._setup||{}),QI._setup=function(t){"use strict";function e(t){t.subscribe("ctrl-init",i),t.subscribe("teardown-init",n),t.subscribe("force-close",n),t.subscribe("template-change",s)}function i(t){function e(t){a.focusNextTextBox(),t.preventDefault()}function i(t){var e=$(".qi-container .go-button")[0].getBoundingClientRect(),i=e.left+e.width/2,s=e.top+e.height/2,n=$(document.elementFromPoint(i,s));n.mouseup(),t.preventDefault()}function s(t){var e=$(a.getFocusedTextBox());e.is(":focus")&&!e.prop("readOnly")||(Controller.isIE()?(t.preventDefault(),8===t.keyCode?e.trigger("qi-input","DEL"):t["char"]&&1===t["char"].length&&e.trigger("qi-input",t["char"]),setTimeout(function(){e.trigger("qi-focus").prop("readOnly",!1).focus()},0)):e.trigger("qi-focus").prop("readOnly",!1).focus())}var n,l=t.skill,a=(t.question,t.controller);n=l.isType("tb")?function(t){if(r)switch(t.keyCode){case 9:e(t);break;case 13:i(t);break;default:if(!o)return void t.preventDefault();s(t)}else t.preventDefault()}:function(t){if(r)switch(t.keyCode){case 8:t.preventDefault();break;case 13:i(t)}else t.preventDefault()},$(document).off("keydown.qi").on("keydown.qi",n)}function s(t){var e=t.template,i=t.templateState;o="question"===e&&"display-result"!==i&&"display-answer"!==i}function n(){$(document).off("keydown.qi")}var o,r=!0;return t.keyboardRedirect=e,t}(QI._setup||{}),QI._setup=function(t,e){"use strict";function i(t){t.subscribe("setup-init",s),t.subscribe("teardown-init",n),t.subscribe("force-close",n)}function s(t){var e=t.$container;e.on("contextmenu",function(t){t.preventDefault(),$(t.target).click()})}function n(t){var e=t.$container;e.off("contextmenu")}return t.rightclickRedirect=i,t}(QI._setup||{},QI._events);var QI=function(t,e,i,s,n,o,r){function l(l){d=$(l.selector),e.set(l);var a=new r,c=new i.Ctrl(a);f=a;new s.LoadingScreen(a),new s.Elements(a),new s.Transitions(a);s.fullscreenResize(a),s.keyboardRedirect(a),s.rightclickRedirect(a),n.init(a),n.trackFlow(a),n.trackTools(a),n.trackTTS(a),o.init(a),a.publish("setup-init",{$container:d,background:l.background,currency:l.inAmerica?"usd":"cad",secondChance:l.secondChance,callback:l.callback,question:h,educationSystem:educationSystem,classIds:l.classIDs});var u=setInterval(function(){function e(t){var e=t.skill,i=t.questionId,s=t.userID;c.initialize(e,i,s,function(){d.removeClass("loaded"),setTimeout(function(){d.addClass("loaded")},0)})}t._areAssetsLoaded()&&(clearInterval(u),e(l))},100)}function a(){_.isUndefined(d)||_.isUndefined(f)||(f.publish("teardown-init",{$container:d}),d=void 0,f=void 0)}function c(){_.isUndefined(d)||_.isUndefined(f)||(f.publish("force-close",{$container:d,ps:f}),d=void 0,f=void 0)}function u(t){educationSystem.selectSkill().ID,educationSystem.selectQuestion(),educationSystem.answerQuestion(t===!0,0)}var h;reporter=_.extend({},Backbone.Events),educationSystem=new Prodigy.EducationSystem(reporter),t.init=educationSystem.init.bind(educationSystem),t.getUpdatedData=educationSystem.getUpdatedData.bind(educationSystem),t.getMasteredSkills=educationSystem.getMasteredSkills.bind(educationSystem),t.showQuestion=function(t){if(_.isUndefined(t.skill)){var e=educationSystem.selectSkill().ID;h=educationSystem.selectQuestion(),h.skillID=e,$.ajax({dataType:"json",url:Controller.DEPLOY_PATH+"skills/"+e+".json",success:function(e){var i=h.homeworkID,s=!Util.isDefined(i)||i<=0,n=h.ID||e.skill.questions[h.index].ID;h.ID=n,t.skill=t.skill||e,t.questionId=t.questionId||n,t.secondChance=t.secondChance||s,t.inAmerica=t.inAmerica||educationSystem.inUSA,l(t)}})}else setTimeout(l.apply(this,arguments));return reporter};var d,f;return t.close=c,t.teardown=a,t.bypass=u,t.getLocationID=function(t,e){return t&&1!=t&&2==t?1==e?3:2==e?4:2:1},t}(QI||{},QI._settings,QI._ctrl,QI._setup,QI._ctrl.analytics,QI._cb,QI._PS);
}
/*
FILE ARCHIVED ON 01:52:18 Dec 10, 2016 AND RETRIEVED FROM THE
INTERNET ARCHIVE ON 22:28:02 Jun 22, 2020.
JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
SECTION 108(a)(3)).
*/
/*
playback timings (ms):
esindex: 0.017
PetaboxLoader3.datanode: 403.903 (4)
CDXLines.iter: 18.725 (3)
RedisCDXSource: 53.621
PetaboxLoader3.resolve: 91.484
exclusion.robots.policy: 0.169
captures_list: 213.837
LoadShardBlock: 137.51 (3)
exclusion.robots: 0.183
load_resource: 388.084
*/