Files
Probability-and-Statistics-…/_static/486.b03e25ab1e190440.js
T
2026-04-02 07:47:45 -04:00

2 lines
25 KiB
JavaScript
Executable File

(self.webpackChunkWebComponents=self.webpackChunkWebComponents||[]).push([[486],{35358:(e,t,s)=>{var r={"./af":25177,"./af.js":25177,"./ar":61509,"./ar-dz":41488,"./ar-dz.js":41488,"./ar-kw":58676,"./ar-kw.js":58676,"./ar-ly":42353,"./ar-ly.js":42353,"./ar-ma":24496,"./ar-ma.js":24496,"./ar-sa":82682,"./ar-sa.js":82682,"./ar-tn":89756,"./ar-tn.js":89756,"./ar.js":61509,"./az":95533,"./az.js":95533,"./be":28959,"./be.js":28959,"./bg":47777,"./bg.js":47777,"./bm":54903,"./bm.js":54903,"./bn":61290,"./bn.js":61290,"./bo":31545,"./bo.js":31545,"./br":11470,"./br.js":11470,"./bs":44429,"./bs.js":44429,"./ca":7306,"./ca.js":7306,"./cs":56464,"./cs.js":56464,"./cv":73635,"./cv.js":73635,"./cy":64226,"./cy.js":64226,"./da":93601,"./da.js":93601,"./de":77853,"./de-at":26111,"./de-at.js":26111,"./de-ch":54697,"./de-ch.js":54697,"./de.js":77853,"./dv":60708,"./dv.js":60708,"./el":54691,"./el.js":54691,"./en-au":53872,"./en-au.js":53872,"./en-ca":28298,"./en-ca.js":28298,"./en-gb":56195,"./en-gb.js":56195,"./en-ie":66584,"./en-ie.js":66584,"./en-nz":79402,"./en-nz.js":79402,"./eo":32934,"./eo.js":32934,"./es":97650,"./es-do":20838,"./es-do.js":20838,"./es-us":56575,"./es-us.js":56575,"./es.js":97650,"./et":3035,"./et.js":3035,"./eu":3508,"./eu.js":3508,"./fa":119,"./fa.js":119,"./fi":90527,"./fi.js":90527,"./fo":52477,"./fo.js":52477,"./fr":85498,"./fr-ca":26435,"./fr-ca.js":26435,"./fr-ch":37892,"./fr-ch.js":37892,"./fr.js":85498,"./fy":37071,"./fy.js":37071,"./gd":70217,"./gd.js":70217,"./gl":77329,"./gl.js":77329,"./gom-latn":93383,"./gom-latn.js":93383,"./gu":95050,"./gu.js":95050,"./he":11713,"./he.js":11713,"./hi":43861,"./hi.js":43861,"./hr":26308,"./hr.js":26308,"./hu":90609,"./hu.js":90609,"./hy-am":17160,"./hy-am.js":17160,"./id":74063,"./id.js":74063,"./is":89374,"./is.js":89374,"./it":88383,"./it.js":88383,"./ja":23827,"./ja.js":23827,"./jv":89722,"./jv.js":89722,"./ka":41794,"./ka.js":41794,"./kk":27088,"./kk.js":27088,"./km":96870,"./km.js":96870,"./kn":84451,"./kn.js":84451,"./ko":63164,"./ko.js":63164,"./ky":78474,"./ky.js":78474,"./lb":79680,"./lb.js":79680,"./lo":15867,"./lo.js":15867,"./lt":45766,"./lt.js":45766,"./lv":69532,"./lv.js":69532,"./me":58076,"./me.js":58076,"./mi":41848,"./mi.js":41848,"./mk":30306,"./mk.js":30306,"./ml":73739,"./ml.js":73739,"./mr":86169,"./mr.js":86169,"./ms":73386,"./ms-my":92297,"./ms-my.js":92297,"./ms.js":73386,"./mt":77075,"./mt.js":77075,"./my":72264,"./my.js":72264,"./nb":22274,"./nb.js":22274,"./ne":8235,"./ne.js":8235,"./nl":92572,"./nl-be":43784,"./nl-be.js":43784,"./nl.js":92572,"./nn":54566,"./nn.js":54566,"./pa-in":29849,"./pa-in.js":29849,"./pl":94418,"./pl.js":94418,"./pt":79834,"./pt-br":48303,"./pt-br.js":48303,"./pt.js":79834,"./ro":24457,"./ro.js":24457,"./ru":82271,"./ru.js":82271,"./sd":1221,"./sd.js":1221,"./se":33478,"./se.js":33478,"./si":17538,"./si.js":17538,"./sk":5784,"./sk.js":5784,"./sl":46637,"./sl.js":46637,"./sq":86794,"./sq.js":86794,"./sr":45719,"./sr-cyrl":3322,"./sr-cyrl.js":3322,"./sr.js":45719,"./ss":56e3,"./ss.js":56e3,"./sv":41011,"./sv.js":41011,"./sw":40748,"./sw.js":40748,"./ta":11025,"./ta.js":11025,"./te":11885,"./te.js":11885,"./tet":28861,"./tet.js":28861,"./th":55802,"./th.js":55802,"./tl-ph":29231,"./tl-ph.js":29231,"./tlh":31052,"./tlh.js":31052,"./tr":85096,"./tr.js":85096,"./tzl":79846,"./tzl.js":79846,"./tzm":81765,"./tzm-latn":97711,"./tzm-latn.js":97711,"./tzm.js":81765,"./uk":16618,"./uk.js":16618,"./ur":57777,"./ur.js":57777,"./uz":57609,"./uz-latn":72475,"./uz-latn.js":72475,"./uz.js":57609,"./vi":21135,"./vi.js":21135,"./x-pseudo":64051,"./x-pseudo.js":64051,"./yo":82218,"./yo.js":82218,"./zh-cn":52648,"./zh-cn.js":52648,"./zh-hk":1632,"./zh-hk.js":1632,"./zh-tw":50304,"./zh-tw.js":50304};function n(e){var t=o(e);return s(t)}function o(e){if(!s.o(r,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return r[e]}n.keys=function(){return Object.keys(r)},n.resolve=o,e.exports=n,n.id=35358},39234:()=>{},46490:()=>{},56906:()=>{$.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"}})},67920:()=>{},71182:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>g,hpList:()=>p});var r=s(78673);class n{constructor(e){this.hparsons=e,this.percent=0}createOutput(){console.log("createOutput method not implemented in feedback!")}async runButtonHandler(){console.log("runButtonClicked method not implemented in feedback!")}customizeUI(){}init(){}clearFeedback(){console.log("clearFeedback method not implemented in feedback!")}reset(){console.log("reset method not implemented in feedback!")}}class o{constructor(e){this.problem=e,this.percent=0}inverseLISIndices(e){for(var t=[],s=0;s<e.length;s++){for(var r=[e[s]],n=e[s],o=-1,i=s;i<e.length;i++){var a=e[i];a>n&&o<a&&(r.push(a),o=a)}t.push(r)}var l,c=-1;for(let e in t){var d=t[e];d.length>c&&(c=d.length,l=d)}var h=[],u=0;for(let t=0;t<e.length;t++)u>l.length?h.push(t):e[t]==l[u]?u+=1:h.push(t);return h}grade(){this.correctLines=0,this.percentLines=0;var e,t,s=this.solution,r=this.answer;this.percentLines=Math.min(r.length,s.length)/Math.max(r.length,s.length),r.length<s.length?(t="incorrectTooShort",this.correctLength=!1):r.length==s.length?this.correctLength=!0:this.correctLength=!1;let n=!0;this.correctLines=0,this.solutionLength=s.length;let o=Math.min(s.length,r.length);for(e=0;e<o;e++)r[e]!==s[e]?n=!1:this.correctLines+=1;return n&&this.correctLength?t="correct":(n||"incorrectTooShort"==t)&&(this.correctLength||"incorrectTooShort"==t)||(t="incorrectMoveBlocks"),this.calculatePercent(),this.graderState=t,t}calculatePercent(){let e=.2*this.percentLines,t=this.answer.length,s=this.correctLines/t*.8;this.percent=e+s}}s(75794),s(56906);class i extends n{createOutput(){this.messageDiv=document.createElement("div"),this.hparsons.outerDiv.appendChild(this.messageDiv)}customizeUI(){this.hparsons.runButton.textContent="Check Me"}init(){this.checkCount=0,this.solved=!1,this.grader=new o;const e=this.hparsons.blockAnswer.map(Number);this.solution=e,this.grader.solution=e,this.answerArea=this.hparsons.hparsonsInput.querySelector(".drop-area")}async runButtonHandler(){this.checkCurrentAnswer(),this.logCurrentAnswer(),this.renderFeedback()}async logCurrentAnswer(){let e={scheme:"block",correct:"correct"==this.grader.graderState?"T":"F",answer:this.hparsons.hparsonsInput.getBlockIndices(),percent:this.grader.percent},t={event:"hparsonsAnswer",div_id:this.hparsons.divid,act:JSON.stringify(e),answer:JSON.stringify({blocks:e.answer}),percent:this.grader.percent,correct:e.correct};await this.hparsons.logBookEvent(t)}checkCurrentAnswer(){this.solved||(this.checkCount++,this.clearFeedback(),this.grader.answer=this.hparsons.hparsonsInput.getBlockIndices(),this.grade=this.grader.grade(),"correct"==this.grade&&(this.hparsons.runButton.disabled=!0,this.solved=!0))}renderFeedback(){var e;this.grade=this.grader.graderState;var t=this.answerArea;if(e=this.messageDiv,"correct"===this.grade&&(t.classList.add("correct"),e.style.display="",e.className="hp_feedback alert alert-info",this.checkCount>1?e.innerHTML=$.i18n("msg_parson_correct",this.checkCount):e.innerHTML=$.i18n("msg_parson_correct_first_try"),this.checkCount=0),"incorrectTooShort"===this.grade&&(t.classList.add("incorrect"),e.style.display="",e.className="hp_feedback alert alert-danger",e.innerHTML=$.i18n("msg_parson_too_short")),"incorrectMoveBlocks"===this.grade){var s=this.answerArea.children,r=[],n=[],o=[];for(let e=0;e<s.length;e++){var i=s[e],a=this.solution.indexOf(Number(i.dataset.index));-1==a?o.push(i):(r.push(i),n.push(a))}var l=this.grader.inverseLISIndices(n);for(let e=0;e<l.length;e++)o.push(r[l[e]]);t.classList.add("incorrect"),e.style.display="",e.className="alert alert-danger";for(let e=0;e<o.length;e++)o[e].classList.add("incorrectPosition");e.innerHTML=$.i18n("msg_parson_wrong_order")}}clearFeedback(){this.answerArea.classList.remove("incorrect","correct");for(var e=this.answerArea.childNodes,t=0;t<e.length;t++)e[t].classList.remove("correctPosition","incorrectPosition");this.messageDiv.style.display="none"}reset(){this.solved&&(this.checkCount=0,this.hparsons.runButton.disabled=!1,this.solved=!1),this.clearFeedback()}}var a=s(15826),l=s.n(a),c=s(12307),d={};class h extends n{createOutput(){var e=document.createElement("div");e.classList.add("hp_output"),this.outDiv=e,this.output=document.createElement("pre"),this.output.id=this.hparsons.divid+"_stdout",this.output.style.visibility="hidden";var t=document.createElement("div");t.style.clear="both",this.hparsons.outerDiv.appendChild(t),e.appendChild(this.output),this.hparsons.outerDiv.appendChild(e),(t=document.createElement("div")).style.clear="both",this.hparsons.outerDiv.appendChild(t)}renderFeedback(){this.testResult&&(this.output.textContent=this.testResult,this.output.style.visibility="visible"),this.outDiv.style.display=""}clearFeedback(){this.outDiv.style.display="none"}reset(){this.clearFeedback()}init(){var e,t;eBookConfig.useRunestoneServices||window.location.search.includes("mode=browsing")?(e=`/books/published/${eBookConfig.basecourse}`,t=e+"/_static"):(e="",t="/_static");let s={locateFile:e=>`${t}/${e}`};var r=this.hparsons;l()(s).then((function(t){if(r.dburl){r.dburl.startsWith("/_static")&&(r.dburl=`${e}${r.dburl}`),r.runButton.setAttribute("disabled","disabled");let n=r.runButton.textContent;if(r.runButton.textContent="Loading database...",r.dburl in d)return"loading"==d[r.dburl].status?void d[r.dburl].xWaitFor.promise.then((function(){r.db=d[r.dburl].dbObject,r.runButton.removeAttribute("disabled"),r.runButton.textContent=n})):(r.db=d[r.dburl].dbObject,r.runButton.removeAttribute("disabled"),void(r.runButton.textContent=n));{let e;const t=new Promise((t=>{e=t}));d[r.dburl]={status:"loading",xWaitFor:{promise:t,resolve:e}}}var s=new XMLHttpRequest;s.open("GET",r.dburl,!0),s.responseType="arraybuffer",s.onload=e=>{var o=new Uint8Array(s.response);r.db=new t.Database(o),d[r.dburl].dbObject=r.db,r.runButton.textContent=n,r.runButton.removeAttribute("disabled"),d[r.dburl].db=o,d[r.dburl].status="ready",d[r.dburl].xWaitFor.resolve()},s.send()}else r.db=new t.Database}))}async runButtonHandler(){this.hparsons.runButton.disabled=!0;try{await this.runProg()}catch(e){console.log(`there was an error ${e} running the code`)}this.logCurrentAnswer(),this.renderFeedback(),this.hparsons.runButton.disabled=!1}async runProg(){let e=this.hparsons.divid+"_sql_out",t=document.getElementById(e);t&&t.parentElement.removeChild(t),this.output.textContent="",t=document.createElement("div"),t.id=e,this.outDiv.appendChild(t),this.outDiv.style.display="";let s=await this.buildProg();if(!this.hparsons.db)return void(this.output.textContent=`Error: Database not initialized! DBURL: ${this.hparsons.dburl}`);let r=!0;return s.prefix&&(this.prefixresults=this.executeIteratedStatements(this.hparsons.db.iterateStatements(s.prefix)),"failure"==this.prefixresults.at(-1).status&&(this.visualizeResults(t,this.prefixresults,"Error executing hidden code in prefix"),r=!1)),r&&(this.results=this.executeIteratedStatements(this.hparsons.db.iterateStatements(s.input)),"failure"==this.results.at(-1).status?(this.visualizeResults(t,this.results),r=!1):s.suffix||this.visualizeResults(t,this.results)),r&&s.suffix&&(this.suffixresults=this.executeIteratedStatements(this.hparsons.db.iterateStatements(s.suffix)),"failure"==this.suffixresults.at(-1).status?(this.visualizeResults(t,this.suffixresults,"Error executing hidden code in suffix"),r=!1):this.visualizeResults(t,this.suffixresults)),this.hparsons.unittest?r?this.suffixresults?this.testResult=this.autograde(this.suffixresults[this.suffixresults.length-1]):this.testResult=this.autograde(this.results[this.results.length-1]):(this.passed=0,this.failed=0,this.percent=NaN,this.unit_results=`percent:${this.percent}:passed:${this.passed}:failed:${this.failed}`,this.output.style.visibility="hidden"):this.output.style.visibility="hidden",Promise.resolve("done")}executeIteratedStatements(e){let t=[];try{for(let s of e){let e=s.getColumnNames();if(e.length>0){let r=[];for(;s.step();)r.push(s.get());t.push({status:"success",columns:e,values:r,rowcount:r.length})}else{let e=s.getNormalizedSQL().substr(0,6).toLowerCase();s.step(),"insert"===e||"update"===e||"delete"===e?t.push({status:"success",operation:e,rowcount:this.hparsons.db.getRowsModified()}):t.push({status:"success"})}}}catch(s){t.push({status:"failure",message:s.toString(),sql:e.getRemainingSQL()})}return 0===t.length&&t.push({status:"failure",message:"No queries submitted."}),t}visualizeResults(e,t,s){if(s){let t=document.createElement("div");t.setAttribute("class","hp_sql_result"),e.appendChild(t);let r=document.createElement("pre");r.textContent=s,r.setAttribute("class","hp_sql_result_failure"),t.appendChild(r)}for(let s of t){let r=document.createElement("div");if(r.setAttribute("class","hp_sql_result"),e.appendChild(r),"success"===s.status)if(s.columns){let e=document.createElement("div");r.appendChild(e);let n=350;t.length>1&&(n=200),u(s,e,n);let o=document.createElement("pre"),i=1!==s.rowcount?" rows ":" row ",a=""+s.rowcount+i+"returned";s.rowcount>100&&(a+=" (only first 100 rows displayed)"),a+=".",o.textContent=a,o.setAttribute("class","hp_sql_result_success"),r.appendChild(o)}else if(s.rowcount){let e=document.createElement("pre"),t=s.operation;t+="e"===t.charAt(t.length-1)?"d.":"ed.";let n=1!==s.rowcount?" rows ":" row ";e.textContent=""+s.rowcount+n+t,e.setAttribute("class","hp_sql_result_success"),r.appendChild(e)}else{let e=document.createElement("pre");e.textContent="Operation succeeded.",e.setAttribute("class","hp_sql_result_success"),r.appendChild(e)}else{let e=document.createElement("pre");e.textContent=s.message,e.setAttribute("class","hp_sql_result_failure"),r.appendChild(e)}}}async buildProg(){let e={};return this.hparsons.hiddenPrefix&&(e.prefix=this.hparsons.hiddenPrefix),e.input=this.hparsons.hparsonsInput.getParsonsTextArray().join(" ")+"\n",this.hparsons.hiddenSuffix&&(e.suffix=this.hparsons.hiddenSuffix),Promise.resolve(e)}async logCurrentAnswer(){if(this.unit_results){let e={scheme:"execution",correct:0==this.failed&&0!=this.passed?"T":"F",answer:this.hparsons.hparsonsInput.getParsonsTextArray(),percent:this.percent},t={event:"hparsonsAnswer",div_id:this.hparsons.divid,act:JSON.stringify(e),percent:this.percent||0,correct:e.correct,answer:JSON.stringify({blocks:e.answer})};await this.hparsons.logBookEvent(t)}}autograde(e){var t=this.hparsons.unittest.split(/\n/);this.passed=0,this.failed=0;var s="";t=t.filter((function(e){return e.indexOf("assert")>-1}));for(let r of t){let t=r.split(/\s+/);t.shift();let n=t.shift(),o=t.shift(),i=t.join(" "),[a,l]=n.split(",");s+=this.testOneAssert(a,l,o,i,e),s+="\n"}let r=100*this.passed/(this.passed+this.failed);return this.percent=r,r=r.toLocaleString(void 0,{maximumFractionDigits:2}),s+=`You passed ${this.passed} out of ${this.passed+this.failed} tests for ${r}%`,this.unit_results=`percent:${r}:passed:${this.passed}:failed:${this.failed}`,s}testOneAssert(e,t,s,r,n){let o,i="";try{o=n.values[e][t]}catch(s){return"NO_DATA"==r?(this.passed++,i=`Passed: No data in row ${e}, column ${t}`,i):(i=`Failed: Not enough data to check row ${e} or column ${t}`,i)}return{"==":function(e,t){return e==t},"!=":function(e,t){return e!=t},">":function(e,t){return e>t},"<":function(e,t){return e>t}}[s](o,r)?(i=`Pass: ${o} ${s} ${r} in row ${e} column ${n.columns[t]}`,this.passed++):(i=`Failed ${o} ${s} ${r} in row ${e} column ${n.columns[t]}`,this.failed++),i}}function u(e,t,s){let r,n=e.values;0===n.length&&(n=[e.columns.map((e=>null))],r=[0]);var o=new c.A(t,{data:n,trimRows:r,width:"100%",height:s,autoRowSize:!0,autoColumnSize:{useHeaders:!0},rowHeaders:!1,colHeaders:e.columns,editor:!1,maxRows:100,filters:!1,dropdownMenu:!1,licenseKey:"non-commercial-and-evaluation"});let i=40;if(e.values.length>0)for(let e=0;e<n.length&&(i+=o.getRowHeight(e),!(i>s));e++);return o.updateSettings({height:i}),o}var p,m=s(78207);void 0===p&&(p={});class g extends r.A{constructor(e){super(e);var t=e.orig.querySelector("textarea");this.reuse=this.parseBooleanAttribute(t,"data-reuse"),this.randomize=this.parseBooleanAttribute(t,"data-randomize"),this.isBlockGrading=this.parseBooleanAttribute(t,"data-blockanswer"),this.language=t.getAttribute("data-language"),null==this.language&&t.textContent.includes('span class="process-math"')&&(this.language="math"),this.isBlockGrading&&(this.blockAnswer=t.getAttribute("data-blockanswer").split(" ")),this.divid=e.orig.id,this.containerDiv=e.orig,this.useRunestoneServices=e.useRunestoneServices;var s=super.localStorageKey();this.storageId=s,this.origElem=t;let r=e.orig.querySelector(".hp_question");r&&r.classList.add("exercise-statement"),this.origText=this.origElem.textContent,this.code=t.textContent||"\n\n\n\n\n",this.dburl=t.getAttribute("data-dburl"),this.runButton=null,this.saveButton=null,this.loadButton=null,this.outerDiv=null,this.controlDiv=null,this.processContent(this.code),this.isBlockGrading?this.feedbackController=new i(this):this.feedbackController=new h(this),this.createEditor(),this.createControls(),this.createOutput(),this.feedbackController.customizeUI(),t.getAttribute("data-caption")?this.caption=t.getAttribute("data-caption"):this.caption="MicroParsons",this.addCaption("runestone"),this.indicate_component_ready(),this.feedbackController.init(),this.checkServer("hparsonsAnswer",!0)}processContent(e){this.hiddenPrefix=this.processSingleContent(e,"--hiddenprefix--"),this.originalBlocks=this.processSingleContent(e,"--blocks--").split("\n").slice(1,-1),this.hiddenSuffix=this.processSingleContent(e,"--hiddensuffix--"),this.unittest=this.processSingleContent(e,"--unittest--")}processSingleContent(e,t){let s=e.indexOf(t);if(s>-1){let r=e.substring(s+t.length),n=r.indexOf("\n--");return r=n>-1?r.substring(0,n+1):r,r}}createEditor(){this.outerDiv=document.createElement("div"),this.origElem.replaceWith(this.outerDiv),this.outerDiv.id=`${this.divid}-container`,this.outerDiv.addEventListener("micro-parsons",(e=>{["input","reset"].includes(e.detail.type)&&(this.logHorizontalParsonsEvent(e.detail),this.feedbackController.clearFeedback())}));const e={selector:`#${this.divid}-container`,id:`${this.divid}-hparsons`,reuse:this.reuse,randomize:this.randomize,parsonsBlocks:[...this.originalBlocks],language:this.language};(0,m.z)(e),this.hparsonsInput=this.outerDiv.querySelector("micro-parsons"),this.renderMathInBlocks(),null!=this.language&&"math"!==this.language||this.outerDiv.querySelectorAll(".hparsons-tip").forEach((e=>{e.textContent.includes("our code")&&(e.textContent=e.textContent.replace("our code","our answer"))}))}createOutput(){this.feedbackController.createOutput()}createControls(){var e=document.createElement("div");e.classList.add("hp_actions"),this.runButton=document.createElement("button"),this.runButton.classList.add("btn","btn-success","run-button"),e.appendChild(this.runButton),this.runButton.setAttribute("type","button"),this.runButton.textContent="Run";var t,s=this;this.runButton.onclick=()=>{s.feedbackController.runButtonHandler(),s.setLocalStorage()},(t=document.createElement("button")).textContent="Reset",t.classList.add("btn","btn-warning","run-button"),e.appendChild(t),this.resetButton=t,this.resetButton.onclick=()=>{s.hparsonsInput.resetInput(),s.setLocalStorage(),s.feedbackController.reset(),s.renderMathInBlocks()},t.setAttribute("type","button"),this.outerDiv.appendChild(e),this.controlDiv=e}decodeHTMLEntities(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}renderMathInBlocks(){"math"===this.language&&setTimeout((()=>{document.querySelectorAll(`#${this.divid}-container .parsons-block`).forEach((e=>{e.innerHTML=this.decodeHTMLEntities(e.innerHTML),this.queueMathJax(e)}))}),10)}localData(){var e=localStorage.getItem(this.storageId);return null!==e&&"{"==e.charAt(0)?JSON.parse(e):{}}restoreAnswers(e){if(e.answer){const t=e.answer.blocks??e.answer;if(Array.isArray(t)&&t.length>0){const e=t[0];("number"==typeof e||/^\d+$/.test(String(e)))&&this.hparsonsInput.restoreAnswerByIndices?this.hparsonsInput.restoreAnswerByIndices(t.map(Number)):this.hparsonsInput.restoreAnswer(t)}}e.count&&(this.feedbackController.checkCount=e.count)}checkLocalStorage(){if(this.graderactive)return;let e=this.localData();if(e.timestamp&&e.timestamp<eBookConfig.termStartDate)localStorage.removeItem(this.storageId);else{if(e.answerIndices&&this.hparsonsInput.restoreAnswerByIndices)this.hparsonsInput.restoreAnswerByIndices(e.answerIndices.map(Number));else if(e.answer&&(this.hparsonsInput.restoreAnswer(e.answer),this.isBlockGrading)){const t=this.hparsonsInput.getBlockIndices();e.answerIndices=t,localStorage.setItem(this.storageId,JSON.stringify(e))}e.count&&(this.feedbackController.checkCount=e.count)}}setLocalStorage(e){let t={};null==e?(this.isBlockGrading?(t={answerIndices:this.hparsonsInput.getBlockIndices()},t.count=this.feedbackController.checkCount):t={answer:this.hparsonsInput.getParsonsTextArray()},t.timestamp=new Date):t=e,localStorage.setItem(this.storageId,JSON.stringify(t))}logHorizontalParsonsEvent(e){let t={event:"hparsons",div_id:this.divid,act:JSON.stringify(e)};this.logBookEvent(t)}}document.addEventListener("runestone:login-complete",(function(){document.querySelectorAll("[data-component=hparsons]").forEach((function(e){e.closest("[data-component=timedAssessment]")||(p[e.id]=new g({orig:e,useRunestoneServices:eBookConfig.useRunestoneServices}))}))})),void 0===window.component_factory&&(window.component_factory={}),window.component_factory.hparsons=function(e){return new g(e)}},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"}})}}]);
//# sourceMappingURL=486.b03e25ab1e190440.js.map