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