"use strict";(self.webpackChunkWebComponents=self.webpackChunkWebComponents||[]).push([[680],{84680:(e,t,s)=>{s.r(t);var r=s(78673);window.wwList={};class o extends r.A{constructor(e){super(e),this.useRunestoneServices=!0,this.multipleanswers=!1,this.divid=e.orig.id,this.correct=null,this.optional=!1,this.answerList=[],this.correctList=[],this.question=null,this.caption="WebWork",this.containerDiv=e.orig,this.answers={},this.percent=0,"fakeww-ww-rs"!==this.divid&&this.checkServer("webwork",!0),window.wwList[this.divid]=this}restoreAnswers(e){e.answer||(e.answer=""),this.answers=e.answer,this.correct=e.correct,this.percent=e.percent,console.log(`about to decorate the status of WW ${this.divid} ${this.correct}`),this.decorateStatus()}checkLocalStorage(){var e;if(!this.graderactive){localStorage.length;var t=localStorage.getItem(this.localStorageKey());if(null!==t)try{e=JSON.parse(t),this.answers=e.answer,this.correct=e.correct,this.percent=e.percent,this.decorateStatus()}catch(e){return console.log(e.message),void localStorage.removeItem(this.localStorageKey())}}}setLocalStorage(e){var t=new Date,s={answer:e.answer,timestamp:t,correct:e.correct};localStorage.setItem(this.localStorageKey(),JSON.stringify(s))}processCurrentAnswers(e){let t=0,s=0,r="check:";this.answerObj={},this.lastAnswerRaw=e,this.answerObj.answers={},this.answerObj.mqAnswers={};for(let o of Object.keys(e.rh_result.answers)){let n;s+=1,1==e.rh_result.answers[o].score&&(t+=1),n=!("ww_version"in e)||e.ww_version.includes("2.16")||e.ww_version.includes("2.17")||e.ww_version.includes("2.18")?["Value (parserRadioButtons)","Value (PopUp)","Value (CheckboxList)"].includes(e.rh_result.answers[o].type)?e.rh_result.answers[o].student_value:e.rh_result.answers[o].original_student_ans:e.inputs_ref[o],this.answerObj.answers[o]=n;let i=`MaThQuIlL_${o}`;this.answerObj.mqAnswers[i]=e.inputs_ref[i],r+=`actual:${n}:expected:${e.rh_result.answers[o].correct_value}:`}let o=t/s;this.percent=o,this.actString=r+`correct:${t}:count:${s}:pct:${o}`,this.correct=1==o;let n={};n.answer=this.answerObj,n.correct=this.correct,n.percent=this.percent,this.setLocalStorage(n),this.decorateStatus()}async logCurrentAnswer(e){this.logBookEvent({event:"webwork",div_id:this.divid,act:this.actString,correct:this.correct,answer:JSON.stringify(this.answerObj)})}checkCurrentAnswer(){}}function n(e,t){if(eBookConfig.useRunestoneServices){let e=wwList[t.inputs_ref.problemUUID.replace("-ww-rs","")];e?(e.processCurrentAnswers(t),e.logCurrentAnswer()):console.log(`Error: Could not find webwork object ${t.inputs_ref.problemUUID}`)}}function i(e,t){if(eBookConfig.useRunestoneServices){let e=wwList[t.inputs_ref.problemUUID.replace("-ww-rs","")];e?e.logBookEvent({event:"webwork",div_id:t.inputs_ref.problemUUID,act:"show"}):console.log(`Error: Could not find webwork object ${t.inputs_ref.problemUUID}`)}}void 0===window.component_factory&&(window.component_factory={}),window.component_factory.webwork=function(e){return new o(e)},$((function(){$("body").on("runestone_ww_check",n),$("body").on("runestone_show_correct",i)})),$(document).on("runestone:login-complete",(function(){$("[data-component=webwork]").each((function(e){var t={orig:this,useRunestoneServices:eBookConfig.useRunestoneServices};0==$(this).closest("[data-component=timedAssessment]").length&&(window.wwList[this.id]=new o(t))}))}))}}]);
//# sourceMappingURL=680.ec85c3ce31480628.js.map