"use strict";(self.webpackChunkWebComponents=self.webpackChunkWebComponents||[]).push([[662],{10662:(e,t,i)=>{i.r(t),i.d(t,{default:()=>l});var n=i(98098),s=i(78673),o=i(34089);class l extends s.A{constructor(e){super(e),this.origOpts=e,this.questions=(0,o.Qt)(e.orig,"questionlist"),this.proficiency=(0,o.Qt)(e.orig,"proficiency"),this.minDifficulty=(0,o.Qt)(e.orig,"min-difficulty"),this.maxDifficulty=(0,o.Qt)(e.orig,"max-difficulty"),this.points=(0,o.Qt)(e.orig,"points"),this.autogradable=(0,o.Qt)(e.orig,"autogradable"),this.not_seen_ever=(0,o.Qt)(e.orig,"not_seen_ever"),this.selector_id=e.orig.getAttribute("id"),this.primaryOnly=(0,o.Qt)(e.orig,"primary"),this.ABExperiment=(0,o.Qt)(e.orig,"ab"),this.toggleOptions=(0,o.Qt)(e.orig,"toggleoptions"),this.toggleLabels=(0,o.Qt)(e.orig,"togglelabels"),this.limitBaseCourse=(0,o.Qt)(e.orig,"limit-basecourse"),e.orig.id=this.selector_id}async initialize(){let e=this,t={selector_id:this.selector_id};this.questions?t.questions=this.questions:this.proficiency&&(t.proficiency=this.proficiency),this.minDifficulty&&(t.minDifficulty=this.minDifficulty),this.maxDifficulty&&(t.maxDifficulty=this.maxDifficulty),this.points&&(t.points=this.points),this.autogradable&&(t.autogradable=this.autogradable),this.not_seen_ever&&(t.not_seen_ever=this.not_seen_ever),this.primaryOnly&&(t.primary=this.primaryOnly),this.ABExperiment&&(t.AB=this.ABExperiment),this.timedWrapper&&(t.timedWrapper=this.timedWrapper),this.toggleOptions&&(t.toggleOptions=this.toggleOptions),this.toggleLabels&&(t.toggleLabels=this.toggleLabels),this.limitBaseCourse&&(t.limitBaseCourse=eBookConfig.basecourse);let i=this.origOpts,s=this.selector_id;console.log("getting question source");let o,l=new Request(`${eBookConfig.new_server_prefix}/assessment/get_question_source`,{method:"POST",headers:this.jsonHeaders,body:JSON.stringify(t)}),a=await fetch(l),c=await a.json();if(c=c.detail,c.indexOf("No preview")>=0)throw alert(`Error: Not able to find a question for ${s} based on the criteria`),new Error(`Unable to find a question for ${s}`);if(i.timed){o=(0,n.$y)(c,{timed:!0,selector_id:s,assessmentTaken:i.assessmentTaken});for(let t of i.rqa)if(t.question==e){t.question=o.question;break}e.realComponent=o.question,e.containerDiv=o.question.containerDiv,e.realComponent.selectorId=s}else{if(t.toggleOptions){var g=t.toggleLabels;if(g){g=(g=g.replace("togglelabels:","").trim()).split(",");for(var d=0;dToggle Question:
';var y=c.split('id="')[1];y=y.split('"')[0],c=f+c+"
"}if(await(0,n.JK)(c,s,{selector_id:s,is_toggle:this.toggleOptions,is_select:!0,useRunestoneServices:!0}),t.toggleOptions){r(document.getElementById("component-preview"));var w=document.getElementById(s+"-toggleQuestion");for(p=0;p")+10),v=i.slice(i.indexOf(""),i.length);i=f+p+v,await this.toggleSet(e,t,i,n),r(document.getElementById("component-preview"))}}function r(e){e&&(e.style.display="none")}void 0===window.component_factory&&(window.component_factory={}),window.component_factory.selectquestion=function(e){return new l(e)},document.addEventListener("runestone:login-complete",(async function(){let e=document.querySelectorAll("[data-component=selectquestion]");for(let t of e)try{if(!t.closest("[data-component=timedAssessment]")){let e=new l({orig:t});await e.initialize()}}catch(e){console.log(`Error rendering New Exercise ${t.id}\n Details: ${e}`),console.log(e.stack)}}))}}]); //# sourceMappingURL=662.054322cea578175f.js.map