/*! For license information please see 39.dc45aaf5abca8027.js.LICENSE.txt */ (self.webpackChunkWebComponents=self.webpackChunkWebComponents||[]).push([[39,420],{52420:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>_});var s=i(78673);i(75794),i(56906),i(78811);class n{constructor(e){this.problem=e}inverseLISIndices(e){for(var t=[],i=0;in&&rh&&(h=c.length,l=c)}var d=[],u=0;for(let t=0;tl.length?d.push(t):e[t]==l[u]?u+=1:d.push(t);return d}grade(){var e=this.problem;e.clearFeedback(),this.correctLines=0,this.percentLines=0,this.incorrectIndents=0;var t,i=e.solution,s=e.answerLines();this.percentLines=Math.min(s.length,i.length)/Math.max(s.length,i.length),s.lengthe[s].indent&&this.indentLeft.push(t[s]);return this.incorrectIndents=this.indentLeft.length+this.indentRight.length,0==this.incorrectIndents}checkCorrectOrdering(e,t){let i=!0;this.correctLines=0,this.solutionLength=e.length;let s=Math.min(e.length,t.length);for(let n=0;n0&&u.length>0;)if(c.length<=u.length){a=c,c=[];for(let e of a)for(let t of o(e))if(l.has(t)||(c.push(t),l.set(t,e)),h.has(t))return[l,h,t]}else{a=u,u=[];for(let e of a)for(let t of r(e))if(h.has(t)||(u.push(t),h.set(t,e)),l.has(t))return[l,h,t]}throw new d("No path between "+t.toString()+" and "+i.toString()+".")}(e,t,i),o=[];null!=r;)o.push(r),r=s.get(r);for(r=n.get(o[0]),o.reverse();null!=r;)o.push(r),r=n.get(r)}(e,t,i)}catch(e){if(e instanceof d)return!1;throw e}return!0}class o{constructor(){this.graph={},this.node=new Map,this.adj=new Map,this.pred=new Map,this.succ=this.adj,this.edge=this.adj}addNode(e){this.succ.has(e)||(this.succ.set(e,new Map),this.pred.set(e,new Map),this.node.set(e))}addEdge(e,t){this.succ.has(e)||(this.succ.set(e,new Map),this.pred.set(e,new Map),this.node.set(e,{})),this.succ.has(t)||(this.succ.set(t,new Map),this.pred.set(t,new Map),this.node.set(t,{}));var i=this.adj.get(e).get(t)||{};this.succ.get(e).set(t,i),this.pred.get(t).set(e,i)}nodes(e=!1){return Array.from(e?this.node.entries():this.node.keys())}edges(e,t=!1){return Array.from(this.edgesIter(e,t))}nodesIter(e=!1){return e?toIterator(this.node):this.node.keys()}get(e){var t=this.adj.get(e);if(void 0===t)throw new KeyError("Graph does not contain node "+e+".");return t}numberOfNodes(){return this.node.size}*nbunchIter(e){if(null==e)yield*this.adj.keys();else if(this.hasNode(e))yield e;else{var t=this.adj;try{for(var i of toIterator(e))t.has(i)&&(yield i)}catch(e){if(e instanceof TypeError)throw new h("nbunch is not a node or a sequence of nodes")}}}*edgesIter(e,t=!1){var i;for(var s of((!0===(i=e)||!1===i||function(e){return!!e&&"object"==typeof e}(i)&&"[object Boolean]"==Object.prototype.toString.call(i))&&(t=e,e=void 0),void 0===e?this.adj:mapIterator(this.nbunchIter(e),(e=>tuple2(e,this.adj.get(e))))))for(var n of s[1]){var r=[s[0],n[0]];t&&(r[2]=n[1]),yield r}}reverse(e=!0){var t;if(e)(t=new this.constructor(null,{name:"Reverse of ("+this.name+")"})).addNodesFrom(this),t.addEdgesFrom(mapIterator(this.edgesIter(null,!0),(e=>tuple3c(e[1],e[0],deepcopy(e[2]),e)))),t.graph=deepcopy(this.graph),t.node=deepcopy(this.node);else{var i=this.pred,s=this.succ;this.succ=i,this.pred=s,this.adj=this.succ,t=this}return t}successorsIter(e){var t=this.succ.get(e);if(void 0!==t)return t.keys();throw new h(sprintf('The node "%j" is not in the digraph.',e))}predecessorsIter(e){var t=this.pred.get(e);if(void 0!==t)return t.keys();throw new h(sprintf('The node "%j" is not in the digraph.',e))}successors(e){return Array.from(this.successorsIter(e))}predecessors(e){return Array.from(this.predecessorsIter(e))}}class a{constructor(e){this.name="JSNetworkXException",this.message=e}}class l extends a{constructor(e){super(e),this.name="JSNetworkXAlgorithmError"}}class h extends a{constructor(e){super(e),this.name="JSNetworkXError"}}class c extends l{constructor(e){super(e),this.name="JSNetworkXUnfeasible"}}class d extends c{constructor(e){super(e),this.name="JSNetworkXNoPath"}}function u(e){var t=new o;for(let i of e){t.addNode(i.tag);for(let e of i.depends)t.addEdge(e,i.tag)}return t}function p(e,t){for(let i of e.edges())if(!t.has(i[0])&&!t.has(i[1]))return!1;return!0}class v extends n{inverseLISIndices(e,t){var i=this.problem.solution,s=t.map((e=>e.lines[0]));let n=u(i),a=new Set,l=new o;for(let e of s){for(let t of a)r(n,{source:e.tag,target:t.tag})&&l.addEdge(e.tag,t.tag);a.add(e)}let h=null,c=function(e){let t={};for(let i=0;i<=e.length;i++)t[i]=[];for(let i=0;i{for(let t=0;ti&&this.indentLeft.push(e.lines[0])}return this.incorrectIndents=this.indentLeft.length+this.indentRight.length,0==this.incorrectIndents}checkCorrectOrdering(e,t){if(!function(e){try{return function(e,t){var i=new Set,s=[],n=new Set;null==t&&(t=e.nodesIter());for(let l of t){if(n.has(l))return;for(var r=[l];r.length>0;){var o=r[r.length-1];if(n.has(o))r.pop();else{i.add(o);var a=[];e.get(o).forEach((function(e,t){if(!n.has(t)){if(i.has(t))throw new c("Graph contains a cycle.");a.push(t)}})),a.length>0?r.push.apply(r,a):(n.add(o),s.unshift(o))}}}}(e),!0}catch(e){if(e instanceof c)return!1;throw e}}(u(e)))throw"Dependency between blocks does not form a Directed Acyclic Graph; Problem unsolvable.";let i=new Set,s=!0;this.correctLines=0,this.solutionLength=e.length;let n=Math.min(e.length,t.length);for(let e=0;ee.trimStart().toLowerCase().startsWith("class ")))?this.text.toLowerCase().startsWith("class")?this.indent=0:this.indent=n.length-this.text.length:this.text.toLowerCase().startsWith("def")?this.indent=0:this.indent=n.length-this.text.length}else this.text=n.replace(/^\s*/,""),this.indent=n.length-this.text.length;"natural"==e.options.language||"math"==e.options.language?s=i?document.createElement("div"):document.createElement("p"):(s=document.createElement("code"),$(s).addClass(e.options.prettifyLanguage)),s.id=e.counterId+"-line-"+this.index,s.innerHTML+=this.text,this.view=s,e.lines.push(this)}initializeWidth(){this.width=$(this.view).outerWidth(!0)-this.problem.options.pixelsPerIndent*this.indent,this.view.fontSize=window.getComputedStyle(this.view,null).getPropertyValue("font-size"),this.view.pixelsPerIndent=this.problem.options.pixelsPerIndent,this.view.indent=this.indent;var e=document.createElement("canvas").getContext("2d"),t=window.getComputedStyle(this.view,null).getPropertyValue("font-family").split(", "),i="abcdefghijklmnopqrstuvwxyz0123456789,./!@#$%^&*-+";e.font=this.view.fontSize+" serif";var s=e.measureText(i).width;for(let n=0;n0&&$(o.view).addClass("indent"+r),n.appendChild(o.view)}var a=document.createElement("div");$(a).addClass("labels"),"left"==this.problem.options.numbered?($(n).addClass("border_left"),$(i).prepend(a),$(i).css({"justify-content":"flex-start"})):"right"==this.problem.options.numbered&&($(a).addClass("border_left"),$(a).css({float:"right"}),$(i).css({"justify-content":"space-between"}),$(i).append(a)),this.view=i,this.isPlaceholder=!1}addLine(e){if($(e.view).removeClass("indent1 indent2 indent3 indent4 indent5 indent6"),this.problem.noindent)e.indent>0&&$(e.view).addClass("indent"+e.indent);else{var t=this.lines,i=t[0].indent;for(let e=1;ee.indent)for(let i=0;i0&&($(e.view).removeClass("indent1 indent2 indent3 indent4 indent5 indent6"),$(e.view).addClass("indent"+e.indent))}this.indent=0,$(this.view).css({"padding-left":"",width:this.problem.areaWidth-22})}addLabel(e,t){var i=document.createElement("div");$(i).addClass("block-label"),"right"==this.problem.options.numbered&&$(i).addClass("right-label"),"left"==this.problem.options.numbered&&$(i).addClass("left-label"),$(i).append(document.createTextNode(e)),$(this.view).children(".labels")[0].append(i),0!=this.labels.length&&$(i).css("margin-top",(t-this.labels[this.labels.length-1][1]-1)*this.lines[t].view.offsetHeight),this.labels.push([e,t])}initializeInteractivity(){if($(this.view).hasClass("disabled"))return this;$(this.view).attr("tabindex","-1"),this.hammer=new(m().Manager)(this.view,{recognizers:[[m().Pan,{direction:m().DIRECTION_ALL,threshold:0,pointers:1}]]});var e=this;this.hammer.on("panstart",(function(t){e.panStart(t)})),this.hammer.on("panend",(function(t){e.panEnd(t)})),this.hammer.on("panmove",(function(t){e.panMove(t)}))}enabled(){return void 0!==$(this.view).attr("tabindex")}isDistractor(){return this.lines[0].distractor}inSourceArea(){var e=this.problem.sourceArea.childNodes;for(let t=0;t=0;s--){var i=e[s];if(i.pairedBin()==t)return i}return e[e.length-1]}}pairedBin(){for(var e=this.problem.pairedBins,t=0;t=0){for(e=0;e0)return s}for(e=0;e=s)break}this.problem.textMoving=!0,this.problem.sourceArea.insertBefore(this.view,t.view),$(this.view).focus()}else this.indent=this.indent-1;this.problem.state=void 0,this.problem.updateView()}}moveUp(){if(this.inSourceArea()){let n=this.problem.sourceBlocks();var e=this.verticalOffset(),t=this.validSourceIndexes();for(let r=0;r=e)return this.problem.textMoving=!0,this.problem.answerArea.insertBefore(this.view,s.view),$(this.view).focus(),this.problem.state=void 0,this.problem.updateView(),this}this.problem.textMoving=!0,this.problem.answerArea.appendChild(this.view),$(this.view).focus(),this.problem.state=void 0,this.problem.updateView()}else this.indent!==this.problem.indent&&(this.indent=this.indent+1,this.problem.state=void 0,this.problem.updateView())}moveDown(){if(this.inSourceArea()){let s=this.problem.sourceBlocks();var e=this.validSourceIndexes();for(let e=0;e1)return this.problem.textMoving=!0,this.problem.sourceArea.insertBefore(this.view,s[i].view),$(this.view).focus(),this.problem.state=void 0,this.problem.updateView(),this}}else{let e=this.problem.answerBlocks();for(var s=0;s=0;i--){var s=e[i];if(t)return this.problem.textFocus=s,s.makeTabIndex(),$(s.view).focus(),this;s.view.id==this.view.id&&(t=!0)}}selectRight(){if(this.inSourceArea()){var e=this.verticalOffset(),t=this.problem.enabledAnswerBlocks();if(0==t.length)return this;for(var i=t[0],s=i.verticalOffset()-e,n=1;n1?`${i} blocks are missing here`:`${i} block is missing here`,$(this.view).append(n),this.isPlaceholder=!0}}class k extends g{constructor(e){super(e,"placeholder",!1),this.isPlaceholderLine=!0}}class y extends b{constructor(e,t){super(e,t),this.isSettled=!0,$(this.view).addClass("settled-block"),$(this.view).addClass("disabled");let i=document.createElement("span");i.classList.add("settled-tooltip"),$(this.view).append(i),$(this.view).find(".settled-tooltip").text("OK")}setBlocksBefore(e){this.blocksBefore=e;var t=e>1?"s":"";if(this.blocksAfter){var i=this.blocksAfter>1?"s":"";$(this.view).find(".settled-tooltip").html(`${e} block${t} ⬆️️), ${this.blocksAfter} block${i} ⬇️`)}else $(this.view).find(".settled-tooltip").html(`${e} block${t} ⬆️️`)}setBlocksAfter(e){this.blocksAfter=e;var t=e>1?"s":"";if(this.blocksBefore){var i=this.blocksBefore>1?"s":"";$(this.view).find(".settled-tooltip").html(`${this.blocksBefore} block${i} ⬆️, ${e} block${t} ⬇️`)}else $(this.view).find(".settled-tooltip").html(`${e} block${t} ️️⬇️`)}}class x extends s.A{constructor(e){super(e);var t=e.orig;this.containerDiv=t,this.origElem=$(t).find("pre.parsonsblocks")[0],this.question=$(t).find(".parsons_question")[0],this.useRunestoneServices=e.useRunestoneServices,this.divid=e.orig.id;var i=super.localStorageKey();this.storageId=i,this.children=this.origElem.childNodes,this.contentArray=[],x.counter++,this.counterId="parsons-"+x.counter,this.initializeOptions(),this.grader="dag"===this.options.grader?new v(this):new n(this),this.grader.showfeedback=this.showfeedback;var s=$(this.origElem).html();this.blockIndex=0,this.checkCount=0,this.numDistinct=0,this.hasSolved=!1,this.initializeLines(s.trim()),this.initializeView(),this.caption="Parsons",this.addCaption("runestone"),this.checkServer("parsons",!0),this.runnableDiv=null}initializeOptions(){var e={pixelsPerIndent:30},t=$(this.origElem).data("maxdist"),i=$(this.origElem).data("order"),s=$(this.origElem).data("noindent"),n=$(this.origElem).data("adaptive"),r=$(this.origElem).data("numbered"),o=$(this.origElem).data("grader"),a=$(this.origElem).data("scaffolding");if(e.numbered=r,e.grader=o,e.scaffolding=a,void 0!==t&&(e.maxdist=t),void 0!==i){i=i.match(/\d+/g);for(var l=0;le.replace(/\s+/g,"")))).indexOf("#tag:"),""==(y=o.substring(w+5,o.indexOf(";",w+5)))&&(y="block-"+r),x=o.indexOf(";depends:");let e=o.substring(x+9,o.indexOf(";",x+9));h=e.length>0?e.split(","):[]}if(o.includes('class="displaymath')?a.displaymath=!0:a.displaymath=!1,o=o.replace(/#(paired|distractor|settled|tag:.*;.*;)/,(function(e,t){return a[t]=!0,""})),a.settled&&r>0&&u.length>0&&!u[u.length-1].isSettled){var d=new k(this);u.push(d),d.distractor=!0,d.paired=!1,d.distractHelptext="",d.groupWithNext=!1,d.indent=0}a.settled&&(n=!0);var u=[];if(a.displaymath)p=[o];else var p=o.split("\n");for(var v=0;v0){for(v=0;v0&&(n-=1),t.indent=n}}else{s=s.sort((function(e,t){return e-t}));for(let e=0;ee.replace(/\s+/g,"")))).indexOf("#tag:"),""==(y=o.substring(w+5,o.indexOf(";",w+5)))&&(y="block-"+r),x=o.indexOf(";depends:");let e=o.substring(x+9,o.indexOf(";",x+9));h=e.length>0?e.split(","):[]}if(o.includes('class="displaymath')?a.displaymath=!0:a.displaymath=!1,o=o.replace(/\s*#(paired|distractor|tag:.*;.*;)\s*/g,(function(e,t){return a[t]=!0,""})),u=[],a.displaymath)p=[o];else p=o.split("\n");for(v=0;v0){for(v=0;vawait f.queueMathJax(e[0]))):void 0!==MathJax.startup&&await f.queueMathJax(e[0])),u=Math.max(u,e.outerWidth(!0)),e.width(u-22);var t=3.8;let i=e.outerHeight(!0);38!=i&&(t=3.1*(i-38)/21),p+=i+g*t}.bind(this),s=0;s0&&a<=4?$(this.answerArea).addClass("answer"+a):$(this.answerArea).addClass("answer");var m=[],b=[];for(s=0;s0&&(m.push(b),b=[]):(b.push(w),w.groupWithNext||(m.push(b),b=[]))}var k,y=[],x=[],_=[];if(this.pairDistractors||!this.options.adaptive){for(s=m.length-1;s>-1;s--)if((b=m[s])[0].paired)for(k=b.length-1;k>-1;k--)x.unshift(b[k].index);else if(x.length>0){for(k=b.length-1;k>-1;k--)x.unshift(b[k].index);y.unshift(x),x=[]}for(s=0;sor{"),_.push(C),this.sourceArea.appendChild(C)}}else y=[];p+=10*y.length,this.areaHeight=p+40,$(this.sourceArea).css({width:this.areaWidth+2,height:p}),$(this.answerArea).css({width:this.options.pixelsPerIndent*a+this.areaWidth+2,height:p}),this.pairedBins=y,this.pairedDivs=_,null!=this.options.numbered&&this.addBlockLabels(e.concat(t)),this.state=void 0,this.updateView(),h&&$(l).replaceWith(this.outerDiv)}initializeInteractivity(){for(var e=0;e(s=this.dateFromTimestamp(s))?e:t}async loadData(e){if(!0===this.options.scaffolding){null==(i=e.source)&&(i=e.trash);var t=e.answer;void 0!==(n=null==(s=e.adaptive)?{}:this.optionsFromHash(s)).noindent&&(this.noindent=!0),void 0!==n.checkCount&&(this.checkCount=n.checkCount),void 0!==n.hasSolved&&(this.hasSolved=n.hasSolved),await this.initializeAreas(this.blocksFromSource(),this.settledBlocksFromSource(),n),!0!==this.needsReinitialization&&(this.initializeInteractivity(),this.isTimed&&!this.assessmentTaken&&this.resetView())}else{var i,s,n;null==(i=e.source)&&(i=e.trash),t=e.answer,void 0!==(n=null==(s=e.adaptive)?{}:this.optionsFromHash(s)).noindent&&(this.noindent=!0),void 0!==n.checkCount&&(this.checkCount=n.checkCount),void 0!==n.hasSolved&&(this.hasSolved=n.hasSolved),null==i||null==t||1==t.length?await this.initializeAreas(this.blocksFromSource(),[],n):(this.initializeAreas(this.blocksFromHash(i),this.blocksFromHash(t),n),this.grade=this.grader.grade(),"correct"==this.grade?this.correct=!0:0==this.answerLines().length?this.correct=null:this.correct=!1),!0!==this.needsReinitialization&&(this.initializeInteractivity(),this.isTimed&&!this.assessmentTaken&&this.resetView())}}localData(){var e=localStorage.getItem(this.storageId);return null!==e&&"{"==e.charAt(0)?JSON.parse(e):{}}restoreAnswers(e){this.loadData(e)}checkLocalStorage(){this.graderactive||this.loadData(this.localData())}setLocalStorage(e){var t;if(null==e){t={source:this.sourceHash(),answer:this.answerHash(),timestamp:new Date};var i=this.adaptiveHash();i.length>0&&(t.adaptive=i)}else t=e;localStorage.setItem(this.storageId,JSON.stringify(t))}async updatePlaceholders(){setTimeout((()=>{var e,t,i,s=this.answerBlocks();for(e=0;e0&&!s[e-1].isSettled&&!s[e-1].isPlaceholder&&(t=!0),e{for(var e=this.answerBlocks(),t=0;t=t;o--)if(e[o].afterSettledBlockCount==r){n=e[o];break}if(e[o].afterSettledBlockCount!=r)return void console.log("error moving up; no placeholder found");if($(n.view).hasClass("hide")){$(n.view).removeClass("hide");for(var a=0;a0&&(i.disabled=s),i}answerHash(){for(var e=[],t=this.answerBlocks(),i=0;ib&&(f-=1),t.lines[t.lines.length-1].indent==g.lines[0].indent&&(f+=1),f>=p&&(p=f,v=u)}for(t=d[v],g=d[v+1],u=0;u-1?r.push(t):a.push(s):r.push(t);n=r,r=[]}}if(this.recentAttempts<2?this.pairDistractors=!1:this.pairDistractors=!0,void 0===this.options.order){var c=[],d=[];for(s=0;s1)for(d=this.shuffled(d),p=0;p=0){for(var p=s;$.inArray(e[p-1],r)<0;)p--;var v=$.inArray(e[p-1],r),g=$.inArray(e[s],r);r.splice(g,1),r.splice(v,0,e[s])}return r}blockFromHash(e){for(var t=e.split("_"),i=[],s=0;s0&&l.setBlocksBefore(a),o=l,r++,n=0,s=[]}else s[0].distractor||n++,s=[];return i.length>0&&i[i.length-1].isSettled&&(this.lastBlockSettled=!0),console.log("settledblocksfromsource",i),i}getBlockById(e){for(var t=0;t1?$.i18n("msg_parson_correct",this.checkCount):$.i18n("msg_parson_correct_first_try");this.options.runnable&&(i+=" "+$.i18n("msg_parson_correct_runnable")),setTimeout((()=>{e.html(i)}),10)}if("incorrectTooShort"===this.grade&&(t.addClass("incorrect"),this.messageDiv.style.visibility="visible",e.attr("class","alert alert-danger"),setTimeout((()=>{e.html($.i18n("msg_parson_too_short"))}),10)),"incorrectIndent"===this.grade){var i=[];for(let e=0;e{1==i.length?e.html($.i18n("msg_parson_wrong_indent")):e.html($.i18n("msg_parson_wrong_indents"))}),10)}if("incorrectMoveBlocks"===this.grade){var s=this.answerBlocks(),n=[],r=[],o=[];for(let e=0;e{e.html($.i18n("msg_parson_wrong_order"))}),10)}}initializeAdaptive(){if(this.adaptiveId=super.localStorageKey(),this.canHelp=!0,this.checkCount=0,this.numDistinct=0,this.gotHelp=!1,localStorage.getItem(this.adaptiveId+"Problem")==this.divid)return this.checkCount=localStorage.getItem(this.adaptiveId+this.divid+"Count"),null==this.checkCount&&(this.checkCount=0),this;var e=localStorage.getItem(this.adaptiveId+this.divid+"Count");null!=e&&"NaN"!=e||(e=0),this.checkCount=e,this.recentAttempts=localStorage.getItem(this.adaptiveId+"recentAttempts"),null!=this.recentAttempts&&"NaN"!=this.recentAttempts||(this.recentAttempts=3),localStorage.setItem(this.adaptiveId+"recentAttempts",this.recentAttempts),localStorage.setItem(this.adaptiveId+"Problem",this.divid),localStorage.setItem(this.adaptiveId+this.divid+"Count",this.checkCount),localStorage.setItem(this.adaptiveId+"Solved",!1)}usesIndentation(){return!this.noindent&&0!=this.solutionIndent()}distractorToRemove(){var e,t=this.enabledAnswerBlocks();for(let i=0;i{t.html($.i18n("msg_parson_not_solution"))}),10),e.lines[0].distractHelptext&&(e.view.setAttribute("data-toggle","tooltip"),e.view.setAttribute("title",e.lines[0].distractHelptext)),e.disable(),e.inSourceArea())$(e.view).css({"border-color":"#000","background-color":"#fff"}),$(e.view).animate({opacity:.3,"border-color":"#d3d3d3","background-color":"#efefef"},{duration:2e3,complete:function(){$(e.view).css({"border-color":"","background-color":""})}});else{var i=this.sourceArea.getBoundingClientRect(),s=e.pageXCenter()-1,n=e.pageYCenter(),r=i.left+window.pageXOffset+i.width/2,o=i.top+window.pageYOffset+e.view.getBoundingClientRect().height/2,a=e.slideUnderBlock();void 0!==a&&(o+=a.view.getBoundingClientRect().height+20,o+=parseInt($(a.view).css("top")));var l=this;$(e.view).css({"border-color":"#000","background-color":"#fff"}),$(e.view).animate({opacity:1},{duration:4*Math.sqrt(Math.pow(o-n,2)+Math.pow(r-s,2))+500,start:function(){l.moving=e,l.movingX=s,l.movingY=n,l.updateView()},progress:function(e,t,i){l.movingX=s*(1-t)+r*t,l.movingY=n*(1-t)+o*t,l.updateView()},complete:function(){delete l.moving,delete l.movingX,delete l.movingY,l.updateView(),$(e.view).animate({opacity:.3,"border-color":"#d3d3d3","background-color":"#efefef"},{duration:1e3,complete:function(){$(e.view).css({opacity:"","border-color":"","background-color":""}),$(e.view).addClass("disabled")}})}})}}removeIndentation(){var e=$(this.messageDiv);this.messageDiv.style.visibility="visible",e.attr("class","alert alert-info"),setTimeout((()=>{e.html($.i18n("msg_parson_provided_indent"))}),10);for(var t,i,s=200,n=0;n0&&t.indexOf(s)<0)return s;return null}getFurthestBlock(){for(var e=this.solutionBlocks(),t=this.answerBlocks(),i=0,s=0,n=null,r=null,o=0,a=null,l=0,h=0;h0&&(a=e[o-1],l=t.indexOf(a),(s=Math.abs(h-l))>i&&(i=s,n=r));return n}combineBlocks(){var e=this.solutionBlocks(),t=this.answerBlocks(),i=this.sourceBlocks(),s=$(this.messageDiv);this.messageDiv.style.visibility="visible",s.attr("class","alert alert-info"),setTimeout((()=>{s.html($.i18n("msg_parson_combined_blocks"))}),10);var n=null,r=null;null==(r=this.getSolutionBlockInSource())&&(r=this.getFurthestBlock());var o=e.indexOf(r);n=e[o-1];var a=t.indexOf(n),l=t.indexOf(r),h=!1;a>=0&&l>=0?h=a+1!==l:a<0&&l<0?h=(a=i.indexOf(n))+1!==(l=i.indexOf(r)):(h=!0,a<0&&(a=i.indexOf(n)),l<0&&(l=i.indexOf(r)));var c=l3?(alert($.i18n("msg_parson_will_combine")),this.combineBlocks(),this.logMove("combinedBlocks")):(alert($.i18n("msg_parson_three_blocks_left")),this.canHelp=!1):(alert($.i18n("msg_parson_remove_incorrect")),this.removeDistractor(e),this.logMove("removedDistractor-"+e.hash()))}helpMe(){this.clearFeedback(),this.numDistinct<3?alert($.i18n("msg_parson_atleast_three_attempts")):(this.gotHelp=!0,this.makeEasier())}dateFromTimestamp(e){var t=new Date(e);if(isNaN(t.getTime())){var i=e.split(/[- :]/);t=new Date(i[0],i[1]-1,i[2],i[3],i[4],i[5])}return t}shuffled(e){for(var t,i,s=e.length,n=e.slice();0!==s;)i=Math.floor(Math.random()*s),t=n[s-=1],n[s]=n[i],n[i]=t;return n}enterKeyboardMode(){$(this.keyboardTip).show(),$(this.sourceLabel).hide(),$(this.answerLabel).hide(),this.clearFeedback()}exitKeyboardMode(){$(this.keyboardTip).hide(),$(this.sourceLabel).show(),$(this.answerLabel).show()}clearFeedback(){$(this.answerArea).removeClass("incorrect correct");for(var e=this.answerArea.childNodes,t=0;t=i.left&&e<=i.right&&t>=i.top&&t<=i.bottom?"answer":e>=(i=this.sourceArea.getBoundingClientRect()).left&&e<=i.right&&t>=i.top&&t<=i.bottom?"source":"moving"}updateView(){var e,t,i,s=this.state,n=this.movingState(),r=!0,o=!0,a="moving"==n;s==n&&("rest"==n?(r=!1,o=!1):"source"==n?o=!1:"answer"==n?r=!1:"moving"==n&&(o=!1,r=!1)),void 0!==this.moving&&(e=$(this.moving.view).outerHeight(!0),$(this.moving.view).detach());var l,h,c=this.areaWidth-22;if(r){t=0;var d=this.sourceBlocks();if("source"==n){var u=!1,p=this.moving.pairedBin(),v=[];for(y=0;yor{")}1==_.length&&$(C).html("")}}if(o)if(t=0,i=this.areaWidth+this.indent*this.options.pixelsPerIndent-22,d=this.answerBlocks(),"answer"==n){u=!1,f=this.movingX-this.answerArea.getBoundingClientRect().left-window.pageXOffset-c/2-11;var A=Math.round(f/this.options.pixelsPerIndent);for(A<0?A=0:A>this.indent?A=this.indent:f=A*this.options.pixelsPerIndent,m=this.movingY-this.answerArea.getBoundingClientRect().top-window.pageYOffset,this.moving.indent=A,y=0;y=10&&(o+=" "),e[a].addLabel(o,0),s++}n+this.pairedBins.length>=10&&(this.areaWidth+=5,$(this.sourceArea).css({width:$(this.sourceArea).width()+5}),$(this.answerArea).css({width:$(this.answerArea).width()+5}))}resetView(){if(this.clearFeedback(),!0===this.options.scaffolding){const e=document.querySelector(`#copy-answer-button-${this.divid}`);e&&e.classList.add("copy-button-hide")}var e,t=document.body.scrollTop;for(let t=0;t{$.i18n().load({"pt-br":{msg_parson_check_me:"Verificar",msg_parson_reset:"Resetar",msg_parson_help:"Ajuda",msg_parson_too_short:"Seu programa é muito curto. Adicione mais blocos.",msg_parson_drag_from_here:"Arraste daqui",msg_parson_drag_to_here:"Largue os blocos aqui",msg_parson_correct_first_try:"Perfeito! Você levou apenas uma tentativa para resolver. Bom trabalho!",msg_parson_correct:"Perfeito! Você levou $1 tentativas para resolver. Clique em Resetar para tentar resolver em uma tentativa.",msg_parson_wrong_indent:"Este bloco não está indentado corretamente. Indente mais arrastando-o para a direita ou reduza a indentação arrastando para a esquerda.",msg_parson_wrong_indents:"Estes blocos não estão indentados corretamente. Para indentar mais, arraste o bloco para a direita. Para reduzir a indentação, arraste para a esquerda.",msg_parson_wrong_order:"Blocos destacados no seu programa estão errados ou estão na ordem errada. Isso pode ser resolvido movendo, excluindo ou substituindo os blocos destacados.",msg_parson_arrow_navigate:"Use as teclas de setas para navegar. Espaço para selecionar/ desmarcar blocos para mover.",msg_parson_help_info:"Clique no botão Ajuda se você quiser facilitar o problema",msg_parson_not_solution:"Foi desabilitado um bloco de código desnecessário (que não faz parte da solução).",msg_parson_provided_indent:"Foi fornecida a indentação.",msg_parson_combined_blocks:"Dois blocos de códigos foram combinados em um.",msg_parson_remove_incorrect:"Será removido um bloco de código incorreto da área de resposta",msg_parson_will_combine:"Serão combinados dois blocos",msg_parson_atleast_three_attempts:"Você deve tentar pelo menos três vezes antes de pedir ajuda",msg_parson_three_blocks_left:"Restam apenas 3 blocos corretos. Você deve colocá-los em ordem",msg_parson_will_provide_indent:"Será fornecida a indentação"}})},75794:()=>{$.i18n().load({en:{msg_parson_check_me:"Check",msg_parson_reset:"Reset",msg_parson_help:"Help me",msg_parson_too_short:"Your answer is too short. Add more blocks.",msg_parson_drag_from_here:"Drag from here",msg_parson_drag_to_here:"Drop blocks here",msg_parson_correct_first_try:"Perfect! It took you only one try to solve this. Great job!",msg_parson_correct:"Perfect! It took you $1 tries to solve this. Click Reset to try to solve it in one attempt.",msg_parson_correct_runnable:"Click Run below to test out your solution.",msg_parson_wrong_indent:"This block is not indented correctly. Either indent it more by dragging it right or reduce the indention by dragging it left.",msg_parson_wrong_indents:"These blocks are not indented correctly. To indent a block more, drag it to the right. To reduce the indention, drag it to the left.",msg_parson_wrong_order:"Highlighted blocks in your answer are wrong or are in the wrong order. This can be fixed by moving, removing, or replacing highlighted blocks.",msg_parson_arrow_navigate:"Arrow keys to navigate. Space to select / deselect block to move.",msg_parson_help_info:"Click on the Help Me button if you want to make the problem easier",msg_parson_not_solution:"Disabled an unneeded code block (one that is not part of the solution).",msg_parson_provided_indent:"Provided the indentation.",msg_parson_combined_blocks:"Combined two code blocks into one.",msg_parson_remove_incorrect:"Will remove an incorrect code block from answer area",msg_parson_will_combine:"Will combine two blocks",msg_parson_atleast_three_attempts:"You must make at least three distinct full attempts at a solution before you can get help",msg_parson_three_blocks_left:"There are only 3 correct blocks left. You should be able to put them in order",msg_parson_will_provide_indent:"Will provide indentation"}})},78811:()=>{function e(){var t=navigator&&navigator.userAgent&&/\bMSIE 6\./.test(navigator.userAgent);return e=function(){return t},t}!function(){var t="break continue do else for if return while ",i=t+"auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try ",s=i+"alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename typeof using virtual wchar_t where ",n=i+"boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ",r=i+"debugger eval export function get null set undefined var with Infinity NaN ",o="caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END ",a=t+"and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None ",l=t+"alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END ",h=t+"case done elif esac eval fi function in local set then until ",c=s+(n+"as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ")+r+o+a+l+h;function d(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function u(e,t,i,s){e.unshift(i,s||0);try{t.splice.apply(t,e)}finally{e.splice(0,2)}}var p=function(){for(var e=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===",">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=","~","break","case","continue","delete","do","else","finally","instanceof","return","throw","try","typeof"],t="(?:(?:(?:^|[^0-9.])\\.{1,3})|(?:(?:^|[^\\+])\\+)|(?:(?:^|[^\\-])-)",i=0;i:&])/g,"\\$1")}return t+="|^)\\s*$",new RegExp(t)}(),v=/&/g,g=//g,m=/\"/g;function b(e){return e.replace(v,"&").replace(g,"<").replace(f,">")}var w=/</g,k=/>/g,y=/'/g,$=/"/g,x=/&/g,_=/ /g;function C(e){var t=e.indexOf("&");if(t<0)return e;for(--t;(t=e.indexOf("&#",t+1))>=0;){var i=e.indexOf(";",t);if(i>=0){var s=e.substring(t+3,i),n=10;s&&"x"===s.charAt(0)&&(s=s.substring(1),n=16);var r=parseInt(s,n);isNaN(r)||(e=e.substring(0,t)+String.fromCharCode(r)+e.substring(i+1))}}return e.replace(w,"<").replace(k,">").replace(y,"'").replace($,'"').replace(x,"&").replace(_," ")}function I(e){return"XMP"===e.tagName}function A(e,t){switch(e.nodeType){case 1:var i=e.tagName.toLowerCase();t.push("<",i);for(var s=0;s");for(var r=e.firstChild;r;r=r.nextSibling)A(r,t);!e.firstChild&&/^(?:br|link|img)$/.test(i)||t.push("");break;case 2:t.push(e.name.toLowerCase(),'="',function(e){return e.replace(v,"&").replace(g,"<").replace(f,">").replace(m,""")}(e.value),'"');break;case 3:case 4:t.push(b(e.nodeValue))}}var S=null;function T(e){if(null===S){var t=document.createElement("PRE");t.appendChild(document.createTextNode('\n')),S=!/||<\/?[a-zA-Z][^>]*>|<)/g,D=/^