@citolab/qti-components 7.26.0 → 7.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/index.global.js +1 -1
- package/cdn/index.js +351 -342
- package/custom-elements.json +17216 -18384
- package/dist/base.d.ts +2 -2
- package/dist/base.js +1 -1
- package/dist/{chunk-FEO7D54Z.js → chunk-75ME6QG5.js} +3 -3
- package/dist/{chunk-VQAG7NSK.js → chunk-DG5TP35K.js} +2 -2
- package/dist/{chunk-IKBPPSNQ.js → chunk-G5ZUC3OT.js} +14 -2
- package/dist/{chunk-IKBPPSNQ.js.map → chunk-G5ZUC3OT.js.map} +1 -1
- package/dist/{chunk-RKXUA6D6.js → chunk-GG36UR7F.js} +2 -2
- package/dist/{chunk-DUBGJJ75.js → chunk-QUWFDFGZ.js} +3 -3
- package/dist/{chunk-BHB6PYJG.js → chunk-TORB5UN2.js} +1 -59
- package/dist/chunk-TORB5UN2.js.map +1 -0
- package/dist/{chunk-LPVYU726.js → chunk-TZMDZQFG.js} +4 -4
- package/dist/{chunk-I4NHZ6D6.js → chunk-XZY2TIZJ.js} +8404 -6413
- package/dist/chunk-XZY2TIZJ.js.map +1 -0
- package/dist/config.context-BjZ2bZSY.d.ts +42 -0
- package/dist/elements.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -8
- package/dist/{interaction-B1Pu7KOD.d.ts → interaction-Bgzlw7Iu.d.ts} +1 -1
- package/dist/interactions.d.ts +124 -13
- package/dist/interactions.js +3 -3
- package/dist/item.css +12 -0
- package/dist/item.d.ts +1 -1
- package/dist/item.js +3 -3
- package/dist/processing.js +2 -2
- package/dist/qti-components-jsx.d.ts +1169 -1126
- package/dist/test.d.ts +1 -1
- package/dist/test.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-BHB6PYJG.js.map +0 -1
- package/dist/chunk-I4NHZ6D6.js.map +0 -1
- package/dist/config.context-DUz2-kxN.d.ts +0 -14
- /package/dist/{chunk-FEO7D54Z.js.map → chunk-75ME6QG5.js.map} +0 -0
- /package/dist/{chunk-VQAG7NSK.js.map → chunk-DG5TP35K.js.map} +0 -0
- /package/dist/{chunk-RKXUA6D6.js.map → chunk-GG36UR7F.js.map} +0 -0
- /package/dist/{chunk-DUBGJJ75.js.map → chunk-QUWFDFGZ.js.map} +0 -0
- /package/dist/{chunk-LPVYU726.js.map → chunk-TZMDZQFG.js.map} +0 -0
package/cdn/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${r}" has already been used with this registry`);if(this.__reverseDefinitions.has(e))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(e)}`);e.__localName=r,this.__definitions.set(r,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,r),this.__pendingWhenDefineds.get(r)?.resolve(e),this.__pendingWhenDefineds.delete(r)}get(r){return this.__definitions.get(r)?.ctor}getName(r){return this.__reverseDefinitions.get(r)??null}upgrade(r){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(r){let e=this.__definitions.get(r);if(e)return e.ctor;let t=this.__pendingWhenDefineds.get(r);return t||(t=
|
|
3
|
-
\f\r]`,
|
|
4
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),nn=/'/g,an=/"/g,dn=/^(?:script|style|textarea|title)$/i,Us=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),f=Us(1),Ii=Us(2),Ac=Us(3),z=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),ln=new WeakMap,ct=dt.createTreeWalker(dt,129);function pn(o,r){if(!zs(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return rn!==void 0?rn.createHTML(r):r}var un=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=mr;for(let a=0;a<e;a++){let l=o[a],d,p,m=-1,h=0;for(;h<l.length&&(n.lastIndex=h,p=n.exec(l),p!==null);)h=n.lastIndex,n===mr?p[1]==="!--"?n=sn:p[1]!==void 0?n=on:p[2]!==void 0?(dn.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=lt):p[3]!==void 0&&(n=lt):n===lt?p[0]===">"?(n=i??mr,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?lt:p[3]==='"'?an:nn):n===an||n===nn?n=lt:n===sn||n===on?n=mr:(n=lt,i=void 0);let g=n===lt&&o[a+1].startsWith("/>")?" ":"";s+=n===mr?l+ql:m>=0?(t.push(d),l.slice(0,m)+Ds+l.slice(m)+Ie+g):l+Ie+(m===-2?a:g)}return[pn(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},gr=class o{constructor({strings:r,_$litType$:e},t){let i;this.parts=[];let s=0,n=0,a=r.length-1,l=this.parts,[d,p]=un(r,e);if(this.el=o.createElement(d,t),ct.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=ct.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Ds)){let h=p[n++],g=i.getAttribute(m).split(Ie),v=/([.?@])?(.*)/.exec(h);l.push({type:1,index:s,name:v[2],strings:g,ctor:v[1]==="."?Ti:v[1]==="?"?Ai:v[1]==="@"?Si:ut}),i.removeAttribute(m)}else m.startsWith(Ie)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(dn.test(i.tagName)){let m=i.textContent.split(Ie),h=m.length-1;if(h>0){i.textContent=wi?wi.emptyScript:"";for(let g=0;g<h;g++)i.append(m[g],hr()),ct.nextNode(),l.push({type:2,index:++s});i.append(m[h],hr())}}}else if(i.nodeType===8)if(i.data===Hs)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(Ie,m+1))!==-1;)l.push({type:7,index:s}),m+=Ie.length-1}s++}}static createElement(r,e){let t=dt.createElement("template");return t.innerHTML=r,t}};function pt(o,r,e=o,t){if(r===z)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=fr(r)?void 0:r._$litDirective$;return i?.constructor!==s&&(i?._$AO?.(!1),s===void 0?i=void 0:(i=new s(o),i._$AT(o,e,t)),t!==void 0?(e._$Co??=[])[t]=i:e._$Cl=i),i!==void 0&&(r=pt(o,i._$AS(o,r.values),i,t)),r}var Ei=class{constructor(r,e){this._$AV=[],this._$AN=void 0,this._$AD=r,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(r){let{el:{content:e},parts:t}=this._$AD,i=(r?.creationScope??dt).importNode(e,!0);ct.currentNode=i;let s=ct.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new Et(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new ki(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=ct.nextNode(),n++)}return ct.currentNode=dt,i}p(r){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(r,t,e),e+=t.strings.length-2):t._$AI(r[e])),e++}},Et=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=L,this._$AN=void 0,this._$AA=r,this._$AB=e,this._$AM=t,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let r=this._$AA.parentNode,e=this._$AM;return e!==void 0&&r?.nodeType===11&&(r=e.parentNode),r}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(r,e=this){r=pt(this,r,e),fr(r)?r===L||r==null||r===""?(this._$AH!==L&&this._$AR(),this._$AH=L):r!==this._$AH&&r!==z&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):cn(r)?this.k(r):this._(r)}O(r){return this._$AA.parentNode.insertBefore(r,this._$AB)}T(r){this._$AH!==r&&(this._$AR(),this._$AH=this.O(r))}_(r){this._$AH!==L&&fr(this._$AH)?this._$AA.nextSibling.data=r:this.T(dt.createTextNode(r)),this._$AH=r}$(r){let{values:e,_$litType$:t}=r,i=typeof t=="number"?this._$AC(r):(t.el===void 0&&(t.el=gr.createElement(pn(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Ei(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=ln.get(r.strings);return e===void 0&&ln.set(r.strings,e=new gr(r)),e}k(r){zs(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,i=0;for(let s of r)i===e.length?e.push(t=new o(this.O(hr()),this.O(hr()),this,this.options)):t=e[i],t._$AI(s),i++;i<e.length&&(this._$AR(t&&t._$AB.nextSibling,i),e.length=i)}_$AR(r=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);r!==this._$AB;){let t=r.nextSibling;r.remove(),r=t}}setConnected(r){this._$AM===void 0&&(this._$Cv=r,this._$AP?.(r))}},ut=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=L,this._$AN=void 0,this.element=r,this.name=e,this._$AM=i,this.options=s,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=L}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=pt(this,r,e,0),n=!fr(r)||r!==this._$AH&&r!==z,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=pt(this,a[t+l],e,l),d===z&&(d=this._$AH[l]),n||=!fr(d)||d!==this._$AH[l],d===L?r=L:r!==L&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===L?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Ti=class extends ut{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===L?void 0:r}},Ai=class extends ut{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==L)}},Si=class extends ut{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=pt(this,r,e,0)??L)===z)return;let t=this._$AH,i=r===L&&t!==L||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==L&&(t===L||i);i&&this.element.removeEventListener(this.name,this,t),s&&this.element.addEventListener(this.name,this,r),this._$AH=r}handleEvent(r){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,r):this._$AH.handleEvent(r)}},ki=class{constructor(r,e,t){this.element=r,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(r){pt(this,r)}},W={M:Ds,P:Ie,A:Hs,C:1,L:un,R:Ei,D:cn,V:pt,I:Et,H:ut,N:Ai,U:Si,B:Ti,F:ki},Cl=Mi.litHtmlPolyfillSupport;Cl?.(gr,Et),(Mi.litHtmlVersions??=[]).push("3.3.1");var Bs=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new Et(r.insertBefore(hr(),s),s,void 0,e??{})}return i._$AI(o),i};var Fs=globalThis,b=class extends Me{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let r=super.createRenderRoot();return this.renderOptions.renderBefore??=r.firstChild,r}update(r){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(r),this._$Do=Bs(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return z}};b._$litElement$=!0,b.finalized=!0,Fs.litElementHydrateSupport?.({LitElement:b});var wl=Fs.litElementPolyfillSupport;wl?.({LitElement:b});(Fs.litElementVersions??=[]).push("4.2.1");var C=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var El={attribute:!0,type:String,converter:pr,reflect:!1,hasChanged:Ci},Tl=(o=El,r,e)=>{let{kind:t,metadata:i}=e,s=globalThis.litPropertyMetadata.get(i);if(s===void 0&&globalThis.litPropertyMetadata.set(i,s=new Map),t==="setter"&&((o=Object.create(o)).wrapped=!0),s.set(e.name,o),t==="accessor"){let{name:n}=e;return{set(a){let l=r.get.call(this);r.set.call(this,a),this.requestUpdate(n,l,o)},init(a){return a!==void 0&&this.C(n,void 0,o,a),a}}}if(t==="setter"){let{name:n}=e;return function(a){let l=this[n];r.call(this,a),this.requestUpdate(n,l,o)}}throw Error("Unsupported decorator location: "+t)};function u(o){return(r,e)=>typeof e=="object"?Tl(o,r,e):((t,i,s)=>{let n=i.hasOwnProperty(s);return i.constructor.createProperty(s,t),n?Object.getOwnPropertyDescriptor(i,s):void 0})(o,r,e)}function w(o){return u({...o,state:!0,attribute:!1})}var ze=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function Tt(o,r){return(e,t,i)=>{let s=n=>n.renderRoot?.querySelector(o)??null;if(r){let{get:n,set:a}=typeof t=="object"?e:i??(()=>{let l=Symbol();return{get(){return this[l]},set(d){this[l]=d}}})();return ze(e,t,{get(){let l=n.call(this);return l===void 0&&(l=s(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return ze(e,t,{get(){return s(this)}})}}function mn(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return ze(r,e,{get(){let n=this.renderRoot?.querySelector(s),a=n?.assignedElements(o)??[];return i===void 0?a:a.filter((l=>l.matches(i)))}})}}function hn(o,r,e){Array.from(o.getElementsByTagName("*")).filter(s=>s.localName===r||s.localName?.toLowerCase()===r.toLowerCase()).forEach(s=>{let n=`${r}-${e}`,a=gn(s,n);s.replaceWith(a)})}function fn(o,r){o.querySelectorAll("*").forEach(e=>{let t=e.classList;t&&t.forEach(i=>{if(i.startsWith(`${r}:`)){let s=i.slice(`${r}:`.length),n=`${e.nodeName}-${s}`,a=gn(e,n);e.replaceWith(a)}})})}function gn(o,r){let e=o.ownerDocument.createElement(r);for(let t of o.attributes)e.setAttribute(t.name,t.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function bn(o){let r=[];return o.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let t=e.getAttribute("identifier"),i=e.getAttribute("href"),s=e.getAttribute("category");r.push({identifier:t,href:i,category:s})}),r}function At(o,r){return fetch(o,{signal:r}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>new DOMParser().parseFromString(e,"text/xml")).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function St(o){return new DOMParser().parseFromString(o,"text/xml")}function vn(o,r){if(o.nodeType===Node.ELEMENT_NODE){let e=o,t=r.createElement(e.localName);for(let i=0;i<e.attributes.length;i++){let s=e.attributes[i];t.setAttribute(s.localName,s.value)}for(let i=0;i<e.childNodes.length;i++)t.appendChild(vn(e.childNodes[i],r));return t}return o.cloneNode(!1)}function kt(o){let r=document.createDocumentFragment();for(let e=0;e<o.childNodes.length;e++)r.appendChild(vn(o.childNodes[e],document));return r}function Mt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("*").forEach(t=>{for(let i of["src","href"]){let s=t.getAttribute(i)?.trim();if(s&&!/^(data:|https?:|blob:)/.test(s)){let n=r+encodeURI(s);t.setAttribute(i,n)}}})}function yn(o){o.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let t=document.createComment(e.textContent);e.replaceChild(t,e.firstChild)})}function xn(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function qn(o){switch(o){case"qti-choice-interaction":case"qti-order-interaction":return"qti-simple-choice";case"qti-inline-choice-interaction":return"qti-inline-choice";case"qti-match-interaction":return["qti-simple-match-set:first-of-type qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice"];case"qti-gap-match-interaction":return"qti-gap-text";case"qti-associate-interaction":return"qti-simple-associable-choice";default:return null}}var ve=(o=!1)=>{let r,e="",t={load(i,s){e=i;let n=encodeURI(i);return o&&sessionStorage.getItem(n)?Promise.resolve(t.parse(sessionStorage.getItem(n))):At(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=St(i),t},path:i=>(Mt(r,i),e=null,t),fn(i){return i(r),t},pciHooks(i){let s=["hook","module"],n=i.substring(0,i.lastIndexOf("/"));for(let a of s)r.querySelectorAll("["+a+"]").forEach(d=>{let p=d.getAttribute(a);!p.startsWith("data:")&&!p.startsWith("http")&&(d.setAttribute("base-url",i),d.setAttribute("module",n+"/"+encodeURI(p+(p.endsWith(".js")?"":".js"))))});return t},async configurePci(i,s,n="qti-portable-custom-interaction"){let a=[],l=r.querySelectorAll(n);if(l.length===0)return t;let d=null,p=null,m=async()=>{if(d===null)try{d=await s(i,"/modules/module_resolution.js")}catch{d=null}if(p===null)try{p=await s(i,"/modules/fallback_module_resolution.js")}catch{p=null}};for(let h of Array.from(l)){h.setAttribute("data-base-url",i);let g=h.getAttribute("custom-interaction-type-identifier");g&&a.includes(g)&&(g=g+a.length,h.setAttribute("custom-interaction-type-identifier",g),a.push(g)),g&&a.push(g);let v=h.querySelector("qti-interaction-modules");if(v&&v.getAttribute("primary-configuration")){await m();let E=v.getAttribute("primary-configuration");if(E)try{let A=await s(i,`/${E}`),q=Array.from(v.querySelectorAll("qti-interaction-module"));for(let M of q){let P=M.getAttribute("id");if(P&&A.paths&&A.paths[P]){let H=A.paths[P],Z=Array.isArray(H)?H[0]:H;if(M.setAttribute("primary-path",Z),p&&p.paths&&p.paths[P]){let F=p.paths[P];Array.isArray(F)?M.setAttribute("fallback-path",F[0]):M.setAttribute("fallback-path",F)}}}if(A.paths){for(let M in A.paths)if(!v.querySelector(`qti-interaction-module[id="${M}"]`)){let H=r.createElement("qti-interaction-module");H.setAttribute("id",M);let Z=Array.isArray(A.paths[M])?A.paths[M][0]:A.paths[M];if(H.setAttribute("primary-path",Z),p&&p.paths&&p.paths[M]){let F=p.paths[M];Array.isArray(F)?H.setAttribute("fallback-path",F[0]):H.setAttribute("fallback-path",F)}v.appendChild(H)}}A.urlArgs&&v.setAttribute("url-args",A.urlArgs)}catch(A){console.warn(`Failed to load primary configuration: ${E}`,A)}}else if(await m(),d){h.querySelector("qti-interaction-modules")===null?(v=r.createElement("qti-interaction-modules"),h.appendChild(v)):v=h.querySelector("qti-interaction-modules");for(let E in d.paths){let A=d.paths[E],q="";p&&p.paths&&p.paths[E]&&(q=p.paths[E]);let M=Array.isArray(A)?A:[A],P=Array.isArray(q)?q:[q],H=M.map((Z,F)=>{let nl=P.length>F?P[F]:"";return{primaryPath:Z,fallbackPath:nl}});for(let Z of P)H.some(F=>F.fallbackPath===Z)||H.push({primaryPath:M.length>0?M[0]:Z,fallbackPath:Z});for(let Z of H){let F=r.createElement("qti-interaction-module");Z.fallbackPath&&F.setAttribute("fallback-path",Z.fallbackPath),F.setAttribute("id",E),F.setAttribute("primary-path",Z.primaryPath),v&&v.appendChild(F)}}}}return t},shuffleInteractions(){let i=r.querySelectorAll('[shuffle="true"]'),s=Array.from(i).filter(n=>n.tagName?.toLowerCase().endsWith("-interaction"));for(let n of s){let a=qn(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((q,M)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:M})).filter(q=>q.fixed),h=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(h.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let g=[...h],v=!1,E=0;for(;!v&&E<20;){E++;for(let q=h.length-1;q>0;q--){let M=Math.floor(Math.random()*(q+1));[h[q],h[M]]=[h[M],h[q]]}v=!h.every((q,M)=>q===g[M])}if(!v)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let A=0;for(let q of h)q.parentElement.insertBefore(q,m[A]?.element),A++;for(let q of m)q.element.parentElement.insertBefore(q.element,h[q.originalOrder])}}return t},extendElementName:(i,s)=>(hn(r,i,s),t),extendElementsWithClass:(i="extend")=>(fn(r,i),t),customInteraction(i,s){let n=r.querySelector("qti-custom-interaction"),a=n.querySelector("object");return n.setAttribute("data-base-ref",i),n.setAttribute("data-base-item",i+s),n.setAttribute("data",a.getAttribute("data")),n.setAttribute("width",a.getAttribute("width")),n.setAttribute("height",a.getAttribute("height")),n.removeChild(a),t},convertCDATAtoComment(){return yn(r),t},stripStyleSheets(){return xn(r),t},html(){return e!==null&&Mt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(kt(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&Mt(r,e.substring(0,e.lastIndexOf("/"))),kt(r)},xmlDoc(){return r}};return t};var Cn=()=>{let o,r={async load(e,t){return new Promise(i=>{At(e,t).then(s=>(o=s,i(r)))})},parse(e){o=St(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var It=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{At(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=St(e),r},path:e=>(Mt(o,e),r),fn(e){return e(o),r},items(){return bn(o)},html(){return new XMLSerializer().serializeToString(kt(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return kt(o)},xmlDoc(){return o}};return r};var wn=o=>{class r extends o{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.postLoadTransformCallback=null;this.postLoadTestTransformCallback=null;this._activeController=null;this._loadResults=[];this._navigationId=0;this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1};this._loadedStimulusHrefs=new Set;this._loadingStimulusHrefs=new Set;this._bindEventHandlers()}navigateTo(i,s){let n=s||this._getDefaultNavigationId(i);n&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_bindEventHandlers(){this.addEventListener("qti-request-navigation",this._handleNavigationRequest.bind(this)),this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-assessment-stimulus-ref-connected",this._handleStimulusRefConnected.bind(this))}_handleTestConnected(i){this._testElement=i.detail,this._initializeNavigation()}_handleItemConnected(i){let s=i.detail;this._loadingState.connectedItems++;let n=s.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=n.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:s,item:n}=i;if(console.info("Stimulus ref connected:",{identifier:s.identifier,href:s.href,item:n.identifier}),this._loadedStimulusHrefs.has(s.href)){console.info("Stimulus already loaded, skipping:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(s.href)){console.info("Stimulus already loading, skipping duplicate:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(s.href),console.info("Starting stimulus load:",s.href);try{await this._loadStimulusRef(s,n),this._loadedStimulusHrefs.add(s.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",s.href),this._checkLoadingComplete()}catch(a){a.name!=="AbortError"&&console.warn(`Failed to load stimulus ${s.identifier}:`,a),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(s.href)}}_getDefaultNavigationId(i){return i==="section"?this._testElement?.querySelector("qti-assessment-section")?.identifier:this.sessionContext?.navItemRefId??this._testElement?.querySelector("qti-assessment-item-ref")?.identifier}_initializeNavigation(){if(!this.navigate)return;let i=this._getDefaultNavigationId(this.navigate);i&&this.navigateTo(this.navigate,i)}async _handleNavigationRequest({detail:i}){if(!i?.id)return;this._cancelPreviousNavigation();let s=++this._navigationId,n=new AbortController;try{this._dispatchLoadingStarted(i.type,i.id),this._activeController=n,await this._executeNavigation(i.type,i.id,s,n)}catch(a){this._handleNavigationError(a,i.type,i.id)}finally{this._activeController===n&&(this._activeController=null),this._dispatchLoadingEnded(i.type,i.id)}}_handleNavigationError(i,s,n){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,s,n))}async _executeNavigation(i,s,n,a){i==="item"?await this._navigateToItem(s,n,a):await this._navigateToSection(s,n,a)}async _navigateToItem(i,s,n){let a=this._findItemRef(i);this._updateSessionContext(a,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i],s,n),await this._waitForLoadingComplete(s,n),!this._isStaleNavigation(s,n)&&this._dispatchTestLoaded(this._loadResults)}async _navigateToSection(i,s,n){let l=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:l,navSectionId:i,navItemRefId:null};let d=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=d.length,await this._loadItems(d,s,n),await this._waitForLoadingComplete(s,n),!this._isStaleNavigation(s,n)&&this._dispatchTestLoaded(this._loadResults)}_resetLoadingState(){this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs.clear(),this._loadingStimulusHrefs.clear()}_checkLoadingComplete(){let i=this._loadingState.connectedItems>=this._loadingState.expectedItems,s=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&s&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0)}async _waitForLoadingComplete(i,s){for(;!this._loadingState.isComplete;){if(this._isStaleNavigation(i,s))return;await new Promise(n=>setTimeout(n,10))}}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,s){console.info("Loading stimulus:",i.href);let n=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",n?"has content":"no content"),this._applyStimulusContent(n,i,s)}_applyStimulusContent(i,s,n){if(!i){console.warn("No stimulus content to apply");return}let a=i.querySelectorAll("qti-stimulus-body, qti-stylesheet");if(console.info(`Found ${a.length} stimulus elements to apply for ${s.identifier}`),a.length===0){console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");return}let l=[],d=document.querySelector(`qti-assessment-item[identifier="${n.identifier}"] [data-stimulus-idref="${s.identifier}"]`);if(d)l.push(d),console.info("Found specific target:",d);else{let p=Array.from(this.querySelectorAll(`[data-stimulus-idref="${s.identifier}"]`));if(p.length>0)l=p,console.info("Found targets by identifier:",p.length);else{let m=Array.from(this.querySelectorAll("[data-stimulus-idref]"));l=m,console.info("Using fallback targets:",m.length)}}if(l.length===0){console.warn("No targets found for stimulus content");return}l.forEach((p,m)=>{p.innerHTML="";let h=Array.from(a).map(g=>g.cloneNode(!0));p.append(...h),console.info(`Applied stimulus content to target ${m+1}/${l.length}`)})}_cancelPreviousNavigation(){this._activeController&&(this._activeController.abort(),console.info("Previous navigation request cancelled")),this._clearNavigationState()}_clearNavigationState(){this._clearLoadedItems(),this._resetLoadingState(),this._loadResults=[]}async _loadItems(i,s,n){if(!this._testElement||i.length===0)return;let a=i.map(p=>this._findItemRef(p));this._clearLoadedItems(),this._clearStimulusRef();let d=(await Promise.all(a.map(p=>this._loadSingleItem(p,s,n)))).filter(Boolean);this._isStaleNavigation(s,n)||(d.forEach(({itemRef:p,doc:m})=>{p&&m&&(p.xmlDoc=m)}),d.forEach(({itemRef:p})=>{let m=p?.identifier;if(!p||!m)return;let h=this.testContext.items.find(g=>g.identifier===m)?.state;h!==void 0&&p.updateComplete.then(()=>{let g=p.assessmentItem;g&&(g.state=h)})}),this._loadResults=d)}async _loadSingleItem(i,s,n){try{let a=await ve(this.cacheTransform).load(i.href,n.signal);return this.postLoadTransformCallback&&(a=await this.postLoadTransformCallback(a,i)),this._isStaleNavigation(s,n)?null:{itemRef:i,doc:a.htmlDoc()}}catch(a){if(a.name==="AbortError")throw console.info(`Item load for ${i.identifier} was aborted`),a;return console.warn(`Failed to load item ${i.identifier}:`,a),null}}async _loadStimulus(i){return(await ve().load(i,this._activeController?.signal)).htmlDoc()}_findItemRef(i){let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!s)throw new Error(`Item with identifier "${i}" not found`);return s}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,s){let n=i.closest("qti-test-part")?.identifier,a=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:s}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(s=>s.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(s=>{s.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_isStaleNavigation(i,s){return s.signal.aborted||i!==this._navigationId}_createNavigationError(i,s,n){return{message:i.message||`Failed to load ${s}: ${n}`,details:i,itemId:s==="item"?n:void 0,sectionId:s==="section"?n:void 0}}_dispatchLoadingStarted(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-started",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchLoadingEnded(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchError(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchTestLoaded(i){requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:i.map(({itemRef:s})=>({identifier:s?.identifier,element:s})),bubbles:!0,composed:!0}))})}}return c([u({type:String})],r.prototype,"navigate",2),c([u({type:Boolean,attribute:"cache-transform"})],r.prototype,"cacheTransform",2),c([u({type:Number})],r.prototype,"requestTimeout",2),c([u({attribute:!1})],r.prototype,"postLoadTransformCallback",2),c([u({attribute:!1})],r.prototype,"postLoadTestTransformCallback",2),r};var En=o=>{class r extends o{constructor(...t){super(...t),this.sessionContext={...this.sessionContext,view:"candidate"},this.addEventListener("on-test-switch-view",i=>{this.sessionContext={...this.sessionContext,view:i.detail},this._updateElementView()}),this.addEventListener("qti-assessment-test-connected",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",i=>{this._updateElementView(),this._setCorrectResponseVisibility(i.detail)})}willUpdate(t){super.willUpdate(t),t.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.sessionContext.view)});let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;s&&s.showCorrectResponse(this.sessionContext.view==="scorer")}}_setCorrectResponseVisibility(t){t.showCorrectResponse(this.sessionContext.view==="scorer")}}return r};var Ue=class extends Event{constructor(r,e,t,i){super("context-request",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e,this.callback=t,this.subscribe=i??!1}};var Rt=class{constructor(r,e,t,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(s,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(s,n)),this.unsubscribe=n},this.host=r,e.context!==void 0){let s=e;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Ue(this.context,this.host,this.t,this.subscribe))}};var Ri=class{get value(){return this.o}set value(r){this.setValue(r)}setValue(r,e=!1){let t=e||!Object.is(r,this.o);this.o=r,t&&this.updateObservers()}constructor(r){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},r!==void 0&&(this.value=r)}addCallback(r,e,t){if(!t)return void r(this.value);this.subscriptions.has(r)||this.subscriptions.set(r,{disposer:()=>{this.subscriptions.delete(r)},consumerHost:e});let{disposer:i}=this.subscriptions.get(r);r(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var js=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},_t=class extends Ri{constructor(r,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=i=>{if(i.context!==this.context)return;let s=i.contextTarget??i.composedPath()[0];s!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,s,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;let s=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)s.has(n)||(s.add(n),a.dispatchEvent(new Ue(this.context,a,n,!0)));i.stopPropagation()},this.host=r,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new js(this.context,this.host))}};function ee({context:o}){return(r,e)=>{let t=new WeakMap;if(typeof e=="object")return{get(){return r.get.call(this)},set(i){return t.get(this).setValue(i),r.set.call(this,i)},init(i){return t.set(this,new _t(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new _t(n,{context:o}))}));let i=Object.getOwnPropertyDescriptor(r,e),s;if(i===void 0){let n=new WeakMap;s={get(){return n.get(this)},set(a){t.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;s={...i,set(a){t.get(this).setValue(a),n?.call(this,a)}}}return void Object.defineProperty(r,e,s)}}}function k({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new Rt(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new Rt(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var Be=Symbol("computedItemContext");var N=Symbol("computedContext");var le=Symbol("configContext");var Tn=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var D=Symbol("item");var Lt=Symbol("qtiContext");var Ws={view:"candidate"},Fe=Symbol("testContext");var Xs={items:[],testOutcomeVariables:[]},ye=Symbol("testContext");function _i(o,r){return(e,t)=>{let{connectedCallback:i,disconnectedCallback:s}=e;e.connectedCallback=function(){i.call(this);let n=this[t],a=m=>{let h=[],g=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(M=>{if(M.nodeType!==1)return;let P=M;P.matches?.(o)&&h.push(P),h.push(...P.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(M=>{if(M.nodeType!==1)return;let P=M;P.matches?.(o)&&g.push(P),g.push(...P.querySelectorAll?.(o)??[])}));let v=q=>Array.from(new Set(q)),E=v(h),A=v(g);(E.length||A.length)&&n.call(this,E,A)},l=new MutationObserver(a);l.observe(this,{childList:!0,subtree:!0});let d=this.shadowRoot?new MutationObserver(a):null;d?.observe(this.shadowRoot,{childList:!0,subtree:!0}),this.__lqObservers=[l,d].filter(m=>!!m),(async()=>{r?.waitUntilFirstUpdate&&"updateComplete"in this&&await this.updateComplete;let m=[...this.querySelectorAll(o),...this.shadowRoot?.querySelectorAll(o)??[]];m.length&&n.call(this,m,[])})()},e.disconnectedCallback=function(){s.call(this),this.__lqObservers?.forEach(n=>n.disconnect()),this.__lqObservers=void 0}}}function O(o,r){let e={waitUntilFirstUpdate:!1,...r};return(t,i)=>{let{update:s}=t,n=Array.isArray(o)?o:[o];t.update=function(a){n.forEach(l=>{let d=l;if(a.has(d)){let p=a.get(d),m=this[d];p!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](p,m)}}),s.call(this,a)}}}var je={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},te=o=>(...r)=>({_$litDirective$:o,values:r}),xe=class{constructor(r){}get _$AU(){return this._$AM._$AU}_$AT(r,e,t){this._$Ct=r,this._$AM=e,this._$Ci=t}_$AS(r,e){return this.update(r,e)}update(r,e){return this.render(...e)}};var{I:Al}=W,Sn=o=>o===null||typeof o!="object"&&typeof o!="function";var kn=o=>o.strings===void 0,An=()=>document.createComment(""),$t=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(An(),i),n=t.insertBefore(An(),i);e=new Al(s,n,o,o.options)}else{let s=e._$AB.nextSibling,n=e._$AM,a=n!==o;if(a){let l;e._$AQ?.(o),e._$AM=o,e._$AP!==void 0&&(l=o._$AU)!==n._$AU&&e._$AP(l)}if(s!==i||a){let l=e._$AA;for(;l!==s;){let d=l.nextSibling;t.insertBefore(l,i),l=d}}}return e},We=(o,r,e=o)=>(o._$AI(r,e),o),Sl={},Mn=(o,r=Sl)=>o._$AH=r,In=o=>o._$AH,Li=o=>{o._$AR(),o._$AA.remove()};var br=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),br(t,r);return!0},$i=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},Rn=o=>{for(let r;r=o._$AM;o=r){let e=r._$AN;if(e===void 0)r._$AN=e=new Set;else if(e.has(o))break;e.add(o),Il(r)}};function kl(o){this._$AN!==void 0?($i(this),this._$AM=o,Rn(this)):this._$AM=o}function Ml(o,r=!1,e=0){let t=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(r)if(Array.isArray(t))for(let s=e;s<t.length;s++)br(t[s],!1),$i(t[s]);else t!=null&&(br(t,!1),$i(t));else br(this,o)}var Il=o=>{o.type==je.CHILD&&(o._$AP??=Ml,o._$AQ??=kl)},Xe=class extends xe{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),Rn(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(br(this,r),$i(this))}setValue(r){if(kn(this._$Ct))this._$Ct._$AI(r,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=r,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Gs=class extends Xe{constructor(){super(...arguments);this.prevData={}}render(e){return L}update(e,[t]){return this.element!==e.element&&(this.element=e.element),this.host=e.options?.host||this.element,this.apply(t),this.groom(t),this.prevData={...t},L}apply(e){let t=this.#e(e),{prevData:i,element:s}=this;for(let n in t){let a=t[n];a!==i[n]&&(a===!0?s.setAttribute(n,""):a===!1?s.removeAttribute(n):a!=null?s.setAttribute(n,String(a)):s.removeAttribute(n))}}groom(e){let{prevData:t,element:i}=this;if(!t)return;let s=e?this.#e(e):{};for(let n in t)(!s||!(n in s))&&i.removeAttribute(n)}#e(e){return Object.fromEntries(Object.entries(e).filter(([t,i])=>typeof i=="function"?!1:t==="max-choices"&&i===0?!0:!(i===""||i===null||i===void 0)))}},Pp=te(Gs);var _n=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(_n||{}),R=class extends b{constructor(){super();this.disabled=!1;this.readonly=!1;this.showCorrectResponse=!1;this._handleShowCorrectResponseChange=(e,t)=>{this.toggleInternalCorrectResponse(t)};this.showFullCorrectResponse=!1;this._handleShowFullCorrectResponseChange=(e,t)=>{this.toggleFullCorrectResponse(t)};this.showCandidateCorrection=!1;this._handleShowCandidateCorrectionChange=(e,t)=>{this.toggleCandidateCorrection(t)};this._correctResponse=null;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}set correctResponseAttr(e){e===null?this._correctResponse=null:e.includes(",")?this._correctResponse=e.split(",").map(t=>t.trim()):this._correctResponse=e}get correctResponseAttr(){return this._correctResponse===null||this._correctResponse===void 0?null:Array.isArray(this._correctResponse)?this._correctResponse.join(","):this._correctResponse}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("inert",""),this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){let e=this.responseVariable;return e?.correctResponse?e.correctResponse:this._correctResponse}set correctResponse(e){let t=this._correctResponse;this._correctResponse=e,e==null?this.removeAttribute("correct-response"):this.setAttribute("correct-response",Array.isArray(e)?e.join(","):e),this.requestUpdate("_correctResponse",t)}get correctness(){let e=this.correctResponse;if(!e)return null;let t=this.response;if(t==null||t===""||Array.isArray(t)&&t.length===0)return null;let i=Array.isArray(e)?e:[e],n=(Array.isArray(t)?t:[t]).filter(d=>d!=="");if(n.length===0)return null;let a=n.filter(d=>i.includes(d)).length,l=n.filter(d=>!i.includes(d)).length;return a===i.length&&l===0&&n.length===i.length?"correct":a>0&&(a<i.length||l>0)?"partially-correct":"incorrect"}get isInline(){return!1}get responseVariable(){if(!this._context?.variables)return;let e=this._context.variables.filter(i=>i.type==="response"),t=this.getAttribute("response-identifier");return e.find(i=>i.identifier===t)}toggleCorrectResponse(e){(this?.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(e):this.toggleInternalCorrectResponse(e)}async toggleFullCorrectResponse(e){let t=this.nextSibling,i=t instanceof HTMLDivElement&&t?.classList.contains("full-correct-response"),s=this.correctResponse;if(!s)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t);return}if(i)return;let a=this.cloneNode(!0);a.removeAttribute("show-full-correct-response"),a.removeAttribute("show-correct-response"),a.removeAttribute("show-candidate-correction");let l=document.createElement("div");l.classList.add("full-correct-response"),this.isInline?l.classList.add("full-correct-response-inline"):l.classList.add("full-correct-response-block"),l.role="full-correct-response",l.appendChild(a),a.isFullCorrectResponse=!0,this.parentElement?.insertBefore(l,this.nextSibling),await a.updateComplete,a.response=Array.isArray(s)?[...s]:s}toggleInternalCorrectResponse(e){this._internals.states.delete("show-correct-response"),e&&this.correctResponse&&this._internals.states.add("show-correct-response")}toggleCandidateCorrection(e){this._internals.states.delete("candidate-correct"),this._internals.states.delete("candidate-partially-correct"),this._internals.states.delete("candidate-incorrect"),e&&(this.correctness==="correct"&&this._internals.states.add("candidate-correct"),this.correctness==="partially-correct"&&this._internals.states.add("candidate-partially-correct"),this.correctness==="incorrect"&&this._internals.states.add("candidate-incorrect"))}get value(){return JSON.stringify(this.response)}set value(e){this.response=e?JSON.parse(e):null}reportValidity(){return this._internals.reportValidity()}reset(){this.response=null}formResetCallback(){this.reset()}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}firstUpdated(){this.isFullCorrectResponse||(this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0),this.showCandidateCorrection&&this.toggleCandidateCorrection(!0))}saveResponse(e,t){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e,...t!==void 0?{state:t}:{}}}))}};c([k({context:D,subscribe:!0})],R.prototype,"_context",2),c([k({context:le,subscribe:!0})],R.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],R.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],R.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],R.prototype,"readonly",2),c([u({type:String})],R.prototype,"name",2),c([u({type:String,attribute:"correct-response",reflect:!0})],R.prototype,"correctResponseAttr",1),c([u({type:Boolean,attribute:"show-correct-response",reflect:!0})],R.prototype,"showCorrectResponse",2),c([O("showCorrectResponse",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],R.prototype,"showFullCorrectResponse",2),c([O("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowFullCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],R.prototype,"showCandidateCorrection",2),c([O("showCandidateCorrection",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowCandidateCorrectionChange",2),c([w()],R.prototype,"_isFullCorrectResponse",2),c([w()],R.prototype,"_correctResponse",2);var Ot=class extends b{render(){return f`<slot></slot>`}defaultValues(r){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(i=>i.innerHTML.trim());return t.length>1||r==="multiple"||r==="ordered"?t:t[0]}};var S=class extends b{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(console.debug("getVariables",e.tagName.toLowerCase()),e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return t==="QTI_CONTEXT"?this.qtiContext?.QTI_CONTEXT?{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}:(console.warn("QTI_CONTEXT not available"),{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}):this.context.variables.find(s=>s.identifier===t)||null}case"qti-multiple":{let i=e.getResult();return console.debug("values",i),i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let i=e.getResult();return i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"ordered",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",i=this.context?.variables?.find(s=>s.identifier===t)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult()?.toString()||null,cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}static{this.styles=y`
|
|
1
|
+
var sc=Object.defineProperty;var nc=Object.getOwnPropertyDescriptor;var qn=s=>{throw TypeError(s)};var d=(s,r,e,t)=>{for(var i=t>1?void 0:t?nc(r,e):r,o=s.length-1,n;o>=0;o--)(n=s[o])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&sc(r,e,i),i};var Zo=(s,r,e)=>r.has(s)||qn("Cannot "+e);var I=(s,r,e)=>(Zo(s,r,"read from private field"),e?e.call(s):r.get(s)),_=(s,r,e)=>r.has(s)?qn("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(s):r.set(s,e),B=(s,r,e,t)=>(Zo(s,r,"write to private field"),t?t.call(s,e):r.set(s,e),e),D=(s,r,e)=>(Zo(s,r,"access private method"),e);var wn=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(r){this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColSpan="",this.ariaCurrent="",this.ariaDescription="",this.ariaDisabled="",this.ariaExpanded="",this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=r}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var Te=function(s,r,e,t,i){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?s!==r||!i:!r.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?i.call(s,e):i?i.value=e:r.set(s,e),e},J=function(s,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?s!==r||!t:!r.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(s):t?t.value:r.get(s)},Vt,Di,$i,xr,es,qr,Oi,qt,wr,Je,Vi,Cn,En=s=>typeof s=="boolean"?s:s?.capture??!1;var ts=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=En(t)?this.__captureEventListeners:this.__eventListeners,o=i.get(r);if(o===void 0)o=new Map,i.set(r,o);else if(o.has(e))return;let n=typeof t=="object"&&t?t:{};n.signal?.addEventListener("abort",()=>this.removeEventListener(r,e,t)),o.set(e,n??{})}removeEventListener(r,e,t){if(e==null)return;let i=En(t)?this.__captureEventListeners:this.__eventListeners,o=i.get(r);o!==void 0&&(o.delete(e),o.size||i.delete(r))}dispatchEvent(r){let e=[this],t=this.__eventTargetParent;if(r.composed)for(;t;)e.push(t),t=t.__eventTargetParent;else for(;t&&t!==this.__host;)e.push(t),t=t.__eventTargetParent;let i=!1,o=!1,n=0,a=null,l=null,c=null,p=r.stopPropagation,h=r.stopImmediatePropagation;Object.defineProperties(r,{target:{get(){return a??l},...j},srcElement:{get(){return r.target},...j},currentTarget:{get(){return c},...j},eventPhase:{get(){return n},...j},composedPath:{value:()=>e,...j},stopPropagation:{value:()=>{i=!0,p.call(r)},...j},stopImmediatePropagation:{value:()=>{o=!0,h.call(r)},...j}});let m=(u,g,q)=>{typeof u=="function"?u(r):typeof u?.handleEvent=="function"&&u.handleEvent(r),g.once&&q.delete(u)},y=()=>(c=null,n=0,!r.defaultPrevented),v=e.slice().reverse();a=!this.__host||!r.composed?this:null;let w=u=>{for(l=this;l.__host&&u.includes(l.__host);)l=l.__host};for(let u of v){!a&&(!l||l===u.__host)&&w(v.slice(v.indexOf(u))),c=u,n=u===r.target?2:1;let g=u.__captureEventListeners.get(r.type);if(g){for(let[q,T]of g)if(m(q,T,g),o)return y()}if(i)return y()}let f=r.bubbles?e:[this];l=null;for(let u of f){!a&&(!l||u===l.__host)&&w(f.slice(0,f.indexOf(u)+1)),c=u,n=u===r.target?2:3;let g=u.__eventListeners.get(r.type);if(g){for(let[q,T]of g)if(m(q,T,g),o)return y()}if(i)return y()}return y()}},rs=ts;var j={__proto__:null};j.enumerable=!0;Object.freeze(j);var is=(Je=class{constructor(r,e={}){if(Vt.set(this,!1),Di.set(this,!1),$i.set(this,!1),xr.set(this,!1),es.set(this,Date.now()),qr.set(this,!1),Oi.set(this,void 0),qt.set(this,void 0),wr.set(this,void 0),this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,arguments.length===0)throw new Error("The type argument must be specified");if(typeof e!="object"||!e)throw new Error('The "options" argument must be an object');let{bubbles:t,cancelable:i,composed:o}=e;Te(this,Vt,!!i,"f"),Te(this,Di,!!t,"f"),Te(this,$i,!!o,"f"),Te(this,Oi,`${r}`,"f"),Te(this,qt,null,"f"),Te(this,wr,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){Te(this,xr,!0,"f")}get target(){return J(this,qt,"f")}get currentTarget(){return J(this,qt,"f")}get srcElement(){return J(this,qt,"f")}get type(){return J(this,Oi,"f")}get cancelable(){return J(this,Vt,"f")}get defaultPrevented(){return J(this,Vt,"f")&&J(this,xr,"f")}get timeStamp(){return J(this,es,"f")}composedPath(){return J(this,wr,"f")?[J(this,qt,"f")]:[]}get returnValue(){return!J(this,Vt,"f")||!J(this,xr,"f")}get bubbles(){return J(this,Di,"f")}get composed(){return J(this,$i,"f")}get eventPhase(){return J(this,wr,"f")?Je.AT_TARGET:Je.NONE}get cancelBubble(){return J(this,qr,"f")}set cancelBubble(r){r&&Te(this,qr,!0,"f")}stopPropagation(){Te(this,qr,!0,"f")}get isTrusted(){return!1}},Vt=new WeakMap,Di=new WeakMap,$i=new WeakMap,xr=new WeakMap,es=new WeakMap,qr=new WeakMap,Oi=new WeakMap,qt=new WeakMap,wr=new WeakMap,Je.NONE=0,Je.CAPTURING_PHASE=1,Je.AT_TARGET=2,Je.BUBBLING_PHASE=3,Je);Object.defineProperties(is.prototype,{initEvent:j,stopImmediatePropagation:j,preventDefault:j,target:j,currentTarget:j,srcElement:j,type:j,cancelable:j,defaultPrevented:j,timeStamp:j,composedPath:j,returnValue:j,bubbles:j,composed:j,eventPhase:j,cancelBubble:j,stopPropagation:j,isTrusted:j});var Sn=(Cn=class extends is{constructor(r,e={}){super(r,e),Vi.set(this,void 0),Te(this,Vi,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return J(this,Vi,"f")}},Vi=new WeakMap,Cn);Object.defineProperties(Sn.prototype,{detail:j});var os=is,ss=Sn;globalThis.Event??=os;globalThis.CustomEvent??=ss;var Tn=new WeakMap,Cr=s=>{let r=Tn.get(s);return r===void 0&&Tn.set(s,r=new Map),r},ac=class extends rs{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(Cr(this)).map(([r,e])=>({name:r,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(r,e){Cr(this).set(r,String(e))}removeAttribute(r){Cr(this).delete(r)}toggleAttribute(r,e){if(this.hasAttribute(r)){if(e===void 0||!e)return this.removeAttribute(r),!1}else return e===void 0||e?(this.setAttribute(r,""),!0):!1;return!0}hasAttribute(r){return Cr(this).has(r)}attachShadow(r){let e={host:this};return this.__shadowRootMode=r.mode,r&&r.mode==="open"&&(this.__shadowRoot=e),e}attachInternals(){if(this.__internals!==null)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");let r=new wn(this);return this.__internals=r,r}getAttribute(r){return Cr(this).get(r)??null}};var lc=class extends ac{},as=lc;globalThis.litServerRoot??=Object.defineProperty(new as,"localName",{get(){return"lit-server-root"}});function cc(){let s,r;return{promise:new Promise((t,i)=>{s=t,r=i}),resolve:s,reject:r}}var ns=class{constructor(){this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map}define(r,e){if(this.__definitions.has(r))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${r}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
|
|
2
|
+
Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${r}" has already been used with this registry`);if(this.__reverseDefinitions.has(e))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(e)}`);e.__localName=r,this.__definitions.set(r,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,r),this.__pendingWhenDefineds.get(r)?.resolve(e),this.__pendingWhenDefineds.delete(r)}get(r){return this.__definitions.get(r)?.ctor}getName(r){return this.__reverseDefinitions.get(r)??null}upgrade(r){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(r){let e=this.__definitions.get(r);if(e)return e.ctor;let t=this.__pendingWhenDefineds.get(r);return t||(t=cc(),this.__pendingWhenDefineds.set(r,t)),t.promise}},dc=ns;var An=new dc;var Er=globalThis,Ni=Er.ShadowRoot&&(Er.ShadyCSS===void 0||Er.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ls=Symbol(),In=new WeakMap,Sr=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==ls)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=r,this.t=e}get styleSheet(){let r=this.o,e=this.t;if(Ni&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=In.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&In.set(e,r))}return r}toString(){return this.cssText}},kn=s=>new Sr(typeof s=="string"?s:s+"",void 0,ls),S=(s,...r)=>{let e=s.length===1?s[0]:r.reduce(((t,i,o)=>t+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+s[o+1]),s[0]);return new Sr(e,s,ls)},Mn=(s,r)=>{if(Ni)s.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=Er.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,s.appendChild(t)}},cs=Ni||Er.CSSStyleSheet===void 0?s=>s:s=>s instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return kn(e)})(s):s;var{is:pc,defineProperty:uc,getOwnPropertyDescriptor:mc,getOwnPropertyNames:hc,getOwnPropertySymbols:fc,getPrototypeOf:gc}=Object,Ir=globalThis;Ir.customElements??=An;var Rn=Ir.trustedTypes,bc=Rn?Rn.emptyScript:"",vc=Ir.reactiveElementPolyfillSupport,Tr=(s,r)=>s,Ar={toAttribute(s,r){switch(r){case Boolean:s=s?bc:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,r){let e=s;switch(r){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},Hi=(s,r)=>!pc(s,r),_n={attribute:!0,type:String,converter:Ar,reflect:!1,useDefault:!1,hasChanged:Hi};Symbol.metadata??=Symbol("metadata"),Ir.litPropertyMetadata??=new WeakMap;var Ne=class extends(globalThis.HTMLElement??as){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=_n){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(r)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(r,e),!e.noAccessor){let t=Symbol(),i=this.getPropertyDescriptor(r,t,e);i!==void 0&&uc(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:o}=mc(this.prototype,r)??{get(){return this[e]},set(n){this[e]=n}};return{get:i,set(n){let a=i?.call(this);o?.call(this,n),this.requestUpdate(r,a,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(r){return this.elementProperties.get(r)??_n}static _$Ei(){if(this.hasOwnProperty(Tr("elementProperties")))return;let r=gc(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Tr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Tr("properties"))){let e=this.properties,t=[...hc(e),...fc(e)];for(let i of t)this.createProperty(i,e[i])}let r=this[Symbol.metadata];if(r!==null){let e=litPropertyMetadata.get(r);if(e!==void 0)for(let[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let i=this._$Eu(e,t);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(r){let e=[];if(Array.isArray(r)){let t=new Set(r.flat(1/0).reverse());for(let i of t)e.unshift(cs(i))}else r!==void 0&&e.push(cs(r));return e}static _$Eu(r,e){let t=e.attribute;return t===!1?void 0:typeof t=="string"?t:typeof r=="string"?r.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((r=>this.enableUpdating=r)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((r=>r(this)))}addController(r){(this._$EO??=new Set).add(r),this.renderRoot!==void 0&&this.isConnected&&r.hostConnected?.()}removeController(r){this._$EO?.delete(r)}_$E_(){let r=new Map,e=this.constructor.elementProperties;for(let t of e.keys())this.hasOwnProperty(t)&&(r.set(t,this[t]),delete this[t]);r.size>0&&(this._$Ep=r)}createRenderRoot(){let r=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Mn(r,this.constructor.elementStyles),r}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((r=>r.hostConnected?.()))}enableUpdating(r){}disconnectedCallback(){this._$EO?.forEach((r=>r.hostDisconnected?.()))}attributeChangedCallback(r,e,t){this._$AK(r,t)}_$ET(r,e){let t=this.constructor.elementProperties.get(r),i=this.constructor._$Eu(r,t);if(i!==void 0&&t.reflect===!0){let o=(t.converter?.toAttribute!==void 0?t.converter:Ar).toAttribute(e,t.type);this._$Em=r,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(r,e){let t=this.constructor,i=t._$Eh.get(r);if(i!==void 0&&this._$Em!==i){let o=t.getPropertyOptions(i),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Ar;this._$Em=i;let a=n.fromAttribute(e,o.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(r,e,t){if(r!==void 0){let i=this.constructor,o=this[r];if(t??=i.getPropertyOptions(r),!((t.hasChanged??Hi)(o,e)||t.useDefault&&t.reflect&&o===this._$Ej?.get(r)&&!this.hasAttribute(i._$Eu(r,t))))return;this.C(r,e,t)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(r,e,{useDefault:t,reflect:i,wrapped:o},n){t&&!(this._$Ej??=new Map).has(r)&&(this._$Ej.set(r,n??e??this[r]),o!==!0||n!==void 0)||(this._$AL.has(r)||(this.hasUpdated||t||(e=void 0),this._$AL.set(r,e)),i===!0&&this._$Em!==r&&(this._$Eq??=new Set).add(r))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let r=this.scheduleUpdate();return r!=null&&await r,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[i,o]of t){let{wrapped:n}=o,a=this[i];n!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,o,a)}}let r=!1,e=this._$AL;try{r=this.shouldUpdate(e),r?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(t){throw r=!1,this._$EM(),t}r&&this._$AE(e)}willUpdate(r){}_$AE(r){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(r)),this.updated(r)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(r){return!0}update(r){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(r){}firstUpdated(r){}};Ne.elementStyles=[],Ne.shadowRootOptions={mode:"open"},Ne[Tr("elementProperties")]=new Map,Ne[Tr("finalized")]=new Map,vc?.({ReactiveElement:Ne}),(Ir.reactiveElementVersions??=[]).push("2.1.1");var Gi=globalThis,Fi=Gi.trustedTypes,Ln=Fi?Fi.createPolicy("lit-html",{createHTML:s=>s}):void 0,ps="$lit$",He=`lit$${Math.random().toFixed(9).slice(2)}$`,us="?"+He,yc=`<${us}>`,Et=Gi.document===void 0?{createTreeWalker:()=>({})}:document,Mr=()=>Et.createComment(""),Rr=s=>s===null||typeof s!="object"&&typeof s!="function",ms=Array.isArray,Nn=s=>ms(s)||typeof s?.[Symbol.iterator]=="function",ds=`[
|
|
3
|
+
\f\r]`,kr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Pn=/-->/g,Dn=/>/g,wt=RegExp(`>|${ds}(?:([^\\s"'>=/]+)(${ds}*=${ds}*(?:[^
|
|
4
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),$n=/'/g,On=/"/g,Hn=/^(?:script|style|textarea|title)$/i,hs=s=>(r,...e)=>({_$litType$:s,strings:r,values:e}),x=hs(1),Xi=hs(2),Hd=hs(3),X=Symbol.for("lit-noChange"),N=Symbol.for("lit-nothing"),Vn=new WeakMap,Ct=Et.createTreeWalker(Et,129);function Fn(s,r){if(!ms(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ln!==void 0?Ln.createHTML(r):r}var Bn=(s,r)=>{let e=s.length-1,t=[],i,o=r===2?"<svg>":r===3?"<math>":"",n=kr;for(let a=0;a<e;a++){let l=s[a],c,p,h=-1,m=0;for(;m<l.length&&(n.lastIndex=m,p=n.exec(l),p!==null);)m=n.lastIndex,n===kr?p[1]==="!--"?n=Pn:p[1]!==void 0?n=Dn:p[2]!==void 0?(Hn.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=wt):p[3]!==void 0&&(n=wt):n===wt?p[0]===">"?(n=i??kr,h=-1):p[1]===void 0?h=-2:(h=n.lastIndex-p[2].length,c=p[1],n=p[3]===void 0?wt:p[3]==='"'?On:$n):n===On||n===$n?n=wt:n===Pn||n===Dn?n=kr:(n=wt,i=void 0);let y=n===wt&&s[a+1].startsWith("/>")?" ":"";o+=n===kr?l+yc:h>=0?(t.push(c),l.slice(0,h)+ps+l.slice(h)+He+y):l+He+(h===-2?a:y)}return[Fn(s,o+(s[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},_r=class s{constructor({strings:r,_$litType$:e},t){let i;this.parts=[];let o=0,n=0,a=r.length-1,l=this.parts,[c,p]=Bn(r,e);if(this.el=s.createElement(c,t),Ct.currentNode=this.el.content,e===2||e===3){let h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(i=Ct.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let h of i.getAttributeNames())if(h.endsWith(ps)){let m=p[n++],y=i.getAttribute(h).split(He),v=/([.?@])?(.*)/.exec(m);l.push({type:1,index:o,name:v[2],strings:y,ctor:v[1]==="."?Ui:v[1]==="?"?zi:v[1]==="@"?ji:Tt}),i.removeAttribute(h)}else h.startsWith(He)&&(l.push({type:6,index:o}),i.removeAttribute(h));if(Hn.test(i.tagName)){let h=i.textContent.split(He),m=h.length-1;if(m>0){i.textContent=Fi?Fi.emptyScript:"";for(let y=0;y<m;y++)i.append(h[y],Mr()),Ct.nextNode(),l.push({type:2,index:++o});i.append(h[m],Mr())}}}else if(i.nodeType===8)if(i.data===us)l.push({type:2,index:o});else{let h=-1;for(;(h=i.data.indexOf(He,h+1))!==-1;)l.push({type:7,index:o}),h+=He.length-1}o++}}static createElement(r,e){let t=Et.createElement("template");return t.innerHTML=r,t}};function St(s,r,e=s,t){if(r===X)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,o=Rr(r)?void 0:r._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(s),i._$AT(s,e,t)),t!==void 0?(e._$Co??=[])[t]=i:e._$Cl=i),i!==void 0&&(r=St(s,i._$AS(s,r.values),i,t)),r}var Bi=class{constructor(r,e){this._$AV=[],this._$AN=void 0,this._$AD=r,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(r){let{el:{content:e},parts:t}=this._$AD,i=(r?.creationScope??Et).importNode(e,!0);Ct.currentNode=i;let o=Ct.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new Nt(o,o.nextSibling,this,r):l.type===1?c=new l.ctor(o,l.name,l.strings,this,r):l.type===6&&(c=new Wi(o,this,r)),this._$AV.push(c),l=t[++a]}n!==l?.index&&(o=Ct.nextNode(),n++)}return Ct.currentNode=Et,i}p(r){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(r,t,e),e+=t.strings.length-2):t._$AI(r[e])),e++}},Nt=class s{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=N,this._$AN=void 0,this._$AA=r,this._$AB=e,this._$AM=t,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let r=this._$AA.parentNode,e=this._$AM;return e!==void 0&&r?.nodeType===11&&(r=e.parentNode),r}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(r,e=this){r=St(this,r,e),Rr(r)?r===N||r==null||r===""?(this._$AH!==N&&this._$AR(),this._$AH=N):r!==this._$AH&&r!==X&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):Nn(r)?this.k(r):this._(r)}O(r){return this._$AA.parentNode.insertBefore(r,this._$AB)}T(r){this._$AH!==r&&(this._$AR(),this._$AH=this.O(r))}_(r){this._$AH!==N&&Rr(this._$AH)?this._$AA.nextSibling.data=r:this.T(Et.createTextNode(r)),this._$AH=r}$(r){let{values:e,_$litType$:t}=r,i=typeof t=="number"?this._$AC(r):(t.el===void 0&&(t.el=_r.createElement(Fn(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let o=new Bi(i,this),n=o.u(this.options);o.p(e),this.T(n),this._$AH=o}}_$AC(r){let e=Vn.get(r.strings);return e===void 0&&Vn.set(r.strings,e=new _r(r)),e}k(r){ms(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,i=0;for(let o of r)i===e.length?e.push(t=new s(this.O(Mr()),this.O(Mr()),this,this.options)):t=e[i],t._$AI(o),i++;i<e.length&&(this._$AR(t&&t._$AB.nextSibling,i),e.length=i)}_$AR(r=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);r!==this._$AB;){let t=r.nextSibling;r.remove(),r=t}}setConnected(r){this._$AM===void 0&&(this._$Cv=r,this._$AP?.(r))}},Tt=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,o){this.type=1,this._$AH=N,this._$AN=void 0,this.element=r,this.name=e,this._$AM=i,this.options=o,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=N}_$AI(r,e=this,t,i){let o=this.strings,n=!1;if(o===void 0)r=St(this,r,e,0),n=!Rr(r)||r!==this._$AH&&r!==X,n&&(this._$AH=r);else{let a=r,l,c;for(r=o[0],l=0;l<o.length-1;l++)c=St(this,a[t+l],e,l),c===X&&(c=this._$AH[l]),n||=!Rr(c)||c!==this._$AH[l],c===N?r=N:r!==N&&(r+=(c??"")+o[l+1]),this._$AH[l]=c}n&&!i&&this.j(r)}j(r){r===N?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Ui=class extends Tt{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===N?void 0:r}},zi=class extends Tt{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==N)}},ji=class extends Tt{constructor(r,e,t,i,o){super(r,e,t,i,o),this.type=5}_$AI(r,e=this){if((r=St(this,r,e,0)??N)===X)return;let t=this._$AH,i=r===N&&t!==N||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,o=r!==N&&(t===N||i);i&&this.element.removeEventListener(this.name,this,t),o&&this.element.addEventListener(this.name,this,r),this._$AH=r}handleEvent(r){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,r):this._$AH.handleEvent(r)}},Wi=class{constructor(r,e,t){this.element=r,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(r){St(this,r)}},Y={M:ps,P:He,A:us,C:1,L:Bn,R:Bi,D:Nn,V:St,I:Nt,H:Tt,N:zi,U:ji,B:Ui,F:Wi},xc=Gi.litHtmlPolyfillSupport;xc?.(_r,Nt),(Gi.litHtmlVersions??=[]).push("3.3.1");var fs=(s,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let o=e?.renderBefore??null;t._$litPart$=i=new Nt(r.insertBefore(Mr(),o),o,void 0,e??{})}return i._$AI(s),i};var gs=globalThis,C=class extends Ne{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let r=super.createRenderRoot();return this.renderOptions.renderBefore??=r.firstChild,r}update(r){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(r),this._$Do=fs(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return X}};C._$litElement$=!0,C.finalized=!0,gs.litElementHydrateSupport?.({LitElement:C});var qc=gs.litElementPolyfillSupport;qc?.({LitElement:C});(gs.litElementVersions??=[]).push("4.2.1");var k=s=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(s,r)})):customElements.define(s,r)};var wc={attribute:!0,type:String,converter:Ar,reflect:!1,hasChanged:Hi},Cc=(s=wc,r,e)=>{let{kind:t,metadata:i}=e,o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),t==="setter"&&((s=Object.create(s)).wrapped=!0),o.set(e.name,s),t==="accessor"){let{name:n}=e;return{set(a){let l=r.get.call(this);r.set.call(this,a),this.requestUpdate(n,l,s)},init(a){return a!==void 0&&this.C(n,void 0,s,a),a}}}if(t==="setter"){let{name:n}=e;return function(a){let l=this[n];r.call(this,a),this.requestUpdate(n,l,s)}}throw Error("Unsupported decorator location: "+t)};function b(s){return(r,e)=>typeof e=="object"?Cc(s,r,e):((t,i,o)=>{let n=i.hasOwnProperty(o);return i.constructor.createProperty(o,t),n?Object.getOwnPropertyDescriptor(i,o):void 0})(s,r,e)}function R(s){return b({...s,state:!0,attribute:!1})}var Ye=(s,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(s,r,e),e);function Ht(s,r){return(e,t,i)=>{let o=n=>n.renderRoot?.querySelector(s)??null;if(r){let{get:n,set:a}=typeof t=="object"?e:i??(()=>{let l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return Ye(e,t,{get(){let l=n.call(this);return l===void 0&&(l=o(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return Ye(e,t,{get(){return o(this)}})}}function Un(s){return(r,e)=>{let{slot:t,selector:i}=s??{},o="slot"+(t?`[name=${t}]`:":not([name])");return Ye(r,e,{get(){let n=this.renderRoot?.querySelector(o),a=n?.assignedElements(s)??[];return i===void 0?a:a.filter((l=>l.matches(i)))}})}}function zn(s,r,e){Array.from(s.getElementsByTagName("*")).filter(o=>o.localName===r||o.localName?.toLowerCase()===r.toLowerCase()).forEach(o=>{let n=`${r}-${e}`,a=Wn(o,n);o.replaceWith(a)})}function jn(s,r){s.querySelectorAll("*").forEach(e=>{let t=e.classList;t&&t.forEach(i=>{if(i.startsWith(`${r}:`)){let o=i.slice(`${r}:`.length),n=`${e.nodeName}-${o}`,a=Wn(e,n);e.replaceWith(a)}})})}function Wn(s,r){let e=s.ownerDocument.createElement(r);for(let t of s.attributes)e.setAttribute(t.name,t.value);for(;s.firstChild;)e.appendChild(s.firstChild);return e}function Gn(s){let r=[];return s.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let t=e.getAttribute("identifier"),i=e.getAttribute("href"),o=e.getAttribute("category");r.push({identifier:t,href:i,category:o})}),r}function Ft(s,r){return fetch(s,{signal:r}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>new DOMParser().parseFromString(e,"text/xml")).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function Bt(s){return new DOMParser().parseFromString(s,"text/xml")}function Xn(s,r){if(s.nodeType===Node.ELEMENT_NODE){let e=s,t=r.createElement(e.localName);for(let i=0;i<e.attributes.length;i++){let o=e.attributes[i];t.setAttribute(o.localName,o.value)}for(let i=0;i<e.childNodes.length;i++)t.appendChild(Xn(e.childNodes[i],r));return t}return s.cloneNode(!1)}function Ut(s){let r=document.createDocumentFragment();for(let e=0;e<s.childNodes.length;e++)r.appendChild(Xn(s.childNodes[e],document));return r}function zt(s,r){r.endsWith("/")||(r+="/"),s.querySelectorAll("*").forEach(t=>{for(let i of["src","href"]){let o=t.getAttribute(i)?.trim();if(o&&!/^(data:|https?:|blob:)/.test(o)){let n=r+encodeURI(o);t.setAttribute(i,n)}}})}function Qn(s){s.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let t=document.createComment(e.textContent);e.replaceChild(t,e.firstChild)})}function Jn(s){s.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function Yn(s){switch(s){case"qti-choice-interaction":case"qti-order-interaction":return"qti-simple-choice";case"qti-inline-choice-interaction":return"qti-inline-choice";case"qti-match-interaction":return["qti-simple-match-set:first-of-type qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice"];case"qti-gap-match-interaction":return"qti-gap-text";case"qti-associate-interaction":return"qti-simple-associable-choice";default:return null}}var Ae=(s=!1)=>{let r,e="",t={load(i,o){e=i;let n=encodeURI(i);return s&&sessionStorage.getItem(n)?Promise.resolve(t.parse(sessionStorage.getItem(n))):Ft(i,o).then(a=>(r=a,t.shuffleInteractions(),s&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=Bt(i),t},path:i=>(zt(r,i),e=null,t),fn(i){return i(r),t},pciHooks(i){let o=["hook","module"],n=i.substring(0,i.lastIndexOf("/"));for(let a of o)r.querySelectorAll("["+a+"]").forEach(c=>{let p=c.getAttribute(a);!p.startsWith("data:")&&!p.startsWith("http")&&(c.setAttribute("base-url",i),c.setAttribute("module",n+"/"+encodeURI(p+(p.endsWith(".js")?"":".js"))))});return t},async configurePci(i,o,n="qti-portable-custom-interaction"){let a=[],l=r.querySelectorAll(n);if(l.length===0)return t;let c=null,p=null,h=async()=>{if(c===null)try{c=await o(i,"/modules/module_resolution.js")}catch{c=null}if(p===null)try{p=await o(i,"/modules/fallback_module_resolution.js")}catch{p=null}};for(let m of Array.from(l)){m.setAttribute("data-base-url",i);let y=m.getAttribute("custom-interaction-type-identifier");y&&a.includes(y)&&(y=y+a.length,m.setAttribute("custom-interaction-type-identifier",y),a.push(y)),y&&a.push(y);let v=m.querySelector("qti-interaction-modules");if(v&&v.getAttribute("primary-configuration")){await h();let w=v.getAttribute("primary-configuration");if(w)try{let f=await o(i,`/${w}`),u=Array.from(v.querySelectorAll("qti-interaction-module"));for(let g of u){let q=g.getAttribute("id");if(q&&f.paths&&f.paths[q]){let T=f.paths[q],E=Array.isArray(T)?T[0]:T;if(g.setAttribute("primary-path",E),p&&p.paths&&p.paths[q]){let A=p.paths[q];Array.isArray(A)?g.setAttribute("fallback-path",A[0]):g.setAttribute("fallback-path",A)}}}if(f.paths){for(let g in f.paths)if(!v.querySelector(`qti-interaction-module[id="${g}"]`)){let T=r.createElement("qti-interaction-module");T.setAttribute("id",g);let E=Array.isArray(f.paths[g])?f.paths[g][0]:f.paths[g];if(T.setAttribute("primary-path",E),p&&p.paths&&p.paths[g]){let A=p.paths[g];Array.isArray(A)?T.setAttribute("fallback-path",A[0]):T.setAttribute("fallback-path",A)}v.appendChild(T)}}f.urlArgs&&v.setAttribute("url-args",f.urlArgs)}catch(f){console.warn(`Failed to load primary configuration: ${w}`,f)}}else if(await h(),c){m.querySelector("qti-interaction-modules")===null?(v=r.createElement("qti-interaction-modules"),m.appendChild(v)):v=m.querySelector("qti-interaction-modules");for(let w in c.paths){let f=c.paths[w],u="";p&&p.paths&&p.paths[w]&&(u=p.paths[w]);let g=Array.isArray(f)?f:[f],q=Array.isArray(u)?u:[u],T=g.map((E,A)=>{let M=q.length>A?q[A]:"";return{primaryPath:E,fallbackPath:M}});for(let E of q)T.some(A=>A.fallbackPath===E)||T.push({primaryPath:g.length>0?g[0]:E,fallbackPath:E});for(let E of T){let A=r.createElement("qti-interaction-module");E.fallbackPath&&A.setAttribute("fallback-path",E.fallbackPath),A.setAttribute("id",w),A.setAttribute("primary-path",E.primaryPath),v&&v.appendChild(A)}}}}return t},shuffleInteractions(){let i=r.querySelectorAll('[shuffle="true"]'),o=Array.from(i).filter(n=>n.tagName?.toLowerCase().endsWith("-interaction"));for(let n of o){let a=Yn(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let c of l){let p=Array.from(n.querySelectorAll(c)),h=p.map((u,g)=>({element:u,fixed:u.hasAttribute("fixed")&&u.getAttribute("fixed")==="true",originalOrder:g})).filter(u=>u.fixed),m=p.filter(u=>!u.hasAttribute("fixed")||u.getAttribute("fixed")!=="true");if(m.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let y=[...m],v=!1,w=0;for(;!v&&w<20;){w++;for(let u=m.length-1;u>0;u--){let g=Math.floor(Math.random()*(u+1));[m[u],m[g]]=[m[g],m[u]]}v=!m.every((u,g)=>u===y[g])}if(!v)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let f=0;for(let u of m)u.parentElement.insertBefore(u,h[f]?.element),f++;for(let u of h)u.element.parentElement.insertBefore(u.element,m[u.originalOrder])}}return t},extendElementName:(i,o)=>(zn(r,i,o),t),extendElementsWithClass:(i="extend")=>(jn(r,i),t),customInteraction(i,o){let n=r.querySelector("qti-custom-interaction"),a=n.querySelector("object");return n.setAttribute("data-base-ref",i),n.setAttribute("data-base-item",i+o),n.setAttribute("data",a.getAttribute("data")),n.setAttribute("width",a.getAttribute("width")),n.setAttribute("height",a.getAttribute("height")),n.removeChild(a),t},convertCDATAtoComment(){return Qn(r),t},stripStyleSheets(){return Jn(r),t},html(){return e!==null&&zt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(Ut(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&zt(r,e.substring(0,e.lastIndexOf("/"))),Ut(r)},xmlDoc(){return r}};return t};var Kn=()=>{let s,r={async load(e,t){return new Promise(i=>{Ft(e,t).then(o=>(s=o,i(r)))})},parse(e){s=Bt(e)},assessmentTest(){let e=s.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var jt=()=>{let s,r={async load(e,t){return new Promise((i,o)=>{Ft(e,t).then(n=>(s=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return s=Bt(e),r},path:e=>(zt(s,e),r),fn(e){return e(s),r},items(){return Gn(s)},html(){return new XMLSerializer().serializeToString(Ut(s))},xml(){return new XMLSerializer().serializeToString(s)},htmlDoc(){return Ut(s)},xmlDoc(){return s}};return r};var Zn=s=>{class r extends s{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.postLoadTransformCallback=null;this.postLoadTestTransformCallback=null;this._activeController=null;this._loadResults=[];this._navigationId=0;this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1};this._loadedStimulusHrefs=new Set;this._loadingStimulusHrefs=new Set;this._bindEventHandlers()}navigateTo(i,o){let n=o||this._getDefaultNavigationId(i);n&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_bindEventHandlers(){this.addEventListener("qti-request-navigation",this._handleNavigationRequest.bind(this)),this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-assessment-stimulus-ref-connected",this._handleStimulusRefConnected.bind(this))}_handleTestConnected(i){this._testElement=i.detail,this._initializeNavigation()}_handleItemConnected(i){let o=i.detail;this._loadingState.connectedItems++;let n=o.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=n.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:o,item:n}=i;if(console.info("Stimulus ref connected:",{identifier:o.identifier,href:o.href,item:n.identifier}),this._loadedStimulusHrefs.has(o.href)){console.info("Stimulus already loaded, skipping:",o.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(o.href)){console.info("Stimulus already loading, skipping duplicate:",o.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(o.href),console.info("Starting stimulus load:",o.href);try{await this._loadStimulusRef(o,n),this._loadedStimulusHrefs.add(o.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",o.href),this._checkLoadingComplete()}catch(a){a.name!=="AbortError"&&console.warn(`Failed to load stimulus ${o.identifier}:`,a),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(o.href)}}_getDefaultNavigationId(i){return i==="section"?this._testElement?.querySelector("qti-assessment-section")?.identifier:this.sessionContext?.navItemRefId??this._testElement?.querySelector("qti-assessment-item-ref")?.identifier}_initializeNavigation(){if(!this.navigate)return;let i=this._getDefaultNavigationId(this.navigate);i&&this.navigateTo(this.navigate,i)}async _handleNavigationRequest({detail:i}){if(!i?.id)return;this._cancelPreviousNavigation();let o=++this._navigationId,n=new AbortController;try{this._dispatchLoadingStarted(i.type,i.id),this._activeController=n,await this._executeNavigation(i.type,i.id,o,n)}catch(a){this._handleNavigationError(a,i.type,i.id)}finally{this._activeController===n&&(this._activeController=null),this._dispatchLoadingEnded(i.type,i.id)}}_handleNavigationError(i,o,n){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,o,n))}async _executeNavigation(i,o,n,a){i==="item"?await this._navigateToItem(o,n,a):await this._navigateToSection(o,n,a)}async _navigateToItem(i,o,n){let a=this._findItemRef(i);this._updateSessionContext(a,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i],o,n),await this._waitForLoadingComplete(o,n),!this._isStaleNavigation(o,n)&&this._dispatchTestLoaded(this._loadResults)}async _navigateToSection(i,o,n){let l=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:l,navSectionId:i,navItemRefId:null};let c=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=c.length,await this._loadItems(c,o,n),await this._waitForLoadingComplete(o,n),!this._isStaleNavigation(o,n)&&this._dispatchTestLoaded(this._loadResults)}_resetLoadingState(){this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs.clear(),this._loadingStimulusHrefs.clear()}_checkLoadingComplete(){let i=this._loadingState.connectedItems>=this._loadingState.expectedItems,o=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&o&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0)}async _waitForLoadingComplete(i,o){for(;!this._loadingState.isComplete;){if(this._isStaleNavigation(i,o))return;await new Promise(n=>setTimeout(n,10))}}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,o){console.info("Loading stimulus:",i.href);let n=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",n?"has content":"no content"),this._applyStimulusContent(n,i,o)}_applyStimulusContent(i,o,n){if(!i){console.warn("No stimulus content to apply");return}let a=i.querySelectorAll("qti-stimulus-body, qti-stylesheet");if(console.info(`Found ${a.length} stimulus elements to apply for ${o.identifier}`),a.length===0){console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");return}let l=[],c=document.querySelector(`qti-assessment-item[identifier="${n.identifier}"] [data-stimulus-idref="${o.identifier}"]`);if(c)l.push(c),console.info("Found specific target:",c);else{let p=Array.from(this.querySelectorAll(`[data-stimulus-idref="${o.identifier}"]`));if(p.length>0)l=p,console.info("Found targets by identifier:",p.length);else{let h=Array.from(this.querySelectorAll("[data-stimulus-idref]"));l=h,console.info("Using fallback targets:",h.length)}}if(l.length===0){console.warn("No targets found for stimulus content");return}l.forEach((p,h)=>{p.innerHTML="";let m=Array.from(a).map(y=>y.cloneNode(!0));p.append(...m),console.info(`Applied stimulus content to target ${h+1}/${l.length}`)})}_cancelPreviousNavigation(){this._activeController&&(this._activeController.abort(),console.info("Previous navigation request cancelled")),this._clearNavigationState()}_clearNavigationState(){this._clearLoadedItems(),this._resetLoadingState(),this._loadResults=[]}async _loadItems(i,o,n){if(!this._testElement||i.length===0)return;let a=i.map(p=>this._findItemRef(p));this._clearLoadedItems(),this._clearStimulusRef();let c=(await Promise.all(a.map(p=>this._loadSingleItem(p,o,n)))).filter(Boolean);this._isStaleNavigation(o,n)||(c.forEach(({itemRef:p,doc:h})=>{p&&h&&(p.xmlDoc=h)}),c.forEach(({itemRef:p})=>{let h=p?.identifier;if(!p||!h)return;let m=this.testContext.items.find(y=>y.identifier===h)?.state;m!==void 0&&p.updateComplete.then(()=>{let y=p.assessmentItem;y&&(y.state=m)})}),this._loadResults=c)}async _loadSingleItem(i,o,n){try{let a=await Ae(this.cacheTransform).load(i.href,n.signal);return this.postLoadTransformCallback&&(a=await this.postLoadTransformCallback(a,i)),this._isStaleNavigation(o,n)?null:{itemRef:i,doc:a.htmlDoc()}}catch(a){if(a.name==="AbortError")throw console.info(`Item load for ${i.identifier} was aborted`),a;return console.warn(`Failed to load item ${i.identifier}:`,a),null}}async _loadStimulus(i){return(await Ae().load(i,this._activeController?.signal)).htmlDoc()}_findItemRef(i){let o=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!o)throw new Error(`Item with identifier "${i}" not found`);return o}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,o){let n=i.closest("qti-test-part")?.identifier,a=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:o}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(o=>o.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(o=>{o.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_isStaleNavigation(i,o){return o.signal.aborted||i!==this._navigationId}_createNavigationError(i,o,n){return{message:i.message||`Failed to load ${o}: ${n}`,details:i,itemId:o==="item"?n:void 0,sectionId:o==="section"?n:void 0}}_dispatchLoadingStarted(i,o){this.dispatchEvent(new CustomEvent("qti-navigation-loading-started",{detail:{type:i,id:o},bubbles:!0,composed:!0}))}_dispatchLoadingEnded(i,o){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:o},bubbles:!0,composed:!0}))}_dispatchError(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchTestLoaded(i){requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:i.map(({itemRef:o})=>({identifier:o?.identifier,element:o})),bubbles:!0,composed:!0}))})}}return d([b({type:String})],r.prototype,"navigate",2),d([b({type:Boolean,attribute:"cache-transform"})],r.prototype,"cacheTransform",2),d([b({type:Number})],r.prototype,"requestTimeout",2),d([b({attribute:!1})],r.prototype,"postLoadTransformCallback",2),d([b({attribute:!1})],r.prototype,"postLoadTestTransformCallback",2),r};var ea=s=>{class r extends s{constructor(...t){super(...t),this.sessionContext={...this.sessionContext,view:"candidate"},this.addEventListener("on-test-switch-view",i=>{this.sessionContext={...this.sessionContext,view:i.detail},this._updateElementView()}),this.addEventListener("qti-assessment-test-connected",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",i=>{this._updateElementView(),this._setCorrectResponseVisibility(i.detail)})}willUpdate(t){super.willUpdate(t),t.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.sessionContext.view)});let o=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;o&&o.showCorrectResponse(this.sessionContext.view==="scorer")}}_setCorrectResponseVisibility(t){t.showCorrectResponse(this.sessionContext.view==="scorer")}}return r};var Ke=class extends Event{constructor(r,e,t,i){super("context-request",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e,this.callback=t,this.subscribe=i??!1}};var Wt=class{constructor(r,e,t,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(o,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=o,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(o,n)),this.unsubscribe=n},this.host=r,e.context!==void 0){let o=e;this.context=o.context,this.callback=o.callback,this.subscribe=o.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Ke(this.context,this.host,this.t,this.subscribe))}};var Qi=class{get value(){return this.o}set value(r){this.setValue(r)}setValue(r,e=!1){let t=e||!Object.is(r,this.o);this.o=r,t&&this.updateObservers()}constructor(r){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},r!==void 0&&(this.value=r)}addCallback(r,e,t){if(!t)return void r(this.value);this.subscriptions.has(r)||this.subscriptions.set(r,{disposer:()=>{this.subscriptions.delete(r)},consumerHost:e});let{disposer:i}=this.subscriptions.get(r);r(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var bs=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},Gt=class extends Qi{constructor(r,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=i=>{if(i.context!==this.context)return;let o=i.contextTarget??i.composedPath()[0];o!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,o,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;let o=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)o.has(n)||(o.add(n),a.dispatchEvent(new Ke(this.context,a,n,!0)));i.stopPropagation()},this.host=r,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new bs(this.context,this.host))}};function ne({context:s}){return(r,e)=>{let t=new WeakMap;if(typeof e=="object")return{get(){return r.get.call(this)},set(i){return t.get(this).setValue(i),r.set.call(this,i)},init(i){return t.set(this,new Gt(this,{context:s,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new Gt(n,{context:s}))}));let i=Object.getOwnPropertyDescriptor(r,e),o;if(i===void 0){let n=new WeakMap;o={get(){return n.get(this)},set(a){t.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;o={...i,set(a){t.get(this).setValue(a),n?.call(this,a)}}}return void Object.defineProperty(r,e,o)}}}function P({context:s,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new Wt(this,{context:s,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new Wt(i,{context:s,callback:o=>{i[t]=o},subscribe:r})}))}}var Ze=Symbol("computedItemContext");var W=Symbol("computedContext");var he=Symbol("configContext");var ta=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var G=Symbol("item");var Xt=Symbol("qtiContext");var vs={view:"candidate"},et=Symbol("testContext");var ys={items:[],testOutcomeVariables:[]},Ie=Symbol("testContext");function U(s,r){let e={waitUntilFirstUpdate:!1,...r};return(t,i)=>{let{update:o}=t,n=Array.isArray(s)?s:[s];t.update=function(a){n.forEach(l=>{let c=l;if(a.has(c)){let p=a.get(c),h=this[c];p!==h&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](p,h)}}),o.call(this,a)}}}var tt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ae=s=>(...r)=>({_$litDirective$:s,values:r}),ke=class{constructor(r){}get _$AU(){return this._$AM._$AU}_$AT(r,e,t){this._$Ct=r,this._$AM=e,this._$Ci=t}_$AS(r,e){return this.update(r,e)}update(r,e){return this.render(...e)}};var{I:Ec}=Y,ia=s=>s===null||typeof s!="object"&&typeof s!="function";var oa=s=>s.strings===void 0,ra=()=>document.createComment(""),Qt=(s,r,e)=>{let t=s._$AA.parentNode,i=r===void 0?s._$AB:r._$AA;if(e===void 0){let o=t.insertBefore(ra(),i),n=t.insertBefore(ra(),i);e=new Ec(o,n,s,s.options)}else{let o=e._$AB.nextSibling,n=e._$AM,a=n!==s;if(a){let l;e._$AQ?.(s),e._$AM=s,e._$AP!==void 0&&(l=s._$AU)!==n._$AU&&e._$AP(l)}if(o!==i||a){let l=e._$AA;for(;l!==o;){let c=l.nextSibling;t.insertBefore(l,i),l=c}}}return e},rt=(s,r,e=s)=>(s._$AI(r,e),s),Sc={},sa=(s,r=Sc)=>s._$AH=r,na=s=>s._$AH,Ji=s=>{s._$AR(),s._$AA.remove()};var Lr=(s,r)=>{let e=s._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),Lr(t,r);return!0},Yi=s=>{let r,e;do{if((r=s._$AM)===void 0)break;e=r._$AN,e.delete(s),s=r}while(e?.size===0)},aa=s=>{for(let r;r=s._$AM;s=r){let e=r._$AN;if(e===void 0)r._$AN=e=new Set;else if(e.has(s))break;e.add(s),Ic(r)}};function Tc(s){this._$AN!==void 0?(Yi(this),this._$AM=s,aa(this)):this._$AM=s}function Ac(s,r=!1,e=0){let t=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(r)if(Array.isArray(t))for(let o=e;o<t.length;o++)Lr(t[o],!1),Yi(t[o]);else t!=null&&(Lr(t,!1),Yi(t));else Lr(this,s)}var Ic=s=>{s.type==tt.CHILD&&(s._$AP??=Ac,s._$AQ??=Tc)},it=class extends ke{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),aa(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(Lr(this,r),Yi(this))}setValue(r){if(oa(this._$Ct))this._$Ct._$AI(r,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=r,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var xs=class extends it{constructor(){super(...arguments);this.prevData={}}render(e){return N}update(e,[t]){return this.element!==e.element&&(this.element=e.element),this.host=e.options?.host||this.element,this.apply(t),this.groom(t),this.prevData={...t},N}apply(e){let t=this.#e(e),{prevData:i,element:o}=this;for(let n in t){let a=t[n];a!==i[n]&&(a===!0?o.setAttribute(n,""):a===!1?o.removeAttribute(n):a!=null?o.setAttribute(n,String(a)):o.removeAttribute(n))}}groom(e){let{prevData:t,element:i}=this;if(!t)return;let o=e?this.#e(e):{};for(let n in t)(!o||!(n in o))&&i.removeAttribute(n)}#e(e){return Object.fromEntries(Object.entries(e).filter(([t,i])=>typeof i=="function"?!1:t==="max-choices"&&i===0?!0:!(i===""||i===null||i===void 0)))}},Ju=ae(xs);var la=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(la||{}),$=class extends C{constructor(){super();this.disabled=!1;this.readonly=!1;this.showCorrectResponse=!1;this._handleShowCorrectResponseChange=(e,t)=>{this.toggleInternalCorrectResponse(t)};this.showFullCorrectResponse=!1;this._handleShowFullCorrectResponseChange=(e,t)=>{this.toggleFullCorrectResponse(t)};this.showCandidateCorrection=!1;this._handleShowCandidateCorrectionChange=(e,t)=>{this.toggleCandidateCorrection(t)};this._correctResponse=null;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}set correctResponseAttr(e){e===null?this._correctResponse=null:e.includes(",")?this._correctResponse=e.split(",").map(t=>t.trim()):this._correctResponse=e}get correctResponseAttr(){return this._correctResponse===null||this._correctResponse===void 0?null:Array.isArray(this._correctResponse)?this._correctResponse.join(","):this._correctResponse}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("inert",""),this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){let e=this.responseVariable;return e?.correctResponse?e.correctResponse:this._correctResponse}set correctResponse(e){let t=this._correctResponse;this._correctResponse=e,e==null?this.removeAttribute("correct-response"):this.setAttribute("correct-response",Array.isArray(e)?e.join(","):e),this.requestUpdate("_correctResponse",t)}get correctness(){let e=this.correctResponse;if(!e)return null;let t=this.response;if(t==null||t===""||Array.isArray(t)&&t.length===0)return null;let i=Array.isArray(e)?e:[e],n=(Array.isArray(t)?t:[t]).filter(c=>c!=="");if(n.length===0)return null;let a=n.filter(c=>i.includes(c)).length,l=n.filter(c=>!i.includes(c)).length;return a===i.length&&l===0&&n.length===i.length?"correct":a>0&&(a<i.length||l>0)?"partially-correct":"incorrect"}get isInline(){return!1}get responseVariable(){if(!this._context?.variables)return;let e=this._context.variables.filter(i=>i.type==="response"),t=this.getAttribute("response-identifier");return e.find(i=>i.identifier===t)}toggleCorrectResponse(e){(this?.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(e):this.toggleInternalCorrectResponse(e)}async toggleFullCorrectResponse(e){let t=this.nextSibling,i=t instanceof HTMLDivElement&&t?.classList.contains("full-correct-response"),o=this.correctResponse;if(!o)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t);return}if(i)return;let a=this.cloneNode(!0);a.removeAttribute("show-full-correct-response"),a.removeAttribute("show-correct-response"),a.removeAttribute("show-candidate-correction");let l=document.createElement("div");l.classList.add("full-correct-response"),this.isInline?l.classList.add("full-correct-response-inline"):l.classList.add("full-correct-response-block"),l.role="full-correct-response",l.appendChild(a),a.isFullCorrectResponse=!0,this.parentElement?.insertBefore(l,this.nextSibling),await a.updateComplete,a.response=Array.isArray(o)?[...o]:o}toggleInternalCorrectResponse(e){this._internals.states.delete("show-correct-response"),e&&this.correctResponse&&this._internals.states.add("show-correct-response")}toggleCandidateCorrection(e){this._internals.states.delete("candidate-correct"),this._internals.states.delete("candidate-partially-correct"),this._internals.states.delete("candidate-incorrect"),e&&(this.correctness==="correct"&&this._internals.states.add("candidate-correct"),this.correctness==="partially-correct"&&this._internals.states.add("candidate-partially-correct"),this.correctness==="incorrect"&&this._internals.states.add("candidate-incorrect"))}get value(){return JSON.stringify(this.response)}set value(e){this.response=e?JSON.parse(e):null}reportValidity(){return this._internals.reportValidity()}reset(){this.response=null}formResetCallback(){this.reset()}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}firstUpdated(){this.isFullCorrectResponse||(this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0),this.showCandidateCorrection&&this.toggleCandidateCorrection(!0))}saveResponse(e,t){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e,...t!==void 0?{state:t}:{}}}))}};d([P({context:G,subscribe:!0})],$.prototype,"_context",2),d([P({context:he,subscribe:!0})],$.prototype,"configContext",2),d([b({type:String,attribute:"response-identifier"})],$.prototype,"responseIdentifier",2),d([b({reflect:!0,type:Boolean})],$.prototype,"disabled",2),d([b({reflect:!0,type:Boolean})],$.prototype,"readonly",2),d([b({type:String})],$.prototype,"name",2),d([b({type:String,attribute:"correct-response",reflect:!0})],$.prototype,"correctResponseAttr",1),d([b({type:Boolean,attribute:"show-correct-response",reflect:!0})],$.prototype,"showCorrectResponse",2),d([U("showCorrectResponse",{waitUntilFirstUpdate:!0})],$.prototype,"_handleShowCorrectResponseChange",2),d([b({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],$.prototype,"showFullCorrectResponse",2),d([U("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],$.prototype,"_handleShowFullCorrectResponseChange",2),d([b({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],$.prototype,"showCandidateCorrection",2),d([U("showCandidateCorrection",{waitUntilFirstUpdate:!0})],$.prototype,"_handleShowCandidateCorrectionChange",2),d([R()],$.prototype,"_isFullCorrectResponse",2),d([R()],$.prototype,"_correctResponse",2);var Jt=class extends C{render(){return x`<slot></slot>`}defaultValues(r){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(i=>i.innerHTML.trim());return t.length>1||r==="multiple"||r==="ordered"?t:t[0]}};var L=class extends C{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(console.debug("getVariables",e.tagName.toLowerCase()),e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return t==="QTI_CONTEXT"?this.qtiContext?.QTI_CONTEXT?{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}:(console.warn("QTI_CONTEXT not available"),{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}):this.context.variables.find(o=>o.identifier===t)||null}case"qti-multiple":{let i=e.getResult();return console.debug("values",i),i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(o=>o.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let i=e.getResult();return i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(o=>o.value),cardinality:"ordered",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",i=this.context?.variables?.find(o=>o.identifier===t)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult()?.toString()||null,cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}static{this.styles=S`
|
|
5
5
|
slot {
|
|
6
6
|
display: none;
|
|
7
7
|
}
|
|
8
|
-
`}render(){return
|
|
9
|
-
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([w()],S.prototype,"result",2),c([k({context:D,subscribe:!0}),w()],S.prototype,"context",2),c([k({context:Lt,subscribe:!0}),w()],S.prototype,"qtiContext",2);var ce=class extends S{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Rl=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),vr=o=>{if(typeof o=="string")return o;let r=Rl();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Qs(o){return o==null}function Oi(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var re=class extends b{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(r){let e=this._context.variables.find(i=>i.identifier===r)||null;if(this.outcomeIdentifier!==r||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!Qs(this.identifier)&&!Qs(e?.value)&&this.identifier===e.value||!1,this.#e(t)}#e(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],re.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],re.prototype,"outcomeIdentifier",2),c([u({type:String})],re.prototype,"identifier",2),c([u({type:String,attribute:!1})],re.prototype,"showStatus",2),c([k({context:D,subscribe:!0}),w()],re.prototype,"_context",2);var Ln=class extends b{};var X=class{static isPointInArea(r,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[i,s]=r.split(" ").map(Number),[n,...a]=e.split(","),l=a.map(Number);switch(n.toLowerCase()){case"circle":case"default":{let[d,p,m]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((i-d)**2+(s-p)**2)<=m}case"rect":{let[d,p,m,h]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=h}case"ellipse":{let[d,p,m,h]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let g=(i-d)**2/m**2,v=(s-p)**2/h**2;return g+v<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let d=[];for(let p=0;p<l.length;p+=2)d.push({x:l[p],y:l[p+1]});return this.isPointInPolygon({x:i,y:s},d)}default:return console.warn(`Unsupported shape type: ${n}`),!1}}static isPointInPolygon(r,e){let t=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){let n=e[i].x,a=e[i].y,l=e[s].x,d=e[s].y;a>r.y!=d>r.y&&r.x<(l-n)*(r.y-a)/(d-a)+n&&(t=!t)}return t}static compareSingleValues(r,e,t){switch(t){case"identifier":case"string":return r===e;case"integer":{let i=parseInt(r,10),s=parseInt(e,10);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`Cannot convert ${r} and/or ${e} to int.`);break}case"float":{let i=parseFloat(r),s=parseFloat(e);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`couldn't convert ${r} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=r.split(" ").sort(),s=e.split(" ").sort();if(i.length===2&&s.length===2)return t==="pair"&&(i.sort(),s.sort()),i.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${r} 2: ${e}`);break}}return!1}};var Ys=o=>{class r extends o{constructor(...i){super(...i);this.testContext=Xs;this.sessionContext=Ws;this._updateItemInTestContext=i=>{let s=i._context,n=s.identifier,a=s.variables,l=this.testContext.items.find(d=>d?.identifier===n);if(!l){console.warn(`Item IDs between assessment.xml and item.xml should match: ${n} is not found!`);return}if(l.variables?.length===1)this._updateItemVariablesInTestContext(n,a);else{let d=[...i.variables];for(let p of l.variables){let m=d.find(h=>h.identifier===p.identifier);m?m.value=p.value:d.push(p)}i.variables=d}};this._initializeEventListeners()}updateItemVariables(i,s){let n=this.testContext.items.find(l=>l.identifier===i);n&&(n.variables=n.variables.map(l=>{let d=s.find(p=>p.identifier===l.identifier);return d?{...l,...d}:l}));let a=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);a&&a.assessmentItem&&(a.assessmentItem.variables=s)}_initializeEventListeners(){this.addEventListener("qti-assessment-test-connected",i=>{if(this.testContext=Xs,this.sessionContext=Ws,this.testContext&&this.testContext.items.length>0)return;this._testElement=i.detail;let s=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(n=>({href:n.href,identifier:n.identifier,category:n.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:s}}),this.addEventListener("qti-assessment-item-connected",i=>{let s=i.detail,n=s.closest("qti-assessment-item-ref")?.identifier;n&&(s.assessmentItemRefId=n),this._updateItemInTestContext(i.detail)}),this.addEventListener("qti-item-context-updated",i=>{this._updateItemVariablesInTestContext(i.detail.itemContext.identifier,i.detail.itemContext.variables,i.detail.itemContext.state)})}_updateItemVariablesInTestContext(i,s,n){this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:s.map(l=>{let d=a.variables.find(p=>p.identifier===l.identifier);return d?{...d,...l}:l}),...n!==void 0?{state:n?{...n}:void 0}:{}})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}}return c([u({attribute:!1,type:Object}),ee({context:ye})],r.prototype,"testContext",2),c([u({attribute:!1,type:Object}),ee({context:Fe})],r.prototype,"sessionContext",2),r},$n=class extends Ys(b){};var On=o=>{class r extends o{constructor(...t){super(...t),this.addEventListener("qti-register-variable",i=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],i.detail.variable]},i.stopPropagation()}),this.addEventListener("qti-set-outcome-value",i=>{let{outcomeIdentifier:s,value:n}=i.detail;this.updateOutcomeVariable(s,n),i.stopPropagation()})}outcomeProcessing(){let t=this.querySelector("qti-outcome-processing");return t?(t?.process(),!0):!1}updateOutcomeVariable(t,i){let s=this.getOutcome(t);if(!s){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(n=>n.identifier!==t?n:{...n,value:s.cardinality==="single"?i:[...n.value,i]})}}getOutcome(t){return this.getVariable(t)}getVariable(t){return this.testContext.testOutcomeVariables?.find(i=>i.identifier===t)||null}}return r};var Pi=class extends wn(En(On(Ys(b)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return f`<slot></slot>`}};Pi=c([C("qti-test")],Pi);var Pn={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Re=class extends b{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-item-ref-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href,category:this.category}}))}render(){return this.myTemplate?this.myTemplate({xmlDoc:this.xmlDoc}):this.xmlDoc}};c([u({type:String})],Re.prototype,"category",2),c([u({type:String})],Re.prototype,"identifier",2),c([u({type:Boolean,converter:Pn})],Re.prototype,"required",2),c([u({type:Boolean,converter:Pn})],Re.prototype,"fixed",2),c([u({type:String})],Re.prototype,"href",2),c([u({type:Object,attribute:!1})],Re.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",Re);var Js={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},_e=class extends b{get title(){return this.#e}set title(r){this.#e=r,this.removeAttribute("title"),this.setAttribute("data-title",r)}#e="";async connectedCallback(){this.#e=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return f`<slot name="qti-rubric-block"></slot><slot></slot>`}};c([u({type:String})],_e.prototype,"identifier",2),c([u({type:String})],_e.prototype,"required",2),c([u({type:Boolean,converter:Js})],_e.prototype,"fixed",2),c([u({type:Boolean,converter:Js})],_e.prototype,"visible",2),c([u({type:Boolean,converter:Js,attribute:"keep-together"})],_e.prototype,"keepTogether",2),c([k({context:ye,subscribe:!0})],_e.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",_e);var yr,ht=class extends b{constructor(){super(...arguments);T(this,yr,"")}get title(){return x(this,yr)}set title(e){$(this,yr,e),this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return f` <slot></slot>`}};yr=new WeakMap,c([u({type:String})],ht.prototype,"identifier",2),c([u({type:String})],ht.prototype,"title",1),c([k({context:ye,subscribe:!0})],ht.prototype,"_testContext",2),ht=c([C("qti-assessment-test")],ht);var xr,Le=class extends b{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";T(this,xr,"")}get title(){return x(this,xr)}set title(e){$(this,xr,e),this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return f` <slot></slot>`}};xr=new WeakMap,c([u({type:String})],Le.prototype,"identifier",2),c([u({type:String})],Le.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Le.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Le.prototype,"submissionMode",2),Le=c([C("qti-test-part")],Le);customElements.get("qti-test-part")||customElements.define("qti-test-part",Le);var qr,Pt,Cr,Vt,de,se,Vn,Nn,wr,Er,Tr,Ar,Sr,kr,Dn,Ks,Hn,ie=class extends b{constructor(){super(...arguments);T(this,se);T(this,qr);T(this,Pt,null);this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{x(this,de).forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>x(this,de).forEach(i=>i.readonly=t);this._context={variables:Tn};T(this,Cr,{...this._context,variables:this._context.variables});T(this,Vt,[]);T(this,de,[]);T(this,wr,e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},$(this,Cr,this._context),e.stopPropagation()});T(this,Er,e=>{e.stopImmediatePropagation();let t=e.detail;x(this,Vt).push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)});T(this,Tr,e=>{e.stopImmediatePropagation(),x(this,de).push(e.detail.interactionElement)});T(this,Ar,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)});T(this,Sr,e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()});T(this,kr,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i,state:s}=e.detail;this.updateResponseVariable(t,i),s!==void 0&&(this._context={...this._context,state:{...this._context.state||{},[t]:s}}),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))})}get title(){return x(this,qr)}set title(e){$(this,qr,e),this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(s=>s.identifier===t.identifier);return i?{...t,...i,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=x(this,de).find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&x(this,Vt).forEach(i=>i.checkShowFeedback(t.identifier))})}get state(){return this._context.state}set state(e){this._context={...this._context,state:e?{...e}:void 0}}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=x(this,de).find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return f`<slot></slot>`}connectedCallback(){I(this,se,Vn).call(this),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),I(this,se,Dn).call(this)})}disconnectedCallback(){I(this,se,Nn).call(this),super.disconnectedCallback()}showCorrectResponse(e){for(let t of x(this,de))t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of x(this,de))t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(n=>n.identifier==="numAttempts")?.value+1).toString()),this.adaptive==="false"&&I(this,se,Hn).call(this);let i=this.querySelector("qti-response-processing"),s=!!(i&&typeof i.process=="function");return s&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",I(this,se,Ks).call(this)),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),s}resetResponses(){this._context=x(this,Cr)}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this.showCandidateCorrection(!1),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",I(this,se,Ks).call(this))}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(s=>s.identifier!==e?s:{...s,value:i.cardinality==="single"||Array.isArray(t)?t:[t]})},x(this,Vt).forEach(s=>s.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value}}))}validate(e=!0){let t=x(this,de).every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of x(this,de))e.reportValidity()}};qr=new WeakMap,Pt=new WeakMap,Cr=new WeakMap,Vt=new WeakMap,de=new WeakMap,se=new WeakSet,Vn=function(){this.addEventListener("qti-register-variable",x(this,wr)),this.addEventListener("qti-register-feedback",x(this,Er)),this.addEventListener("qti-register-interaction",x(this,Tr)),this.addEventListener("end-attempt",x(this,Ar)),this.addEventListener("qti-set-outcome-value",x(this,Sr)),this.addEventListener("qti-interaction-response",x(this,kr))},Nn=function(){this.removeEventListener("qti-register-variable",x(this,wr)),this.removeEventListener("qti-register-feedback",x(this,Er)),this.removeEventListener("qti-register-interaction",x(this,Tr)),this.removeEventListener("end-attempt",x(this,Ar)),this.removeEventListener("qti-set-outcome-value",x(this,Sr)),this.removeEventListener("qti-interaction-response",x(this,kr))},wr=new WeakMap,Er=new WeakMap,Tr=new WeakMap,Ar=new WeakMap,Sr=new WeakMap,kr=new WeakMap,Dn=function(){$(this,Pt,this.querySelector("qti-template-processing")),x(this,Pt)&&x(this,Pt).process()},Ks=function(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"},Hn=function(){this._context={...this._context,variables:this._context.variables.map(e=>{if(e.type!=="outcome")return e;let s=("defaultValue"in e?e.defaultValue:null)??null;return s==null&&(e.baseType==="integer"||e.baseType==="float")&&(s="0"),{...e,value:s}})}},c([u({type:String})],ie.prototype,"identifier",2),c([u({type:String})],ie.prototype,"adaptive",2),c([u({type:String})],ie.prototype,"timeDependent",2),c([u({type:String})],ie.prototype,"title",1),c([u({type:Boolean})],ie.prototype,"disabled",2),c([O("disabled",{waitUntilFirstUpdate:!0})],ie.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],ie.prototype,"readonly",2),c([O("readonly",{waitUntilFirstUpdate:!0})],ie.prototype,"_handleReadonlyChange",2),c([ee({context:D})],ie.prototype,"_context",2),ie=c([C("qti-assessment-item")],ie);var Zs=class o extends Event{constructor(e,t){super(o.eventName,{bubbles:!0,composed:!0,cancelable:!0});this.element=e;this.item=t}static{this.eventName="qti-assessment-stimulus-ref-connected"}},Nt=class extends b{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Zs(this,e);this.dispatchEvent(t);let i=e?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!t.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(e){let t=await ve().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};c([u({type:String})],Nt.prototype,"identifier",2),c([u({type:String})],Nt.prototype,"href",2),Nt=c([C("qti-assessment-stimulus-ref")],Nt);var Vi=class extends b{};Vi=c([C("qti-companion-materials-info")],Vi);var Ir,Mr=class extends b{constructor(){super(...arguments);T(this,Ir)}render(){return f`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let e=Array.from(this.firstElementChild?.childNodes??[]).find(t=>t.nodeType===Node.COMMENT_NODE);try{$(this,Ir,new Function("context","fn","item",e?.textContent??""))}catch(t){console.error("custom-operator contains invalid javascript code",t)}}calculate(){let e={variable:i=>this._context?.variables.find(s=>s.identifier===i)?.value??"",correct:i=>this._context?.variables.find(s=>s.identifier===i)?.correctResponse??""},t={getVariable:i=>this._context?.variables.find(s=>s.identifier===i),updateOutcomeVariable:(i,s)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:s}}))},updateResponseVariable:(i,s)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:i,response:s}}))}};return x(this,Ir).call(this,this._context,e,t)}};Ir=new WeakMap,c([k({context:D,subscribe:!0}),w()],Mr.prototype,"_context",2),Mr=c([C("qti-custom-operator")],Mr);var Rr=class extends re{render(){return f` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Rr.styles=y`
|
|
8
|
+
`}render(){return x`<pre>${JSON.stringify(this.result,null,2)}</pre>
|
|
9
|
+
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};d([R()],L.prototype,"result",2),d([P({context:G,subscribe:!0}),R()],L.prototype,"context",2),d([P({context:Xt,subscribe:!0}),R()],L.prototype,"qtiContext",2);var fe=class extends L{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var kc=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Pr=s=>{if(typeof s=="string")return s;let r=kc();return r==="."?s.toLocaleString():s.toString().replace(".","").replace(r,".")};function qs(s){return s==null}function Ki(s){return s.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var le=class extends C{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(r){let e=this._context.variables.find(i=>i.identifier===r)||null;if(this.outcomeIdentifier!==r||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!qs(this.identifier)&&!qs(e?.value)&&this.identifier===e.value||!1,this.#e(t)}#e(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};d([b({type:String,attribute:"show-hide"})],le.prototype,"showHide",2),d([b({type:String,attribute:"outcome-identifier"})],le.prototype,"outcomeIdentifier",2),d([b({type:String})],le.prototype,"identifier",2),d([b({type:String,attribute:!1})],le.prototype,"showStatus",2),d([P({context:G,subscribe:!0}),R()],le.prototype,"_context",2);var ca=class extends C{};var K=class{static isPointInArea(r,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[i,o]=r.split(" ").map(Number),[n,...a]=e.split(","),l=a.map(Number);switch(n.toLowerCase()){case"circle":case"default":{let[c,p,h]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((i-c)**2+(o-p)**2)<=h}case"rect":{let[c,p,h,m]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=c&&i<=h&&o>=p&&o<=m}case"ellipse":{let[c,p,h,m]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let y=(i-c)**2/h**2,v=(o-p)**2/m**2;return y+v<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let c=[];for(let p=0;p<l.length;p+=2)c.push({x:l[p],y:l[p+1]});return this.isPointInPolygon({x:i,y:o},c)}default:return console.warn(`Unsupported shape type: ${n}`),!1}}static isPointInPolygon(r,e){let t=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let n=e[i].x,a=e[i].y,l=e[o].x,c=e[o].y;a>r.y!=c>r.y&&r.x<(l-n)*(r.y-a)/(c-a)+n&&(t=!t)}return t}static compareSingleValues(r,e,t){switch(t){case"identifier":case"string":return r===e;case"integer":{let i=parseInt(r,10),o=parseInt(e,10);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`Cannot convert ${r} and/or ${e} to int.`);break}case"float":{let i=parseFloat(r),o=parseFloat(e);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`couldn't convert ${r} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=r.split(" ").sort(),o=e.split(" ").sort();if(i.length===2&&o.length===2)return t==="pair"&&(i.sort(),o.sort()),i.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${r} 2: ${e}`);break}}return!1}};var ws=s=>{class r extends s{constructor(...i){super(...i);this.testContext=ys;this.sessionContext=vs;this._updateItemInTestContext=i=>{let o=i._context,n=o.identifier,a=o.variables,l=this.testContext.items.find(c=>c?.identifier===n);if(!l){console.warn(`Item IDs between assessment.xml and item.xml should match: ${n} is not found!`);return}if(l.variables?.length===1)this._updateItemVariablesInTestContext(n,a);else{let c=[...i.variables];for(let p of l.variables){let h=c.find(m=>m.identifier===p.identifier);h?h.value=p.value:c.push(p)}i.variables=c}};this._initializeEventListeners()}updateItemVariables(i,o){let n=this.testContext.items.find(l=>l.identifier===i);n&&(n.variables=n.variables.map(l=>{let c=o.find(p=>p.identifier===l.identifier);return c?{...l,...c}:l}));let a=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);a&&a.assessmentItem&&(a.assessmentItem.variables=o)}_initializeEventListeners(){this.addEventListener("qti-assessment-test-connected",i=>{if(this.testContext=ys,this.sessionContext=vs,this.testContext&&this.testContext.items.length>0)return;this._testElement=i.detail;let o=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(n=>({href:n.href,identifier:n.identifier,category:n.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:o}}),this.addEventListener("qti-assessment-item-connected",i=>{let o=i.detail,n=o.closest("qti-assessment-item-ref")?.identifier;n&&(o.assessmentItemRefId=n),this._updateItemInTestContext(i.detail)}),this.addEventListener("qti-item-context-updated",i=>{this._updateItemVariablesInTestContext(i.detail.itemContext.identifier,i.detail.itemContext.variables,i.detail.itemContext.state)})}_updateItemVariablesInTestContext(i,o,n){this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:o.map(l=>{let c=a.variables.find(p=>p.identifier===l.identifier);return c?{...c,...l}:l}),...n!==void 0?{state:n?{...n}:void 0}:{}})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}}return d([b({attribute:!1,type:Object}),ne({context:Ie})],r.prototype,"testContext",2),d([b({attribute:!1,type:Object}),ne({context:et})],r.prototype,"sessionContext",2),r},da=class extends ws(C){};var pa=s=>{class r extends s{constructor(...t){super(...t),this.addEventListener("qti-register-variable",i=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],i.detail.variable]},i.stopPropagation()}),this.addEventListener("qti-set-outcome-value",i=>{let{outcomeIdentifier:o,value:n}=i.detail;this.updateOutcomeVariable(o,n),i.stopPropagation()})}outcomeProcessing(){let t=this.querySelector("qti-outcome-processing");return t?(t?.process(),!0):!1}updateOutcomeVariable(t,i){let o=this.getOutcome(t);if(!o){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(n=>n.identifier!==t?n:{...n,value:o.cardinality==="single"?i:[...n.value,i]})}}getOutcome(t){return this.getVariable(t)}getVariable(t){return this.testContext.testOutcomeVariables?.find(i=>i.identifier===t)||null}}return r};var Zi=class extends Zn(ea(pa(ws(C)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return x`<slot></slot>`}};Zi=d([k("qti-test")],Zi);var ua={fromAttribute(s){return s==="true"},toAttribute(s){return s?"true":"false"}},Fe=class extends C{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-item-ref-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href,category:this.category}}))}render(){return this.myTemplate?this.myTemplate({xmlDoc:this.xmlDoc}):this.xmlDoc}};d([b({type:String})],Fe.prototype,"category",2),d([b({type:String})],Fe.prototype,"identifier",2),d([b({type:Boolean,converter:ua})],Fe.prototype,"required",2),d([b({type:Boolean,converter:ua})],Fe.prototype,"fixed",2),d([b({type:String})],Fe.prototype,"href",2),d([b({type:Object,attribute:!1})],Fe.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",Fe);var Cs={fromAttribute(s){return s==="true"},toAttribute(s){return s?"true":"false"}},Be=class extends C{get title(){return this.#e}set title(r){this.#e=r,this.removeAttribute("title"),this.setAttribute("data-title",r)}#e="";async connectedCallback(){this.#e=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return x`<slot name="qti-rubric-block"></slot><slot></slot>`}};d([b({type:String})],Be.prototype,"identifier",2),d([b({type:String})],Be.prototype,"required",2),d([b({type:Boolean,converter:Cs})],Be.prototype,"fixed",2),d([b({type:Boolean,converter:Cs})],Be.prototype,"visible",2),d([b({type:Boolean,converter:Cs,attribute:"keep-together"})],Be.prototype,"keepTogether",2),d([P({context:Ie,subscribe:!0})],Be.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",Be);var Dr,It=class extends C{constructor(){super(...arguments);_(this,Dr,"")}get title(){return I(this,Dr)}set title(e){B(this,Dr,e),this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return x` <slot></slot>`}};Dr=new WeakMap,d([b({type:String})],It.prototype,"identifier",2),d([b({type:String})],It.prototype,"title",1),d([P({context:Ie,subscribe:!0})],It.prototype,"_testContext",2),It=d([k("qti-assessment-test")],It);var $r,Ue=class extends C{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";_(this,$r,"")}get title(){return I(this,$r)}set title(e){B(this,$r,e),this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return x` <slot></slot>`}};$r=new WeakMap,d([b({type:String})],Ue.prototype,"identifier",2),d([b({type:String})],Ue.prototype,"class",2),d([b({type:String,attribute:"navigation-mode"})],Ue.prototype,"navigationMode",2),d([b({type:String,attribute:"submission-mode"})],Ue.prototype,"submissionMode",2),Ue=d([k("qti-test-part")],Ue);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ue);var Or,Yt,Vr,Kt,ge,de,ma,ha,Nr,Hr,Fr,Br,Ur,zr,fa,Es,ga,ce=class extends C{constructor(){super(...arguments);_(this,de);_(this,Or);_(this,Yt,null);this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{I(this,ge).forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>I(this,ge).forEach(i=>i.readonly=t);this._context={variables:ta};_(this,Vr,{...this._context,variables:this._context.variables});_(this,Kt,[]);_(this,ge,[]);_(this,Nr,e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},B(this,Vr,this._context),e.stopPropagation()});_(this,Hr,e=>{e.stopImmediatePropagation();let t=e.detail;I(this,Kt).push(t),(Number(this._context.variables.find(o=>o.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)});_(this,Fr,e=>{e.stopImmediatePropagation(),I(this,ge).push(e.detail.interactionElement)});_(this,Br,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)});_(this,Ur,e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()});_(this,zr,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i,state:o}=e.detail;this.updateResponseVariable(t,i),o!==void 0&&(this._context={...this._context,state:{...this._context.state||{},[t]:o}}),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))})}get title(){return I(this,Or)}set title(e){B(this,Or,e),this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(o=>o.identifier===t.identifier);return i?{...t,...i,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=I(this,ge).find(o=>o.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&I(this,Kt).forEach(i=>i.checkShowFeedback(t.identifier))})}get state(){return this._context.state}set state(e){this._context={...this._context,state:e?{...e}:void 0}}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let o=I(this,ge).find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);o&&(o.response=t.response)}}render(){return x`<slot></slot>`}connectedCallback(){D(this,de,ma).call(this),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),D(this,de,fa).call(this)})}disconnectedCallback(){D(this,de,ha).call(this),super.disconnectedCallback()}showCorrectResponse(e){for(let t of I(this,ge))t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of I(this,ge))t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(n=>n.identifier==="numAttempts")?.value+1).toString()),this.adaptive==="false"&&D(this,de,ga).call(this);let i=this.querySelector("qti-response-processing"),o=!!(i&&typeof i.process=="function");return o&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",D(this,de,Es).call(this)),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),o}resetResponses(){this._context=I(this,Vr)}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this.showCandidateCorrection(!1),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",D(this,de,Es).call(this))}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(o=>o.identifier!==e?o:{...o,value:i.cardinality==="single"||Array.isArray(t)?t:[t]})},I(this,Kt).forEach(o=>o.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(o=>o.identifier===e)?.value}}))}validate(e=!0){let t=I(this,ge).every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of I(this,ge))e.reportValidity()}};Or=new WeakMap,Yt=new WeakMap,Vr=new WeakMap,Kt=new WeakMap,ge=new WeakMap,de=new WeakSet,ma=function(){this.addEventListener("qti-register-variable",I(this,Nr)),this.addEventListener("qti-register-feedback",I(this,Hr)),this.addEventListener("qti-register-interaction",I(this,Fr)),this.addEventListener("end-attempt",I(this,Br)),this.addEventListener("qti-set-outcome-value",I(this,Ur)),this.addEventListener("qti-interaction-response",I(this,zr))},ha=function(){this.removeEventListener("qti-register-variable",I(this,Nr)),this.removeEventListener("qti-register-feedback",I(this,Hr)),this.removeEventListener("qti-register-interaction",I(this,Fr)),this.removeEventListener("end-attempt",I(this,Br)),this.removeEventListener("qti-set-outcome-value",I(this,Ur)),this.removeEventListener("qti-interaction-response",I(this,zr))},Nr=new WeakMap,Hr=new WeakMap,Fr=new WeakMap,Br=new WeakMap,Ur=new WeakMap,zr=new WeakMap,fa=function(){B(this,Yt,this.querySelector("qti-template-processing")),I(this,Yt)&&I(this,Yt).process()},Es=function(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"},ga=function(){this._context={...this._context,variables:this._context.variables.map(e=>{if(e.type!=="outcome")return e;let o=("defaultValue"in e?e.defaultValue:null)??null;return o==null&&(e.baseType==="integer"||e.baseType==="float")&&(o="0"),{...e,value:o}})}},d([b({type:String})],ce.prototype,"identifier",2),d([b({type:String})],ce.prototype,"adaptive",2),d([b({type:String})],ce.prototype,"timeDependent",2),d([b({type:String})],ce.prototype,"title",1),d([b({type:Boolean})],ce.prototype,"disabled",2),d([U("disabled",{waitUntilFirstUpdate:!0})],ce.prototype,"_handleDisabledChange",2),d([b({type:Boolean})],ce.prototype,"readonly",2),d([U("readonly",{waitUntilFirstUpdate:!0})],ce.prototype,"_handleReadonlyChange",2),d([ne({context:G})],ce.prototype,"_context",2),ce=d([k("qti-assessment-item")],ce);var Ss=class s extends Event{constructor(e,t){super(s.eventName,{bubbles:!0,composed:!0,cancelable:!0});this.element=e;this.item=t}static{this.eventName="qti-assessment-stimulus-ref-connected"}},Zt=class extends C{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Ss(this,e);this.dispatchEvent(t);let i=e?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!t.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(e){let t=await Ae().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};d([b({type:String})],Zt.prototype,"identifier",2),d([b({type:String})],Zt.prototype,"href",2),Zt=d([k("qti-assessment-stimulus-ref")],Zt);var eo=class extends C{};eo=d([k("qti-companion-materials-info")],eo);var Wr,jr=class extends C{constructor(){super(...arguments);_(this,Wr)}render(){return x`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let e=Array.from(this.firstElementChild?.childNodes??[]).find(t=>t.nodeType===Node.COMMENT_NODE);try{B(this,Wr,new Function("context","fn","item",e?.textContent??""))}catch(t){console.error("custom-operator contains invalid javascript code",t)}}calculate(){let e={variable:i=>this._context?.variables.find(o=>o.identifier===i)?.value??"",correct:i=>this._context?.variables.find(o=>o.identifier===i)?.correctResponse??""},t={getVariable:i=>this._context?.variables.find(o=>o.identifier===i),updateOutcomeVariable:(i,o)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:o}}))},updateResponseVariable:(i,o)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:i,response:o}}))}};return I(this,Wr).call(this,this._context,e,t)}};Wr=new WeakMap,d([P({context:G,subscribe:!0}),R()],jr.prototype,"_context",2),jr=d([k("qti-custom-operator")],jr);var Gr=class extends le{render(){return x` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Gr.styles=S`
|
|
10
10
|
:host {
|
|
11
11
|
display: block;
|
|
12
12
|
}
|
|
@@ -16,21 +16,21 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
16
16
|
.off {
|
|
17
17
|
display: none;
|
|
18
18
|
}
|
|
19
|
-
`,
|
|
19
|
+
`,Gr=d([k("qti-feedback-block")],Gr);var Me=s=>s??N;var Xr=class extends le{constructor(){super(...arguments);this.render=()=>x` <slot part="feedback" class="${Me(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Xr.styles=S`
|
|
20
20
|
.on {
|
|
21
21
|
display: inline-block;
|
|
22
22
|
}
|
|
23
23
|
.off {
|
|
24
24
|
display: none;
|
|
25
25
|
}
|
|
26
|
-
`,
|
|
26
|
+
`,Xr=d([k("qti-feedback-inline")],Xr);var kt=class extends le{render(){return x`
|
|
27
27
|
<dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
|
|
28
28
|
<slot></slot>
|
|
29
29
|
<div style="margin-top: var(--qti-gap-size); text-align: center;">
|
|
30
30
|
<button class="button close-button" @click="${this.closeFeedback}">Close</button>
|
|
31
31
|
</div>
|
|
32
32
|
</dialog>
|
|
33
|
-
`}openFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&!r.open&&r.showModal()}closeFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&r.open&&(r.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(r){r.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};
|
|
33
|
+
`}openFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&!r.open&&r.showModal()}closeFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&r.open&&(r.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(r){r.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};kt.styles=S`
|
|
34
34
|
.qti-dialog {
|
|
35
35
|
background: var(--qti-bg);
|
|
36
36
|
border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
|
|
@@ -69,23 +69,23 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
69
69
|
.button:focus {
|
|
70
70
|
outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
|
|
71
71
|
}
|
|
72
|
-
`,
|
|
72
|
+
`,kt=d([k("qti-modal-feedback")],kt);var ba=S`
|
|
73
73
|
:host {
|
|
74
74
|
display: block;
|
|
75
75
|
}
|
|
76
|
-
`;var
|
|
76
|
+
`;var Qr=class extends C{render(){return x`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};Qr.styles=ba,Qr=d([k("qti-item-body")],Qr);var to=class extends C{render(){return x`<slot></slot>`}};to=d([k("qti-content-body")],to);var Re=class extends C{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{let t=new CustomEvent("qti-rubric:discretionary-placement",{detail:{className:e,element:this},bubbles:!0,composed:!0,cancelable:!0});if(!this.dispatchEvent(t))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return x`<slot></slot>`}};Re.styles=S`
|
|
77
77
|
:host {
|
|
78
78
|
display: block;
|
|
79
79
|
}
|
|
80
|
-
`,
|
|
80
|
+
`,d([b({type:String})],Re.prototype,"id",2),d([b({type:String})],Re.prototype,"use",2),d([b({type:String})],Re.prototype,"view",2),d([b({type:String,attribute:"class"})],Re.prototype,"classNames",2),d([U("classNames",{waitUntilFirstUpdate:!0})],Re.prototype,"handleclassNamesChange",1),Re=d([k("qti-rubric-block")],Re);var pe,Jr,Ts,ro=class extends C{constructor(){super(...arguments);_(this,Jr);_(this,pe,null)}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let o=D(this,Jr,Ts).call(this,i);B(this,pe,document.createElement("style")),I(this,pe).media="screen",I(this,pe).textContent=`@scope {${o}}`,this.parentElement?this.parentElement.appendChild(I(this,pe)):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=D(this,Jr,Ts).call(this,this.textContent);B(this,pe,document.createElement("style")),I(this,pe).media="screen",I(this,pe).textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(I(this,pe)):console.warn("No parent element to append the scoped stylesheet to.")}}disconnectedCallback(){if(I(this,pe))try{I(this,pe).remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};pe=new WeakMap,Jr=new WeakSet,Ts=function(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()},ro=d([k("qti-stylesheet")],ro);var ot,va,ya,xa,ze=class extends Jt{constructor(){super(...arguments);_(this,ot)}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return x`${JSON.stringify(e,null,2)}`}connectedCallback(){super.connectedCallback();let e=this.defaultValues(this.cardinality),t={baseType:this.baseType,identifier:this.identifier,correctResponse:I(this,ot,va),cardinality:this.cardinality||"single",mapping:I(this,ot,ya),defaultValue:e,areaMapping:I(this,ot,xa),value:null,type:"response",candidateResponse:null};t.value=e,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}};ot=new WeakSet,va=function(){let e,t=this.querySelector("qti-correct-response");if(t){let i=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&i.length>0)e=i[0].textContent.trim(),i[0].remove();else if(this.cardinality!=="single"){e=[];for(let o=0;o<i.length;o++)e.push(i[o].textContent.trim()),i[o].remove()}}return e},ya=function(){let e=this.querySelector("qti-mapping"),t=parseFloat(e?.getAttribute("lower-bound")),i=parseFloat(e?.getAttribute("upper-bound"));return{defaultValue:Number(e?.getAttribute("default-value"))||0,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,mapEntries:Array.from(e?.querySelectorAll("qti-map-entry")||[]).map(n=>({mapKey:n.getAttribute("map-key")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,caseSensitive:n.hasAttribute("case-sensitive")?n.getAttribute("case-sensitive")!=="false":!1}))}},xa=function(){let e=this.querySelector("qti-area-mapping"),t=Number(e?.getAttribute("default-value"))||0,i=parseFloat(e?.getAttribute("lower-bound")),o=parseFloat(e?.getAttribute("upper-bound")),n=Array.from(e?.querySelectorAll("qti-area-map-entry")||[]).map(a=>({shape:a.getAttribute("shape")||"default",coords:a.getAttribute("coords")||"",mappedValue:Number(a.getAttribute("mapped-value"))||0,defaultValue:Number(a.getAttribute("default-value"))||0}));return{defaultValue:t,lowerBound:isNaN(i)?null:i,upperBound:isNaN(o)?null:o,areaMapEntries:n}},ze.styles=[S`
|
|
81
81
|
:host {
|
|
82
82
|
display: none;
|
|
83
83
|
}
|
|
84
|
-
`],
|
|
84
|
+
`],d([b({type:String,attribute:"base-type"})],ze.prototype,"baseType",2),d([b({type:String})],ze.prototype,"identifier",2),d([b({type:String})],ze.prototype,"cardinality",2),d([P({context:G,subscribe:!0}),R()],ze.prototype,"itemContext",2),ze=d([k("qti-response-declaration")],ze);var _e=class extends Jt{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return x`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let i of e.querySelectorAll("qti-interpolation-table-entry")){!i.getAttribute("source-value")&&i.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let o=parseFloat(i.getAttribute("source-value")),n=parseFloat(i.getAttribute("target-value"));(isNaN(o)||isNaN(n))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(o,n)}return t}return null}connectedCallback(){super.connectedCallback();let e=this.defaultValues(this.cardinality),t={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:e,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};t.value=e,(t.value===null||t.value==null)&&(t.baseType==="integer"||t.baseType==="float")&&(t.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}};_e.styles=[S`
|
|
85
85
|
:host {
|
|
86
86
|
display: none;
|
|
87
87
|
}
|
|
88
|
-
`],
|
|
88
|
+
`],d([b({type:String,attribute:"base-type"})],_e.prototype,"baseType",2),d([b({type:String,attribute:"external-scored"})],_e.prototype,"externalScored",2),d([b({type:String})],_e.prototype,"identifier",2),d([b({type:String})],_e.prototype,"cardinality",2),d([P({context:G,subscribe:!0}),R()],_e.prototype,"itemContext",2),_e=d([k("qti-outcome-declaration")],_e);var qa=`<qti-response-processing>
|
|
89
89
|
<qti-response-condition>
|
|
90
90
|
<qti-response-if>
|
|
91
91
|
<qti-match>
|
|
@@ -102,7 +102,7 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
102
102
|
</qti-set-outcome-value>
|
|
103
103
|
</qti-response-else>
|
|
104
104
|
</qti-response-condition>
|
|
105
|
-
</qti-response-processing>`,
|
|
105
|
+
</qti-response-processing>`,wa=`<qti-response-processing>
|
|
106
106
|
<qti-response-condition>
|
|
107
107
|
<qti-response-if>
|
|
108
108
|
<qti-is-null>
|
|
@@ -118,7 +118,7 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
118
118
|
</qti-set-outcome-value>
|
|
119
119
|
</qti-response-else>
|
|
120
120
|
</qti-response-condition>
|
|
121
|
-
</qti-response-processing>`,
|
|
121
|
+
</qti-response-processing>`,Ca=`<qti-response-processing>
|
|
122
122
|
<qti-response-condition>
|
|
123
123
|
<qti-response-if>
|
|
124
124
|
<qti-is-null>
|
|
@@ -134,84 +134,84 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
134
134
|
</qti-set-outcome-value>
|
|
135
135
|
</qti-response-else>
|
|
136
136
|
</qti-response-condition>
|
|
137
|
-
</qti-response-processing>`;var
|
|
137
|
+
</qti-response-processing>`;var er,io,Yr=class extends C{constructor(){super(...arguments);_(this,er)}render(){return x`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let t=[...this.children];for(let i of t)i.process()}firstUpdated(e){if(this.getAttribute("template")){let t=this.getAttribute("template").split("/"),i=t[t.length-1].replace(".xml","");switch(this.innerHTML="",i){case"map_response":{this.appendChild(D(this,er,io).call(this,wa).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(D(this,er,io).call(this,Ca).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(D(this,er,io).call(this,qa).firstElementChild.firstElementChild);break}}}};er=new WeakSet,io=function(e){return document.createRange().createContextualFragment(e)},Yr.styles=[S`
|
|
138
138
|
:host {
|
|
139
139
|
display: none;
|
|
140
140
|
}
|
|
141
|
-
`],
|
|
141
|
+
`],Yr=d([k("qti-response-processing")],Yr);var st,nt,Ea,Sa,Ta,Le=class extends C{constructor(){super(...arguments);_(this,nt);this.identifier="";this.cardinality="single";this.baseType="string";this.mathVariable=!1;this.paramVariable=!1;_(this,st,null)}render(){return x`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{D(this,nt,Ea).call(this),D(this,nt,Ta).call(this)})}getTemplateVariable(){return{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,value:I(this,st),type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable}}};st=new WeakMap,nt=new WeakSet,Ea=function(){let e=this.querySelector("qti-default-value");if(!e)return;let t=e.textContent?.trim()||"";B(this,st,D(this,nt,Sa).call(this,t))},Sa=function(e){if(!e)return null;switch(this.baseType){case"integer":return parseInt(e,10);case"float":case"duration":return parseFloat(e);case"boolean":return e.toLowerCase()==="true";default:return e}},Ta=function(){let t={...{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:I(this,st),value:I(this,st),type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable},value:I(this,st)?.toString()||""};this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))},Le.styles=[S`
|
|
142
142
|
:host {
|
|
143
143
|
display: none;
|
|
144
144
|
}
|
|
145
|
-
`],
|
|
145
|
+
`],d([b({type:String})],Le.prototype,"identifier",2),d([b({type:String})],Le.prototype,"cardinality",2),d([b({type:String,attribute:"base-type"})],Le.prototype,"baseType",2),d([b({type:Boolean,attribute:"math-variable"})],Le.prototype,"mathVariable",2),d([b({type:Boolean,attribute:"param-variable"})],Le.prototype,"paramVariable",2),Le=d([k("qti-template-declaration")],Le);var Mt=class extends C{constructor(){super(...arguments);this.identifier="";this.cardinality="record"}render(){return x`<slot></slot>`}};Mt.styles=[S`
|
|
146
146
|
:host {
|
|
147
147
|
display: none;
|
|
148
148
|
}
|
|
149
|
-
`],
|
|
149
|
+
`],d([b({type:String})],Mt.prototype,"identifier",2),d([b({type:String})],Mt.prototype,"cardinality",2),Mt=d([k("qti-context-declaration")],Mt);var Kr=class extends kt{render(){return x``}};Kr.styles=S`
|
|
150
150
|
:host {
|
|
151
151
|
color: gray;
|
|
152
152
|
}
|
|
153
|
-
`,
|
|
153
|
+
`,Kr=d([k("qti-test-feedback")],Kr);var ue,Q,Aa,Ia,ka,Ma,Ra,_a,La,Pa,be=class extends C{constructor(){super();_(this,Q);this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;_(this,ue);this.addEventListener("qti-assessment-test-connected",D(this,Q,_a).bind(this)),this.addEventListener("qti-assessment-item-connected",D(this,Q,Pa).bind(this)),this.addEventListener("qti-interaction-changed",D(this,Q,Ra).bind(this)),this.addEventListener("test-end-attempt",D(this,Q,Aa).bind(this)),this.addEventListener("test-show-correct-response",D(this,Q,Ia).bind(this)),this.addEventListener("test-show-candidate-correction",D(this,Q,ka).bind(this)),this.addEventListener("test-update-outcome-variable",D(this,Q,Ma).bind(this))}render(){return x`<slot></slot>`}willUpdate(e){if(!this.computedContext)return;let t=1;this.computedContext={...this.computedContext,view:this._sessionContext?.view,testParts:this.computedContext.testParts.map(i=>({...i,active:this._sessionContext?.navPartId===i.identifier||!1,sections:i.sections.map(o=>({...o,active:this._sessionContext?.navSectionId===o.identifier||!1,completed:o.items.every(n=>this._testContext.items.find(a=>a.identifier===n.identifier)?.variables.find(a=>a.identifier==="completionStatus").value==="completed"),items:o.items.map(n=>{let a=this._testContext?.items.find(g=>g.identifier===n.identifier),l={...n,...a,...this.initContext?.find(g=>g.identifier===n.identifier)},c=l.variables?.find(g=>g.identifier=="SCORE")?.value,p=c==null?null:parseFloat(c?.toString()),h=l.variables?.find(g=>g.identifier==="completionStatus")?.value,m=l.variables?.find(g=>g.identifier==="RESPONSE")?.value||"",y=l.variables?.find(g=>g.identifier==="numAttempts")?.value||0,v=this._sessionContext?.navItemRefId===l.identifier||!1,w=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,f=n.variables?.find(g=>g.identifier=="MAXSCORE")?.value,u=f==null?null:parseFloat(f?.toString());return{...l,completionStatus:h,numAttempts:y,score:p,response:m,index:w,active:v,maxScore:u}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};ue=new WeakMap,Q=new WeakSet,Aa=function(e){let i=I(this,ue).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,o=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,o)},Ia=function(e){let i=I(this,ue).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)},ka=function(e){I(this,ue).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)},Ma=function(e){I(this,ue).querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)},Ra=function(e){if(this.autoScoreItems){let t=e.composedPath()[0].closest("qti-assessment-item"),i=t.variables.find(o=>o.identifier==="SCORE");if(i&&i.externalScored===null&&t.adaptive==="false"){let o=this.configContext?.reportValidityAfterScoring===!0;t.processResponse(!0,o)}}},_a=function(e){if(B(this,ue,e.detail),!this.qtiContext.QTI_CONTEXT?.testIdentifier){let o=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.qtiContext={QTI_CONTEXT:{...o,testIdentifier:I(this,ue).identifier,environmentIdentifier:o.environmentIdentifier||"default"}}}I(this,ue).querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(o=>{let n=D(this,Q,La).call(this,o);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(I(this,ue)?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:I(this,ue).identifier,title:I(this,ue).title,view:this._sessionContext?.view,testParts:i.map(o=>{let n=[...o.querySelectorAll("qti-assessment-section")];return{active:!1,identifier:o.identifier,navigationMode:o.navigationMode,submissionMode:o.submissionMode,sections:n.map(a=>{let l=[...a.querySelectorAll("qti-assessment-item-ref")];return{active:!1,identifier:a.identifier,title:a.title,items:l.map(c=>({...this.initContext?.find(p=>p.identifier===c.identifier),active:!1,identifier:c.identifier,categories:c.category?c.category?.split(" "):[],href:c.href,variables:[]}))}})}})}},La=function(e){let t={},i=e.querySelector("qti-default-value");return i&&i.querySelectorAll("qti-value[field-identifier]").forEach(n=>{let a=n.getAttribute("field-identifier"),l=n.getAttribute("base-type")||"string",c=n.textContent?.trim()||"";if(a){let p=c;switch(l){case"integer":p=parseInt(c,10);break;case"float":case"duration":p=parseFloat(c);break;case"boolean":p=c.toLowerCase()==="true";break;default:p=c;break}t[a]=p}}),t},Pa=function(e){let t=e.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(o=>({...o,items:o.items.map(n=>{if(n.identifier!==t.parentElement.getAttribute("identifier"))return n;let l=t.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),c=t.querySelectorAll("qti-response-declaration"),p=Array.from(c).some(v=>v.querySelector("qti-correct-response")),h=Array.from(c).some(v=>{let w=v.querySelector("qti-mapping"),f=v.querySelector("qti-area-mapping");return w?.querySelector("qti-map-entry")||f?.querySelector("qti-area-map-entry")}),m=p||h,y=!!t.querySelector("qti-response-processing");return{...n,assessmentItemIdentifier:t.getAttribute("identifier"),label:t.getAttribute("label"),title:t.title,externalScored:l,adaptive:t.adaptive=="true"||!1,timeDependent:t.timeDependent=="true"||!1,variables:t.variables,hasCorrectResponse:m,hasResponseProcessing:y}})}))}))}},d([b({type:String})],be.prototype,"identifier",2),d([R()],be.prototype,"initContext",2),d([R(),ne({context:Xt})],be.prototype,"qtiContext",2),d([R(),ne({context:he})],be.prototype,"configContext",2),d([R(),P({context:Ie,subscribe:!0})],be.prototype,"_testContext",2),d([R(),P({context:et,subscribe:!0})],be.prototype,"_sessionContext",2),d([R(),ne({context:W})],be.prototype,"computedContext",2),d([b({type:Boolean,attribute:"auto-score-items"})],be.prototype,"autoScoreItems",2),be=d([k("test-navigation")],be);var Da=S`
|
|
154
154
|
display: inline-flex;
|
|
155
155
|
align-items: center;
|
|
156
156
|
cursor: pointer;
|
|
157
157
|
padding: 0.5rem 1rem;
|
|
158
158
|
border-radius: 0.25rem;
|
|
159
159
|
user-select: none;
|
|
160
|
-
`,
|
|
160
|
+
`,te=S`
|
|
161
161
|
background-color: lightgray;
|
|
162
|
-
${
|
|
163
|
-
`,
|
|
162
|
+
${Da};
|
|
163
|
+
`,re=S`
|
|
164
164
|
cursor: not-allowed;
|
|
165
165
|
opacity: 0.8;
|
|
166
|
-
`,
|
|
167
|
-
${
|
|
166
|
+
`,eb=S`
|
|
167
|
+
${Da};
|
|
168
168
|
border: 1px solid gray;
|
|
169
|
-
`;var
|
|
169
|
+
`;var tr,at=class extends C{constructor(){super();this._internalDisabled=!0;_(this,tr);B(this,tr,this.attachInternals()),I(this,tr).role="button",I(this,tr).ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex+1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}connectedCallback(){super.connectedCallback(),this.checkDisabled()}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex<0||this.itemIndex>=this.sectionItems?.length-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return x`<slot></slot>`}};tr=new WeakMap,at.styles=S`
|
|
170
170
|
:host {
|
|
171
|
-
${
|
|
171
|
+
${te};
|
|
172
172
|
}
|
|
173
173
|
:host([disabled]) {
|
|
174
|
-
${
|
|
174
|
+
${re};
|
|
175
175
|
}
|
|
176
|
-
`,
|
|
176
|
+
`,d([b({type:Boolean,reflect:!0,attribute:"disabled"})],at.prototype,"_internalDisabled",2),d([P({context:W,subscribe:!0})],at.prototype,"computedContext",2),d([U("computedContext")],at.prototype,"_handleTestElementChange",1),at=d([k("test-next")],at);var lt=class extends C{constructor(){super();this._internalDisabled=!0;this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex-1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex===0||this.itemIndex===-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return x`<slot></slot>`}};lt.styles=S`
|
|
177
177
|
:host {
|
|
178
|
-
${
|
|
178
|
+
${te};
|
|
179
179
|
}
|
|
180
180
|
:host([disabled]) {
|
|
181
|
-
${
|
|
181
|
+
${re};
|
|
182
182
|
}
|
|
183
|
-
`,
|
|
183
|
+
`,d([b({type:Boolean,reflect:!0,attribute:"disabled"})],lt.prototype,"_internalDisabled",2),d([P({context:W,subscribe:!0})],lt.prototype,"computedContext",2),d([U("computedContext")],lt.prototype,"_handleTestElementChange",1),lt=d([k("test-prev")],lt);var Zr,As,ie=class extends C{constructor(){super(...arguments);_(this,Zr);this.label="view";this._handleViewOptionsChange=()=>{D(this,Zr,As).call(this)};this._viewOptions=ie.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),D(this,Zr,As).call(this)}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return x`
|
|
184
184
|
<label part="label" for="viewSelect">${this.label}</label>
|
|
185
185
|
<select
|
|
186
186
|
part="select"
|
|
187
187
|
id="viewSelect"
|
|
188
188
|
@change=${e=>{let t=e.target;this._switchView(t.value)}}
|
|
189
189
|
>
|
|
190
|
-
${this._viewOptions.map(e=>
|
|
190
|
+
${this._viewOptions.map(e=>x`<option value="${e}" ?selected=${e===this.sessionContext.view}>${e}</option>`)}
|
|
191
191
|
</select>
|
|
192
|
-
`}};
|
|
192
|
+
`}};Zr=new WeakSet,As=function(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>ie.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=ie.DEFAULT_VIEW_OPTIONS},ie.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],d([P({context:et,subscribe:!0})],ie.prototype,"sessionContext",2),d([b({type:String})],ie.prototype,"label",2),d([b({type:String,attribute:"view-options"})],ie.prototype,"viewOptions",2),d([U("viewOptions",{waitUntilFirstUpdate:!0})],ie.prototype,"_handleViewOptionsChange",2),d([R()],ie.prototype,"_viewOptions",2),ie=d([k("test-view")],ie);var rr=class extends C{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return x` <slot></slot> `}};rr.styles=S`
|
|
193
193
|
:host {
|
|
194
|
-
${
|
|
194
|
+
${te};
|
|
195
195
|
}
|
|
196
196
|
:host([disabled]) {
|
|
197
|
-
${
|
|
197
|
+
${re};
|
|
198
198
|
}
|
|
199
|
-
`,
|
|
199
|
+
`,d([b({type:String,attribute:"item-id"})],rr.prototype,"itemId",2),rr=d([k("test-item-link")],rr);var ei=class extends C{constructor(){super(),this.addEventListener("click",()=>this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})))}render(){return x` <slot></slot> `}};ei.styles=S`
|
|
200
200
|
:host {
|
|
201
|
-
${
|
|
201
|
+
${te};
|
|
202
202
|
}
|
|
203
203
|
:host([disabled]) {
|
|
204
|
-
${
|
|
204
|
+
${re};
|
|
205
205
|
}
|
|
206
|
-
`,
|
|
206
|
+
`,ei=d([k("test-end-attempt")],ei);var ti,ir,$a,Oa,ye=class extends C{constructor(){super(...arguments);_(this,ir);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";_(this,ti)}willUpdate(e){let t=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(o=>o.items)).find(i=>i.active);if(I(this,ti)!==t&&(this.shown=!1,B(this,ti,t)),t){let i=!!t?.variables?.some(n=>n.correctResponse),o=!!t?.variables?.some(n=>n.mapping?.mapEntries?.length>0||n.areaMapping?.areaMapEntries?.length>0);this.disabled=!i&&!o}else this.disabled=!0}render(){return x` <div @click="${D(this,ir,$a)}">${D(this,ir,Oa).call(this)}</div> `}};ti=new WeakMap,ir=new WeakSet,$a=function(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))},Oa=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText},ye.styles=S`
|
|
207
207
|
:host {
|
|
208
|
-
${
|
|
208
|
+
${te};
|
|
209
209
|
}
|
|
210
210
|
:host([disabled]) {
|
|
211
|
-
${
|
|
211
|
+
${re};
|
|
212
212
|
}
|
|
213
|
-
`,
|
|
214
|
-
`;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),Bi=class{#e;#t=-1;#i=0;#r;constructor(r){this.#e=r,this.#s()}nextToken(){for(;$l(this.#r);)this.#s(!0);if(Vl(this.#r))return this.#a();if(da(this.#r))return this.#p();if(Hr(this.#r))return this.#u();if(this.#r===46)return this.#l();if(this.#r===44)return this.#f();if(this.#r===58)return this.#m();if(Nl(this.#r))return this.#b();if(Dl(this.#r))return this.#h();if(this.#s(),this.#r!==void 0)throw new Error(`Expected end of input, got ${this.#r}`)}#s(r){this.#t++,this.#t<this.#e.length?(this.#r=this.#e.charCodeAt(this.#t),r===!0&&(this.#i=this.#t)):this.#r=void 0}#o(r=0){let e=this.#e.substring(this.#i,this.#t+r);return r===0&&this.#n(),e}#n(){this.#i=this.#t}#a(){let r="unterminated string",e=this.#r;for(this.#s(!0);this.#r!==e;){if(this.#r===void 0)throw new Error(r);if(this.#r===92&&(this.#s(),this.#r===void 0))throw new Error(r);this.#s()}let t=Te(_.STRING,Hl(this.#o()));return this.#s(),t}#p(){do this.#s();while(Ol(this.#r));let r=this.#o(),e=Pl(r)?_.KEYWORD:_.IDENTIFIER;return Te(e,r)}#u(){do this.#s();while(Hr(this.#r));return this.#r===46?this.#l():Te(_.INTEGER,this.#o())}#l(){return this.#s(),Hr(this.#r)?this.#g():(this.#n(),Te(_.DOT,".",Ui))}#f(){return this.#s(!0),Te(_.COMMA,",")}#m(){return this.#s(!0),Te(_.COLON,":")}#g(){do this.#s();while(Hr(this.#r));return Te(_.DECIMAL,this.#o())}#b(){this.#s();let r=this.#o(2);if(Ll.indexOf(r)!==-1)this.#s(),this.#s();else{if(r=this.#o(1),r==="=>")return this.#s(),Te(_.ARROW,r);_l.indexOf(r)!==-1&&this.#s()}return r=this.#o(),Te(_.OPERATOR,r,ro[r])}#h(){let r=String.fromCharCode(this.#r),e=Te(_.GROUPER,r,ro[r]);return this.#s(!0),e}};var io=(o,r)=>new zr(o,r).parse(),zr=class{#e;#t;#i;#r;#s;constructor(r,e){this.#t=new Bi(r),this.#i=e}parse(){return this.#o(),this.#n()}#o(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#r?.kind} (${this.#r?.value})`);let t=this.#t.nextToken();this.#r=t,this.#e=t?.kind,this.#s=t?.value}_matches(r,e){return!(r&&this.#e!==r||e&&this.#s!==e)}#n(){if(!this.#r)return this.#i.empty();let r=this.#l();return r===void 0?void 0:this.#a(r,0)}#a(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#r;)if(this._matches(_.GROUPER,"(")){let t=this.#c();r=this.#i.invoke(r,void 0,t)}else if(this._matches(_.GROUPER,"[")){let t=this.#v();r=this.#i.index(r,t)}else if(this._matches(_.DOT)){this.#o();let t=this.#l();r=this.#p(r,t)}else{if(this._matches(_.KEYWORD))break;if(this._matches(_.OPERATOR)&&this.#r.precedence>=e)r=this.#s==="?"?this.#f(r):this.#u(r,this.#r);else break}return r}#p(r,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#i.getter(r,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let t=e.receiver;return this.#i.invoke(r,t.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#u(r,e){if(ca.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#o();let t=this.#l();for(;(this.#e===_.OPERATOR||this.#e===_.DOT||this.#e===_.GROUPER)&&this.#r.precedence>e.precedence;)t=this.#a(t,this.#r.precedence);return this.#i.binary(r,e.value,t)}#l(){if(this._matches(_.OPERATOR)){let r=this.#s;if(this.#o(),r==="+"||r==="-"){if(this._matches(_.INTEGER))return this.#x(r);if(this._matches(_.DECIMAL))return this.#d(r)}if(la.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#a(this.#m(),Ui);return this.#i.unary(r,e)}return this.#m()}#f(r){this.#o(_.OPERATOR,"?");let e=this.#n();this.#o(_.COLON);let t=this.#n();return this.#i.ternary(r,e,t)}#m(){switch(this.#e){case _.KEYWORD:let r=this.#s;if(r==="this")return this.#o(),this.#i.id(r);throw zi.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case _.IDENTIFIER:return this.#h();case _.STRING:return this.#C();case _.INTEGER:return this.#x();case _.DECIMAL:return this.#d();case _.GROUPER:return this.#s==="("?this.#q():this.#s==="{"?this.#b():this.#s==="["?this.#g():void 0;case _.COLON:throw new Error('unexpected token ":"');default:return}}#g(){let r=[];do{if(this.#o(),this._matches(_.GROUPER,"]"))break;r.push(this.#n())}while(this._matches(_.COMMA));return this.#o(_.GROUPER,"]"),this.#i.list(r)}#b(){let r={};do{if(this.#o(),this._matches(_.GROUPER,"}"))break;let e=this.#s;(this._matches(_.STRING)||this._matches(_.IDENTIFIER))&&this.#o(),this.#o(_.COLON),r[e]=this.#n()}while(this._matches(_.COMMA));return this.#o(_.GROUPER,"}"),this.#i.map(r)}#h(){let r=this.#s;if(r==="true")return this.#o(),this.#i.literal(!0);if(r==="false")return this.#o(),this.#i.literal(!1);if(r==="null")return this.#o(),this.#i.literal(null);if(r==="undefined")return this.#o(),this.#i.literal(void 0);let e=this.#y(),t=this.#c();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(_.IDENTIFIER))throw new Error(`expected identifier: ${this.#s}`);let r=this.#s;return this.#o(),this.#i.id(r)}#c(){if(!this._matches(_.GROUPER,"("))return;let r=[];do{if(this.#o(),this._matches(_.GROUPER,")"))break;let e=this.#n();r.push(e)}while(this._matches(_.COMMA));return this.#o(_.GROUPER,")"),r}#v(){this.#o();let r=this.#n();return this.#o(_.GROUPER,"]"),r}#q(){let r=this.#c();if(this._matches(_.ARROW)){this.#o();let e=this.#n(),t=r?.map(i=>i.value)??[];return this.#i.arrowFunction(t,e)}else return this.#i.paren(r[0])}#C(){let r=this.#i.literal(this.#s);return this.#o(),r}#x(r=""){let e=this.#i.literal(parseInt(`${r}${this.#s}`,10));return this.#o(),e}#d(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#s}`));return this.#o(),e}};var{hasOwn:pa,fromEntries:zl}=Object,Ul={"+":(o,r)=>o+r,"-":(o,r)=>o-r,"*":(o,r)=>o*r,"/":(o,r)=>o/r,"%":(o,r)=>o%r,"==":(o,r)=>o==r,"!=":(o,r)=>o!=r,"===":(o,r)=>o===r,"!==":(o,r)=>o!==r,">":(o,r)=>o>r,">=":(o,r)=>o>=r,"<":(o,r)=>o<r,"<=":(o,r)=>o<=r,"||":(o,r)=>o||r,"&&":(o,r)=>o&&r,"??":(o,r)=>o??r,"|":(o,r)=>r(o),"|>":(o,r)=>r(o)},Bl={"+":o=>o,"-":o=>-o,"!":o=>!o},Fi=class{empty(){return{type:"Empty",evaluate(r){return r},getIds(r){return r}}}literal(r){return{type:"Literal",value:r,evaluate(e){return this.value},getIds(e){return e}}}id(r){return{type:"ID",value:r,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(r,e){let t=Bl[r];return{type:"Unary",operator:r,child:e,evaluate(i){return t(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(r,e,t){let i=Ul[e];return{type:"Binary",operator:e,left:r,right:t,evaluate(s){if(this.operator==="="){if(this.left.type!=="ID"&&this.left.type!=="Getter"&&this.left.type!=="Index")throw new Error(`Invalid assignment target: ${this.left}`);let n=this.right.evaluate(s),a,l;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(s),l=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(s),l=this.left.argument.evaluate(s)):this.left.type==="ID"&&(a=s,l=this.left.value),a===void 0?void 0:a[l]=n}return i(this.left.evaluate(s),this.right.evaluate(s))},getIds(s){return this.left.getIds(s),this.right.getIds(s),s}}}getter(r,e){return{type:"Getter",receiver:r,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(r,e,t){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:r,method:e,arguments:t,evaluate(i){let s=this.receiver.evaluate(i),n=this.method?s:i?.this??i,a=this.method?s?.[e]:s,d=(this.arguments??[]).map(p=>p?.evaluate(i));return a?.apply?.(n,d)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(s=>s?.getIds(i)),i}}}paren(r){return r}index(r,e){return{type:"Index",receiver:r,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(r,e,t){return{type:"Ternary",condition:r,trueExpr:e,falseExpr:t,evaluate(i){return this.condition.evaluate(i)?this.trueExpr.evaluate(i):this.falseExpr.evaluate(i)},getIds(i){return this.condition.getIds(i),this.trueExpr.getIds(i),this.falseExpr.getIds(i),i}}}map(r){return{type:"Map",entries:r,evaluate(e){let t={};if(r&&this.entries)for(let i in r){let s=this.entries[i];s&&(t[i]=s.evaluate(e))}return t},getIds(e){if(r&&this.entries)for(let t in r){let i=this.entries[t];i&&i.getIds(e)}return e}}}list(r){return{type:"List",items:r,evaluate(e){return this.items?.map(t=>t?.evaluate(e))},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(r,e){return{type:"ArrowFunction",params:r,body:e,evaluate(t){let i=this.params,s=this.body;return function(...n){let a=zl(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return pa(a,p)&&(a[p]=m),d[p]=m},get(d,p){return pa(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var so=null,ua={boundAttributeSuffix:W.M,marker:W.P,markerMatch:W.A,HTML_RESULT:W.C,getTemplateHtml:W.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){so??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(so))return void(e[so]=r);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(o,r){o._$litDirective$=r},getAttributePartCommittedValue:(o,r,e)=>{let t=z;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:W.V,AttributePart:W.H,PropertyPart:W.B,BooleanAttributePart:W.N,EventPart:W.U,ElementPart:W.F,TemplateInstance:W.R,isIterable:W.D,ChildPart:W.I};var{AttributePart:Fl,PropertyPart:jl,BooleanAttributePart:Wl,EventPart:Xl}=ua,no=new Fi,oo=new Map,ma=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ji=(o,r)=>{let e=oo.get(o);if(e===void 0){if(oo.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new zr(t,no).parse(),oo.set(o,e)}}return e?.evaluate(r)},Gl=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ji(i,r))return Wi(o,r,e,t)},ha=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,fa=o=>/(?:\\{{)|(?:\\}})/g.test(o),Ur=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Ql=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ji(i,r);if(!s[Symbol.iterator])return L;let n=Br(o),a=-1,l=[];for(let d of s){a++;let p=Object.create(r);p.item=d,p.index=a,p.this=r.this??r;let m=[];for(let g of n.parts){let v=g.update(p,e,t);g.type===1?m.push(...v):m.push(v)}let h={_$litType$:n,values:m};l.push(h)}return l}},ba={if:Gl,repeat:Ql},Ae=(o,r=ba,e={},t)=>{let s=Br(o).renderers;if(t){let a=Br(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(h,g,v)=>Wi(t,h,g,v)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>Wi(o,n,r,e)};var Wi=(o,r,e=ba,t={})=>{let i=Br(o),s=[];for(let a of i.parts){let l=a.update(r,e,t);a.type===1?s.push(...l):s.push(l)}return{_$litType$:i,values:s}},ga=new Map,Br=o=>{let r=ga.get(o);return r===void 0&&ga.set(o,r=Yl(o)),r},Yl=o=>{let r={h:void 0,el:o.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(r.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),t=e.currentNode,i=-1,s=[];for(;(t=e.nextNode())!==null;)if(t.nodeType===Node.COMMENT_NODE)i++;else if(t.nodeType===Node.ELEMENT_NODE){i++;let n=t;if(n.tagName==="TEMPLATE"){let l=n.getAttribute("type"),d=n.getAttribute("name"),p=n.getAttribute("call");if(p!==null||l!==null||d!==null){n.parentNode.insertBefore(document.createComment(""),n),s.push(n);let m;if(p!==null){let h=p.trim(),g=h.startsWith("{{")&&h.endsWith("}}");m=(v,E,A)=>{let q=n.getAttribute("data"),M=q===null?void 0:ji(q,v);return(g?ji(h,v):A[p])?.(M,E,A)}}else l!==null?m=(h,g,v)=>{let E=g[l];return E?.(n,h,g,v)}:(d==="super"?r.renderers.super=(h,g,v)=>{let E=v.super,A=Br(n);return v={...v,...A.renderers},E(h,g,v)}:r.renderers[d]=(h,g,v)=>Wi(n,h,g,v),m=(h,g,v)=>{let E=v[d];return E?.(h,g,v)});r.parts.push({type:2,index:i,update:m});continue}}let a=n.getAttributeNames();for(let l of a){let d=n.getAttribute(l),p=d.split(ha);if(p.length===1){fa(d)&&n.setAttribute(l,Ur(d));continue}n.removeAttribute(l);let m=l,h=Fl,g=l[0];g==="."?(m=ma(l.substring(1)),h=jl):g==="?"?(m=l.substring(1),h=Wl):g==="@"&&(m=ma(l.substring(1)),h=Xl);let v=[Ur(p[0])],E=[];for(let A=1;A<p.length;A+=2){let q=p[A];E.push(io(q,no)),v.push(Ur(p[A+1]))}r.parts.push({type:1,index:i,name:m,strings:v,ctor:h,update:(A,q,M)=>E.map(P=>P.evaluate(A))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(ha);l.length>1?n.textContent=Ur(l[0]):fa(a)&&(n.textContent=Ur(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=io(p,no);r.parts.push({type:2,index:++i,update:(g,v)=>m.evaluate(g)});let h=new Text(l[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(h,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=h,e.currentNode=h}}for(let n of s)n.remove();return r};var jr,Fr=class extends b{constructor(){super();T(this,jr);$(this,jr,this.attachInternals()),x(this,jr).ariaLabel="pagination"}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");this.myTemplate=Ae(e)}render(){if(!this.computedContext)return f``;let e=this.computedContext.testParts.flatMap(t=>t.sections.flatMap(i=>i.items));return f` ${e.map(t=>this.myTemplate({item:t,view:this.computedContext.view}))} `}};jr=new WeakMap,c([k({context:N,subscribe:!0})],Fr.prototype,"computedContext",2),Fr=c([C("test-paging-buttons-stamp")],Fr);var Xi=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},Gi=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise((r=>this.Z=r))}resume(){this.Z?.(),this.Y=this.Z=void 0}};var va=o=>!Sn(o)&&typeof o.then=="function",ya=1073741823,ao=class extends Xe{constructor(){super(...arguments),this._$Cwt=ya,this._$Cbt=[],this._$CK=new Xi(this),this._$CX=new Gi}render(...r){return r.find((e=>!va(e)))??z}update(r,e){let t=this._$Cbt,i=t.length;this._$Cbt=e;let s=this._$CK,n=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let l=e[a];if(!va(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=ya,i=0,Promise.resolve(l).then((async d=>{for(;n.get();)await n.get();let p=s.deref();if(p!==void 0){let m=p._$Cbt.indexOf(l);m>-1&&m<p._$Cwt&&(p._$Cwt=m,p.setValue(d))}})))}return z}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},Qi=te(ao);var Yi=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
|
|
213
|
+
`,d([P({context:W,subscribe:!0})],ye.prototype,"computedContext",2),d([b({type:Boolean,reflect:!0})],ye.prototype,"shown",2),d([b({type:Boolean,reflect:!0})],ye.prototype,"disabled",2),d([b({type:String})],ye.prototype,"showCorrectText",2),d([b({type:String})],ye.prototype,"hideCorrectText",2),d([b({type:String})],ye.prototype,"noCorrectResponseText",2),ye=d([k("test-show-correct-response")],ye);var oo=["this"],Va=["+","-","!"],Na=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Is={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},so=13;var Mc=["==","!=","<=",">=","||","&&","??","|>"],Rc=["===","!=="],O;(function(s){s[s.STRING=1]="STRING",s[s.IDENTIFIER=2]="IDENTIFIER",s[s.DOT=3]="DOT",s[s.COMMA=4]="COMMA",s[s.COLON=5]="COLON",s[s.INTEGER=6]="INTEGER",s[s.DECIMAL=7]="DECIMAL",s[s.OPERATOR=8]="OPERATOR",s[s.GROUPER=9]="GROUPER",s[s.KEYWORD=10]="KEYWORD",s[s.ARROW=11]="ARROW"})(O||(O={}));var Pe=(s,r,e=0)=>({kind:s,value:r,precedence:e}),_c=s=>s===9||s===10||s===13||s===32,Ha=s=>s===95||s===36||(s&=-33,65<=s&&s<=90),Lc=s=>Ha(s)||ri(s),Pc=s=>oo.indexOf(s)!==-1,Dc=s=>s===34||s===39,ri=s=>48<=s&&s<=57,$c=s=>s===43||s===45||s===42||s===47||s===33||s===38||s===37||s===60||s===61||s===62||s===63||s===94||s===124,Oc=s=>s===40||s===41||s===91||s===93||s===123||s===125,Vc=s=>s.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
|
|
214
|
+
`;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),no=class{#e;#t=-1;#r=0;#i;constructor(r){this.#e=r,this.#o()}nextToken(){for(;_c(this.#i);)this.#o(!0);if(Dc(this.#i))return this.#a();if(Ha(this.#i))return this.#c();if(ri(this.#i))return this.#d();if(this.#i===46)return this.#l();if(this.#i===44)return this.#u();if(this.#i===58)return this.#h();if($c(this.#i))return this.#b();if(Oc(this.#i))return this.#f();if(this.#o(),this.#i!==void 0)throw new Error(`Expected end of input, got ${this.#i}`)}#o(r){this.#t++,this.#t<this.#e.length?(this.#i=this.#e.charCodeAt(this.#t),r===!0&&(this.#r=this.#t)):this.#i=void 0}#s(r=0){let e=this.#e.substring(this.#r,this.#t+r);return r===0&&this.#n(),e}#n(){this.#r=this.#t}#a(){let r="unterminated string",e=this.#i;for(this.#o(!0);this.#i!==e;){if(this.#i===void 0)throw new Error(r);if(this.#i===92&&(this.#o(),this.#i===void 0))throw new Error(r);this.#o()}let t=Pe(O.STRING,Vc(this.#s()));return this.#o(),t}#c(){do this.#o();while(Lc(this.#i));let r=this.#s(),e=Pc(r)?O.KEYWORD:O.IDENTIFIER;return Pe(e,r)}#d(){do this.#o();while(ri(this.#i));return this.#i===46?this.#l():Pe(O.INTEGER,this.#s())}#l(){return this.#o(),ri(this.#i)?this.#g():(this.#n(),Pe(O.DOT,".",so))}#u(){return this.#o(!0),Pe(O.COMMA,",")}#h(){return this.#o(!0),Pe(O.COLON,":")}#g(){do this.#o();while(ri(this.#i));return Pe(O.DECIMAL,this.#s())}#b(){this.#o();let r=this.#s(2);if(Rc.indexOf(r)!==-1)this.#o(),this.#o();else{if(r=this.#s(1),r==="=>")return this.#o(),Pe(O.ARROW,r);Mc.indexOf(r)!==-1&&this.#o()}return r=this.#s(),Pe(O.OPERATOR,r,Is[r])}#f(){let r=String.fromCharCode(this.#i),e=Pe(O.GROUPER,r,Is[r]);return this.#o(!0),e}};var ks=(s,r)=>new ii(s,r).parse(),ii=class{#e;#t;#r;#i;#o;constructor(r,e){this.#t=new no(r),this.#r=e}parse(){return this.#s(),this.#n()}#s(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#i?.kind} (${this.#i?.value})`);let t=this.#t.nextToken();this.#i=t,this.#e=t?.kind,this.#o=t?.value}_matches(r,e){return!(r&&this.#e!==r||e&&this.#o!==e)}#n(){if(!this.#i)return this.#r.empty();let r=this.#l();return r===void 0?void 0:this.#a(r,0)}#a(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#i;)if(this._matches(O.GROUPER,"(")){let t=this.#p();r=this.#r.invoke(r,void 0,t)}else if(this._matches(O.GROUPER,"[")){let t=this.#v();r=this.#r.index(r,t)}else if(this._matches(O.DOT)){this.#s();let t=this.#l();r=this.#c(r,t)}else{if(this._matches(O.KEYWORD))break;if(this._matches(O.OPERATOR)&&this.#i.precedence>=e)r=this.#o==="?"?this.#u(r):this.#d(r,this.#i);else break}return r}#c(r,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#r.getter(r,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let t=e.receiver;return this.#r.invoke(r,t.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#d(r,e){if(Na.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#s();let t=this.#l();for(;(this.#e===O.OPERATOR||this.#e===O.DOT||this.#e===O.GROUPER)&&this.#i.precedence>e.precedence;)t=this.#a(t,this.#i.precedence);return this.#r.binary(r,e.value,t)}#l(){if(this._matches(O.OPERATOR)){let r=this.#o;if(this.#s(),r==="+"||r==="-"){if(this._matches(O.INTEGER))return this.#m(r);if(this._matches(O.DECIMAL))return this.#w(r)}if(Va.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#a(this.#h(),so);return this.#r.unary(r,e)}return this.#h()}#u(r){this.#s(O.OPERATOR,"?");let e=this.#n();this.#s(O.COLON);let t=this.#n();return this.#r.ternary(r,e,t)}#h(){switch(this.#e){case O.KEYWORD:let r=this.#o;if(r==="this")return this.#s(),this.#r.id(r);throw oo.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case O.IDENTIFIER:return this.#f();case O.STRING:return this.#q();case O.INTEGER:return this.#m();case O.DECIMAL:return this.#w();case O.GROUPER:return this.#o==="("?this.#x():this.#o==="{"?this.#b():this.#o==="["?this.#g():void 0;case O.COLON:throw new Error('unexpected token ":"');default:return}}#g(){let r=[];do{if(this.#s(),this._matches(O.GROUPER,"]"))break;r.push(this.#n())}while(this._matches(O.COMMA));return this.#s(O.GROUPER,"]"),this.#r.list(r)}#b(){let r={};do{if(this.#s(),this._matches(O.GROUPER,"}"))break;let e=this.#o;(this._matches(O.STRING)||this._matches(O.IDENTIFIER))&&this.#s(),this.#s(O.COLON),r[e]=this.#n()}while(this._matches(O.COMMA));return this.#s(O.GROUPER,"}"),this.#r.map(r)}#f(){let r=this.#o;if(r==="true")return this.#s(),this.#r.literal(!0);if(r==="false")return this.#s(),this.#r.literal(!1);if(r==="null")return this.#s(),this.#r.literal(null);if(r==="undefined")return this.#s(),this.#r.literal(void 0);let e=this.#y(),t=this.#p();return t?this.#r.invoke(e,void 0,t):e}#y(){if(!this._matches(O.IDENTIFIER))throw new Error(`expected identifier: ${this.#o}`);let r=this.#o;return this.#s(),this.#r.id(r)}#p(){if(!this._matches(O.GROUPER,"("))return;let r=[];do{if(this.#s(),this._matches(O.GROUPER,")"))break;let e=this.#n();r.push(e)}while(this._matches(O.COMMA));return this.#s(O.GROUPER,")"),r}#v(){this.#s();let r=this.#n();return this.#s(O.GROUPER,"]"),r}#x(){let r=this.#p();if(this._matches(O.ARROW)){this.#s();let e=this.#n(),t=r?.map(i=>i.value)??[];return this.#r.arrowFunction(t,e)}else return this.#r.paren(r[0])}#q(){let r=this.#r.literal(this.#o);return this.#s(),r}#m(r=""){let e=this.#r.literal(parseInt(`${r}${this.#o}`,10));return this.#s(),e}#w(r=""){let e=this.#r.literal(parseFloat(`${r}${this.#o}`));return this.#s(),e}};var{hasOwn:Fa,fromEntries:Nc}=Object,Hc={"+":(s,r)=>s+r,"-":(s,r)=>s-r,"*":(s,r)=>s*r,"/":(s,r)=>s/r,"%":(s,r)=>s%r,"==":(s,r)=>s==r,"!=":(s,r)=>s!=r,"===":(s,r)=>s===r,"!==":(s,r)=>s!==r,">":(s,r)=>s>r,">=":(s,r)=>s>=r,"<":(s,r)=>s<r,"<=":(s,r)=>s<=r,"||":(s,r)=>s||r,"&&":(s,r)=>s&&r,"??":(s,r)=>s??r,"|":(s,r)=>r(s),"|>":(s,r)=>r(s)},Fc={"+":s=>s,"-":s=>-s,"!":s=>!s},ao=class{empty(){return{type:"Empty",evaluate(r){return r},getIds(r){return r}}}literal(r){return{type:"Literal",value:r,evaluate(e){return this.value},getIds(e){return e}}}id(r){return{type:"ID",value:r,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(r,e){let t=Fc[r];return{type:"Unary",operator:r,child:e,evaluate(i){return t(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(r,e,t){let i=Hc[e];return{type:"Binary",operator:e,left:r,right:t,evaluate(o){if(this.operator==="="){if(this.left.type!=="ID"&&this.left.type!=="Getter"&&this.left.type!=="Index")throw new Error(`Invalid assignment target: ${this.left}`);let n=this.right.evaluate(o),a,l;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(o),l=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(o),l=this.left.argument.evaluate(o)):this.left.type==="ID"&&(a=o,l=this.left.value),a===void 0?void 0:a[l]=n}return i(this.left.evaluate(o),this.right.evaluate(o))},getIds(o){return this.left.getIds(o),this.right.getIds(o),o}}}getter(r,e){return{type:"Getter",receiver:r,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(r,e,t){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:r,method:e,arguments:t,evaluate(i){let o=this.receiver.evaluate(i),n=this.method?o:i?.this??i,a=this.method?o?.[e]:o,c=(this.arguments??[]).map(p=>p?.evaluate(i));return a?.apply?.(n,c)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(o=>o?.getIds(i)),i}}}paren(r){return r}index(r,e){return{type:"Index",receiver:r,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(r,e,t){return{type:"Ternary",condition:r,trueExpr:e,falseExpr:t,evaluate(i){return this.condition.evaluate(i)?this.trueExpr.evaluate(i):this.falseExpr.evaluate(i)},getIds(i){return this.condition.getIds(i),this.trueExpr.getIds(i),this.falseExpr.getIds(i),i}}}map(r){return{type:"Map",entries:r,evaluate(e){let t={};if(r&&this.entries)for(let i in r){let o=this.entries[i];o&&(t[i]=o.evaluate(e))}return t},getIds(e){if(r&&this.entries)for(let t in r){let i=this.entries[t];i&&i.getIds(e)}return e}}}list(r){return{type:"List",items:r,evaluate(e){return this.items?.map(t=>t?.evaluate(e))},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(r,e){return{type:"ArrowFunction",params:r,body:e,evaluate(t){let i=this.params,o=this.body;return function(...n){let a=Nc(i.map((c,p)=>[c,n[p]])),l=new Proxy(t??{},{set(c,p,h){return Fa(a,p)&&(a[p]=h),c[p]=h},get(c,p){return Fa(a,p)?a[p]:c[p]}});return o.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var Ms=null,Ba={boundAttributeSuffix:Y.M,marker:Y.P,markerMatch:Y.A,HTML_RESULT:Y.C,getTemplateHtml:Y.L,overrideDirectiveResolve:(s,r)=>class extends s{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(s,r)=>{if(s.prototype._$AS.name!==r.name){Ms??=s.prototype._$AS.name;for(let e=s.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Ms))return void(e[Ms]=r);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(s,r){s._$litDirective$=r},getAttributePartCommittedValue:(s,r,e)=>{let t=X;return s.j=i=>t=i,s._$AI(r,s,e),t},connectedDisconnectable:s=>({...s,_$AU:!0}),resolveDirective:Y.V,AttributePart:Y.H,PropertyPart:Y.B,BooleanAttributePart:Y.N,EventPart:Y.U,ElementPart:Y.F,TemplateInstance:Y.R,isIterable:Y.D,ChildPart:Y.I};var{AttributePart:Bc,PropertyPart:Uc,BooleanAttributePart:zc,EventPart:jc}=Ba,_s=new ao,Rs=new Map,Ua=s=>s.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),lo=(s,r)=>{let e=Rs.get(s);if(e===void 0){if(Rs.has(s))return;if(s=s.trim(),s.startsWith("{{")&&s.endsWith("}}")){let t=s.substring(2,s.length-2).trim();e=new ii(t,_s).parse(),Rs.set(s,e)}}return e?.evaluate(r)},Wc=(s,r,e,t)=>{let i=s.getAttribute("if");if(i!==null&&lo(i,r))return co(s,r,e,t)},za=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,ja=s=>/(?:\\{{)|(?:\\}})/g.test(s),oi=s=>s.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Gc=(s,r,e,t)=>{let i=s.getAttribute("repeat");if(i!==null){let o=lo(i,r);if(!o[Symbol.iterator])return N;let n=si(s),a=-1,l=[];for(let c of o){a++;let p=Object.create(r);p.item=c,p.index=a,p.this=r.this??r;let h=[];for(let y of n.parts){let v=y.update(p,e,t);y.type===1?h.push(...v):h.push(v)}let m={_$litType$:n,values:h};l.push(m)}return l}},Ga={if:Wc,repeat:Gc},De=(s,r=Ga,e={},t)=>{let o=si(s).renderers;if(t){let a=si(t).renderers,l=o.super;l!==void 0?e={...o,...e,super:(c,p,h)=>(h={...a,...h,super:(m,y,v)=>co(t,m,y,v)},l(c,p,h))}:(e={...a,...o,...e},s=t)}else e={...o,...e};return n=>co(s,n,r,e)};var co=(s,r,e=Ga,t={})=>{let i=si(s),o=[];for(let a of i.parts){let l=a.update(r,e,t);a.type===1?o.push(...l):o.push(l)}return{_$litType$:i,values:o}},Wa=new Map,si=s=>{let r=Wa.get(s);return r===void 0&&Wa.set(s,r=Xc(s)),r},Xc=s=>{let r={h:void 0,el:s.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(r.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),t=e.currentNode,i=-1,o=[];for(;(t=e.nextNode())!==null;)if(t.nodeType===Node.COMMENT_NODE)i++;else if(t.nodeType===Node.ELEMENT_NODE){i++;let n=t;if(n.tagName==="TEMPLATE"){let l=n.getAttribute("type"),c=n.getAttribute("name"),p=n.getAttribute("call");if(p!==null||l!==null||c!==null){n.parentNode.insertBefore(document.createComment(""),n),o.push(n);let h;if(p!==null){let m=p.trim(),y=m.startsWith("{{")&&m.endsWith("}}");h=(v,w,f)=>{let u=n.getAttribute("data"),g=u===null?void 0:lo(u,v);return(y?lo(m,v):f[p])?.(g,w,f)}}else l!==null?h=(m,y,v)=>{let w=y[l];return w?.(n,m,y,v)}:(c==="super"?r.renderers.super=(m,y,v)=>{let w=v.super,f=si(n);return v={...v,...f.renderers},w(m,y,v)}:r.renderers[c]=(m,y,v)=>co(n,m,y,v),h=(m,y,v)=>{let w=v[c];return w?.(m,y,v)});r.parts.push({type:2,index:i,update:h});continue}}let a=n.getAttributeNames();for(let l of a){let c=n.getAttribute(l),p=c.split(za);if(p.length===1){ja(c)&&n.setAttribute(l,oi(c));continue}n.removeAttribute(l);let h=l,m=Bc,y=l[0];y==="."?(h=Ua(l.substring(1)),m=Uc):y==="?"?(h=l.substring(1),m=zc):y==="@"&&(h=Ua(l.substring(1)),m=jc);let v=[oi(p[0])],w=[];for(let f=1;f<p.length;f+=2){let u=p[f];w.push(ks(u,_s)),v.push(oi(p[f+1]))}r.parts.push({type:1,index:i,name:h,strings:v,ctor:m,update:(f,u,g)=>w.map(q=>q.evaluate(f))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(za);l.length>1?n.textContent=oi(l[0]):ja(a)&&(n.textContent=oi(a));for(let c=1;c<l.length;c+=2){let p=l[c],h=ks(p,_s);r.parts.push({type:2,index:++i,update:(y,v)=>h.evaluate(y)});let m=new Text(l[c+1].replace("\\{{","{{"));n.parentNode.insertBefore(m,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=m,e.currentNode=m}}for(let n of o)n.remove();return r};var ai,ni=class extends C{constructor(){super();_(this,ai);B(this,ai,this.attachInternals()),I(this,ai).ariaLabel="pagination"}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");this.myTemplate=De(e)}render(){if(!this.computedContext)return x``;let e=this.computedContext.testParts.flatMap(t=>t.sections.flatMap(i=>i.items));return x` ${e.map(t=>this.myTemplate({item:t,view:this.computedContext.view}))} `}};ai=new WeakMap,d([P({context:W,subscribe:!0})],ni.prototype,"computedContext",2),ni=d([k("test-paging-buttons-stamp")],ni);var po=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},uo=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise((r=>this.Z=r))}resume(){this.Z?.(),this.Y=this.Z=void 0}};var Xa=s=>!ia(s)&&typeof s.then=="function",Qa=1073741823,Ls=class extends it{constructor(){super(...arguments),this._$Cwt=Qa,this._$Cbt=[],this._$CK=new po(this),this._$CX=new uo}render(...r){return r.find((e=>!Xa(e)))??X}update(r,e){let t=this._$Cbt,i=t.length;this._$Cbt=e;let o=this._$CK,n=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let l=e[a];if(!Xa(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Qa,i=0,Promise.resolve(l).then((async c=>{for(;n.get();)await n.get();let p=o.deref();if(p!==void 0){let h=p._$Cbt.indexOf(l);h>-1&&h<p._$Cwt&&(p._$Cwt=h,p.setValue(c))}})))}return X}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},mo=ae(Ls);var ho=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
|
|
215
215
|
|
|
216
216
|
/* https://www.imsglobal.org/sites/default/files/spec/qti/v3/guide/img/qti3p0.css */
|
|
217
217
|
|
|
@@ -2469,6 +2469,9 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
2469
2469
|
border-color: var(--qti-border-color);
|
|
2470
2470
|
outline: 4px solid var(--qti-disabled-bg)
|
|
2471
2471
|
}
|
|
2472
|
+
&:not(:empty) {
|
|
2473
|
+
border-color: var(--qti-border) !important;
|
|
2474
|
+
}
|
|
2472
2475
|
&:empty::after {
|
|
2473
2476
|
padding: var(--qti-padding-md) var(--qti-padding-lg);
|
|
2474
2477
|
content: '\\0000a0';
|
|
@@ -2483,6 +2486,14 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
2483
2486
|
box-shadow: 0 0 0 1px #e5e7eb;
|
|
2484
2487
|
}
|
|
2485
2488
|
}
|
|
2489
|
+
&.qti-selections-light qti-associable-hotspot:not(:empty) {
|
|
2490
|
+
background-color: var(--qti-light-bg-active) !important;
|
|
2491
|
+
border-color: var(--qti-light-border-active) !important;
|
|
2492
|
+
}
|
|
2493
|
+
&.qti-selections-dark qti-associable-hotspot:not(:empty) {
|
|
2494
|
+
background-color: var(--qti-dark-bg-active) !important;
|
|
2495
|
+
border-color: var(--qti-dark-border-active) !important;
|
|
2496
|
+
}
|
|
2486
2497
|
& img {
|
|
2487
2498
|
margin: 0;
|
|
2488
2499
|
padding: 0;
|
|
@@ -2637,6 +2648,7 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
2637
2648
|
}
|
|
2638
2649
|
display: inline-flex;
|
|
2639
2650
|
align-items: center;
|
|
2651
|
+
vertical-align: middle;
|
|
2640
2652
|
&:empty::after {
|
|
2641
2653
|
padding: var(--qti-padding-md) var(--qti-padding-lg);
|
|
2642
2654
|
content: '\\0000a0';
|
|
@@ -3772,11 +3784,11 @@ div.full-correct-response-inline {
|
|
|
3772
3784
|
margin-right: var(--qti-padding-horizontal);
|
|
3773
3785
|
padding: 0.2rem;
|
|
3774
3786
|
}
|
|
3775
|
-
`;var
|
|
3776
|
-
${
|
|
3787
|
+
`;var li,or,Ja,Ya,je=class extends C{constructor(){super(...arguments);_(this,or);this.testURL=null;this.testDoc=null;this.testXML=null;_(this,li,null)}async handleTestURLChange(){if(this.testURL)try{let e=await jt().load(this.testURL),t=this.closest("qti-test");if(t?.postLoadTestTransformCallback){let o=e.htmlDoc().querySelector("qti-assessment-test");o&&(e=await t.postLoadTestTransformCallback(e,o))}this.testDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleTestXMLChange(){if(this.testXML)try{this.testDoc=jt().parse(this.testXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),D(this,or,Ja).call(this),D(this,or,Ya).call(this),this.testURL&&this.handleTestURLChange(),this.testXML&&this.handleTestXMLChange()}render(){return x`
|
|
3788
|
+
${I(this,li)}
|
|
3777
3789
|
<slot></slot>
|
|
3778
|
-
${
|
|
3779
|
-
`}};
|
|
3790
|
+
${mo(this.testDoc,x`<span>Loading...</span>`)}
|
|
3791
|
+
`}};li=new WeakMap,or=new WeakSet,Ja=function(){let e=this.querySelector("template");B(this,li,e?e.content:x``)},Ya=function(){let e=new CSSStyleSheet;e.replaceSync(ho),this.shadowRoot.adoptedStyleSheets=[e]},d([b({type:String,attribute:"test-url"})],je.prototype,"testURL",2),d([R()],je.prototype,"testDoc",2),d([R()],je.prototype,"testXML",2),d([U("testURL",{waitUntilFirstUpdate:!0})],je.prototype,"handleTestURLChange",1),d([U("testXML",{waitUntilFirstUpdate:!0})],je.prototype,"handleTestXMLChange",1),je=d([k("test-container")],je);var sr=class extends C{render(){let r=this.computedContext?.testParts.flatMap(o=>o.sections.flatMap(n=>n.items)).find(o=>o.active);if(!r||!r.variables)return x``;let e=r.variables.filter(o=>o.type==="response"),t=r.variables.filter(o=>o.type==="outcome"),i=(o,n)=>x`
|
|
3780
3792
|
<h3>${n}</h3>
|
|
3781
3793
|
<table>
|
|
3782
3794
|
<thead>
|
|
@@ -3789,20 +3801,20 @@ div.full-correct-response-inline {
|
|
|
3789
3801
|
</tr>
|
|
3790
3802
|
</thead>
|
|
3791
3803
|
<tbody>
|
|
3792
|
-
${
|
|
3804
|
+
${o.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",c=a.mapping?.mapEntries?.map(h=>`${h.mapKey}=${h.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(h=>`${h.shape}(${h.coords})=${h.mappedValue}pt`).join(", ")||"";return x`
|
|
3793
3805
|
<tr>
|
|
3794
3806
|
<td>${a.identifier}</td>
|
|
3795
3807
|
<td>${Array.isArray(a.value)?a.value.join(", "):a.value}</td>
|
|
3796
3808
|
<td>${a.cardinality}</td>
|
|
3797
3809
|
<td>${a.baseType}</td>
|
|
3798
|
-
<td>${l||
|
|
3810
|
+
<td>${l||c||p}</td>
|
|
3799
3811
|
</tr>
|
|
3800
3812
|
`})}
|
|
3801
3813
|
</tbody>
|
|
3802
3814
|
</table>
|
|
3803
|
-
`;return
|
|
3815
|
+
`;return x`
|
|
3804
3816
|
${i(e,"Response Variables")} ${i(t,"Outcome Variables")}
|
|
3805
|
-
`}};
|
|
3817
|
+
`}};sr.styles=S`
|
|
3806
3818
|
table {
|
|
3807
3819
|
width: 100%;
|
|
3808
3820
|
border-collapse: collapse;
|
|
@@ -3823,67 +3835,67 @@ div.full-correct-response-inline {
|
|
|
3823
3835
|
margin-top: 20px;
|
|
3824
3836
|
font-size: 16px;
|
|
3825
3837
|
}
|
|
3826
|
-
`,
|
|
3838
|
+
`,d([P({context:W,subscribe:!0})],sr.prototype,"computedContext",2),sr=d([k("test-print-item-variables")],sr);var di,ci=class extends C{constructor(){super();_(this,di);B(this,di,this.attachInternals()),I(this,di).ariaLabel="pagination"}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");this.myTemplate=De(e)}render(){if(!this.computedContext)return x``;let e=this.computedContext.testParts.flatMap(t=>t.sections);return x` ${e.map(t=>this.myTemplate({item:t}))} `}};di=new WeakMap,d([P({context:W,subscribe:!0})],ci.prototype,"computedContext",2),ci=d([k("test-section-buttons-stamp")],ci);var fo,Ka,nr=class extends C{constructor(){super();_(this,fo);this.sectionId=null;this.addEventListener("click",()=>D(this,fo,Ka).call(this,this.sectionId))}render(){return x` <slot></slot> `}};fo=new WeakSet,Ka=function(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"section",id:e}}))},nr.styles=S`
|
|
3827
3839
|
:host {
|
|
3828
|
-
${
|
|
3840
|
+
${te};
|
|
3829
3841
|
}
|
|
3830
3842
|
:host([disabled]) {
|
|
3831
|
-
${
|
|
3843
|
+
${re};
|
|
3832
3844
|
}
|
|
3833
|
-
`,
|
|
3834
|
-
${this.myTemplate?this.myTemplate(this.stampContext):
|
|
3845
|
+
`,d([b({type:String,attribute:"section-id"})],nr.prototype,"sectionId",2),nr=d([k("test-section-link")],nr);var pi=class extends C{render(){return x` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};d([R(),P({context:W,subscribe:!0})],pi.prototype,"computedContext",2),pi=d([k("test-print-context")],pi);var _t=class extends C{constructor(){super(...arguments);this.debug=!1;this.stampContext={view:"candidate",activeItem:{},activeSection:{items:[]},activeTestpart:{items:[],sections:[]},test:{}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=De(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(m=>m.active),i=t?.sections.find(m=>m.active),o=i?.items.find(m=>m.active),{variables:n,...a}=o||{};if(!t||!i||!o)return;let l={...t,items:t.sections.flatMap(m=>m.items.map(({variables:y,...v})=>v)),sections:t.sections.map(m=>({...m,items:m.items.map(({variables:y,...v})=>v)}))},c={...i,items:i.items.map(({variables:m,...y})=>y)},{testParts:p,...h}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:a,activeSection:c,activeTestpart:l,test:h},this.dispatchEvent(new CustomEvent("qti-stamp-context-updated",{detail:this.stampContext,bubbles:!0}))}render(){return x` ${this.debug?x`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:N}
|
|
3846
|
+
${this.myTemplate?this.myTemplate(this.stampContext):N}`}};d([b({type:Boolean,reflect:!0})],_t.prototype,"debug",2),d([R(),P({context:W,subscribe:!0})],_t.prototype,"computedContext",2),d([R()],_t.prototype,"stampContext",2),_t=d([k("test-stamp")],_t);var go,Za,Lt=class extends C{constructor(){super();_(this,go);this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&D(this,go,Za).call(this,i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=De(e)}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(c=>c.items)).find(l=>l.active);if(!e||!e.variables)return x``;let t=e.variables.find(l=>l.identifier=="MAXSCORE")?.value,i=e.variables.find(l=>l.identifier=="SCORE"),o=i?.value,n=i?.externalScored!=="human";if(!t||!i)return N;let a=[...Array(Number(t)+1).keys()];return x`${this.myTemplate?this.myTemplate({scores:a,score:o,disabled:n}):N}`}};go=new WeakSet,Za=function(e){let o=(this.computedContext?.testParts.find(n=>n.active)).sections.flatMap(n=>n.items).find(n=>n.active)?.identifier;this.dispatchEvent(new CustomEvent("test-update-outcome-variable",{detail:{assessmentItemRefId:o,outcomeVariableId:"SCORE",value:e},bubbles:!0}))},d([b({type:String,attribute:"view"})],Lt.prototype,"view",2),d([b({type:Boolean})],Lt.prototype,"disabled",2),d([P({context:W,subscribe:!0})],Lt.prototype,"computedContext",2),Lt=d([k("test-scoring-buttons")],Lt);var ui=class extends C{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=De(r)}_switchView(r){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:r}))}firstUpdated(r){this.addEventListener("click",()=>{this.sessionContext?.view==="scorer"?this._switchView("candidate"):this._switchView("scorer")})}render(){return x`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):N}`}};d([P({context:et,subscribe:!0})],ui.prototype,"sessionContext",2),ui=d([k("test-view-toggle")],ui);var ar=class extends C{constructor(){super(...arguments);this.view=null}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(c=>c.items)).find(l=>l.active);if(!e||!e.variables)return x``;if(e.category==="dep-informational")return x`<div>${this.dataset.informational}</div>`;let t=e?.variables.find(l=>l.identifier==="completionStatus")?.value,i=e?.variables.find(l=>l.identifier=="SCORE"),o=parseFloat(i?.value),n=e.externalScored;return x`<div>${t!=="completed"?this.dataset.textNoResponse:!n&&o!==void 0&&!Number.isNaN(o)?o>0?this.dataset.textCorrect:this.dataset.textIncorrect:n==="externalMachine"?Number.isNaN(o)||o===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${o===0?"geen punten":o==1?"\xE9\xE9n punt":`${o} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:n==="human"?Number.isNaN(o)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};d([P({context:W,subscribe:!0})],ar.prototype,"computedContext",2),d([b({type:String,attribute:"view"})],ar.prototype,"view",2),ar=d([k("test-scoring-feedback")],ar);var mi=class extends C{constructor(){super(),this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})),this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:!0,bubbles:!0}));let e=this.closest("qti-test").querySelector("test-container");Array.from(e.shadowRoot.querySelectorAll("[view]")).forEach(i=>{i.classList.toggle("show",!0)})})}render(){return x` <slot></slot> `}};mi.styles=S`
|
|
3835
3847
|
:host {
|
|
3836
|
-
${
|
|
3848
|
+
${te};
|
|
3837
3849
|
}
|
|
3838
3850
|
:host([disabled]) {
|
|
3839
|
-
${
|
|
3851
|
+
${re};
|
|
3840
3852
|
}
|
|
3841
|
-
`,
|
|
3842
|
-
${
|
|
3853
|
+
`,mi=d([k("test-check-item")],mi);var hi,lr,el,tl,We=class extends C{constructor(){super(...arguments);_(this,lr);this.itemURL=null;this.itemDoc=null;this.itemXML=null;_(this,hi,null)}async handleItemURLChange(){if(this.itemURL)try{let e=await Ae().load(this.itemURL);this.itemDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=Ae().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),D(this,lr,el).call(this),D(this,lr,tl).call(this),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}render(){return x`
|
|
3854
|
+
${I(this,hi)}
|
|
3843
3855
|
<slot></slot>
|
|
3844
|
-
${
|
|
3845
|
-
`}};
|
|
3856
|
+
${mo(this.itemDoc,x`<span>Loading...</span>`)}
|
|
3857
|
+
`}};hi=new WeakMap,lr=new WeakSet,el=function(){let e=this.querySelector("template");B(this,hi,e?e.content:x``)},tl=function(){let e=new CSSStyleSheet;e.replaceSync(ho),this.shadowRoot.adoptedStyleSheets=[e]},d([b({type:String,attribute:"item-url"})],We.prototype,"itemURL",2),d([R()],We.prototype,"itemDoc",2),d([R()],We.prototype,"itemXML",2),d([U("itemURL",{waitUntilFirstUpdate:!0})],We.prototype,"handleItemURLChange",1),d([U("itemXML",{waitUntilFirstUpdate:!0})],We.prototype,"handleItemXMLChange",1),We=d([k("item-container")],We);var bo,rl,Pt=class extends C{constructor(){super(...arguments);_(this,bo);this.label="Correct response mode";this._options={internal:"Internal",full:"Full (copy)"}}render(){return x`
|
|
3846
3858
|
<label part="label" for="modeSelect">${this.label}</label>
|
|
3847
3859
|
<select
|
|
3848
3860
|
part="select"
|
|
3849
3861
|
id="modeSelect"
|
|
3850
|
-
@change=${e=>{let t=e.target;
|
|
3862
|
+
@change=${e=>{let t=e.target;D(this,bo,rl).call(this,t.value)}}
|
|
3851
3863
|
>
|
|
3852
|
-
${Object.keys(this._options).map(e=>
|
|
3864
|
+
${Object.keys(this._options).map(e=>x`<option value="${e}" ?selected=${e===this.itemContext?.correctResponseMode}>
|
|
3853
3865
|
${this._options[e]}
|
|
3854
3866
|
</option>`)}
|
|
3855
3867
|
</select>
|
|
3856
|
-
`}};
|
|
3868
|
+
`}};bo=new WeakSet,rl=function(e){this.dispatchEvent(new CustomEvent("item-switch-correct-response-mode",{detail:e,bubbles:!0}))},d([P({context:he,subscribe:!0})],Pt.prototype,"itemContext",2),d([b({type:String})],Pt.prototype,"label",2),d([R()],Pt.prototype,"_options",2),Pt=d([k("item-correct-response-mode")],Pt);var il=S`
|
|
3857
3869
|
display: inline-flex;
|
|
3858
3870
|
align-items: center;
|
|
3859
3871
|
cursor: pointer;
|
|
3860
3872
|
padding: 0.5rem 1rem;
|
|
3861
3873
|
border-radius: 0.25rem;
|
|
3862
3874
|
user-select: none;
|
|
3863
|
-
`,
|
|
3875
|
+
`,vo=S`
|
|
3864
3876
|
background-color: lightgray;
|
|
3865
|
-
${
|
|
3866
|
-
`,
|
|
3877
|
+
${il};
|
|
3878
|
+
`,yo=S`
|
|
3867
3879
|
cursor: not-allowed;
|
|
3868
3880
|
opacity: 0.8;
|
|
3869
|
-
`,
|
|
3870
|
-
${
|
|
3881
|
+
`,fx=S`
|
|
3882
|
+
${il};
|
|
3871
3883
|
border: 1px solid gray;
|
|
3872
|
-
`;var
|
|
3884
|
+
`;var cr,fi,dr,sl,nl,xe=class extends C{constructor(){super();_(this,dr);this.shown=!1;this.disabled=!1;this.showCandidateCorrectionText="Show candidate correction";this.hideCandidateCorrectionText="Hide candidate correction";this.noCorrectResponseText="No correct response specified";_(this,cr,!1);_(this,fi,"")}updated(){if(!I(this,cr)||I(this,fi)!==this.computedContext?.identifier){B(this,fi,this.computedContext?.identifier);let e=!!this.computedContext?.variables.some(i=>i.correctResponse),t=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);B(this,cr,e||t)}this.disabled=!I(this,cr)}render(){return x` <div @click="${D(this,dr,sl)}">${D(this,dr,nl).call(this)}</div> `}};cr=new WeakMap,fi=new WeakMap,dr=new WeakSet,sl=function(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-candidate-correction",{detail:!this.shown,bubbles:!0}))},nl=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCandidateCorrectionText:this.showCandidateCorrectionText},xe.styles=S`
|
|
3873
3885
|
:host {
|
|
3874
|
-
${
|
|
3886
|
+
${vo};
|
|
3875
3887
|
}
|
|
3876
3888
|
:host([disabled]) {
|
|
3877
|
-
${
|
|
3889
|
+
${yo};
|
|
3878
3890
|
}
|
|
3879
|
-
`,
|
|
3891
|
+
`,d([P({context:Ze,subscribe:!0})],xe.prototype,"computedContext",2),d([b({type:Boolean,reflect:!0})],xe.prototype,"shown",2),d([b({type:Boolean,reflect:!0})],xe.prototype,"disabled",2),d([b({type:String})],xe.prototype,"showCandidateCorrectionText",2),d([b({type:String})],xe.prototype,"hideCandidateCorrectionText",2),d([b({type:String})],xe.prototype,"noCorrectResponseText",2),xe=d([k("item-show-candidate-correction")],xe);var pr,gi,ur,al,ll,qe=class extends C{constructor(){super(...arguments);_(this,ur);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";_(this,pr,!1);_(this,gi,"")}updated(){if(!I(this,pr)||I(this,gi)!==this.computedContext?.identifier){B(this,gi,this.computedContext?.identifier);let e=!!this.computedContext?.variables.some(i=>i.correctResponse),t=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);B(this,pr,e||t)}this.disabled=!I(this,pr)}render(){return x` <div @click="${D(this,ur,al)}">${D(this,ur,ll).call(this)}</div> `}};pr=new WeakMap,gi=new WeakMap,ur=new WeakSet,al=function(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-correct-response",{detail:!this.shown,bubbles:!0}))},ll=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText},qe.styles=S`
|
|
3880
3892
|
:host {
|
|
3881
|
-
${
|
|
3893
|
+
${vo};
|
|
3882
3894
|
}
|
|
3883
3895
|
:host([disabled]) {
|
|
3884
|
-
${
|
|
3896
|
+
${yo};
|
|
3885
3897
|
}
|
|
3886
|
-
`,
|
|
3898
|
+
`,d([P({context:Ze,subscribe:!0})],qe.prototype,"computedContext",2),d([b({type:Boolean,reflect:!0})],qe.prototype,"shown",2),d([b({type:Boolean,reflect:!0})],qe.prototype,"disabled",2),d([b({type:String})],qe.prototype,"showCorrectText",2),d([b({type:String})],qe.prototype,"hideCorrectText",2),d([b({type:String})],qe.prototype,"noCorrectResponseText",2),qe=d([k("item-show-correct-response")],qe);var mr=class extends C{render(){let r=this.computedContext;if(!r||!r.variables)return x``;let e=r.variables.filter(o=>o.type==="response"),t=r.variables.filter(o=>o.type==="outcome"),i=(o,n)=>x`
|
|
3887
3899
|
<h3>${n}</h3>
|
|
3888
3900
|
<table>
|
|
3889
3901
|
<thead>
|
|
@@ -3896,20 +3908,20 @@ div.full-correct-response-inline {
|
|
|
3896
3908
|
</tr>
|
|
3897
3909
|
</thead>
|
|
3898
3910
|
<tbody>
|
|
3899
|
-
${
|
|
3911
|
+
${o.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",c=a.mapping?.mapEntries?.map(h=>`${h.mapKey}=${h.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(h=>`${h.shape}(${h.coords})=${h.mappedValue}pt`).join(", ")||"";return x`
|
|
3900
3912
|
<tr>
|
|
3901
3913
|
<td>${a.identifier}</td>
|
|
3902
3914
|
<td>${Array.isArray(a.value)?a.value.join(", "):a.value}</td>
|
|
3903
3915
|
<td>${a.cardinality}</td>
|
|
3904
3916
|
<td>${a.baseType}</td>
|
|
3905
|
-
<td>${l||
|
|
3917
|
+
<td>${l||c||p}</td>
|
|
3906
3918
|
</tr>
|
|
3907
3919
|
`})}
|
|
3908
3920
|
</tbody>
|
|
3909
3921
|
</table>
|
|
3910
|
-
`;return
|
|
3922
|
+
`;return x`
|
|
3911
3923
|
${i(e,"Response Variables")} ${i(t,"Outcome Variables")}
|
|
3912
|
-
`}};
|
|
3924
|
+
`}};mr.styles=S`
|
|
3913
3925
|
table {
|
|
3914
3926
|
width: 100%;
|
|
3915
3927
|
border-collapse: collapse;
|
|
@@ -3930,7 +3942,85 @@ div.full-correct-response-inline {
|
|
|
3930
3942
|
margin-top: 20px;
|
|
3931
3943
|
font-size: 16px;
|
|
3932
3944
|
}
|
|
3933
|
-
`,c([k({context:Be,subscribe:!0})],Kt.prototype,"computedContext",2),Kt=c([C("item-print-variables")],Kt);var K,ti,ri,rs,is,ss,G,La,$a,lo,Oa,Pa,co,Zt=class extends b{constructor(){super();T(this,G);T(this,K);this.configContext={};T(this,ti,I(this,G,La).bind(this));T(this,ri,I(this,G,$a).bind(this));T(this,rs,I(this,G,lo).bind(this));T(this,is,I(this,G,Oa).bind(this));T(this,ss,I(this,G,Pa).bind(this));this.addEventListener("qti-item-context-updated",x(this,ti)),this.addEventListener("qti-assessment-item-connected",x(this,ri)),this.addEventListener("item-show-correct-response",x(this,rs)),this.addEventListener("item-show-candidate-correction",x(this,is)),this.addEventListener("item-switch-correct-response-mode",x(this,ss))}render(){return f`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",x(this,ti)),this.removeEventListener("qti-assessment-item-connected",x(this,ri))}};K=new WeakMap,ti=new WeakMap,ri=new WeakMap,rs=new WeakMap,is=new WeakMap,ss=new WeakMap,G=new WeakSet,La=function(e){I(this,G,co).call(this,e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])},$a=function(e){let t=e.detail._context.variables;$(this,K,e.detail),this.computedContext=this.computedContext?.identifier===x(this,K).identifier?{...this.computedContext,title:x(this,K).title}:{identifier:x(this,K).identifier,title:x(this,K).title,adaptive:x(this,K).getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},I(this,G,co).call(this,x(this,K).identifier,t||[])},lo=function(e){x(this,K)&&x(this,K).showCorrectResponse(e.detail)},Oa=function(e){x(this,K)&&x(this,K).showCandidateCorrection(e.detail)},Pa=function(e){I(this,G,lo).call(this,new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}},co=function(e,t){let i=t?.find(p=>p.identifier=="SCORE")?.value,s=parseFloat(i?.toString()),n=t?.find(p=>p.identifier==="completionStatus")?.value,a=s!==void 0&&!isNaN(s)&&s>0,l=s!==void 0&&!isNaN(s)&&s<=0,d=n==="completed";this.computedContext={...this.computedContext,identifier:e,correct:a,incorrect:l,completed:d,variables:t}},c([w(),ee({context:Be})],Zt.prototype,"computedContext",2),c([w(),ee({context:le})],Zt.prototype,"configContext",2),Zt=c([C("qti-item")],Zt);var Va=(o,r,e)=>{class t extends o{}return t};var Se=(o,r,e,t)=>{class i extends Va(o,e,r){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.dragMoveRaf=0;this.pendingMove=null;this.dragBounds=null;this.dragCloneRect=null;this.dropzoneRects=new Map;this.dropzoneRectsDirty=!1;this.dragBoundsDirty=!1;this.dragCloneStyleCache=new WeakMap;this.onScrollOrResize=()=>{this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0,this.dragBoundsDirty=!0};this.onMove=this.handleTouchMove.bind(this);this.onEnd=this.handleTouchEnd.bind(this);this.onCancel=this.handleTouchCancel.bind(this);this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.MAX_DRAGGABLE_WIDTH=600;this.dataTransfer={data:{},setData(a,l){this.data[a]=l},getData(a){return this.data[a]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=0;this.draggablesModified=(a,l)=>{if(this.isMatchTabular())return;for(let p of l)this.draggables.includes(p)&&(this.draggables=this.draggables.filter(m=>m!==p),p.removeAttribute("tabindex"),p.removeEventListener("touchstart",this.handleTouchStart.bind(this)),p.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let p of a)this.draggables.includes(p)||(this.draggables.push(p),p.setAttribute("tabindex","0"),p.hasTouchStartListener||(p.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),p.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),p.hasTouchStartListener=!0));let d=0;this.draggables.forEach(p=>{p.style.viewTransitionName=`drag-${d}-${this.getAttribute("identifier")||crypto.randomUUID()}`,p.setAttribute("qti-draggable","true"),d++})};this.droppablesModified=(a,l)=>{if(!this.isMatchTabular()){for(let d of l)this.droppables.includes(d)&&(this.droppables=this.droppables.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.droppables.includes(d)||(this.droppables.push(d),this.allDropzones.push(d));for(let d of this.droppables)this.dataset.choicesContainerWidth&&(d.style.width=`${this.dataset.choicesContainerWidth}px`,d.style.boxSizing="border-box");this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0}}}handleDraggableContainerChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.dragContainersModified(a||[],l||[])}dragContainersModified(a,l){for(let d of l)this.dragContainers.includes(d)&&(this.dragContainers=this.dragContainers.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.dragContainers.includes(d)||(this.dragContainers.push(d),this.allDropzones.push(d));this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0}handleDraggablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.draggablesModified(a||[],l||[])}handleDroppablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.droppablesModified(a||[],l||[])}firstUpdated(){if(super.firstUpdated(),this.isMatchTabular())return;this.hasAttribute("disabled")||(document.addEventListener("mousemove",this.onMove,{passive:!1}),document.addEventListener("mouseup",this.onEnd,{passive:!1}),document.addEventListener("touchmove",this.onMove,{passive:!1}),document.addEventListener("touchend",this.onEnd,{passive:!1}),document.addEventListener("touchcancel",this.onCancel,{passive:!1}));let l=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),p=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(p,[]),this.droppablesModified(d,[]),this.draggablesModified(l,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(h=>this.resizeObserver?.observe(h))}async moveDraggableToDroppable(a,l){if(this.isMatchTabular())return;a.style.transform="translate(0, 0)",l.tagName==="SLOT"?a.setAttribute("slot",l.getAttribute("name")):l.appendChild(a),this.checkAllMaxAssociations(),this.saveResponse()}activateDroppable(a){this.dragContainers.includes(a)?(this._internals.states.add("--dragzone-active"),a.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),a.setAttribute("active",""))}deactivateDroppable(a,l=!0){l&&this._internals.states.add("--dragzone-active"),a.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}async updateMinDimensionsForDropZones(){if(await this.updateComplete,this.isMatchTabular())return;this.dropzoneRectsDirty=!0;let a=this.querySelectorAll(r),l=this.querySelector(t)||this.shadowRoot?.querySelector(t),d=this.querySelectorAll(e),p=d[0]?.parentElement,m=this.determineMaxWidth(l,p),h=0,g=0;for(let v of a){v.style.maxWidth=m+"px";let{width:E,height:A}=await this.measureIntrinsicSize(v);h=Math.max(h,A),g=Math.max(g,E)}p&&(p.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(min(${m}px,${g}px + 2 * var(--qti-dropzone-padding))), 1fr))`),l&&(l.style.minHeight=`${h}px`);for(let v of d){v.style.minHeight=`${h}px`,v.style.minWidth=`${g}px`;let E=v.shadowRoot?.querySelector('slot[part="dropslot"]');E&&(E.style.minHeight=`${h}px`)}}determineMaxWidth(a,l){let d=l??a;if(!d||d.clientWidth==0)return this.MAX_DRAGGABLE_WIDTH;let p=window.getComputedStyle(d),m=parseFloat(p.paddingLeft),h=parseFloat(p.paddingRight);return Math.min(this.MAX_DRAGGABLE_WIDTH,d.clientWidth-m-h)}async measureIntrinsicSize(a){let l=a.style.position;a.style.position="fixed";let d=a.getBoundingClientRect();return a.style.position=l,{width:d.width,height:d.height}}activateDroppables(a){if(this.isMatchTabular())return;this.dragContainers.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")}),this.droppables.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("mousemove",this.onMove),document.removeEventListener("mouseup",this.onEnd),document.removeEventListener("touchmove",this.onMove),document.removeEventListener("touchend",this.onEnd),document.removeEventListener("touchcancel",this.onCancel),window.removeEventListener("scroll",this.onScrollOrResize,!0),window.removeEventListener("resize",this.onScrollOrResize)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a);this.pendingMove={clientX:l,clientY:d},this.scheduleDragMove(),a.preventDefault()}}scheduleDragMove(){this.dragMoveRaf||(this.dragMoveRaf=requestAnimationFrame(()=>{if(this.dragMoveRaf=0,!this.pendingMove)return;let a=this.pendingMove;this.pendingMove=null,this.processDragMove(a),this.pendingMove&&this.scheduleDragMove()}))}processDragMove(a){if(!this.isDraggable||!this.dragClone||!this.touchStartPoint||(this.calculateDragDistance(a)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0),!this.isDragging))return;this.updateDragClonePosition(a),this.dropzoneRectsDirty&&this.refreshDropzoneRects();let l=this.findClosestDropzone();this.currentDropTarget=l,l!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),l&&(this.activateDroppable(l),this.dispatchCustomEvent(l,"dragenter")),this.lastTarget=l),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover")}handleTouchEnd(a){this.isMatchTabular()||((this.isDragging||this.isDraggable||this.dragClone)&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(l=>{l.removeAttribute("dragging")}),a.preventDefault())}handleTouchCancel(a){this.resetDragState()}validate(){if(this.isMatchTabular())return null;if(!this.shadowRoot)return!1;let a=this.getValidAssociations(),l=!0,d="";this.maxAssociations>0&&a>this.maxAssociations?(l=!1,d=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&a<this.minAssociations&&(l=!1,d=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let p=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},d,p),l}reportValidity(){let a=this.shadowRoot.querySelector("#validation-message");return a&&(this._internals.validity.valid?(a.textContent="",a.style.display="none"):(a.textContent=this._internals.validationMessage,a.style.setProperty("display","block","important"))),this._internals.validity.valid}checkMaxAssociations(a){let l=this.getMatchMaxValue(a),d=a.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&d>=l}dropDraggableInDroppable(a,l){let d=a.cloneNode(!0);d.removeAttribute("style"),this.moveDraggableToDroppable(d,l),this.draggablesModified([d],[]);let p=this.getMatchMaxValue(a),m=this.draggables.filter(h=>h.getAttribute("identifier")===a.getAttribute("identifier"));p!==0&&m.length>=p?(a.style.opacity="0.0",a.style.pointerEvents="none"):a.style.opacity="1.0"}resetDragState(){if(this.dragMoveRaf&&(cancelAnimationFrame(this.dragMoveRaf),this.dragMoveRaf=0),this.pendingMove=null,this.dragClone){let a=this.currentDropTarget!==null,l=!a||this.dragContainers.includes(this.currentDropTarget);a&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.dragBounds=null,this.dragCloneRect=null,this.dropzoneRects.clear(),this.dropzoneRectsDirty=!1,this.dragBoundsDirty=!1,window.removeEventListener("scroll",this.onScrollOrResize,!0),window.removeEventListener("resize",this.onScrollOrResize),this.deactivateDroppables()}checkAllMaxAssociations(){let a=this.getValidAssociations(),l=this.maxAssociations!==0&&a>=this.maxAssociations;this.droppables.forEach(d=>{l?this.disableDroppable(d):this.checkMaxAssociations(d)?this.disableDroppable(d):this.enableDroppable(d)})}getMatchMaxValue(a){let l=a.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(a){a.setAttribute("disabled","")}enableDroppable(a){a.removeAttribute("disabled")}get response(){let a;return typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),a.join(",")}set response(a){if(!this.isMatchTabular())if(typeof this.getValue=="function"&&(a=this.getValue(a)),Array.isArray(a)){this.reset(!1),a?.forEach(d=>this.placeResponse(d));let l=new FormData;a.forEach(d=>{l.append(this.responseIdentifier,d)}),this._internals.setFormValue(l)}else this._internals.setFormValue(a||"")}placeResponse(a){let[l,...d]=a.split(" ").reverse(),p=Array.from(this.draggables),m=Array.from(this.droppables);d.forEach(h=>{if(h==="")return;let g=p.find(E=>E.getAttribute("identifier")===h),v=m.find(E=>E.getAttribute("identifier")===l);this.dropDraggableInDroppable(g,v)})}getValidAssociations(){let a=0;for(let l of this.droppables)a=a+this.getDraggablesFromDroppable(l).length;return a}saveResponse(){let a;typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:a}}))}collectResponseData(){return this.droppables.map(l=>{let p=this.getDraggablesFromDroppable(l).map(h=>h.getAttribute("identifier")),m=l.getAttribute("identifier");return p.map(h=>`${h} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,h)=>h.indexOf(p)===m).flatMap(p=>Array.from(a.querySelectorAll(`[identifier='${p}']`))).filter(p=>!!p).map(p=>p)}reset(a=!0){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(p=>{p.remove(),this.draggablesModified([],[p])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(p=>{p.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,a&&this.saveResponse()}updateDragClonePosition(a){if(!this.isDragging||!this.dragClone)return;(this.dragBoundsDirty||!this.dragBounds)&&this.refreshDragBounds();let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`;let h=this.dragBounds?.width??this.dragCloneRect?.width,g=this.dragBounds?.height??this.dragCloneRect?.height;if(!h||!g){let v=this.dragClone.getBoundingClientRect();h=v.width,g=v.height}this.dragCloneRect={left:p,top:m,right:p+h,bottom:m+g,width:h,height:g}}applyInteractionBoundaries(a,l){if(!this.dragBounds)return{newLeft:a,newTop:l};let d=Math.max(this.dragBounds.minLeft,Math.min(a,this.dragBounds.maxLeft)),p=Math.max(this.dragBounds.minTop,Math.min(l,this.dragBounds.maxTop));return{newLeft:d,newTop:p}}refreshDragBounds(){if(!this.dragClone)return;let a=this.getBoundingClientRect(),l=this.dragClone.getBoundingClientRect();this.dragBounds={minLeft:a.left,maxLeft:a.right-l.width,minTop:a.top,maxTop:a.bottom-l.height,width:l.width,height:l.height},this.dragCloneRect={left:l.left,top:l.top,right:l.left+l.width,bottom:l.top+l.height,width:l.width,height:l.height},this.dragBoundsDirty=!1}getEventCoordinates(a,l=!1){let d=a.touches?a.touches[0]:a;return{x:l?d.pageX:d.clientX,y:l?d.pageY:d.clientY}}calculateDragDistance(a){let l=Math.abs(a.clientX-this.touchStartPoint.x),d=Math.abs(a.clientY-this.touchStartPoint.y);return l+d}refreshDropzoneRects(){this.dropzoneRects.clear();let a=this.allDropzones.filter(l=>!l.hasAttribute("disabled"));for(let l of a)this.dropzoneRects.set(l,this.getDropzoneRect(l));this.dropzoneRectsDirty=!1}getCachedDropzoneRect(a){let l=this.dropzoneRects.get(a);if(l)return l;let d=this.getDropzoneRect(a);return this.dropzoneRects.set(a,d),d}getDropzoneRect(a){return(a.shadowRoot?.querySelector('slot[part="dropslot"]')??a).getBoundingClientRect()}findClosestDropzone(){let a=this.allDropzones.filter(h=>!h.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let l=this.dragCloneRect??this.dragClone.getBoundingClientRect(),d=null,p=0,m=h=>{for(let g of h){let v=this.getCachedDropzoneRect(g),E=this.calculateOverlapArea(l,v);E>p&&(p=E,d=g)}};if(m(this.droppables.filter(h=>!h.hasAttribute("disabled"))),d||m(this.dragContainers.filter(h=>!h.hasAttribute("disabled"))),!d){let h=Number.POSITIVE_INFINITY;for(let g of a){let v=this.getCachedDropzoneRect(g),E=Math.hypot(l.left-v.left,l.top-v.top);E<h&&(h=E,d=g)}}return d}calculateOverlapArea(a,l){let d=Math.max(0,Math.min(a.right,l.right)-Math.max(a.left,l.left)),p=Math.max(0,Math.min(a.bottom,l.bottom)-Math.max(a.top,l.top));return d*p}getComputedStyleText(a){let l=this.dragCloneStyleCache.get(a);if(l)return l;let d=window.getComputedStyle(a),p="";for(let m=0;m<d.length;m++){let h=d[m];p+=`${h}:${d.getPropertyValue(h)};`}return this.dragCloneStyleCache.set(a,p),p}dispatchCustomEvent(a,l,d=!0){if(!a)return;let p=new CustomEvent(l,{bubbles:d,cancelable:!0});p.dataTransfer=this.dataTransfer,a.dispatchEvent(p)}appendClone(){(document.fullscreenElement??document.body).appendChild(this.dragClone)}handleTouchStart(a){if(this.isMatchTabular()||a instanceof MouseEvent&&a.button!==0||this.isDragging)return;let{x:l,y:d}=this.getEventCoordinates(a);this.touchStartPoint={x:l,y:d},this.dragSource=a.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let p=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),m=this.droppables.some(A=>Array.from(A.children).some(q=>q===this.dragSource)),h=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-h.left,this.cloneOffset.y=d-h.top,this.dragClone=p.cloneNode(!0),this.configuration.copyStylesDragClone&&(this.dragClone.style.cssText=this.getComputedStyleText(p));let g=p.getBoundingClientRect();this.dragClone.style.width=`${g.width}px`,this.dragClone.style.height=`${g.height}px`,h&&this.setDragCloneStyles(h),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone(),this.refreshDragBounds(),this.refreshDropzoneRects(),window.addEventListener("scroll",this.onScrollOrResize,!0),window.addEventListener("resize",this.onScrollOrResize);let v=this.getMatchMaxValue(this.dragSource),E=this.draggables.filter(A=>A.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));v!==0&&E.length>=v?(p.style.opacity="0.0",p.style.pointerEvents="none"):p.style.opacity="1.0",a.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(a){let l=this.dragContainers.flat();for(let d of l){if(d.getAttribute("identifier")===a)return d;let p;d instanceof HTMLSlotElement?p=Array.from(d?.assignedElements()||[]):p=Array.from(d.querySelectorAll(r));let m=p.find(h=>h.getAttribute("identifier")===a);if(m)return m}}setDragCloneStyles(a){this.dragClone.style.position="fixed",this.dragClone.style.top=`${a.top}px`,this.dragClone.style.left=`${a.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return c([u({attribute:!1,type:Object})],i.prototype,"configuration",2),c([u({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),c([u({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),c([_i(t)],i.prototype,"handleDraggableContainerChange",1),c([_i(r)],i.prototype,"handleDraggablesChange",1),c([_i(e)],i.prototype,"handleDroppablesChange",1),i};var Na=y`
|
|
3945
|
+
`,d([P({context:Ze,subscribe:!0})],mr.prototype,"computedContext",2),mr=d([k("item-print-variables")],mr);var oe,bi,vi,xo,qo,wo,ee,cl,dl,Ps,pl,ul,Ds,hr=class extends C{constructor(){super();_(this,ee);_(this,oe);this.configContext={};_(this,bi,D(this,ee,cl).bind(this));_(this,vi,D(this,ee,dl).bind(this));_(this,xo,D(this,ee,Ps).bind(this));_(this,qo,D(this,ee,pl).bind(this));_(this,wo,D(this,ee,ul).bind(this));this.addEventListener("qti-item-context-updated",I(this,bi)),this.addEventListener("qti-assessment-item-connected",I(this,vi)),this.addEventListener("item-show-correct-response",I(this,xo)),this.addEventListener("item-show-candidate-correction",I(this,qo)),this.addEventListener("item-switch-correct-response-mode",I(this,wo))}render(){return x`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",I(this,bi)),this.removeEventListener("qti-assessment-item-connected",I(this,vi))}};oe=new WeakMap,bi=new WeakMap,vi=new WeakMap,xo=new WeakMap,qo=new WeakMap,wo=new WeakMap,ee=new WeakSet,cl=function(e){D(this,ee,Ds).call(this,e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])},dl=function(e){let t=e.detail._context.variables;B(this,oe,e.detail),this.computedContext=this.computedContext?.identifier===I(this,oe).identifier?{...this.computedContext,title:I(this,oe).title}:{identifier:I(this,oe).identifier,title:I(this,oe).title,adaptive:I(this,oe).getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},D(this,ee,Ds).call(this,I(this,oe).identifier,t||[])},Ps=function(e){I(this,oe)&&I(this,oe).showCorrectResponse(e.detail)},pl=function(e){I(this,oe)&&I(this,oe).showCandidateCorrection(e.detail)},ul=function(e){D(this,ee,Ps).call(this,new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}},Ds=function(e,t){let i=t?.find(p=>p.identifier=="SCORE")?.value,o=parseFloat(i?.toString()),n=t?.find(p=>p.identifier==="completionStatus")?.value,a=o!==void 0&&!isNaN(o)&&o>0,l=o!==void 0&&!isNaN(o)&&o<=0,c=n==="completed";this.computedContext={...this.computedContext,identifier:e,correct:a,incorrect:l,completed:c,variables:t}},d([R(),ne({context:Ze})],hr.prototype,"computedContext",2),d([R(),ne({context:he})],hr.prototype,"configContext",2),hr=d([k("qti-item")],hr);var Co=class extends C{static{this.styles=S`
|
|
3946
|
+
:host {
|
|
3947
|
+
display: flex;
|
|
3948
|
+
user-select: none;
|
|
3949
|
+
position: absolute;
|
|
3950
|
+
}
|
|
3951
|
+
`}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return x` <slot name="drags"></slot> `}};customElements.define("qti-associable-hotspot",Co);var yi=class extends C{constructor(){super(...arguments);this.tabindex=0}static{this.styles=S`
|
|
3952
|
+
:host {
|
|
3953
|
+
display: flex;
|
|
3954
|
+
user-select: none;
|
|
3955
|
+
}
|
|
3956
|
+
`}render(){return x` <slot name="drags"></slot>`}};d([b({type:Number,reflect:!0})],yi.prototype,"tabindex",2);customElements.define("qti-gap",yi);var xi=class extends C{constructor(){super(...arguments);this.tabindex=0}static{this.styles=S`
|
|
3957
|
+
:host {
|
|
3958
|
+
display: flex;
|
|
3959
|
+
user-select: none;
|
|
3960
|
+
}
|
|
3961
|
+
`}connectedCallback(){this.setAttribute("slot","drags")}};d([b({type:Number,reflect:!0})],xi.prototype,"tabindex",2);customElements.define("qti-gap-img",xi);var ml={toAttribute:s=>s?"true":"false",fromAttribute:s=>s==="true"};function ve(s,r){class e extends s{constructor(...o){super(...o);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(o,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.internals.ariaChecked="false",this.disabled&&(this.tabIndex=-1),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${r}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${r}`,{bubbles:!0,composed:!0}))}_onKeyUp(o){o.altKey||(o.code==="Space"||o.code==="Enter")&&(o.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${r}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return x`<slot></slot>`}}return d([b({type:String})],e.prototype,"identifier",2),d([b({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),d([b({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:ml})],e.prototype,"disabled",2),d([b({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:ml})],e.prototype,"readonly",2),d([U("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var qi=class extends ve(C,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}static{this.styles=S`
|
|
3962
|
+
:host {
|
|
3963
|
+
display: inline-flex;
|
|
3964
|
+
user-select: none;
|
|
3965
|
+
}
|
|
3966
|
+
`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return x`<slot></slot>`}};d([b({type:Number,reflect:!0})],qi.prototype,"tabindex",2);customElements.define("qti-gap-text",qi);var fr=class extends ve(C,"qti-hotspot-choice"){static{this.styles=S`
|
|
3967
|
+
:host {
|
|
3968
|
+
display: flex;
|
|
3969
|
+
user-select: none;
|
|
3970
|
+
position: absolute;
|
|
3971
|
+
}
|
|
3972
|
+
`}};d([b({attribute:"aria-ordervalue",type:Number,reflect:!0})],fr.prototype,"order",2),d([b({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],fr.prototype,"orderCorrect",2);customElements.define("qti-hotspot-choice",fr);var Eo=class extends ve(C,"qti-hottext"){static{this.styles=S`
|
|
3973
|
+
:host {
|
|
3974
|
+
display: flex;
|
|
3975
|
+
user-select: none;
|
|
3976
|
+
}
|
|
3977
|
+
`}render(){return x`<div part="ch"><div part="cha"></div></div>
|
|
3978
|
+
<slot></slot> `}};customElements.define("qti-hottext",Eo);var Jc=S`
|
|
3979
|
+
:host {
|
|
3980
|
+
display: block;
|
|
3981
|
+
box-sizing: border-box;
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
slot {
|
|
3985
|
+
display: inline;
|
|
3986
|
+
}
|
|
3987
|
+
`,hl=Jc;var wi=class extends ve(C,"qti-inline-choice"){static{this.styles=hl}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.#e),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this.#e)}render(){return x` <slot></slot> `}#e(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};d([b({type:String})],wi.prototype,"identifier",2);customElements.define("qti-inline-choice",wi);var So=class extends C{render(){return x`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",So);var Dt=class extends ve(C,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}static{this.styles=S`
|
|
3988
|
+
:host {
|
|
3989
|
+
display: flex;
|
|
3990
|
+
user-select: none;
|
|
3991
|
+
}
|
|
3992
|
+
slot {
|
|
3993
|
+
width: 100%;
|
|
3994
|
+
display: block;
|
|
3995
|
+
}
|
|
3996
|
+
slot[name='qti-simple-associable-choice'] {
|
|
3997
|
+
width: auto;
|
|
3998
|
+
}
|
|
3999
|
+
`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return x`
|
|
4000
|
+
<slot part="slot"></slot>
|
|
4001
|
+
<slot part="dropslot" name="qti-simple-associable-choice"></slot>
|
|
4002
|
+
`}};d([b({type:Number,attribute:"match-min"})],Dt.prototype,"matchMin",2),d([b({type:Number,attribute:"match-max"})],Dt.prototype,"matchMax",2),d([b({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Dt.prototype,"fixed",2);customElements.define("qti-simple-associable-choice",Dt);var fl=S`
|
|
4003
|
+
:host {
|
|
4004
|
+
display: flex;
|
|
4005
|
+
align-items: center;
|
|
4006
|
+
user-select: none;
|
|
4007
|
+
}
|
|
4008
|
+
slot {
|
|
4009
|
+
width: 100%;
|
|
4010
|
+
display: flex;
|
|
4011
|
+
align-items: center;
|
|
4012
|
+
}
|
|
4013
|
+
[part='ch'] {
|
|
4014
|
+
display: flex;
|
|
4015
|
+
flex-shrink: 0;
|
|
4016
|
+
align-items: center;
|
|
4017
|
+
justify-content: center;
|
|
4018
|
+
}
|
|
4019
|
+
`;var ct=class extends ve(C,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}static{this.styles=fl}get checked(){return this.internals.states.has("--checked")}render(){return x`<div part="ch">
|
|
4020
|
+
<div part="cha"></div>
|
|
4021
|
+
</div>
|
|
4022
|
+
${this.marker?x`<div id="label">${this.marker}</div>`:N}
|
|
4023
|
+
<slot part="slot"></slot>`}};d([b({type:String,attribute:"template-identifier"})],ct.prototype,"templateIdentifier",2),d([b({type:String,attribute:"show-hide"})],ct.prototype,"showHide",2),d([b({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],ct.prototype,"fixed",2),d([b({type:String,attribute:!1})],ct.prototype,"marker",2);customElements.define("qti-simple-choice",ct);var{AbortController:$e,AbortSignal:$s,WeakMap:Yc,WeakRef:Kc,Window:gl,reportError:To=console.log}=globalThis,dt=s=>s&&s.defaultView!==null&&s.defaultView.document===s&&(s.defaultView.top===s.defaultView||dt(s.defaultView.parent.document)),$t=()=>!!gl&&globalThis instanceof gl,Os=Symbol("unset"),[bl,Zc]=(()=>{function s(w,f,u=!0){Object.defineProperty(w,f,{...Object.getOwnPropertyDescriptor(w,f),enumerable:u})}let r="try"in Promise?Promise.try.bind(Promise):(w,...f)=>new Promise(u=>u(w(...f))),e="withResolvers"in Promise?Promise.withResolvers.bind(Promise):()=>{let w,f;return{promise:new Promise((g,q)=>(w=g,f=q)),resolve:w,reject:f}};function t(w,f){let u=f.call(w);if(u===null||typeof u!="object")throw new TypeError("Iterator is not an object");return u}let i=new Yc,o={next(...w){let f=this,u=i.get(f);if(!u?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.next called on invalid object");let{syncIteratorRecord:g}=u;return r(()=>g.next(...w))},return(...w){let f=this,u=i.get(f);if(!u?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.return called on invalid object");let{syncIteratorRecord:g}=u;return r(()=>g.return?g.return(...w):{value:void 0,done:!0})},throw(...w){let f=this,u=i.get(f);if(!u?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.throw called on invalid object");let{syncIteratorRecord:g}=u;return r(()=>{if(!g.throw)throw g.return(),new TypeError("no throw method");return g.throw(...w)})}};function n(w){let f=Object.create(o);return i.set(f,{syncIteratorRecord:w}),f}function a(w,f){let u;if(f){if(u=w[Symbol.asyncIterator],u==null){if(u=w[Symbol.iterator],u==null)throw new TypeError("Object is not async iterable");let g=t(w,u);return n(g)}}else u=w[Symbol.iterator];if(u==null)throw new TypeError("Object is not iterable");return t(w,u)}let l="any"in $s?$s.any.bind($s):w=>{let f=new $e;for(let u of w)if(u.aborted)return f.abort(u.reason),f.signal;for(let u of w)u.addEventListener("abort",()=>{f.abort(u.reason)},{signal:f.signal});return f.signal},c=w=>l(w.filter(Boolean));class p{constructor({next:f,error:u,complete:g}={}){i.set(this,{next:f,error:u,complete:g})}next(f){let{next:u}=i.get(this)||{};u&&u(f)}error(f){let{error:u}=i.get(this)||{};u?u(f):To(f)}complete(){let{complete:f}=i.get(this)||{};f&&f()}}function h(w,f){let u=i.get(w);if(u?.active){u.active=!1,u.subscriptionController.abort(f);for(let g of u.teardowns.reverse()){if($t()&&!dt(document))return;try{g()}catch(q){To(q)}}}}function m(w,f,u={}){if($t()&&!dt(document))return;let g;typeof f=="function"?g=new p({next:f}):f&&!(f instanceof p)?g=new p(f):g=f||new p;let q=i.get(w),T=q.weakSubscriber?.deref();if(T?.active){let A=T,M=i.get(A);M.observers.add(g),u.signal&&(u.signal.aborted?M.observers.delete(g):u.signal.addEventListener("abort",()=>{let V=i.get(A);V?.active&&(V.observers.delete(g),V.observers.size==0&&h(A,u.signal.reason))}));return}let E=new y(g);if(q.weakSubscriber=new Kc(E),"signal"in u&&(u.signal.aborted?h(E,u.signal.reason):u.signal.addEventListener("abort",()=>{let A=i.get(E);A?.active&&(A.observers.delete(g),A.observers.size==0&&h(E,u.signal.reason))})),q.subscribeCallback)try{q.subscribeCallback(E)}catch(A){E.error(A)}}class y{get[Symbol.toStringTag](){return"Subscriber"}constructor(f=null){if(!(f instanceof p))throw new TypeError("Illegal constructor");i.set(this,{active:!0,observers:new Set([f]),teardowns:[],subscriptionController:new $e})}next(f){if(!(this instanceof y))throw new TypeError("illegal invocation");if(!arguments.length)throw new TypeError("too few arguments");let u=i.get(this);if(!u?.active||$t()&&!dt(document))return;let g=new Set(u.observers);for(let q of g)q.next(f)}error(f){if(!(this instanceof y))throw new TypeError("illegal invocation");if(!arguments.length)throw new TypeError("too few arguments");let u=i.get(this);if(!u?.active){To(f);return}if($t()&&!dt(document))return;h(this,f);let g=new Set(u.observers);for(let q of g)q.error(f)}complete(){if(!(this instanceof y))throw new TypeError("illegal invocation");let f=i.get(this);if(!f?.active||$t()&&!dt(document))return;h(this);let u=new Set(f.observers);for(let g of u)g.complete()}addTeardown(f){if(!(this instanceof y))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");if($t()&&!dt(document))return;let u=i.get(this);u?.active?u.teardowns.push(f):f()}get active(){if(!(this instanceof y))throw new TypeError("illegal invocation");return!!i.get(this)?.active}get signal(){if(!(this instanceof y))throw new TypeError("illegal invocation");if(!i.has(this)){let f=new $e;return f.abort(),f.signal}return i.get(this).subscriptionController.signal}}s(y.prototype,"next"),s(y.prototype,"error"),s(y.prototype,"complete"),s(y.prototype,"addTeardown"),s(y.prototype,"active"),s(y.prototype,"signal");class v{get[Symbol.toStringTag](){return"Observable"}constructor(f){if(!f)throw new TypeError("1 argument required but 0 present");i.set(this,{weakSubscriber:null,subscribeCallback:f})}static from(f){if(f===null||typeof f!="object")throw new TypeError("Observable.from only accepts objects");if(f instanceof v)return f;if(typeof(Symbol.asyncIterator in f&&f[Symbol.asyncIterator])=="function"){let T=function(E,A){if(E.signal.aborted)return;let M;try{let V=A.next();M=Promise.resolve(V)}catch(V){M=Promise.reject(V)}M.then(V=>{if(V===null||typeof V!="object"){E.error(new TypeError("Not an IteratorResult."));return}try{({done:q}=V)}catch(z){E.error(z);return}if(q){E.complete();return}let H;try{H=V.value}catch(z){E.error(z);return}E.next(H),T(E,A)},V=>{E.error(V)})},q=!1;return new v(E=>{if(E.signal.aborted)return;let A;try{A=a(f,!0)}catch(V){E.error(V);return}let M=A;E.signal.aborted||(E.signal.addEventListener("abort",()=>{if(typeof M.return!="function"||q)return;r(()=>M.return(E.signal.reason)).then(H=>{if(H===null||typeof H!="object")throw new TypeError("Iterator .return() must return an Object")})}),T(E,M))})}if(typeof(Symbol.iterator in f&&f[Symbol.iterator])=="function")return new v(q=>{if(q.signal.aborted)return;let T;try{T=a(f,!1)}catch(M){q.error(M);return}let E=!1,A=T;if(!q.signal.aborted)for(q.signal.addEventListener("abort",()=>{if(typeof A.return!="function"||E)return;let M=A.return();if(M===null||typeof M!="object")throw new TypeError("Iterator .return() must return an Object")});;)try{let M=A.next();if({done:E}=M,E){q.complete();return}if(q.next(M.value),q.signal.aborted)break}catch(M){q.error(M);break}});if(f instanceof Promise||typeof f.then=="function")return new v(q=>{f.then(T=>{q.next(T),q.complete()},T=>{q.error(T)})});throw new TypeError("Could not convert value to Observable")}subscribe(f=null,u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");m(this,f,u)}takeUntil(f){if(!(this instanceof v))throw new TypeError("illegal invocation");let u=this,g=v.from(f);return new v(q=>{let T=new p({next(){q.complete()},error(){q.complete()}}),E={signal:q.signal};if(m(g,T,E),!q.active)return;let A=new p({next(M){q.next(M)},error(M){q.error(M)},complete(){q.complete()}});m(u,A,E)})}map(f){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let u=this;return new v(g=>{let q=0,T=new p({next(A){let M;try{M=f(A,q)}catch(V){g.error(V);return}q+=1,g.next(M)},error(A){g.error(A)},complete(){g.complete()}}),E={signal:g.signal};m(u,T,E)})}inspect(f={}){let u=null,g=null,q=null,T=null,E=null;typeof f=="function"?g=f:f&&typeof f=="object"&&("subscribe"in f&&(u=f.subscribe),"next"in f&&(g=f.next),"error"in f&&(q=f.error),"complete"in f&&(T=f.complete),"abort"in f&&(E=f.abort));let A=this;return new v(M=>{if(u!==null)try{u()}catch(F){M.error(F);return}let V=()=>{try{E!==null&&E(M.signal.reason)}catch(F){To(F)}};M.signal.addEventListener("abort",V,{once:!0});let H=new p({next(F){if(g!==null)try{g(F)}catch(se){M.signal.removeEventListener("abort",V),M.error(se);return}M.next(F)},error(F){if(M.signal.removeEventListener("abort",V),q!==null)try{q(F)}catch(se){M.error(se);return}M.error(F)},complete(){if(M.signal.removeEventListener("abort",V),T!==null)try{T()}catch(F){M.error(F);return}M.complete()}}),z={signal:M.signal};m(A,H,z)})}filter(f){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let u=this;return new v(g=>{let q=0,T=new p({next(A){let M=!1;try{M=f(A,q)}catch(V){g.error(V);return}q+=1,M&&g.next(A)},error(A){g.error(A)},complete(){g.complete()}}),E={signal:g.signal};m(u,T,E)})}take(f){if(!(this instanceof v))throw new TypeError("illegal invocation");let u=this;return new v(g=>{let q=f;if(q==0)return g.complete();let T=new p({next(A){g.next(A),q-=1,q==0&&g.complete()},error(A){g.error(A)},complete(){g.complete()}}),E={signal:g.signal};m(u,T,E)})}drop(f){if(!(this instanceof v))throw new TypeError("illegal invocation");let u=this;return new v(g=>{let q=f,T=new p({next(A){if(q>0)return q-=1;q==0&&g.next(A)},error(A){g.error(A)},complete(){g.complete()}}),E={signal:g.signal};m(u,T,E)})}flatMap(f){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let u=this;return new v(g=>{let q=0,T=!1,E=[];function A(z){let F;try{F=f(z,q)}catch(Ve){return g.error(Ve)}q+=1;let se;try{se=v.from(F)}catch(Ve){return g.error(Ve)}let Ko=new p({next(Ve){g.next(Ve)},error(Ve){g.error(Ve)},complete(){if(E.length){let Ve=E.shift();A(Ve)}else M=!1,T&&g.complete()}}),Se={signal:g.signal};m(se,Ko,Se)}let M=!1,V=new p({next(z){M?E.push(z):(M=!0,A(z))},error(z){g.error(z)},complete(){T=!0,!M&&!E.length&&g.complete()}}),H={signal:g.signal};m(u,V,H)})}switchMap(f){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let u=this;return new v(g=>{let q=0,T=!1,E=null;function A(H){let z;try{z=f(H,q)}catch(Se){return g.error(Se)}q+=1;let F;try{F=v.from(z)}catch(Se){return g.error(Se)}let se=new p({next(Se){g.next(Se)},error(Se){g.error(Se)},complete(Se){T?g.complete():E=null}}),Ko={signal:c([E.signal,g.signal])};m(F,se,Ko)}let M=new p({next(H){E&&E.abort(),E=new $e,A(H)},error(H){g.error(H)},complete(){T=!0,E||g.complete()}}),V={signal:g.signal};m(u,M,V)})}catch(f){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let u=this;return new v(q=>{let T=new p({next(A){q.next(A)},error(A){let M;try{M=f(A)}catch(F){q.error(F);return}let V;try{V=v.from(M)}catch(F){q.error(F);return}let H=new p({next(F){q.next(F)},error(F){q.error(F)},complete(){q.complete()}}),z={signal:q.signal};m(V,H,z)},complete(){q.complete()}}),E={signal:q.signal};m(u,T,E)})}finally(f){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let u=this;return new v(g=>{g.addTeardown(f);let q=new p({next(E){g.next(E)},error(E){g.error(E)},complete(){g.complete()}}),T={signal:g.signal};m(u,q,T)})}toArray(f={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:u,resolve:g,reject:q}=e();if(f.signal){if(f.signal.aborted)return Promise.reject(f.signal.reason);f.signal.addEventListener("abort",()=>{q(f.signal.reason)})}let T=[],E=new p({next(A){T.push(A)},error(A){q(A)},complete(){g(T)}});return m(this,E,f),u}forEach(f,u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:g,resolve:q,reject:T}=e(),E=new $e,A={signal:c([E.signal,u.signal])};if(A.signal.aborted)return T(A.signal.reason),g;A.signal.addEventListener("abort",()=>{T(A.signal.reason)});let M=0,V=new p({next(H){try{f(H,M)}catch(z){T(z),E.abort(z)}M+=1},error(H){T(H)},complete(){q()}});return m(this,V,A),g}every(f,u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:g,resolve:q,reject:T}=e(),E=new $e,A={signal:c([E.signal,u.signal])};if(A.signal.aborted)return T(A.signal.reason),g;A.signal.addEventListener("abort",()=>{T(A.signal.reason)});let M=0,V=new p({next(H){let z=!1;try{z=f(H,M)}catch(F){T(F),E.abort(F)}M+=1,z||(q(!1),E.abort())},error(H){T(H)},complete(){q(!0)}});return m(this,V,A),g}first(f={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:u,resolve:g,reject:q}=e(),T=new $e,E={signal:c([T.signal,f.signal])};if(E.signal.aborted)return q(E.signal.reason),u;E.signal.addEventListener("abort",()=>{q(E.signal.reason)});let A=new p({next(M){g(M),T.abort()},error(M){q(M)},complete(){q(new RangeError("No values in Observable"))}});return m(this,A,E),u}last(f={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:u,resolve:g,reject:q}=e();if(f.signal){if(f.signal.aborted)return q(f.signal.reason),u;f.signal.addEventListener("abort",()=>{q(f.signal.reason)})}let T=null,E=!1,A=new p({next(M){E=!0,T=M},error(M){q(M)},complete(){E?g(T):q(new RangeError("No values in Observable"))}});return m(this,A,f),u}find(f,u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:g,resolve:q,reject:T}=e(),E=new $e,A={signal:c([E.signal,u.signal])};if(A.signal.aborted)return T(A.signal.reason),g;A.signal.addEventListener("abort",()=>{T(A.signal.reason)});let M=0,V=new p({next(H){let z=!1;try{z=f(H,M)}catch(F){T(F),E.abort(F)}M+=1,z&&(q(H),E.abort())},error(H){T(H)},complete(){q()}});return m(this,V,A),g}some(f,u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:g,resolve:q,reject:T}=e(),E=new $e,A={signal:c([E.signal,u.signal])};if(A.signal.aborted)return T(A.signal.reason),g;A.signal.addEventListener("abort",()=>{T(A.signal.reason)});let M=0,V=new p({next(H){let z=!1;try{z=f(H,M)}catch(F){T(F),E.abort(F)}M+=1,z&&(q(!0),E.abort())},error(H){T(H)},complete(){q(!1)}});return m(this,V,A),g}reduce(f,u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof f!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:q,resolve:T,reject:E}=e(),A=new $e,M={signal:c([A.signal,g.signal])};if(M.signal.aborted)return E(M.signal.reason),q;M.signal.addEventListener("abort",()=>{E(M.signal.reason)},{once:!0});let V=0,H=arguments.length>1?u:Os,z=new p({next(F){if(H===Os){H=F,V++;return}try{let se=f(H,F,V);V++,H=se}catch(se){E(se),A.abort(se);return}},error(F){E(F)},complete(){H!==Os?T(H):E(new TypeError("no initial value provided and no values emitted"))}});return m(this,z,M),q}}return s(v.prototype,"subscribe"),[v,y]})();function vl(){return typeof globalThis.Observable=="function"}function yl(){Object.defineProperties(globalThis,{Observable:{value:bl,configurable:!0,writable:!0},Subscriber:{value:Zc,configurable:!0,writable:!0}}),EventTarget.prototype.when=function(s,r={}){if($t()&&!dt(document))return;let e=this;return new bl(t=>{if(!e||t.signal.aborted)return;let i=o=>{t.next(o)};e.addEventListener(s,i,{capture:r.capture||!1,passive:r.passive,once:!1,signal:t.signal})})}}function Vs(s,r,e){let t=s.filter(i=>!i.hasAttribute("disabled"));for(let i of t){let o=i.getBoundingClientRect();if(r>=o.left&&r<=o.right&&e>=o.top&&e<=o.bottom)return i}return null}function xl(s,r,e,t){if(!t)return null;let i=s.filter(n=>!n.hasAttribute("disabled")),o=t.getBoundingClientRect();for(let n of i){let a=n.getBoundingClientRect();if(!(o.right<a.left||o.left>a.right||o.bottom<a.top||o.top>a.bottom))return n}return null}function ql(s,r,e,t){let i=s.filter(c=>!c.hasAttribute("disabled"));if(i.length===0)return null;let o,n;if(t){let c=t.getBoundingClientRect();o=c.left+c.width/2,n=c.top+c.height/2}else o=r,n=e;let a=null,l=1/0;for(let c of i){let p=c.getBoundingClientRect(),h=p.left+p.width/2,m=p.top+p.height/2,y=Math.sqrt(Math.pow(o-h,2)+Math.pow(n-m,2));y<l&&(l=y,a=c)}return a}function wl(s,r,e,t){let i=s.filter(l=>!l.hasAttribute("disabled"));if(i.length===0)return null;let o;if(t){let l=t.getBoundingClientRect();o=[{x:l.left,y:l.top},{x:l.right,y:l.top},{x:l.left,y:l.bottom},{x:l.right,y:l.bottom}]}else o=[{x:r,y:e},{x:r,y:e},{x:r,y:e},{x:r,y:e}];let n=null,a=1/0;for(let l of i){let c=l.getBoundingClientRect(),p=[{x:c.left,y:c.top},{x:c.right,y:c.top},{x:c.left,y:c.bottom},{x:c.right,y:c.bottom}],h=0,m=0;for(let v of o)for(let w of p){let f=Math.sqrt(Math.pow(v.x-w.x,2)+Math.pow(v.y-w.y,2));h+=f,m++}let y=h/m;y<a&&(a=y,n=l)}return n}function ed(s,r,e,t,i){let o=i&&i.length>0?s.filter(u=>i.includes(u)):s.filter(u=>u.tagName==="SLOT"&&u.hasAttribute("part")&&u.getAttribute("part")?.includes("drags")),a=s.filter(u=>!o.includes(u));if(o.length===0&&a.length===0)return null;let l;if(t){let u=t.getBoundingClientRect();l=[{x:u.left,y:u.top},{x:u.right,y:u.top},{x:u.left,y:u.bottom},{x:u.right,y:u.bottom}]}else l=[{x:r,y:e},{x:r,y:e},{x:r,y:e},{x:r,y:e}];let c=u=>{let g=u.getBoundingClientRect(),q=[{x:g.left,y:g.top},{x:g.right,y:g.top},{x:g.left,y:g.bottom},{x:g.right,y:g.bottom}],T=0,E=0;for(let A of l)for(let M of q){let V=Math.sqrt(Math.pow(A.x-M.x,2)+Math.pow(A.y-M.y,2));T+=V,E++}return T/E},p=null,h=1/0;for(let u of o){let g=c(u);g<h&&(h=g,p=u)}let m=null,y=1/0;for(let u of a){let g=c(u);g<y&&(y=g,m=u)}if(p&&t){let u=t.getBoundingClientRect(),g=p.getBoundingClientRect(),q=u.left+u.width/2,T=u.top+u.height/2;if(q>=g.left&&q<=g.right&&T>=g.top&&T<=g.bottom)return p}let w=t?.getAttribute("data-drag-origin")==="droppable"?.85:1.5;return p&&m?h<=y*w?p:m:p||m}function Cl(s){switch(s){case"pointerWithin":return Vs;case"rectangleIntersection":return xl;case"closestCenter":return ql;case"closestCorners":return wl;case"closestCornersWithInventoryPriority":return ed;default:return Vs}}function gr(s,r,e,t,i="pointerWithin",o){return Cl(i)(s,r,e,t,o)}function pt(s,r){let e=s.composedPath?s.composedPath():[s.target];for(let t of e)if(t instanceof HTMLElement&&t.tagName!=="SLOT"){if(t.matches(r)||t.hasAttribute("qti-draggable"))return t;let i=t.closest(r)||t.closest('[qti-draggable="true"]');if(i)return i}return null}function Ao(s,r){let e=[];return s.forEach(t=>{let i=[];t.tagName.toLowerCase()==="slot"?i=t.assignedElements({flatten:!0}).filter(a=>a.getAttribute("identifier")===r):i=Array.from(t.querySelectorAll(`[identifier="${r}"]`)),e.push(...i)}),e}function El(s,r){let e=s.find(i=>i.getAttribute("identifier")===r);if(!e)return 1;let t=e.getAttribute("match-max");return t?parseInt(t,10)||0:1}function Sl(s,r){let e=parseInt(s.getAttribute("match-max")||"1",10),t=Number.isNaN(e)?1:e;if(t===0)return!1;let i=s.querySelectorAll(r),o=s.querySelectorAll('[qti-draggable="true"]');return Math.max(i.length,o.length)>=t}function Ci(s,r){return s.reduce((e,t)=>{let i=t.querySelectorAll(r).length,o=t.querySelectorAll('[qti-draggable="true"]').length;return e+Math.max(i,o)},0)}function Io(s,r){return s.map(e=>{let i=Array.from(e.querySelectorAll(r)).map(n=>n.getAttribute("identifier")).filter(n=>!!n),o=e.getAttribute("identifier");return i.map(n=>`${n} ${o}`)}).flat()}function Tl(s,r,e,t=typeof window<"u"?window:null){if(!s.length||!r.length||!t)return;let i=0,o=0;s.forEach(c=>{let p=c.getBoundingClientRect();i=Math.max(i,p.height),o=Math.max(o,p.width)});let n=r[0].parentElement,a=r[0].tagName==="QTI-SIMPLE-ASSOCIABLE-CHOICE",l=r[0].tagName==="QTI-GAP";if(a&&n){let c;if(n.clientWidth>0){let p=t.getComputedStyle(n),h=parseFloat(p.paddingLeft),m=parseFloat(p.paddingRight);c=n.clientWidth-h-m}else c=Math.min(t.innerWidth*.8,600);n.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(min(${c}px, ${o}px + 2 * var(--qti-dropzone-padding, 0.5rem))), 1fr))`}r.forEach(c=>{c.style.minHeight=`${i}px`,(a||l)&&(c.style.minWidth=`${o}px`);let p=c.shadowRoot?.querySelector('slot[part="dropslot"]');p&&(p.style.minHeight=`${i}px`)}),e.forEach(c=>{c.style.minHeight=`${i}px`})}vl()||yl();var Al=new WeakSet;function td(s){!s||Al.has(s)||(s.addEventListener("touchmove",()=>{},{capture:!1,passive:!1}),Al.add(s))}var ko=(s,r,e,t='slot[part="drags"]',i="pointerWithin")=>{class o extends s{constructor(){super(...arguments);this.trackedDraggables=[];this.trackedDroppables=[];this.trackedDragContainers=[];this.allDropzones=[];this.collisionDetectionAlgorithm=i;this.dragState={dragging:!1,dragSource:null,dragClone:null,startOffset:{x:0,y:0},currentTarget:null,sourceDroppable:null,inputType:null};this.subscriptions=[];this.dragSubscriptions=[];this.lastPointerDownAt=0;this.lastTouchStartAt=0}connectedCallback(){super.connectedCallback(),td(this.ownerDocument?.defaultView),this.setupDragDrop()}disconnectedCallback(){super.disconnectedCallback(),this.cleanup()}async setupDragDrop(){await this.updateComplete,this.cacheInteractiveElements(),this.afterCache(),this.setupDragObservables()}afterCache(){}cacheInteractiveElements(){let l=(u,g)=>Array.from(g?.querySelectorAll(u)??[]),c=l(r,this),p=l(r,this.shadowRoot),h=l('[qti-draggable="true"]:not([data-drag-clone])',this),m=l('[qti-draggable="true"]:not([data-drag-clone])',this.shadowRoot);this.trackedDraggables=Array.from(new Set([...c,...p,...h,...m]));let y=l(e,this),v=l(e,this.shadowRoot);this.trackedDroppables=Array.from(new Set([...y,...v]));let w=l(t,this),f=l(t,this.shadowRoot);this.trackedDragContainers=Array.from(new Set([...w,...f])),this.allDropzones=[...this.trackedDroppables,...this.trackedDragContainers],this.trackedDraggables.forEach(u=>{u.style.cursor="grab",u.style.userSelect="none",u.style.touchAction="none",u.style.webkitUserSelect="none",u.style.webkitTouchCallout="none",u.setAttribute("qti-draggable","true"),u.setAttribute("tabindex","0")})}setupDragObservables(){let l=this.shadowRoot;if(!l){console.error("\u274C [Observable DnD] No shadow root found!");return}let c=l.when("pointerdown").filter(v=>{if(!v.isTrusted)return!1;let w=pt(v,r),f=this.disabled||this.readonly,u=w?.hasAttribute("disabled")||w?.getAttribute("aria-disabled")==="true",g=Date.now()-this.lastTouchStartAt<50;return w&&v.isPrimary!==!1&&v.button===0&&!f&&!u&&!g}).subscribe(v=>{this.lastPointerDownAt=Date.now();let w=pt(v,r);if(!w){console.warn("\u26A0\uFE0F [Observable DnD] No draggable target found");return}v.pointerType==="touch"&&(v.preventDefault(),v.stopPropagation());let f=v.isTrusted?v.pointerType==="touch"?100:10:0;if(this.dragState.activationTimeout&&clearTimeout(this.dragState.activationTimeout),f===0){this.dragState.dragging||this.initiateDrag(w,v.clientX,v.clientY,v.pointerType,"pointer",v.pointerId,v.isTrusted);return}let u=()=>{this.dragState.activationTimeout&&(clearTimeout(this.dragState.activationTimeout),this.dragState.activationTimeout=void 0),document.removeEventListener("pointerup",u,!0),document.removeEventListener("pointercancel",u,!0)};document.addEventListener("pointerup",u,{once:!0,capture:!0}),document.addEventListener("pointercancel",u,{once:!0,capture:!0}),this.dragState.activationTimeout=window.setTimeout(()=>{this.dragState.activationTimeout=void 0,document.removeEventListener("pointerup",u,!0),document.removeEventListener("pointercancel",u,!0),this.dragState.dragging||this.initiateDrag(w,v.clientX,v.clientY,v.pointerType,"pointer",v.pointerId,v.isTrusted)},f)}),p=l.when("mousedown").filter(v=>{let w=pt(v,r),f=this.disabled||this.readonly,u=w?.hasAttribute("disabled")||w?.getAttribute("aria-disabled")==="true",g=v.button===0,q=Date.now()-this.lastPointerDownAt<50;return w&&g&&!f&&!u&&!q}).subscribe(v=>{let w=pt(v,r);!w||this.dragState.dragging||(v.preventDefault(),this.initiateDrag(w,v.clientX,v.clientY,"mouse","mouse",void 0,v.isTrusted))}),h=l.when("touchstart").filter(v=>{let w=pt(v,r),f=this.disabled||this.readonly,u=w?.hasAttribute("disabled")||w?.getAttribute("aria-disabled")==="true",g=!!(v.touches?.[0]||v.changedTouches?.[0]),q=Date.now()-this.lastPointerDownAt<50;return w&&g&&!f&&!u&&!q}).subscribe(v=>{let w=pt(v,r),f=v.touches?.[0]||v.changedTouches?.[0];!w||!f||this.dragState.dragging||(this.lastTouchStartAt=Date.now(),v.preventDefault(),v.stopPropagation(),this.initiateDrag(w,f.clientX,f.clientY,"touch","touch",void 0,v.isTrusted))}),m={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null},y=l.when("keydown").subscribe(v=>{let w=this.trackedDraggables.filter(u=>u.style.opacity!=="0"),f=[...this.trackedDroppables,...this.trackedDragContainers];if(m.dragging)switch(v.code){case"ArrowRight":case"ArrowDown":{v.preventDefault();let u=(m.dropIndex+1)%f.length;m={...m,dropIndex:u,dropElement:f[u]};break}case"ArrowLeft":case"ArrowUp":{v.preventDefault();let u=(m.dropIndex-1+f.length)%f.length;m={...m,dropIndex:u,dropElement:f[u]};break}case"Space":case"Enter":case"Tab":{v.preventDefault(),m.dragElement&&m.dropElement&&(this.allowDrop(m.dragElement,m.dropElement)||this.trackedDragContainers.includes(m.dropElement)?this.handleDrop(m.dragElement,m.dropElement):this.handleInvalidDrop(m.dragElement)),this.trackedDraggables.forEach(u=>u.removeAttribute("data-keyboard-dragging")),this.saveResponse(),m={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null};break}case"Escape":{v.preventDefault(),this.trackedDraggables.forEach(u=>u.removeAttribute("data-keyboard-dragging")),m={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null};break}}else{let u=pt(v,r),g=this.disabled||this.readonly,q=u?.hasAttribute("disabled")||u?.getAttribute("aria-disabled")==="true";u&&["Space","Enter"].includes(v.code)&&!g&&!q&&(v.preventDefault(),u.setAttribute("data-keyboard-dragging","true"),m={dragging:!0,dragElement:u,dragIndex:w.indexOf(u),dropIndex:0,dropElement:f[0]})}this.allDropzones.forEach(u=>u.removeAttribute("hover")),m.dragging&&m.dropElement&&(m.dropElement.setAttribute("hover",""),m.dropElement.hasAttribute("tabindex")&&m.dropElement.getAttribute("tabindex")!=="-1"&&m.dropElement.focus())});this.subscriptions.push(c,p,h,y)}initiateDrag(l,c,p,h,m="pointer",y,v){if(this.dragState.dragging){console.warn("\u26A0\uFE0F [Observable DnD] Already dragging, ignoring initiateDrag");return}if(l.hasAttribute("data-drag-clone")){console.warn("\u26A0\uFE0F [Observable DnD] Attempted to drag visual clone, ignoring");return}let w=this.trackedDroppables.some(g=>g.contains(l)),f=this.trackedDroppables.find(g=>g.contains(l))||null,u=l.getBoundingClientRect();this.dragState={dragging:!0,dragSource:l,dragClone:this.createDragClone(l,u),startOffset:{x:c-u.left,y:p-u.top},currentTarget:null,sourceDroppable:f,inputType:h,pointerId:y,startedFromTrustedEvent:v,initialCoordinates:{x:c,y:p}},w?(this.dragState.dragClone?.setAttribute("data-drag-origin","droppable"),l.remove(),this.cacheInteractiveElements(),f&&f.setAttribute("data-drag-source","true")):(this.dragState.dragClone?.setAttribute("data-drag-origin","inventory"),l.style.opacity="0",l.style.pointerEvents="none"),this.updateClonePosition(c,p),this.activateAllDroppables(),this.setupMoveObservables(h,m)}setupMoveObservables(l,c="pointer"){if(l==="touch"){if(c==="pointer")try{let T=this.dragState.dragSource,E=this.dragState.pointerId;T&&E!==void 0&&T.setPointerCapture&&T.setPointerCapture(E)}catch{}let g=T=>{T.cancelable&&(T.preventDefault(),c==="pointer"&&T.stopPropagation())};document.addEventListener("touchmove",g,{passive:!1,capture:!0}),document.addEventListener("touchstart",g,{passive:!1,capture:!0}),document.addEventListener("touchend",g,{passive:!1,capture:!0}),document.addEventListener("gesturestart",g,{passive:!1}),document.addEventListener("gesturechange",g,{passive:!1}),document.addEventListener("gestureend",g,{passive:!1});let q=()=>{if(document.removeEventListener("touchmove",g,{capture:!0}),document.removeEventListener("touchstart",g,{capture:!0}),document.removeEventListener("touchend",g,{capture:!0}),document.removeEventListener("gesturestart",g),document.removeEventListener("gesturechange",g),document.removeEventListener("gestureend",g),c==="pointer")try{let T=this.dragState.dragSource,E=this.dragState.pointerId;T&&E!==void 0&&T.releasePointerCapture&&T.releasePointerCapture(E)}catch{}};this.dragState.touchCleanup=q}let p=c==="mouse"?"mousemove":c==="touch"?"touchmove":"pointermove",h=c==="mouse"?"mouseup":c==="touch"?"touchend":"pointerup",m=g=>{let q=this.dragState.startedFromTrustedEvent;return q===void 0||g.isTrusted===q},y=document.when(p).takeUntil(document.when(h)).subscribe({next:g=>{if(m(g)){if(g.preventDefault(),g.stopPropagation(),c==="touch"){let q=g.touches?.[0]||g.changedTouches?.[0];if(!q)return;this.handleDragMove(q.clientX,q.clientY);return}if(c==="mouse"){let q=g;if(typeof q.buttons=="number"&&(q.buttons&1)!==1)return}this.handleDragMove(g.clientX,g.clientY)}}}),v=document.when(h).subscribe({next:g=>{m(g)&&(g.preventDefault(),g.stopPropagation(),this.handleDragEnd())}}),w=c==="touch"?document.when("touchcancel").subscribe({next:g=>{m(g)&&this.handleDragEnd()}}):c==="mouse"?null:document.when("pointercancel").subscribe({next:g=>{m(g)&&this.handleDragEnd()}}),f=document.when("keydown").filter(g=>g.key==="Escape").subscribe({next:g=>{m(g)&&this.handleDragEnd()}}),u=[y,v,f];w&&u.push(w),this.dragSubscriptions.push(...u)}handleDragMove(l,c){if(!this.dragState.dragging||!this.dragState.dragClone)return;this.updateClonePosition(l,c);let p=gr(this.allDropzones,l,c,this.dragState.dragClone,this.collisionDetectionAlgorithm,this.trackedDragContainers),h=Date.now(),m=h-(this.dragState.lastTargetChangeTime||0);p!==this.dragState.currentTarget&&(p===null||m>=50)&&(this.allDropzones.forEach(v=>v.removeAttribute("hover")),p&&p.setAttribute("hover",""),this.dragState.currentTarget=p,this.dragState.lastTargetChangeTime=h)}handleDragEnd(){if(!this.dragState.dragging)return;let{dragSource:l,dragClone:c,currentTarget:p,sourceDroppable:h}=this.dragState,m=p;if(!m&&c){let f=c.getBoundingClientRect(),u=this.dragState.initialCoordinates?.x??f.left+f.width/2,g=this.dragState.initialCoordinates?.y??f.top+f.height/2;m=gr(this.allDropzones,u,g,c,this.collisionDetectionAlgorithm,this.trackedDragContainers)}let y=m?.hasAttribute("disabled")&&m.hasAttribute("data-drag-source");!!l&&!!m&&this.allowDrop(l,m)&&(!m.hasAttribute("disabled")||y)&&l&&m?this.handleDrop(l,m):this.handleInvalidDrop(l),c&&c.remove(),this.dragState.touchCleanup&&this.dragState.touchCleanup(),this.resetDragState(),this.deactivateAllDroppables(),this.saveResponse(),h&&h.removeAttribute("data-drag-source"),this.cacheInteractiveElements();let w=this.checkAllMaxAssociations;typeof w=="function"&&w.call(this)}allowDrop(l,c){return this.trackedDroppables.includes(c)||this.trackedDragContainers.includes(c)}handleInvalidDrop(l){l&&(l.style.opacity="1.0",l.style.pointerEvents="auto")}createDragClone(l,c){let p=l.cloneNode(!0),h=window.getComputedStyle(l);for(let m=0;m<h.length;m++){let y=h[m];p.style.setProperty(y,h.getPropertyValue(y))}return p.style.position="fixed",p.style.width=`${c.width}px`,p.style.height=`${c.height}px`,p.style.zIndex="9999",p.style.pointerEvents="none",p.style.touchAction="none",p.style.userSelect="none",p.style.opacity="0.8",p.removeAttribute("qti-draggable"),p.removeAttribute("tabindex"),p.setAttribute("data-drag-clone","true"),document.body.appendChild(p),p}updateClonePosition(l,c){if(!this.dragState.dragClone)return;let{startOffset:p}=this.dragState,h=l-p.x,m=c-p.y;this.dragState.dragClone.style.left=`${h}px`,this.dragState.dragClone.style.top=`${m}px`}activateAllDroppables(){this.setInternalsState("--dragzone-enabled",!0),this.setInternalsState("--dragzone-active",!0),this.allDropzones.forEach(l=>{l.setAttribute("enabled",""),l.setAttribute("active","")})}deactivateAllDroppables(){this.setInternalsState("--dragzone-enabled",!1),this.setInternalsState("--dragzone-active",!1),this.allDropzones.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active"),l.removeAttribute("hover")})}resetDragState(){if(this.dragState.activationTimeout&&clearTimeout(this.dragState.activationTimeout),this.dragState.touchCleanup)try{this.dragState.touchCleanup()}catch(l){console.warn("\u26A0\uFE0F [Observable DnD] Error during touch cleanup:",l)}this.dragSubscriptions.forEach(l=>{try{l&&typeof l.unsubscribe=="function"&&l.unsubscribe()}catch(c){console.warn("\u26A0\uFE0F [Observable DnD] Error unsubscribing:",c)}}),this.dragSubscriptions=[],this.dragState={dragging:!1,dragSource:null,dragClone:null,startOffset:{x:0,y:0},currentTarget:null,sourceDroppable:null,inputType:null,pointerId:void 0,startedFromTrustedEvent:void 0,touchCleanup:void 0}}setInternalsState(l,c){let p=this._internals;p?.states&&(c?p.states.add(l):p.states.delete(l))}cleanup(){this.subscriptions.forEach(l=>{try{l.unsubscribe()}catch{}}),this.subscriptions=[],this.dragState.dragClone&&this.dragState.dragClone.remove(),this.resetDragState()}}return o};var Il={duration:250,easing:"ease",fill:"both"};function Ns(s){let r=s.getBoundingClientRect();return{left:r.left,top:r.top,width:r.width,height:r.height}}function ut(s){let r=new Map;return s.forEach(e=>{r.set(e,Ns(e))}),r}function kl(s,r){return{deltaX:s.left-r.left,deltaY:s.top-r.top,deltaW:s.width/r.width,deltaH:s.height/r.height}}function Ml(s,r,e={}){let t=Ns(s),{deltaX:i,deltaY:o,deltaW:n,deltaH:a}=kl(r,t);if(i===0&&o===0&&n===1&&a===1)return null;let{duration:l,easing:c,fill:p}={...Il,...e};return s.animate([{transformOrigin:"top left",transform:`translate(${i}px, ${o}px) scale(${n}, ${a})`},{transformOrigin:"top left",transform:"none"}],{duration:l,easing:c,fill:p})}function mt(s,r={}){let e=new Map;return s.forEach((t,i)=>{if(!(i instanceof HTMLElement))return;let o=Ml(i,t,r);o&&e.set(i,o)}),e}var we=(s,r,e,t='slot[part="drags"]',i="closestCornersWithInventoryPriority")=>{let o=ko(s,r,e,t,i);class n extends o{constructor(){super(...arguments);this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this._maxAssociations=0;this._maxAssociationsDefaultApplied=!1;this._response=[];this._dropBlockedDueToMax=!1;this.flipAnimationConfig={duration:200,easing:"ease"};this._enableFlipAnimations=!0;this.autoSizeDropzones=!1}get maxAssociations(){if(!this._maxAssociationsDefaultApplied){this._maxAssociationsDefaultApplied=!0;let c=this.tagName?.toLowerCase()||"";(c==="qti-graphic-gap-match-interaction"||c==="qti-gap-match-interaction")&&!this.hasAttribute("max-associations")&&this._maxAssociations===0&&(this._maxAssociations=1)}return this._maxAssociations}set maxAssociations(c){let p=this._maxAssociations;this._maxAssociations=c,this.requestUpdate("maxAssociations",p)}set disableAnimations(c){this._enableFlipAnimations=!c}get disableAnimations(){return!this._enableFlipAnimations}get enableFlipAnimations(){return this._enableFlipAnimations}get response(){let c=this.getResponse,p=typeof c=="function"?c.call(this):void 0;return(Array.isArray(p)?p:(this.cacheInteractiveElements(),Io(this.trackedDroppables,r))).join(",")}set response(c){if(Array.isArray(c)){let p=this.getValue,h=typeof p=="function"?p.call(this,c):c,m=Array.isArray(h)?h:typeof h=="string"&&h.length>0?[h]:[];this.reset(!1),m.forEach(w=>this.placeResponse(w));let y=this.getResponse,v=typeof y=="function"?y.call(this):void 0;this._response=Array.isArray(v)?v:(this.cacheInteractiveElements(),Io(this.trackedDroppables,r))}else this._response=typeof c=="string"&&c.length>0?[c]:[];this._internals.setFormValue(JSON.stringify(this._response))}afterCache(){this.applyConfiguredChoicesContainerWidth(),this.updateMinDimensionsForDropZones()}applyConfiguredChoicesContainerWidth(){let c=this.dataset.choicesContainerWidth;c&&this.trackedDroppables.forEach(p=>{p.style.width=`${c}px`,p.style.boxSizing="border-box"})}shouldTreatBlockedMaxAsInvalid(){return!0}shouldReturnToInventoryOnInventoryDrop(){return!1}getFirstMessageAttribute(c){for(let h of c){let m=this.getAttribute(h);if(m&&m.trim().length>0)return m}let p=c.map(h=>h.toLowerCase());for(let h of Array.from(this.attributes))if(p.includes(h.name.toLowerCase())&&h.value.trim().length>0)return h.value;return null}allowDrop(c,p){if(this.trackedDragContainers.includes(p))return!0;let h=this.trackedDroppables.includes(p),m=p.hasAttribute("disabled"),y=p.hasAttribute("data-drag-source");return h&&(!m||y)}handleDrop(c,p){let h=this.dragState.dragClone?.getBoundingClientRect();this.dropDraggableInDroppable(c,p,h);let m=c.getAttribute("identifier");m&&this.updateInventoryBasedOnMatchMax(m);let y=Ci(this.trackedDroppables,r);this.maxAssociations>0&&y>this.maxAssociations&&(this._dropBlockedDueToMax=!0,this.validate(),this.reportValidity())}handleInvalidDrop(c){let p=this.dragState.sourceDroppable,h=this.dragState.currentTarget,m=!h,y=this.trackedDragContainers[0]||null;if(!c)return;p&&m&&y&&this.configuration.dragCanBePlacedBack!==!1?this.dropDraggableInDroppable(c,y):p&&this.trackedDroppables.includes(p)?this.dropDraggableInDroppable(c,p):c.style.opacity==="0"&&(this.restoreInventoryItem(c),this.cacheInteractiveElements(),this.checkAllMaxAssociations());let v=Ci(this.trackedDroppables,r),w=this.maxAssociations>0&&v>=this.maxAssociations,f=!!h&&h.hasAttribute("disabled")&&!h.hasAttribute("data-drag-source");this._dropBlockedDueToMax=f&&w,this.validate(),this.reportValidity()}updateMinDimensionsForDropZones(){this.trackedDraggables.length!==0&&Tl(this.trackedDraggables,this.trackedDroppables,this.trackedDragContainers)}restoreInventoryItem(c){c.style.opacity="1.0",c.style.display="",c.style.position="",c.style.pointerEvents="auto"}placeResponse(c){let[p,...h]=c.split(" ").reverse(),m=this.trackedDroppables.find(y=>y.getAttribute("identifier")===p);m&&h.forEach(y=>{if(!y)return;let w=Ao(this.trackedDragContainers,y).at(0)||this.trackedDraggables.find(f=>f.getAttribute("identifier")===y);w&&this.dropDraggableInDroppable(w,m)})}dropDraggableInDroppable(c,p,h){if(this.trackedDragContainers.includes(p)){if(!this.dragState.sourceDroppable){if(this.shouldReturnToInventoryOnInventoryDrop()){this.returnToInventory(c),this._dropBlockedDueToMax=!1,this.validate();return}this.restoreInventoryItem(c),this.cacheInteractiveElements(),this.checkAllMaxAssociations(),this._dropBlockedDueToMax=!1,this.validate();return}let T=c.getAttribute("identifier");c.remove(),T&&this.restoreOriginalInInventory(T),this.cacheInteractiveElements(),this.checkAllMaxAssociations(),this._dropBlockedDueToMax=!1,this.validate();return}let y=parseInt(p.getAttribute("match-max")||"1",10),v=Number.isNaN(y)?1:y,w=v===0||v>1,f=Array.from(p.querySelectorAll('[qti-draggable="true"]')),u=this.enableFlipAnimations&&f.length>0?ut(f):null;if(!w){let T=p.querySelector(r)||p.querySelector('[qti-draggable="true"]');if(T){let E=T.getAttribute("identifier");T.remove(),E&&this.restoreOriginalInInventory(E)}}let g=c.cloneNode(!0);g.removeAttribute("style"),g.removeAttribute("data-keyboard-dragging"),g.setAttribute("qti-draggable","true"),g.setAttribute("tabindex","0"),p.tagName==="SLOT"?g.setAttribute("slot",p.getAttribute("name")||""):p.tagName==="QTI-SIMPLE-ASSOCIABLE-CHOICE"?(g.setAttribute("slot","qti-simple-associable-choice"),p.appendChild(g),p.setAttribute("data-has-drop","true")):p.appendChild(g),u&&this.enableFlipAnimations&&mt(u,this.flipAnimationConfig),h&&this.enableFlipAnimations&&requestAnimationFrame(()=>{let T=g.getBoundingClientRect(),E=h.left-T.left,A=h.top-T.top;(E!==0||A!==0)&&g.animate([{transform:`translate(${E}px, ${A}px)`,opacity:.8},{transform:"translate(0, 0)",opacity:1}],{duration:this.flipAnimationConfig.duration||200,easing:this.flipAnimationConfig.easing||"ease",fill:"both"})});let q=c.getAttribute("identifier");q&&this.updateInventoryBasedOnMatchMax(q),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}returnToInventory(c){let p=c.getAttribute("identifier");p&&(this.trackedDroppables.forEach(h=>{Array.from(h.querySelectorAll(`[identifier="${p}"][qti-draggable="true"]`)).forEach(y=>{y.remove(),h.tagName==="QTI-SIMPLE-ASSOCIABLE-CHOICE"&&h.removeAttribute("data-has-drop")})}),this.restoreOriginalInInventory(p)),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}restoreOriginalInInventory(c){let p=Ao(this.trackedDragContainers,c),h=[];this.trackedDragContainers.forEach(y=>{h.push(...Array.from(y.querySelectorAll('[qti-draggable="true"]')))});let m=this.enableFlipAnimations&&h.length>0?ut(h):null;p.forEach(y=>{y.style.opacity="1.0",y.style.pointerEvents="auto",y.style.display="",y.style.visibility="visible",y.style.setProperty("opacity","1.0","important"),y.style.setProperty("pointer-events","auto","important")}),m&&this.enableFlipAnimations&&mt(m,this.flipAnimationConfig)}updateInventoryBasedOnMatchMax(c){let p=Ao(this.trackedDragContainers,c),h=El(this.trackedDraggables,c),m=this.trackedDroppables.reduce((y,v)=>{let w=v.querySelectorAll(`[identifier="${c}"]`);return y+w.length},0);p.forEach(y=>{h!==0&&m>=h?(y.style.opacity="0.0",y.style.pointerEvents="none"):(y.style.opacity="1.0",y.style.pointerEvents="auto")})}checkAllMaxAssociations(){let c=Ci(this.trackedDroppables,r),p=this.maxAssociations>0&&c>=this.maxAssociations;this.trackedDroppables.forEach(h=>{let m=h.hasAttribute("data-drag-source"),y=Sl(h,r);(p||y)&&!m?h.setAttribute("disabled",""):h.removeAttribute("disabled")})}saveResponse(c){let p=this.getResponse,h=c??(typeof p=="function"?p.call(this):void 0),m=Array.isArray(h)?h:typeof h=="string"?[h]:(this.cacheInteractiveElements(),Io(this.trackedDroppables,r));this._response=m,this._internals.setFormValue(JSON.stringify(this._response)),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:m}})),this.requestUpdate()}reset(c=!0){this.trackedDroppables.forEach(p=>{Array.from(p.querySelectorAll(r)).forEach(m=>m.remove()),p.tagName==="QTI-SIMPLE-ASSOCIABLE-CHOICE"&&p.removeAttribute("data-has-drop")}),this.trackedDraggables.forEach(p=>{let h=p.getAttribute("identifier");h&&this.restoreOriginalInInventory(h)}),this.resetDragState(),this.cacheInteractiveElements(),this._response=[],this._internals.setFormValue(JSON.stringify(this._response)),c&&this.saveResponse()}validate(){let c=Ci(this.trackedDroppables,r),p=this.maxAssociations>0&&c>=this.maxAssociations,h=this.maxAssociations>0&&c>this.maxAssociations,m=this.minAssociations>0&&c<this.minAssociations,y="",v=!0;h?(y=this.getFirstMessageAttribute(["data-max-associations-message","data-max-selections-message"])||this.dataset.maxAssociationsMessage||this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`,v=!1):p&&this._dropBlockedDueToMax&&this.shouldTreatBlockedMaxAsInvalid()?(y=this.getFirstMessageAttribute(["data-max-associations-message","data-max-selections-message"])||this.dataset.maxAssociationsMessage||this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`,v=!1):m?(y=this.getFirstMessageAttribute(["data-min-associations-message","data-min-selections-message"])||this.dataset.minAssociationsMessage||this.dataset.minSelectionsMessage||`Please select at least ${this.minAssociations} ${this.minAssociations===1?"association":"associations"}.`,v=!1,this._dropBlockedDueToMax=!1):this._dropBlockedDueToMax=!1;let w=this.trackedDroppables[0]??this.trackedDraggables[0]??this;return this._internals.setValidity(v?{}:{customError:!0},y,w),v}reportValidity(){let c=this._internals.reportValidity(),p=this.shadowRoot?.querySelector("#validation-message");return p&&(c?(p.textContent="",p.style.display="none"):(p.textContent=this._internals.validationMessage,p.style.setProperty("display","block","important"))),c}}return d([b({attribute:!1,type:Object})],n.prototype,"configuration",2),d([b({type:Number,reflect:!0,attribute:"min-associations"})],n.prototype,"minAssociations",2),d([b({type:Number,reflect:!0,attribute:"max-associations"})],n.prototype,"maxAssociations",1),d([b({type:Boolean,attribute:"disable-animations"})],n.prototype,"disableAnimations",1),d([b({type:Boolean,attribute:"auto-size-dropzones"})],n.prototype,"autoSizeDropzones",2),n};var Mo=class{getInsertPosition(r,e,t,i,o){let n=r.indexOf(t);if(n===-1)return null;let a=t.getBoundingClientRect(),l=(o-a.top)/a.height,p=Math.min(1,Math.max(0,l))>.5;return{index:n,placeAfter:p}}};var Rl=new Mo;var rd={borderStyle:"2px dashed",borderColor:"var(--qti-drop-placeholder, #c1c1c1)",background:"transparent",transitionDuration:150};function Ei(){return{placeholder:null,lastHoverTarget:null,lastPlacement:null,sortContainer:null}}function Ro(s){s.placeholder?.remove(),s.placeholder=null,s.lastHoverTarget=null,s.lastPlacement=null,s.sortContainer=null}function _o(s,r,e={}){let t={...rd,...e},i=document.createElement("div");return i.setAttribute("data-drop-placeholder","true"),i.style.width=`${r.width}px`,i.style.height=`${r.height}px`,i.style.margin=window.getComputedStyle(s).margin,i.style.boxSizing="border-box",i.style.border=`${t.borderStyle} ${t.borderColor}`,i.style.borderRadius=getComputedStyle(s).borderRadius,i.style.background=t.background,i.style.transition=`transform ${t.transitionDuration}ms ease`,i.style.pointerEvents="none",i}function Hs(s,r){for(let e of r)if(e.contains(s)&&e!==s)return e;return null}var Ce=(s,r='[qti-draggable="true"]')=>{class e extends s{constructor(){super(...arguments);this.#e=null;this.#t=Ei();this.#r={hoveredSlot:null,originalPositions:new Map};this.#i=new Set;this.allowReorder=!0;this.sortablePlaceholderConfig={};this.sortableAnimationConfig={duration:150,easing:"ease"}}#e;#t;#r;#i;get isDraggingFromSlot(){return this.#e!==null}findContainingDroppable(o){return Hs(o,this.trackedDroppables)}#o(o){return o.querySelector(r)}#s(o){let n=this.#n(o);return n===0||n>1}#n(o){let n=parseInt(o.getAttribute("match-max")||"1",10);return Number.isNaN(n)?1:n}#a(o){return o.querySelectorAll(r).length}#c(o){let n=this.#n(o);return n===0?!1:this.#a(o)>=n}#d(){this.#r={hoveredSlot:null,originalPositions:new Map}}#l(o){if(!this.#e||o===this.#e){this.#u();return}if(this.#r.hoveredSlot===o)return;this.#u();let n=this.#o(o);if(!n){this.#t.placeholder&&o.appendChild(this.#t.placeholder),this.#r.hoveredSlot=o;return}if(this.#s(o)){if(this.#c(o)){this.#t.placeholder&&this.#e&&this.#e.appendChild(this.#t.placeholder),this.#r.hoveredSlot=null;return}this.#t.placeholder&&o.appendChild(this.#t.placeholder),this.#r.hoveredSlot=o;return}let l=ut([n]);this.#r.originalPositions.set(n,o),this.#t.placeholder&&this.#t.placeholder.parentElement&&this.#t.placeholder.remove(),this.#e.appendChild(n),this.#t.placeholder&&o.appendChild(this.#t.placeholder),this.#r.hoveredSlot=o,mt(l,this.sortableAnimationConfig)}#u(){if(this.#r.originalPositions.size===0&&this.#r.hoveredSlot===null)return;let o=Array.from(this.#r.originalPositions.keys()),n=o.length>0?ut(o):null;for(let[a,l]of this.#r.originalPositions)l.appendChild(a);this.#t.placeholder&&this.#e&&this.#e.appendChild(this.#t.placeholder),n&&mt(n,this.sortableAnimationConfig),this.#r.originalPositions.clear(),this.#r.hoveredSlot=null}initiateDrag(o,n,a,l,...c){this.#e=null,this.#t=Ei(),this.#d();let p=this.findContainingDroppable(o);if(p&&this.allowReorder){this.#e=p,this.#t.sortContainer=p;let m=o.getBoundingClientRect();this.#t.placeholder=_o(o,m,this.sortablePlaceholderConfig);let y=o.getAttribute("slot");y&&this.#t.placeholder.setAttribute("slot",y),this.#t.placeholder.style.visibility="hidden",p.appendChild(this.#t.placeholder),this.trackedDroppables.forEach(v=>{if(v!==p&&v.hasAttribute("disabled")){if(this.#s(v)&&this.#c(v))return;v.removeAttribute("disabled"),this.#i.add(v)}})}let[h]=c;super.initiateDrag(o,n,a,l,h)}cleanupSortableState(o=!0){if(o)for(let[n,a]of this.#r.originalPositions)a.appendChild(n);this.#t.placeholder&&this.#t.placeholder.remove(),Ro(this.#t),this.#i.clear(),this.#e=null,this.#d()}onSortableDragMove(o,n){if(!this.isDraggingFromSlot)return;let a=gr(this.trackedDroppables,o,n,this.dragState.dragClone,this.collisionDetectionAlgorithm);a?this.#l(a):this.#u()}handleDragMove(o,n){Object.getPrototypeOf(e.prototype).handleDragMove?.call(this,o,n),this.onSortableDragMove(o,n)}allowDrop(o,n){return this.isDraggingFromSlot&&this.trackedDroppables.includes(n)?this.#s(n)?!this.#c(n):!0:this.isDraggingFromSlot&&this.trackedDragContainers.includes(n)?!0:super.allowDrop(o,n)}handleDrop(o,n){super.handleDrop(o,n),this.cleanupSortableState(!1)}handleInvalidDrop(o){this.cleanupSortableState(),super.handleInvalidDrop(o)}}return e};var _l=S`
|
|
3934
4024
|
:host {
|
|
3935
4025
|
display: block; /* necessary to calculate scaling position */
|
|
3936
4026
|
}
|
|
@@ -3949,6 +4039,15 @@ div.full-correct-response-inline {
|
|
|
3949
4039
|
background-color: var(--qti-bg-active) !important;
|
|
3950
4040
|
}
|
|
3951
4041
|
|
|
4042
|
+
[part='drop-list'] {
|
|
4043
|
+
display: grid;
|
|
4044
|
+
min-height: 3rem;
|
|
4045
|
+
min-width: 10rem;
|
|
4046
|
+
border: 1px solid var(--qti-border-color, #d1d5db);
|
|
4047
|
+
border-radius: 0.25rem;
|
|
4048
|
+
box-sizing: border-box;
|
|
4049
|
+
}
|
|
4050
|
+
|
|
3952
4051
|
[part='drop-container'] {
|
|
3953
4052
|
display: flex;
|
|
3954
4053
|
flex-direction: column;
|
|
@@ -3969,16 +4068,16 @@ div.full-correct-response-inline {
|
|
|
3969
4068
|
rgb(0 0 0 / 0%) calc(50% + 1px)
|
|
3970
4069
|
);
|
|
3971
4070
|
}
|
|
3972
|
-
`;var
|
|
4071
|
+
`;var ld=we($,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']","pointerWithin"),Si=class extends Ce(ld,'[qti-draggable="true"]'){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}static{this.styles=_l}_registerChoice(e){let t=e.composedPath()[0];if(this.shadowRoot?.contains(t))return;let i=t;this._childrenMap.includes(i)||(this._childrenMap=[...this._childrenMap,i])}getResponse(){let e=Math.ceil(this._childrenMap.length/2),t=[];for(let i=0;i<e;i++){let o=this.shadowRoot?.querySelector(`.dl[identifier="droplist${i}_left"]`),n=this.shadowRoot?.querySelector(`.dl[identifier="droplist${i}_right"]`),a=o?.querySelector('[qti-draggable="true"]')?.getAttribute("identifier"),l=n?.querySelector('[qti-draggable="true"]')?.getAttribute("identifier");a&&l&&t.push(`${a} ${l}`)}return t}getValue(e){return e?.flatMap((t,i)=>{let o=t.split(" ");return o.length!==2?[]:[`${o[0]} droplist${i}_left`,`${o[1]} droplist${i}_right`]})??[]}render(){return x` <slot name="prompt"></slot>
|
|
3973
4072
|
<slot name="qti-simple-associable-choice"></slot>
|
|
3974
4073
|
<div part="drop-container">
|
|
3975
|
-
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>
|
|
4074
|
+
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>x`<div part="associables-container">
|
|
3976
4075
|
<div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
|
|
3977
4076
|
<div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
|
|
3978
4077
|
</div>`)}
|
|
3979
4078
|
|
|
3980
4079
|
<div role="alert" part="message" id="validation-message"></div>
|
|
3981
|
-
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};
|
|
4080
|
+
</div>`}updated(e){super.updated(e),e.has("_childrenMap")&&this.cacheInteractiveElements()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};d([R()],Si.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",Si);var ht=(s,r)=>{class e extends s{constructor(){super(...arguments);this._choiceElements=[];this._mutationObserver=null;this._validationMessageShown=!1;this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(o,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(o,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(o,n){this._determineInputType()}get value(){return Array.isArray(this.response)&&this.response.length===0||this.response===""?null:Array.isArray(this.response)?this.response.join(","):this.response}set value(o){this.maxChoices>1&&(typeof o=="string"||o===null)?this.response=o?o.toString().split(","):[]:this.response=o||""}toggleInternalCorrectResponse(o){let n=this.correctResponse;if(n){let a=Array.isArray(n)?n:[n];this._choiceElements.forEach(l=>{l.internals.states.delete("correct-response"),l.internals.states.delete("incorrect-response"),o&&a.length>0&&(a.includes(l.identifier)?l.internals.states.add("correct-response"):l.internals.states.add("incorrect-response"))})}}toggleCandidateCorrection(o){let n=this.correctResponse;if(!n)return;let a=Array.isArray(n)?n:[n],l=this.response,c=Array.isArray(l)?l:l?[l]:[];this._choiceElements.forEach(p=>{p.internals.states.delete("candidate-correct"),p.internals.states.delete("candidate-incorrect"),o&&c.includes(p.identifier)&&(a.includes(p.identifier)?p.internals.states.add("candidate-correct"):p.internals.states.add("candidate-incorrect"))}),super.toggleCandidateCorrection(o)}connectedCallback(){super.connectedCallback(),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler),this._mutationObserver=new MutationObserver(()=>this._syncChoicesFromDOM()),this._mutationObserver.observe(this,{childList:!0,subtree:!0}),this._syncChoicesFromDOM()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_syncChoicesFromDOM(){let o=new Set(this._choiceElements);this._choiceElements=Array.from(this.querySelectorAll(r)),this._choiceElements.forEach(a=>{o.has(a)||(this.disabled&&(a.disabled=!0),a.readonly=this.readonly,a.internals&&!a.internals.ariaChecked&&(a.internals.ariaChecked="false"),this._setInputType(a))});let n=new Set(this._choiceElements.map(a=>a.identifier));if(Array.isArray(this.response)){let a=this.response.filter(l=>n.has(l));a.length!==this.response.length&&(this.response=a)}else this.response&&!n.has(this.response)&&(this.response="");this._updateChoiceSelection()}validate(){let n=this._choiceElements.filter(p=>this._getChoiceChecked(p)).length,a=!0,l="";this.maxChoices!==0&&n>this.maxChoices?(a=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):n<this.minChoices&&(a=!1,l=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`);let c=this._choiceElements.find(p=>this.contains(p))||this;return this._internals.setValidity(a?{}:{customError:!0},l,c),a}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.setProperty("display","block","important"),this._validationMessageShown=!0)),this._internals.validity.valid}_determineInputType(){this._choiceElements.forEach(o=>{this._setInputType(o)})}async _setInputType(o){if(this._internals.role=this.maxChoices===1?"radiogroup":null,o.internals){let n=this.maxChoices===1?"radio":"checkbox";o.internals.role=n,o.internals.states.delete(n==="radio"?"checkbox":"radio"),o.internals.states.add(n)}}_choiceElementSelectedHandler(o){this._toggleChoiceChecked(o.target),this.maxChoices===1?this._choiceElements.forEach(n=>{n.identifier!==o.detail.identifier&&this._setChoiceChecked(n,!1)}):this.maxChoices!==0&&this._configContext?.disableAfterIfMaxChoicesReached&&(this._choiceElements.filter(a=>this._getChoiceChecked(a)).length>=this.maxChoices?this._choiceElements.forEach(a=>{this._getChoiceChecked(a)||(a.disabled=!0)}):this._choiceElements.forEach(a=>a.disabled=!1)),this._handleChoiceSelection()}_setChoiceChecked(o,n){o.internals?.states&&(n?(o.internals.states.add("--checked"),o.internals.ariaChecked="true"):(o.internals.states.delete("--checked"),o.internals.ariaChecked="false"))}_getChoiceChecked(o){return o.internals.states.has("--checked")}_toggleChoiceChecked(o){let n=this._getChoiceChecked(o);this._setChoiceChecked(o,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.response=this.maxChoices===1?n[0]||"":n,this.validate(),this._validationMessageShown&&(this.reportValidity(),this._internals.validity.valid&&(this._validationMessageShown=!1)),this.saveResponse(this.response)}_updateChoiceSelection(){let o=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(n=>{let a=o.includes(n.identifier);this._setChoiceChecked(n,a)})}}return d([Ht("#validation-message")],e.prototype,"_validationMessageElement",2),d([b({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),d([b({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),d([U("maxChoices")],e.prototype,"_handleMaxChoicesChange",1),d([U("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),d([U("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),d([R()],e.prototype,"response",2),d([U("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),d([R(),P({context:he,subscribe:!0})],e.prototype,"_configContext",2),e};var Ll=(s,r)=>{class e extends s{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"];this._mutationObserver=null}set class(o){o&&(this._classes=o.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(o){super.updated(o),this._addLabels()}connectedCallback(){super.connectedCallback(),this._mutationObserver=new MutationObserver(()=>this._addLabels()),this._mutationObserver.observe(this,{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this._mutationObserver?.disconnect(),this._mutationObserver=null}_addLabels(){let o=this._classes.some(a=>this._allLabels.includes(a)||this._allLabelSuffixes.includes(a)),n=a=>!isNaN(+a);if(o){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,p)=>({el:c,order:n(c.style.order)?+c.style.order:p+1})).sort((c,p)=>c.order-p.order).map(c=>c.el);for(let c=0;c<l.length;c++)l[c].marker=this._getLabel(c+1)}}_getLabel(o){let n=this._classes.filter(c=>this._allLabels.includes(c)).pop(),a=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!n&&a&&(n="qti-labels-upper-alpha");let l="";switch(n){case"qti-labels-decimal":l=`${o}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+o-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+o-1)}`;break}return a==="qti-labels-suffix-period"?l+=".":a==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return d([b({type:String})],e.prototype,"class",1),e};var Pl=S`
|
|
3982
4081
|
:host {
|
|
3983
4082
|
display: block;
|
|
3984
4083
|
}
|
|
@@ -4048,11 +4147,11 @@ div.full-correct-response-inline {
|
|
|
4048
4147
|
:host(.qti-orientation-vertical) ::slotted(qti-simple-choice:nth-child(even)) {
|
|
4049
4148
|
grid-row: auto;
|
|
4050
4149
|
}
|
|
4051
|
-
`;var
|
|
4150
|
+
`;var Ti=class extends Ll(ht($,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}static{this.styles=Pl}#e(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return x`
|
|
4052
4151
|
<slot part="prompt" name="prompt"></slot>
|
|
4053
4152
|
<slot part="slot" @slotchange=${this.#e}></slot>
|
|
4054
4153
|
<div part="message" role="alert" id="validation-message"></div>
|
|
4055
|
-
`}};
|
|
4154
|
+
`}};d([b({type:String})],Ti.prototype,"orientation",2);customElements.define("qti-choice-interaction",Ti);var Dl=S``;var Fs=`
|
|
4056
4155
|
const postToParentWindows = (type, data) => {
|
|
4057
4156
|
window.top.postMessage(data ? { type, data } : { type }, '*');
|
|
4058
4157
|
let w = window.parent;
|
|
@@ -4119,7 +4218,7 @@ window.CES = {
|
|
|
4119
4218
|
},
|
|
4120
4219
|
};
|
|
4121
4220
|
CES.load();
|
|
4122
|
-
`,
|
|
4221
|
+
`,cd=`
|
|
4123
4222
|
(function() {
|
|
4124
4223
|
var blobUrlReceived = null;
|
|
4125
4224
|
|
|
@@ -4163,16 +4262,16 @@ CES.load();
|
|
|
4163
4262
|
requestBlobUrl();
|
|
4164
4263
|
}
|
|
4165
4264
|
})();
|
|
4166
|
-
`,
|
|
4265
|
+
`,Ge=class extends ${constructor(){super();this.#e="";this.#t=null;this.#r=null;this._errorMessage=null;this.#i=null;this.handlePostMessage=this.handlePostMessage.bind(this)}#e;#t;#r;static{this.styles=Dl}#i;connectedCallback(){super.connectedCallback();let e=this.data;if(!e){let i=this.querySelector("object[data]");if(i){e=i.getAttribute("data");let o=i.getAttribute("width"),n=i.getAttribute("height");o&&this.setAttribute("width",o),n&&this.setAttribute("height",n)}}if(!e){this._errorMessage="No manifest path found (neither data attribute nor object child)";return}let t=e.startsWith("http")||e.startsWith("blob")?e:Ki((this.baseItemUrl||"")+"/"+e);this.#t=new URL(t,window.location.href).toString(),fetch(t).then(i=>i.json()).then(i=>{this.manifest=i,this.setupCES()}).catch(i=>{this._errorMessage=i})}async setupCES(){await this.updateComplete;let e=this.shadowRoot?.querySelector("#pciContainer");if(!e){this._errorMessage="pciContainer iframe not found";return}e.getAttribute("src")||e.setAttribute("src","about:blank");let t=e.contentDocument??e.contentWindow?.document??null;if(t||(await new Promise(h=>e.addEventListener("load",()=>h(),{once:!0})),t=e.contentDocument??e.contentWindow?.document??null),!t){this._errorMessage="pciContainer iframe document not available";return}if(!this.manifest.script||this.manifest.script.length===0){this._errorMessage="No script found in manifest";return}if(!this.manifest.style||this.manifest.style.length===0){this._errorMessage="No style found in manifest";return}let i=this.manifest.style[0],o=this.#a(),n=await this.#l(i,o),a=n.url;if(n.baseUrl&&!this.#r&&(this.#r=n.baseUrl),!0){let h="";if(this.manifest.media&&this.manifest.media.length>0){let m=this.manifest.media[0],y=await this.#l(m,o,{returnText:!0});if(h=y.url,y.baseUrl&&!this.#r&&(this.#r=y.baseUrl),y.text){let v=y.text;if(!(v.includes("postToParentWindows")||v.includes("window.CES"))){let u="<script>"+Fs+"</script>",g=v.indexOf("<head>");g!==-1?v=v.slice(0,g+6)+u+v.slice(g+6):v=u+v}let f=new Blob([v],{type:"text/html"});this.#i=URL.createObjectURL(f)}}else{let m=this.data||"manifest.json",y=m.includes("/")?m.substring(0,m.lastIndexOf("/")):"",v=y?`${y}/index.html`:"index.html",w=await this.#l(v,o,{returnText:!0});if(h=w.url,w.baseUrl&&!this.#r&&(this.#r=w.baseUrl),w.text){let f=w.text;if(!(f.includes("postToParentWindows")||f.includes("window.CES"))){let q="<script>"+Fs+"</script>",T=f.indexOf("<head>");T!==-1?f=f.slice(0,T+6)+q+f.slice(T+6):f=q+f}let g=new Blob([f],{type:"text/html"});this.#i=URL.createObjectURL(g)}}if(h&&!this.#i)try{let m=await fetch(h);if(m.ok){let y=await m.text();if(!(y.includes("postToParentWindows")||y.includes("window.CES"))){let f="<script>"+Fs+"</script>",u=y.indexOf("<head>");u!==-1?y=y.slice(0,u+6)+f+y.slice(u+6):y=f+y}let w=new Blob([y],{type:"text/html"});this.#i=URL.createObjectURL(w)}else console.error(`Failed to fetch index.html: ${m.status}`)}catch(m){console.error(`Error fetching index.html: ${m}`)}}let c=`<script>${cd}</script>`;window.addEventListener("message",this.handlePostMessage);let p=`
|
|
4167
4266
|
<!DOCTYPE html>
|
|
4168
4267
|
<html>
|
|
4169
4268
|
<head>
|
|
4170
4269
|
${a?`<link href='${a}' rel="stylesheet" />`:""}
|
|
4171
|
-
${
|
|
4270
|
+
${c}
|
|
4172
4271
|
</head>
|
|
4173
4272
|
<body></body>
|
|
4174
4273
|
</html>
|
|
4175
|
-
`;e.srcdoc=p}#
|
|
4274
|
+
`;e.srcdoc=p}#o(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),i=[...e,...t];for(let o of i){let n=o.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=o.contentDocument||o.contentWindow.document;l&&this.#s(l,i)}catch(l){console.error("Error accessing nested iframe:",l)}}return i.forEach((o,n)=>{i.indexOf(o)!==n&&i.splice(n,1)}),i}#s(e,t=[]){return e.querySelectorAll("iframe").forEach(o=>{t.push(o);let n=o.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=o.contentDocument||o.contentWindow.document;this.#s(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",n)}),t}#n(e,t){window.postMessage({type:e,data:t},"*");let i=this.#o();for(let o of i)o.contentWindow&&o.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:i}=e.data;switch(t){case"setResponse":(i===null||!(Array.isArray(i)&&i.length===1&&i[0]===""))&&(this.#e=i,this.saveResponse(i));break;case"getResponse":{this.#n("responseData",this.#e);break}case"getBlobUrl":{this.#i&&(this.#n("blobUrl",this.#i),e.source&&e.source!==window&&e.source.postMessage({type:"blobUrl",data:this.#i},"*"));break}case"getMedia":{let o=this.#a(),n=this.manifest.media.map(a=>{if(a.startsWith("http")||a.startsWith("blob"))return a;let l=this.#r||o[0];return l?new URL(a,l.endsWith("/")?l:`${l}/`).toString():a});this.#n("mediaData",n);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){if(!this.#e)return!1;if(Array.isArray(this.#e)){if(this.#e.length===0)return!1;for(let e of this.#e)if(e!==""&&e!==null)return!0}return!0}get response(){return this.#e||null}set response(e){if(typeof e=="string")this.#e=e,this.saveResponse(e);else if(Array.isArray(e))this.#e=e;else if(e)throw new Error("Value must be a string or an array of strings")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return x`<iframe
|
|
4176
4275
|
width=${this.getAttribute("width")}
|
|
4177
4276
|
height=${this.getAttribute("height")}
|
|
4178
4277
|
frameborder="0"
|
|
@@ -4180,10 +4279,10 @@ CES.load();
|
|
|
4180
4279
|
id="pciContainer"
|
|
4181
4280
|
>
|
|
4182
4281
|
</iframe>
|
|
4183
|
-
${this._errorMessage&&
|
|
4282
|
+
${this._errorMessage&&x`<div style="color:red">
|
|
4184
4283
|
<h1>Error</h1>
|
|
4185
4284
|
${this._errorMessage}
|
|
4186
|
-
</div>`}`}#a(){let t=[this.#
|
|
4285
|
+
</div>`}`}#a(){let t=[this.#r,this.baseRefUrl,this.baseItemUrl,this.#c()].filter(Boolean).map(o=>new URL(o,window.location.href).toString()),i=this.#d();return i&&t.push(i),[...new Set(t)]}#c(){return this.#t?new URL(".",this.#t).toString():null}#d(){return this.#t?new URL("..",this.#t).toString():null}async#l(e,t,i={}){if(!e)return{url:"",baseUrl:null};if(e.startsWith("http")||e.startsWith("blob"))return{url:e,baseUrl:null};for(let o of t){let n=new URL(o,window.location.href).toString(),a=new URL(e,n.endsWith("/")?n:`${n}/`).toString();try{let l=await fetch(a);if(l.ok){if(i.returnText){let c=await l.text();return{url:a,baseUrl:n,text:c}}return{url:a,baseUrl:n}}}catch{}}return{url:"",baseUrl:null}}};d([b({type:String,attribute:"data"})],Ge.prototype,"data",2),d([b({type:String,attribute:"data-base-item"})],Ge.prototype,"baseItemUrl",2),d([b({type:String,attribute:"data-base-ref"})],Ge.prototype,"baseRefUrl",2),d([b({type:String,attribute:"id"})],Ge.prototype,"id",2),d([R()],Ge.prototype,"_errorMessage",2);customElements.define("qti-custom-interaction",Ge);var $l=S``;var ft=class extends C{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}static{this.styles=$l}render(){return x`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};d([b({type:String,attribute:"response-identifier"})],ft.prototype,"responseIdentifier",2),d([b({reflect:!0,type:Boolean})],ft.prototype,"disabled",2),d([b({type:String,attribute:"count-attempt"})],ft.prototype,"countAttempt",2),d([b({type:String})],ft.prototype,"title",2);customElements.define("qti-end-attempt-interaction",ft);var Ol=S`
|
|
4187
4286
|
/* PK: display host as block, else design will be collapsed */
|
|
4188
4287
|
:host {
|
|
4189
4288
|
display: block;
|
|
@@ -4194,7 +4293,7 @@ CES.load();
|
|
|
4194
4293
|
height: 100%;
|
|
4195
4294
|
border: 0;
|
|
4196
4295
|
}
|
|
4197
|
-
`;var
|
|
4296
|
+
`;var me=class extends ${constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=Ol}handleclassNamesChange(e,t){let i=t.split(" "),o=!1;if(i.forEach(n=>{if(n.startsWith("qti-height-lines-")){let a=n.replace("qti-height-lines-","");this._rows=parseInt(a),o=!0}}),!o&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,i=new RegExp(t);e.checkValidity()&&i.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}toggleCorrectResponse(){}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return x`<slot name="prompt"></slot
|
|
4198
4297
|
><textarea
|
|
4199
4298
|
part="textarea"
|
|
4200
4299
|
name="${this.responseIdentifier}"
|
|
@@ -4205,12 +4304,12 @@ CES.load();
|
|
|
4205
4304
|
@keyup="${this.textChanged}"
|
|
4206
4305
|
@change="${this.textChanged}"
|
|
4207
4306
|
@blur="${e=>{this.reportValidity()}}"
|
|
4208
|
-
placeholder="${
|
|
4307
|
+
placeholder="${Me(this.placeholderText?this.placeholderText:void 0)}"
|
|
4209
4308
|
rows="${this._rows}"
|
|
4210
4309
|
?disabled="${this.disabled}"
|
|
4211
4310
|
?readonly="${this.readonly}"
|
|
4212
4311
|
.value=${this.response}
|
|
4213
|
-
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};
|
|
4312
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};d([R()],me.prototype,"_rows",2),d([b({type:Number,attribute:"expected-length"})],me.prototype,"expectedLength",2),d([b({type:String,attribute:"pattern-mask"})],me.prototype,"patternMask",2),d([b({type:String,attribute:"placeholder-text"})],me.prototype,"placeholderText",2),d([b({type:String,attribute:"data-patternmask-message"})],me.prototype,"dataPatternmaskMessage",2),d([b({type:String,attribute:"class"})],me.prototype,"classNames",2),d([U("classNames")],me.prototype,"handleclassNamesChange",1),d([R()],me.prototype,"response",2),d([U("response",{waitUntilFirstUpdate:!0})],me.prototype,"_handleResponseChange",2);customElements.define("qti-extended-text-interaction",me);var Vl=S`
|
|
4214
4313
|
:host {
|
|
4215
4314
|
display: flex;
|
|
4216
4315
|
align-items: flex-start;
|
|
@@ -4244,10 +4343,10 @@ CES.load();
|
|
|
4244
4343
|
border-radius: 0.3rem;
|
|
4245
4344
|
gap: 0.5rem;
|
|
4246
4345
|
}
|
|
4247
|
-
`;var
|
|
4346
|
+
`;var dd=we($,"qti-gap-text","qti-gap","slot[part='drags']"),Lo=class extends Ce(dd,'[qti-draggable="true"]'){static{this.styles=Vl}render(){return x`<slot name="prompt"> </slot>
|
|
4248
4347
|
<slot part="drags" name="drags"></slot>
|
|
4249
4348
|
<slot part="drops"></slot>
|
|
4250
|
-
<div role="alert" part="message" id="validation-message"></div>`}toggleCorrectResponse(r){let e=this.responseVariable;if(r&&e?.correctResponse){let t=[],i=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];i&&(t=i.map(n=>{let a=n.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(n=>{let a=n.getAttribute("identifier"),l=t.find(p=>p.gap===a)?.text,
|
|
4349
|
+
<div role="alert" part="message" id="validation-message"></div>`}toggleCorrectResponse(r){let e=this.responseVariable;if(r&&e?.correctResponse){let t=[],i=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];i&&(t=i.map(n=>{let a=n.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(n=>{let a=n.getAttribute("identifier"),l=t.find(p=>p.gap===a)?.text,c=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&c){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=c,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",n.insertAdjacentElement("afterend",p)}}else n.nextElementSibling?.classList.contains("correct-option")&&n.nextElementSibling.remove()})}else this.querySelectorAll(".correct-option").forEach(i=>{i.remove()})}#e(r){if(!r.correctResponse)return[];let e=Array.isArray(r.correctResponse)?r.correctResponse:[r.correctResponse],t=[];return e&&e.forEach(i=>{let o=i.split(" ");t.push({source:o[0],target:o[1]})}),t}toggleCandidateCorrection(r){let e=this.responseVariable;if(!e?.correctResponse)return;let t=this.#e(e);Array.from(this.querySelectorAll("qti-gap")).forEach(o=>{let n=o.getAttribute("identifier"),a=t.filter(c=>c.target===n);o.querySelectorAll("qti-gap-text").forEach(c=>{if(c.internals.states.delete("candidate-correct"),c.internals.states.delete("candidate-incorrect"),!r)return;a.find(h=>h.source===c.identifier)?.source!==void 0?c.internals.states.add("candidate-correct"):c.internals.states.add("candidate-incorrect")})})}};customElements.define("qti-gap-match-interaction",Lo);var Nl=(s,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(s[i],i);return t},br=ae(class extends ke{constructor(s){if(super(s),s.type!==tt.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,r,e){let t;e===void 0?e=r:r!==void 0&&(t=r);let i=[],o=[],n=0;for(let a of s)i[n]=t?t(a,n):n,o[n]=e(a,n),n++;return{values:o,keys:i}}render(s,r,e){return this.dt(s,r,e).values}update(s,[r,e,t]){let i=na(s),{values:o,keys:n}=this.dt(r,e,t);if(!Array.isArray(i))return this.ut=n,o;let a=this.ut??=[],l=[],c,p,h=0,m=i.length-1,y=0,v=o.length-1;for(;h<=m&&y<=v;)if(i[h]===null)h++;else if(i[m]===null)m--;else if(a[h]===n[y])l[y]=rt(i[h],o[y]),h++,y++;else if(a[m]===n[v])l[v]=rt(i[m],o[v]),m--,v--;else if(a[h]===n[v])l[v]=rt(i[h],o[v]),Qt(s,l[v+1],i[h]),h++,v--;else if(a[m]===n[y])l[y]=rt(i[m],o[y]),Qt(s,i[h],i[m]),m--,y++;else if(c===void 0&&(c=Nl(n,y,v),p=Nl(a,h,m)),c.has(a[h]))if(c.has(a[m])){let w=p.get(n[y]),f=w!==void 0?i[w]:null;if(f===null){let u=Qt(s,i[h]);rt(u,o[y]),l[y]=u}else l[y]=rt(f,o[y]),Qt(s,i[h],f),i[w]=null;y++}else Ji(i[m]),m--;else Ji(i[h]),h++;for(;y<=v;){let w=Qt(s,l[v+1]);rt(w,o[y]),l[y++]=w}for(;h<=m;){let w=i[h++];w!==null&&Ji(w)}return this.ut=n,sa(s,l),X}});function gt(s,r,e,t){let i=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,o=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(s){case"circle":{if(r.length!==3){console.error("Invalid circle coordinates:",r);return}let[n,a,l]=r,c=n/i*100,p=a/o*100,h=l/i*100,m=l/o*100;t.style.left=c-h+"%",t.style.top=p-m+"%",t.style.width=2*h+"%",t.style.height=2*m+"%",t.style.borderRadius="50%"}break;case"rect":{if(r.length!==4){console.error("Invalid rectangle coordinates:",r);return}let[n,a,l,c]=r,p=n/i*100,h=a/o*100,m=l/i*100,y=c/o*100;t.style.left=p+"%",t.style.top=h+"%",t.style.width=m-p+"%",t.style.height=y-h+"%"}break;case"ellipse":{if(r.length!==4){console.error("Invalid ellipse coordinates:",r);return}let[n,a,l,c]=r,p=n/i*100,h=a/o*100,m=l/i*100,y=c/o*100;t.style.left=p-m+"%",t.style.top=h-y+"%",t.style.width=2*m+"%",t.style.height=2*y+"%",t.style.borderRadius="50%"}break;case"poly":{if(r.length<6||r.length%2!==0){console.error("Invalid polygon coordinates:",r);return}let n=[];for(let u=0;u<r.length;u+=2)n.push({x:r[u],y:r[u+1]});let a=Math.min(...n.map(u=>u.x)),l=Math.max(...n.map(u=>u.x)),c=Math.min(...n.map(u=>u.y)),p=Math.max(...n.map(u=>u.y)),h=a/i*100,m=c/o*100,y=l/i*100,v=p/o*100;t.style.left=h+"%",t.style.top=m+"%",t.style.width=y-h+"%",t.style.height=v-m+"%";let f=n.map(u=>({x:(u.x-a)/(l-a)*100,y:(u.y-c)/(p-c)*100})).map(u=>`${u.x}% ${u.y}%`).join(",");t.style.clipPath=`polygon(${f})`}break;default:console.error(`Unsupported shape: ${s}`);break}}var Hl=S`
|
|
4251
4350
|
slot:not([name='prompt']) {
|
|
4252
4351
|
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4253
4352
|
display: block;
|
|
@@ -4271,14 +4370,14 @@ CES.load();
|
|
|
4271
4370
|
top: 0px;
|
|
4272
4371
|
left: 0px;
|
|
4273
4372
|
}
|
|
4274
|
-
`;var
|
|
4373
|
+
`;var Xe=class extends ${constructor(){super();this.#t=null;this.#r=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.#s)}static{this.styles=Hl}#e;#t;#r;reset(){this._response=[],this._correctLines=[]}validate(){return this.#o().length>0}set response(e){this._response=this.#i(e)}get response(){return this._response}#i(e){return e==null||e===""?[]:Array.isArray(e)?e:[e]}#o(){return this.#i(this._response)}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctLines=[];return}if(!t.correctResponse){console.error("No correct response found for this interaction.");return}let i=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];this._correctLines=i}render(){return x`<slot name="prompt"></slot>
|
|
4275
4374
|
<line-container>
|
|
4276
4375
|
<svg
|
|
4277
|
-
width=${
|
|
4278
|
-
height=${
|
|
4376
|
+
width=${Me(this.grImage[0]?.width)}
|
|
4377
|
+
height=${Me(this.grImage[0]?.height)}
|
|
4279
4378
|
viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
|
|
4280
4379
|
>
|
|
4281
|
-
${
|
|
4380
|
+
${br(this.#o(),e=>e,(e,t)=>Xi`
|
|
4282
4381
|
<line
|
|
4283
4382
|
part="line"
|
|
4284
4383
|
x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
|
|
@@ -4287,10 +4386,10 @@ CES.load();
|
|
|
4287
4386
|
y2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.top)}
|
|
4288
4387
|
stroke="red"
|
|
4289
4388
|
stroke-width="3"
|
|
4290
|
-
@click=${i=>{i.stopPropagation(),this._response=this._response.filter((
|
|
4389
|
+
@click=${i=>{i.stopPropagation(),this._response=this._response.filter((o,n)=>n!==t),this.saveResponse(this.response)}}
|
|
4291
4390
|
/>
|
|
4292
4391
|
`)}
|
|
4293
|
-
${
|
|
4392
|
+
${br(this._correctLines||[],e=>e,(e,t)=>Xi`
|
|
4294
4393
|
<line
|
|
4295
4394
|
part="correct-line"
|
|
4296
4395
|
x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
|
|
@@ -4302,7 +4401,7 @@ CES.load();
|
|
|
4302
4401
|
stroke-dasharray="5,5"
|
|
4303
4402
|
/>
|
|
4304
4403
|
`)}
|
|
4305
|
-
${this.#t&&
|
|
4404
|
+
${this.#t&&Xi`<line
|
|
4306
4405
|
part="point"
|
|
4307
4406
|
x1=${this.startCoord.x}
|
|
4308
4407
|
y1=${this.startCoord.y}
|
|
@@ -4314,7 +4413,7 @@ CES.load();
|
|
|
4314
4413
|
</svg>
|
|
4315
4414
|
<slot></slot>
|
|
4316
4415
|
</line-container>
|
|
4317
|
-
<div role="alert" part="message" id="validation-message"></div>`}#
|
|
4416
|
+
<div role="alert" part="message" id="validation-message"></div>`}#s(e){let t=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(l=>parseInt(l));gt(n,a,t,i)}firstUpdated(){this.#e=this.querySelectorAll("qti-associable-hotspot"),this.addEventListener("mousemove",e=>{let t=this.grImage[0];if(!t)return;let i=t.getBoundingClientRect();this.mouseCoord={x:e.clientX-i.left,y:e.clientY-i.top}}),this.#e.forEach(e=>{e.style.left=e.getAttribute("coords").split(",")[0]+"px",e.style.top=e.getAttribute("coords").split(",")[1]+"px",e.addEventListener("click",t=>{this.#t?this.#r||(this.#r=t.target,this._response=this.#o(),this._response=[...this._response,`${this.#t.getAttribute("identifier")} ${this.#r.getAttribute("identifier")}`],this.saveResponse(this.response),this.#t=null,this.#r=null):(this.#t=t.target,this.startCoord={x:parseInt(this.#t.getAttribute("coords").split(",")[0]),y:parseInt(this.#t.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#s)}};d([R()],Xe.prototype,"_correctLines",2),d([R()],Xe.prototype,"startCoord",2),d([R()],Xe.prototype,"mouseCoord",2),d([Un({selector:"img"})],Xe.prototype,"grImage",2),d([R()],Xe.prototype,"_response",2);customElements.define("qti-graphic-associate-interaction",Xe);var Fl=S`
|
|
4318
4417
|
:host {
|
|
4319
4418
|
display: flex;
|
|
4320
4419
|
align-items: flex-start;
|
|
@@ -4368,10 +4467,10 @@ CES.load();
|
|
|
4368
4467
|
user-select: none;
|
|
4369
4468
|
pointer-events: none;
|
|
4370
4469
|
}
|
|
4371
|
-
`;var
|
|
4470
|
+
`;var pd=we($,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"),Po=class extends Ce(pd,'[qti-draggable="true"]'){static{this.styles=Fl}render(){return x` <slot name="prompt"></slot>
|
|
4372
4471
|
<slot part="image"></slot>
|
|
4373
4472
|
<slot part="drags" name="drags" class="hover-border"></slot>
|
|
4374
|
-
<div role="alert" part="message" id="validation-message"></div>`}#e(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),
|
|
4473
|
+
<div role="alert" part="message" id="validation-message"></div>`}shouldReturnToInventoryOnInventoryDrop(){return!0}#e(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),o=t.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,a,l]=o;e.style.left=n-l+"px",e.style.top=a-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[n,a,l,c]=o;e.style.left=n+"px",e.style.top=a+"px",e.style.width=l-n+"px",e.style.height=c-a+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.#e)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#e)}};customElements.define("qti-graphic-gap-match-interaction",Po);var Bl=S`
|
|
4375
4474
|
slot:not([name='prompt']) {
|
|
4376
4475
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4377
4476
|
display: block;
|
|
@@ -4382,11 +4481,11 @@ CES.load();
|
|
|
4382
4481
|
pointer-events: none;
|
|
4383
4482
|
user-select: none;
|
|
4384
4483
|
}
|
|
4385
|
-
`;var
|
|
4484
|
+
`;var Do=class extends ht($,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}static{this.styles=Bl}render(){return x`
|
|
4386
4485
|
<slot name="prompt"></slot>
|
|
4387
4486
|
<slot></slot>
|
|
4388
4487
|
<div role="alert" part="message" id="validation-message"></div>
|
|
4389
|
-
`}#e(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let
|
|
4488
|
+
`}#e(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let n=this._choiceElements.filter(a=>a.order!=null).length;if(n>=o){this.choiceOrdering=!1;return}i.order=n+1}else{let n=i.order;i.order=null,this._choiceElements.forEach(a=>{a.order!=null&&a.order>n&&a.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e){let t=this.responseVariable,i=this._choiceElements;for(let o of i)if(e&&t?.correctResponse?.length>0&&Array.isArray(t.correctResponse)){let n=t.correctResponse.findIndex(a=>a===o.identifier);n>=0?o.orderCorrect=n+1:o.orderCorrect=null}else o.orderCorrect=null}#t(e){let t=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(l=>parseInt(l));gt(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.#e),this.addEventListener("register-qti-hotspot-choice",this.#t)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.#e),this.removeEventListener("register-qti-hotspot-choice",this.#t)}};customElements.define("qti-graphic-order-interaction",Do);var Ul=S`
|
|
4390
4489
|
slot:not([name='prompt']) {
|
|
4391
4490
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4392
4491
|
display: inline-block;
|
|
@@ -4400,11 +4499,11 @@ CES.load();
|
|
|
4400
4499
|
user-select: none;
|
|
4401
4500
|
/* width:100%; */
|
|
4402
4501
|
}
|
|
4403
|
-
`;var
|
|
4502
|
+
`;var $o=class extends ht($,"qti-hotspot-choice"){static{this.styles=Ul}render(){return x`
|
|
4404
4503
|
<slot name="prompt"></slot>
|
|
4405
4504
|
<slot></slot>
|
|
4406
|
-
`}#e=null;#t(r){return this.#e||(r.naturalWidth>0&&r.naturalHeight>0?this.#e=Promise.resolve(r):this.#e=new Promise(e=>{let t=()=>{r.removeEventListener("load",t),e(r)};r.addEventListener("load",t)})),this.#e}async#
|
|
4407
|
-
<div part="message" role="alert" id="validation-message"></div>`}get#e(){let e={"qti-input-control-hidden":!0};return this.class&&this.class.split(" ").forEach(t=>{t.trim()&&(e[t.trim()]=!0)}),e}connectedCallback(){super.connectedCallback(),this.#t()}updated(e){super.updated(e),this.#t()}#t(){let e=Object.keys(this.#e).join(" ");this.className=e}};
|
|
4505
|
+
`}#e=null;#t(r){return this.#e||(r.naturalWidth>0&&r.naturalHeight>0?this.#e=Promise.resolve(r):this.#e=new Promise(e=>{let t=()=>{r.removeEventListener("load",t),e(r)};r.addEventListener("load",t)})),this.#e}async#r(r){let e=this.querySelector("img"),t=r.target,i=t.getAttribute("coords"),o=t.getAttribute("shape"),n=i.split(",").map(l=>parseInt(l)),a=await this.#t(e);gt(o,n,a,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.#r)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.#r)}};customElements.define("qti-hotspot-interaction",$o);var zl=S``;var Ai=class extends ht($,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>x`<slot></slot>
|
|
4506
|
+
<div part="message" role="alert" id="validation-message"></div>`}static{this.styles=zl}get#e(){let e={"qti-input-control-hidden":!0};return this.class&&this.class.split(" ").forEach(t=>{t.trim()&&(e[t.trim()]=!0)}),e}connectedCallback(){super.connectedCallback(),this.#t()}updated(e){super.updated(e),this.#t()}#t(){let e=Object.keys(this.#e).join(" ");this.className=e}};d([b({type:String,reflect:!0})],Ai.prototype,"class",2);customElements.define("qti-hottext-interaction",Ai);var Ii=class extends ke{constructor(r){if(super(r),this.it=N,r.type!==tt.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===N||r==null)return this._t=void 0,this.it=r;if(r===X)return r;if(typeof r!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;let e=[r];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};Ii.directiveName="unsafeHTML",Ii.resultType=1;var Ot=ae(Ii);var ud=S`
|
|
4408
4507
|
:host {
|
|
4409
4508
|
display: inline-block;
|
|
4410
4509
|
vertical-align: baseline;
|
|
@@ -4460,11 +4559,11 @@ CES.load();
|
|
|
4460
4559
|
display: inline-block;
|
|
4461
4560
|
vertical-align: middle;
|
|
4462
4561
|
}
|
|
4463
|
-
`,
|
|
4562
|
+
`,jl=ud;var md=0,bt=class extends ${constructor(){super();this.options=[];this.correctOption="";this._dropdownOpen=!1;this._slotObserver=null;this._menuId=`qti-inline-choice-menu-${md++}`;this.#s=e=>{(this.disabled||this.readonly)&&e.preventDefault()};this.#n=e=>{this.disabled||this.readonly||(e.key==="ArrowDown"||e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.#o(!0))};this.#a=e=>{let i=e.newState==="open";this._dropdownOpen!==i&&(this._dropdownOpen=i)};this.#c=e=>{if(!this._dropdownOpen)return;if(e.key==="Escape"){e.preventDefault(),this.#o(!1),this.#d();return}let t=this.#v(),i=this.renderRoot.activeElement,o=this.#l(),n=i||(o instanceof HTMLElement&&this.#u(o)?o:null),a=t.findIndex(l=>l===n);if(e.key==="ArrowDown"&&(e.preventDefault(),t[Math.min(t.length-1,Math.max(0,a+1))]?.focus()),e.key==="ArrowUp"&&(e.preventDefault(),t[Math.max(0,a-1)]?.focus()),e.key==="Enter"||e.key===" "){if(!n)return;if(e.preventDefault(),n instanceof HTMLButtonElement)n.click();else{let l=n.getAttribute("identifier")??"";this.#i(l)}}};this.#b=()=>{this.#t()};this.#f=e=>{if(this.disabled||this.readonly)return;let i=e.currentTarget.getAttribute("identifier")??"";this.#i(i)};this.internals.role="listbox"}get isInline(){return!0}static get styles(){return[jl]}render(){let e=this.#e();return x`
|
|
4464
4563
|
<button
|
|
4465
4564
|
part="trigger"
|
|
4466
4565
|
type="button"
|
|
4467
|
-
@click=${this.#
|
|
4566
|
+
@click=${this.#s}
|
|
4468
4567
|
@keydown=${this.#n}
|
|
4469
4568
|
aria-haspopup="listbox"
|
|
4470
4569
|
aria-expanded="${this._dropdownOpen?"true":"false"}"
|
|
@@ -4474,7 +4573,7 @@ CES.load();
|
|
|
4474
4573
|
?disabled="${this.disabled}"
|
|
4475
4574
|
data-readonly="${this.readonly?"true":"false"}"
|
|
4476
4575
|
>
|
|
4477
|
-
<span part="value">${
|
|
4576
|
+
<span part="value">${Ot(e?.textContent??"")}</span>
|
|
4478
4577
|
<span part="${this._dropdownOpen?"dropdown-icon dropdown-icon-open":"dropdown-icon"}" aria-hidden="true"
|
|
4479
4578
|
>▾</span
|
|
4480
4579
|
>
|
|
@@ -4485,21 +4584,21 @@ CES.load();
|
|
|
4485
4584
|
role="listbox"
|
|
4486
4585
|
popover="auto"
|
|
4487
4586
|
@toggle=${this.#a}
|
|
4488
|
-
@keydown=${this.#
|
|
4587
|
+
@keydown=${this.#c}
|
|
4489
4588
|
>
|
|
4490
4589
|
<button
|
|
4491
4590
|
part="${this.options[0]?.selected?"option option-prompt option-selected":"option option-prompt"}"
|
|
4492
4591
|
type="button"
|
|
4493
4592
|
role="option"
|
|
4494
4593
|
aria-selected="${this.options[0]?.selected?"true":"false"}"
|
|
4495
|
-
@click=${()=>this.#
|
|
4594
|
+
@click=${()=>this.#i("")}
|
|
4496
4595
|
>
|
|
4497
|
-
<span part="option-content">${
|
|
4596
|
+
<span part="option-content">${Ot(this.options[0]?.textContent??"")}</span>
|
|
4498
4597
|
</button>
|
|
4499
4598
|
<slot @slotchange=${this.#b}></slot>
|
|
4500
4599
|
</div>
|
|
4501
|
-
${
|
|
4502
|
-
`}async connectedCallback(){super.connectedCallback(),this.#t(),this.#g(),await this.updateComplete,this.#
|
|
4600
|
+
${Ot(this.correctOption)}
|
|
4601
|
+
`}async connectedCallback(){super.connectedCallback(),this.#t(),this.#g(),await this.updateComplete,this.#r()}disconnectedCallback(){super.disconnectedCallback(),this.#y(),this._slotObserver?.disconnect(),this._slotObserver=null}willUpdate(e){e.has("configContext")&&this.#t()}updated(e){e.has("_dropdownOpen")&&this._dropdownOpen&&(this.#p(),this.#v()[0]?.focus()),(e.has("disabled")||e.has("readonly"))&&this.#p()}#e(){return this.options.find(e=>e.selected)??this.options[0]}#t(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataset.prompt||this.configContext?.inlineChoicePrompt||"select",i=this.options.find(a=>a.selected)?.value??"",o=[{textContent:t,value:"",selected:i===""},...e.map(a=>{let l=a.getAttribute("identifier")??"";return{textContent:a.innerHTML,value:l,selected:l!==""&&l===i}})],n=o.some(a=>a.selected);this.options=n?o:o.map((a,l)=>({...a,selected:l===0})),this.#p(),this.#r()}#r(){let e=this.#h(),t=this.renderRoot.querySelector('button[part="trigger"]');if(!e||!t)return;let i=t.querySelector('span[part~="dropdown-icon"]'),o=i?i.getBoundingClientRect().width:0,n=e.matches(":popover-open"),a=e.style.visibility,l=e.style.display;n||(e.style.visibility="hidden",e.style.display="block",e.showPopover());let c=e.getBoundingClientRect().width,p=Math.max(c,e.scrollWidth);n||(e.hidePopover(),e.style.visibility=a,e.style.display=l),t.style.width=`${p+o}px`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.#o(!1),this.options=this.options.map((e,t)=>({...e,selected:t===0})),this.#p()}set response(e){let t=e??"";this.options=this.options.map(i=>({...i,selected:i.value===t})),this.#p()}get response(){let e=this.options.find(t=>t.selected)?.value??"";return e===""?null:e}toggleInternalCorrectResponse(e){super.toggleInternalCorrectResponse(e);let t=this.correctResponse;if(!e||!t){this.correctOption="";return}let i=this.options.find(o=>t===o.value);if(!i){this.correctOption="";return}this.correctOption=`<span part="correct-option" style="border:1px solid var(--qti-correct); border-radius:4px; padding: 2px 4px; margin: 4px; display:inline-block">${i.textContent}</span>`}#i(e){this.options=this.options.map(t=>({...t,selected:t.value===e})),this.#p(),this.saveResponse(e),this.#o(!1)}#o(e){let t=this.#h();if(t){if(e){t.matches(":popover-open")||t.showPopover();return}t.matches(":popover-open")&&t.hidePopover()}}#s;#n;#a;#c;#d(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}#l(){let e=document.activeElement;for(;e&&e instanceof HTMLElement&&e.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}#u(e){return e===this||this.contains(e)||this.renderRoot.contains(e)}#h(){return this.renderRoot.querySelector(`#${this._menuId}`)}#g(){this._slotObserver=new MutationObserver(()=>this.#t()),this._slotObserver.observe(this,{childList:!0,subtree:!0})}#b;#f;#y(){let e=Array.from(this.querySelectorAll("qti-inline-choice"));for(let t of e)t.removeEventListener("click",this.#f),t.removeAttribute("tabindex"),t.internals.role=null,t.internals.ariaSelected=null,t.internals.ariaChecked="false",t.internals.states.delete("--checked")}async#p(){await this.updateComplete;let e=this.options.find(i=>i.selected)?.value??"",t=Array.from(this.querySelectorAll("qti-inline-choice"));for(let i of t){let n=(i.getAttribute("identifier")??"")===e;i.removeEventListener("click",this.#f),i.addEventListener("click",this.#f),i.disabled=this.disabled,i.readonly=this.readonly,i.internals.role="option",i.internals.ariaSelected=n?"true":"false",i.internals.ariaChecked=n?"true":"false",i.internals.ariaDisabled=this.disabled?"true":"false",i.internals.ariaReadOnly=this.readonly?"true":"false",i.removeAttribute("aria-disabled"),i.removeAttribute("aria-readonly"),n?i.internals.states.add("--checked"):i.internals.states.delete("--checked"),i.tabIndex=-1}}#v(){let e=this.renderRoot.querySelector('button[part~="option"]'),t=Array.from(this.querySelectorAll("qti-inline-choice"));return[...e?[e]:[],...t]}};d([R()],bt.prototype,"options",2),d([R()],bt.prototype,"correctOption",2),d([R()],bt.prototype,"_dropdownOpen",2),d([P({context:he,subscribe:!0}),b({attribute:!1})],bt.prototype,"configContext",2);customElements.define("qti-inline-choice-interaction",bt);var Wl=S`
|
|
4503
4602
|
slot:not([hidden]) {
|
|
4504
4603
|
/* slot where the */
|
|
4505
4604
|
display: flex;
|
|
@@ -4525,34 +4624,34 @@ CES.load();
|
|
|
4525
4624
|
/* Make sure the drag and drop container slots have the same width */
|
|
4526
4625
|
flex: 1;
|
|
4527
4626
|
}
|
|
4528
|
-
`;var
|
|
4627
|
+
`;var hd=we($,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"),vt=class extends Ce(hd,'[qti-draggable="true"]'){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=null;this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,o=t.name,n=t.type;t.checked?(this.response?this.response.indexOf(i)===-1&&(n==="radio"&&(this.response=(this.response||[]).filter(a=>a.indexOf(o)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=t):(this.response=(this.response||[]).filter(a=>a!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.response)?[...this.response]:this.response}}))}}static{this.styles=Wl}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.sourceChoices=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.targetChoices=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}#e(e){if(!e.correctResponse)return[];let t=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse],i=[];return t&&t.forEach(o=>{let n=o.split(" ");i.push({source:n[0],target:n[1]})}),i}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!t?.correctResponse){this.querySelectorAll(".correct-option").forEach(o=>o.remove());return}let i=this.#e(t);this.class.split(" ").includes("qti-match-tabular")?e?this.correctOptions=i||[]:this.correctOptions=null:e?(this.querySelectorAll(".correct-option").forEach(o=>o.remove()),this.targetChoices.forEach(o=>{let n=o.getAttribute("identifier"),a=i.find(l=>l.target===n);if(a?.source){let c=this.querySelector(`qti-simple-associable-choice[identifier="${a.source}"]`)?.textContent?.trim();if(c&&!o.previousElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=c,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",o.insertAdjacentElement("beforebegin",p)}}})):this.correctOptions=null}toggleCandidateCorrection(e){let t=this.responseVariable;if(!t?.correctResponse)return;let i=this.#e(t);this.targetChoices.forEach(o=>{let n=o.getAttribute("identifier"),a=i.filter(c=>c.target===n);o.querySelectorAll("qti-simple-associable-choice").forEach(c=>{if(c.internals.states.delete("candidate-correct"),c.internals.states.delete("candidate-incorrect"),!e)return;a.find(h=>h.source===c.identifier)?.source!==void 0?c.internals.states.add("candidate-correct"):c.internals.states.add("candidate-incorrect")})})}render(){let e=this.class.split(" ").includes("qti-match-tabular"),t=this.correctOptions!==null;return x`
|
|
4529
4628
|
<slot name="prompt"></slot>
|
|
4530
4629
|
<slot ?hidden=${e}></slot>
|
|
4531
4630
|
|
|
4532
|
-
${e?
|
|
4631
|
+
${e?x`
|
|
4533
4632
|
<table part="table">
|
|
4534
4633
|
<tr part="r-header">
|
|
4535
4634
|
<td></td>
|
|
4536
|
-
${this.targetChoices.map(i=>
|
|
4635
|
+
${this.targetChoices.map(i=>x`<th part="r-header">${Ot(i.innerHTML)}</th>`)}
|
|
4537
4636
|
</tr>
|
|
4538
4637
|
|
|
4539
|
-
${this.sourceChoices.map(i=>
|
|
4540
|
-
<td part="c-header">${
|
|
4541
|
-
${this.targetChoices.map(
|
|
4638
|
+
${this.sourceChoices.map(i=>x`<tr part="row">
|
|
4639
|
+
<td part="c-header">${Ot(i.innerHTML)}</td>
|
|
4640
|
+
${this.targetChoices.map(o=>{let n=i.getAttribute("identifier"),a=o.getAttribute("identifier"),l=`${n} ${a}`,c=(this.response||[]).filter(w=>w.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,h=i.matchMax===1?"radio":"checkbox",m=!!this.correctOptions?.find(w=>w.source===n&&w.target===a),y=h==="radio"?`rb ${p?"rb-checked":""} ${t?m?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?m?"cb-correct":"cb-incorrect":""}`,v=this.correctOptions?.length>0?!0:i.matchMax===1?!1:i.matchMax!==0&&c>=i.matchMax&&!p;return x`<td part="input-cell">
|
|
4542
4641
|
<div
|
|
4543
4642
|
class="input-container"
|
|
4544
4643
|
style="position: relative; width: 24px; height: 24px; margin: 0 auto;"
|
|
4545
4644
|
>
|
|
4546
4645
|
<input
|
|
4547
|
-
type=${
|
|
4548
|
-
part=${
|
|
4646
|
+
type=${h}
|
|
4647
|
+
part=${y}
|
|
4549
4648
|
name=${n}
|
|
4550
4649
|
value=${l}
|
|
4551
4650
|
.disabled=${v}
|
|
4552
|
-
@change=${
|
|
4553
|
-
@click=${
|
|
4651
|
+
@change=${w=>this.handleRadioChange(w)}
|
|
4652
|
+
@click=${w=>i.matchMax===1?this.handleRadioClick(w):null}
|
|
4554
4653
|
/>
|
|
4555
|
-
${
|
|
4654
|
+
${h==="checkbox"&&p?x`
|
|
4556
4655
|
<svg
|
|
4557
4656
|
part="checkmark"
|
|
4558
4657
|
viewBox="0 0 24 24"
|
|
@@ -4565,11 +4664,11 @@ CES.load();
|
|
|
4565
4664
|
</td>`})}
|
|
4566
4665
|
</tr>`)}
|
|
4567
4666
|
</table>
|
|
4568
|
-
`:
|
|
4667
|
+
`:N}
|
|
4569
4668
|
|
|
4570
4669
|
<div role="alert" part="message" id="validation-message"></div>
|
|
4571
|
-
`}};
|
|
4572
|
-
<slot></slot>`}constructor(){super()}connectedCallback(){super.connectedCallback();let r=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");r&&r.addEventListener("ended",()=>{this.#e++,this.saveResponse(this.value)})}};customElements.define("qti-media-interaction",
|
|
4670
|
+
`}};d([b({type:String})],vt.prototype,"class",2),d([R()],vt.prototype,"_response",2),d([b({type:String,attribute:"response-identifier"})],vt.prototype,"responseIdentifier",2),d([R()],vt.prototype,"correctOptions",2);customElements.define("qti-match-interaction",vt);var Gl=S``;var Oo=class extends ${static{this.styles=Gl}#e=null;reset(){this.#e=null}validate(){return!0}get response(){return this.#e?this.#e.toString():null}set response(r){if(r)if(!isNaN(parseInt(r?.toString())))this.#e=parseInt(r.toString());else throw new Error(`Value must be a number ${r}`)}static get properties(){return{...$.properties,step:{type:Number,attribute:"step",default:10}}}render(){return x` <slot name="prompt"></slot>
|
|
4671
|
+
<slot></slot>`}constructor(){super()}connectedCallback(){super.connectedCallback();let r=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");r&&r.addEventListener("ended",()=>{this.#e++,this.saveResponse(this.value)})}};customElements.define("qti-media-interaction",Oo);var Xl=S`
|
|
4573
4672
|
[part='drags'] {
|
|
4574
4673
|
display: flex;
|
|
4575
4674
|
align-items: flex-start;
|
|
@@ -4611,6 +4710,24 @@ CES.load();
|
|
|
4611
4710
|
background-color: var(--qti-bg-active) !important;
|
|
4612
4711
|
}
|
|
4613
4712
|
|
|
4713
|
+
[part='drop-list'][data-cross-slot-target] {
|
|
4714
|
+
border-color: var(--qti-border-active, #0066cc) !important;
|
|
4715
|
+
background-color: var(--qti-bg-active, rgba(0, 102, 204, 0.1)) !important;
|
|
4716
|
+
outline: 2px dashed var(--qti-border-active, #0066cc);
|
|
4717
|
+
outline-offset: -2px;
|
|
4718
|
+
}
|
|
4719
|
+
|
|
4720
|
+
/* Candidate correction colors for choices placed inside drop-lists. */
|
|
4721
|
+
drop-list [qti-draggable='true']:state(candidate-correct),
|
|
4722
|
+
[part='qti-simple-choice']:state(candidate-correct) {
|
|
4723
|
+
background-color: var(--qti-correct) !important;
|
|
4724
|
+
}
|
|
4725
|
+
|
|
4726
|
+
drop-list [qti-draggable='true']:state(candidate-incorrect),
|
|
4727
|
+
[part='qti-simple-choice']:state(candidate-incorrect) {
|
|
4728
|
+
background-color: var(--qti-incorrect) !important;
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4614
4731
|
[part='container'] {
|
|
4615
4732
|
display: flex;
|
|
4616
4733
|
gap: 0.5rem;
|
|
@@ -4627,24 +4744,30 @@ CES.load();
|
|
|
4627
4744
|
:host(.qti-choices-right) [part='container'] {
|
|
4628
4745
|
flex-direction: row-reverse;
|
|
4629
4746
|
}
|
|
4630
|
-
`;var
|
|
4747
|
+
`;var fd=we($,"qti-simple-choice","drop-list","slot[part='drags']"),yt=class extends Ce(fd,'[qti-draggable="true"]'){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}static{this.styles=Xl}#e(){let e=this.responseVariable;return e?.correctResponse?(Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse]).map((i,o)=>{let[n,a]=i.split(" "),l=a?.startsWith("droplist")?parseInt(a.replace("droplist",""),10):o,c=Number.isNaN(l)?o:l;return{identifier:n,dropIndex:c}}).filter(i=>!!i.identifier):[]}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),x` <slot name="prompt"> </slot>
|
|
4631
4748
|
<div part="container">
|
|
4632
4749
|
<slot part="drags"> </slot>
|
|
4633
4750
|
<div part="drops">
|
|
4634
|
-
${[...Array(this.nrChoices)].map((t,i)=>
|
|
4751
|
+
${[...Array(this.nrChoices)].map((t,i)=>x`<drop-list role="region" part="drop-list" identifier="droplist${i}"></drop-list>`)}
|
|
4635
4752
|
</div>
|
|
4636
|
-
</div>`}toggleCorrectResponse(e){
|
|
4753
|
+
</div>`}toggleCorrectResponse(e){if(this.shadowRoot.querySelectorAll(".correct-option").forEach(t=>t.remove()),e){let t=this.#e(),i=new Map;Array.from(this.querySelectorAll("qti-simple-choice")).forEach(o=>{let n=o.getAttribute("identifier"),a=o.textContent?.trim();n&&a&&i.set(n,a)}),t.forEach(({identifier:o,dropIndex:n})=>{let a=i.get(o);if(!a)return;let l=this.shadowRoot.querySelector(`drop-list[identifier="droplist${n}"]`);if(!l)return;let c=document.createElement("span");c.classList.add("correct-option"),c.textContent=a,c.style.border="1px solid var(--qti-correct)",c.style.borderRadius="4px",c.style.padding="2px 4px",c.style.display="inline-block",c.style.marginTop="4px",l.insertAdjacentElement("afterend",c)})}}toggleCandidateCorrection(e){if(super.toggleCandidateCorrection(e),Array.from(this.shadowRoot.querySelectorAll('drop-list [qti-draggable="true"]')).forEach(a=>{a.internals.states.delete("candidate-correct"),a.internals.states.delete("candidate-incorrect")}),!e)return;let i=this.#e(),o=new Map;i.forEach(a=>o.set(a.dropIndex,a.identifier)),Array.from(this.shadowRoot.querySelectorAll("drop-list")).forEach((a,l)=>{let c=a.querySelector('[qti-draggable="true"]');if(!c)return;let p=o.get(l),h=c.getAttribute("identifier");p&&h===p?c.internals.states.add("candidate-correct"):c.internals.states.add("candidate-incorrect")})}getValue(e){return e?.map((t,i)=>`${t} droplist${i}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let o=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(o).map(a=>a.getAttribute("identifier"))].join(" ")})}shouldTreatBlockedMaxAsInvalid(){return!1}async firstUpdated(){super.firstUpdated(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};d([R()],yt.prototype,"nrChoices",2),d([R()],yt.prototype,"correctResponses",2),d([R()],yt.prototype,"showCorrectResponses",2),d([b({type:String})],yt.prototype,"orientation",2);customElements.define("qti-order-interaction",yt);var Ql=S`
|
|
4754
|
+
:host {
|
|
4755
|
+
display: block;
|
|
4756
|
+
width: 100%;
|
|
4757
|
+
min-height: 50px;
|
|
4758
|
+
}
|
|
4759
|
+
|
|
4637
4760
|
::slotted(qti-interaction-markup) {
|
|
4638
4761
|
display: none;
|
|
4639
4762
|
}
|
|
4640
|
-
`;var
|
|
4763
|
+
`;var Z=class extends ${constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._iframeMessageOrigin=null;this._iframeObjectUrl=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useDefaultPaths=!1;this._errorMessage=null;this.response=null;this.#t=null;this.#r=null;this.#i=null;this.#o="";this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe")&&!(!this.iframe?.contentWindow||e.source!==this.iframe.contentWindow)&&!(t.responseIdentifier&&t.responseIdentifier!==this.responseIdentifier)){if(this._iframeMessageOrigin===null)this._iframeMessageOrigin=e.origin;else if(e.origin!==this._iframeMessageOrigin)return;switch(t.method){case"iframeReady":this.#q(),this.#y(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"console":this.dispatchEvent(new CustomEvent("qti-pci-console",{detail:{level:t.level,args:t.args},bubbles:!0}));break;case"interactionChanged":{let i=t?.params?.value,o=i&&typeof i=="object"?this.#d(i):null,n=typeof t?.params?.valid=="boolean"?t.params.valid:null,a=typeof t?.params?.customValidity=="string"?t.params.customValidity:null;n!==null&&(this.#i=n,n&&a===null&&(this.#o="")),a!==null&&(this.#o=a);let l=t?.params?.state,c;if(l===void 0)c=void 0;else if(l===null)c=null;else if(typeof l=="string")c=l;else try{c=`__qti_json__::${JSON.stringify(l)}`}catch{c=null}if(o===null){let p=this.responseVariable?.cardinality==="single"?"":[];this.response=p,this.validate(),this.saveResponse(p,c);break}this.response=o,this.validate(),this.saveResponse(o,c);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}}};this.#m=null}#e;static{this.styles=[Ql,S`
|
|
4641
4764
|
:host {
|
|
4642
4765
|
display: block;
|
|
4643
4766
|
width: 100%;
|
|
4644
4767
|
min-height: 50px;
|
|
4645
4768
|
}
|
|
4646
|
-
`]}#t;#i;#r;#s;#o(){if(this.#t===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this.#t={},e.forEach(t=>{t.name&&t.value&&(this.#t[t.name]=t.value)})):this.#t=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this.#t={}}return this.#t||{}}#n(){if(this.#i===null&&this.requireShimJson)try{this.#i=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this.#i={}}return this.#i||{}}#a(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/OAT/util/tpl":"/assets/pci-scripts/portableLib/OAT/util/tpl","taoQtiItem/portableLib/OAT/util/asset":"/assets/pci-scripts/portableLib/OAT/util/asset","taoQtiItem/portableLib/OAT/waitForMedia":"/assets/pci-scripts/portableLib/OAT/waitForMedia","taoQtiItem/portableLib/OAT/mediaPlayer":"/assets/pci-scripts/portableLib/OAT/mediaPlayer","taoQtiItem/portableLib/OAT/scale.raphael":"/assets/pci-scripts/portableLib/OAT/scale.raphael","taoQtiItem/portableLib/OAT/interact-rotate":"/assets/pci-scripts/portableLib/OAT/interact-rotate","taoQtiItem/portableLib/OAT/promise":"/assets/pci-scripts/portableLib/OAT/promise","taoQtiItem/portableLib/OAT/sts/common":"/assets/pci-scripts/portableLib/OAT/sts/common","taoQtiItem/portableLib/OAT/sts/transform-helper":"/assets/pci-scripts/portableLib/OAT/sts/transform-helper","taoQtiItem/portableLib/OAT/sts/stsEventManager":"/assets/pci-scripts/portableLib/OAT/sts/stsEventManager","taoQtiItem/portableLib/async":"/assets/pci-scripts/portableLib/async","taoQtiItem/portableLib/interact":"/assets/pci-scripts/portableLib/interact","taoQtiItem/portableLib/es6-promise":"/assets/pci-scripts/portableLib/es6-promise","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/portableLib/jquery.qtip":"/assets/pci-scripts/portableLib/jquery.qtip","taoQtiItem/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/portableLib/handlebars":"/assets/pci-scripts/portableLib/handlebars","taoQtiItem/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/pci-scripts/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}#p(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}#u(){let e=this.#a(),t=this.#o();return this.useDefaultPaths?{...e,...t}:t}#l(){let e=this.#n(),t=this.#p();return this.useDefaultShims?{...t,...e}:e}#f(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let s in i)if(i.hasOwnProperty(s)){let n=i[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}getDirectChildrenByTag(e){let t=e.toLowerCase();return Array.from(this.children).filter(i=>i.tagName.toLowerCase()===t)}coerceBaseValue(e,t){if(e==null)return e;switch(t){case"integer":{if(typeof e=="number")return e;let i=parseInt(String(e),10);return Number.isNaN(i)?e:i}case"float":case"duration":{if(typeof e=="number")return e;let i=parseFloat(String(e));return Number.isNaN(i)?e:i}case"boolean":{if(typeof e=="boolean")return e;if(typeof e=="string"){let i=e.toLowerCase();if(i==="true")return!0;if(i==="false")return!1}return e}default:return String(e)}}normalizeListValue(e){return e==null?[]:Array.isArray(e)?e:[e]}variableToQtiVariableJSON(e,t,i){if(t==="record"||i==="record")return this.recordToQtiVariableJSON(e);if(t!=="single"){let s=this.normalizeListValue(e).map(n=>this.coerceBaseValue(n,i));return{list:{[i]:s}}}return{base:{[i]:this.coerceBaseValue(e,i)}}}recordToQtiVariableJSON(e){if(!e||typeof e!="object")return{record:[]};let t=[];for(let[i,s]of Object.entries(e))t.push(this.recordEntryFromValue(i,s));return{record:t}}recordEntryFromValue(e,t){if(Array.isArray(t)){let i=t.filter(s=>s!=null);if(i.length&&i.every(s=>typeof s=="boolean"))return{name:e,list:{boolean:i}};if(i.length&&i.every(s=>typeof s=="number")){let s=i,n=s.every(a=>Number.isInteger(a));return{name:e,list:{[n?"integer":"float"]:s}}}return{name:e,list:{string:t.map(s=>s==null?"":String(s))}}}if(typeof t=="boolean")return{name:e,base:{boolean:t}};if(typeof t=="number")return Number.isInteger(t)?{name:e,base:{integer:t}}:{name:e,base:{float:t}};if(t==null)return{name:e,base:{string:""}};if(typeof t=="object")try{return{name:e,base:{string:JSON.stringify(t)}}}catch{return{name:e,base:{string:String(t)}}}return{name:e,base:{string:String(t)}}}getQtiContextDefaultsFromItem(){let e=this.closest("qti-assessment-item");if(!e)return{};let t={};return e.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=s.querySelector("qti-default-value");if(!n)return;n.querySelectorAll("qti-value[field-identifier]").forEach(l=>{let d=l.getAttribute("field-identifier");if(!d)return;let p=l.getAttribute("base-type")||"string",m=l.textContent?.trim()||"";t[d]=this.coerceBaseValue(m,p)})}),t}getQtiContextRecord(){let e=this.getQtiContextDefaultsFromItem(),t=this.qtiContext?.QTI_CONTEXT||{},i={...e,...t};if(!Object.keys(i).length)return null;let s={candidateIdentifier:i.candidateIdentifier??"",testIdentifier:i.testIdentifier??"",environmentIdentifier:i.environmentIdentifier??"",...i};return this.recordToQtiVariableJSON(s)}getTemplateVariables(){let e={},t=this.getDirectChildrenByTag("qti-template-variable");return t.length&&t.forEach(i=>{let s=i.getAttribute("template-identifier")||i.getAttribute("identifier")||"";if(!s)return;let n=this.context?.variables?.find(d=>d.identifier===s);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[s]=this.variableToQtiVariableJSON(n.value,a,l)}),e}getContextVariables(){let e={},t=this.getDirectChildrenByTag("qti-context-variable");return t.length&&t.forEach(i=>{let s=i.getAttribute("identifier")||"";if(!s)return;if(s==="QTI_CONTEXT"){let d=this.getQtiContextRecord();d&&(e[s]=d);return}let n=this.context?.variables?.find(d=>d.identifier===s);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[s]=this.variableToQtiVariableJSON(n.value,a,l)}),e}#m(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let s=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let s={list:{}};return s.list[i]=e,s}else{let s={base:{}};return s.base[i]=e,s}}#g(){return this.response===null||this.response===void 0?!1:Array.isArray(this.response)?this.response.length===0?!1:this.response.some(e=>e!==""&&e!==null&&e!==void 0):this.response!==""}#b(e,t){let i=this.dataset.invalidresponsemessage||"Invalid response.",s=e?"":t&&t.trim().length>0?t:i;this._internals.setValidity(e?{}:{customError:!0},s)}validate(){let e=typeof this.#r=="boolean"?this.#r:this.#g();return this.#b(e,this.#s),e}set value(e){e===null?this.#e=[]:this.#e=Array.isArray(e)?e:e.split(",")}get value(){return this.#e===null||this.#e===void 0?null:Array.isArray(this.#e)?this.#e.join(","):String(this.#e)}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.#f(e[this.responseIdentifier]);this.#e=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,s);e[this.responseIdentifier]=a}return e}#h(e){return e&&e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(///g,"/").replace(/`/g,"`").replace(/=/g,"=")}#y(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.#h(s):t[i]=s;return t}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage),this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null)}sendMessageToIframe(e,t){let i=this.iframe?.contentWindow;if(!this._iframeLoaded||!i){this._pendingMessages.push({method:e,params:t});return}i.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:e,params:t},"*")}#c(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),this.#C(),this.#v()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent();try{let i=new Blob([t],{type:"text/html"});this._iframeObjectUrl=URL.createObjectURL(i),this.iframe.src=this._iframeObjectUrl}catch{let i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`}this.appendChild(this.iframe)}#v(){let e=this.#m(this.#y({...this.dataset})),t=this.context?.state?.[this.responseIdentifier],i=typeof t=="string"&&t.length>0?t:null,s={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Oi(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:e,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#q(),boundTo:i?null:this.boundTo,state:i};this.sendMessageToIframe("initialize",s)}#q(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let s of i)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}#C(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=Array.from(this.querySelectorAll("qti-stylesheet"));if(t.length){let s=t.map(n=>n.outerHTML).join(`
|
|
4647
|
-
`);this.sendMessageToIframe("setStylesheets",
|
|
4769
|
+
`]}#t;#r;#i;#o;#s(){if(this.#t===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);if(Array.isArray(e)||!e||typeof e!="object")throw new Error("Require paths must be a JSON object.");this.#t=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this.#t={}}return this.#t||{}}#n(){if(this.#r===null&&this.requireShimJson)try{this.#r=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this.#r={}}return this.#r||{}}#a(){return this.#s()}#c(){return this.#n()}#d(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let o in i)if(i.hasOwnProperty(o)){let n=i[o];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}getDirectChildrenByTag(e){let t=e.toLowerCase();return Array.from(this.children).filter(i=>i.tagName.toLowerCase()===t)}coerceBaseValue(e,t){if(e==null)return e;switch(t){case"integer":{if(typeof e=="number")return e;let i=parseInt(String(e),10);return Number.isNaN(i)?e:i}case"float":case"duration":{if(typeof e=="number")return e;let i=parseFloat(String(e));return Number.isNaN(i)?e:i}case"boolean":{if(typeof e=="boolean")return e;if(typeof e=="string"){let i=e.toLowerCase();if(i==="true")return!0;if(i==="false")return!1}return e}default:return String(e)}}normalizeListValue(e){return e==null?[]:Array.isArray(e)?e:[e]}variableToQtiVariableJSON(e,t,i){if(t==="record"||i==="record")return this.recordToQtiVariableJSON(e);if(t!=="single"){let o=this.normalizeListValue(e).map(n=>this.coerceBaseValue(n,i));return{list:{[i]:o}}}return{base:{[i]:this.coerceBaseValue(e,i)}}}recordToQtiVariableJSON(e){if(!e||typeof e!="object")return{record:[]};let t=[];for(let[i,o]of Object.entries(e))t.push(this.recordEntryFromValue(i,o));return{record:t}}recordEntryFromValue(e,t){if(Array.isArray(t)){let i=t.filter(o=>o!=null);if(i.length&&i.every(o=>typeof o=="boolean"))return{name:e,list:{boolean:i}};if(i.length&&i.every(o=>typeof o=="number")){let o=i,n=o.every(a=>Number.isInteger(a));return{name:e,list:{[n?"integer":"float"]:o}}}return{name:e,list:{string:t.map(o=>o==null?"":String(o))}}}if(typeof t=="boolean")return{name:e,base:{boolean:t}};if(typeof t=="number")return Number.isInteger(t)?{name:e,base:{integer:t}}:{name:e,base:{float:t}};if(t==null)return{name:e,base:{string:""}};if(typeof t=="object")try{return{name:e,base:{string:JSON.stringify(t)}}}catch{return{name:e,base:{string:String(t)}}}return{name:e,base:{string:String(t)}}}getQtiContextDefaultsFromItem(){let e=this.closest("qti-assessment-item");if(!e)return{};let t={};return e.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(o=>{let n=o.querySelector("qti-default-value");if(!n)return;n.querySelectorAll("qti-value[field-identifier]").forEach(l=>{let c=l.getAttribute("field-identifier");if(!c)return;let p=l.getAttribute("base-type")||"string",h=l.textContent?.trim()||"";t[c]=this.coerceBaseValue(h,p)})}),t}getQtiContextRecord(){let e=this.getQtiContextDefaultsFromItem(),t=this.qtiContext?.QTI_CONTEXT||{},i={...e,...t};if(!Object.keys(i).length)return null;let o={candidateIdentifier:i.candidateIdentifier??"",testIdentifier:i.testIdentifier??"",environmentIdentifier:i.environmentIdentifier??"",...i};return this.recordToQtiVariableJSON(o)}getTemplateVariables(){let e={},t=this.getDirectChildrenByTag("qti-template-variable");return t.length&&t.forEach(i=>{let o=i.getAttribute("template-identifier")||i.getAttribute("identifier")||"";if(!o)return;let n=this.context?.variables?.find(c=>c.identifier===o);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[o]=this.variableToQtiVariableJSON(n.value,a,l)}),e}getContextVariables(){let e={},t=this.getDirectChildrenByTag("qti-context-variable");return t.length&&t.forEach(i=>{let o=i.getAttribute("identifier")||"";if(!o)return;if(o==="QTI_CONTEXT"){let c=this.getQtiContextRecord();c&&(e[o]=c);return}let n=this.context?.variables?.find(c=>c.identifier===o);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[o]=this.variableToQtiVariableJSON(n.value,a,l)}),e}#l(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let o=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[o]=e[i]}return t}#u(e){let t={...e},i=(o,n,a)=>{let l=o;for(let c=0;c<n.length;c+=1){let p=n[c];if(c===n.length-1){l[p]=a;return}(!l[p]||typeof l[p]!="object"||Array.isArray(l[p]))&&(l[p]={}),l=l[p]}};for(let[o,n]of Object.entries(e)){if(!o.includes("__"))continue;let a=o.split("__").filter(Boolean);a.length<2||i(t,a,n)}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let o={list:{}};return o.list[i]=e,o}else{let o={base:{}};return o.base[i]=e,o}}#h(){return this.response===null||this.response===void 0?!1:Array.isArray(this.response)?this.response.length===0?!1:this.response.some(e=>e!==""&&e!==null&&e!==void 0):this.response!==""}#g(e,t){let i=this.dataset.invalidresponsemessage||"Invalid response.",o=e?"":t&&t.trim().length>0?t:i;this._internals.setValidity(e?{}:{customError:!0},o)}validate(){let e=typeof this.#i=="boolean"?this.#i:this.#h();return this.#g(e,this.#o),e}set value(e){e===null?this.#e=[]:this.#e=Array.isArray(e)?e:e.split(",")}get value(){return this.#e===null||this.#e===void 0?null:Array.isArray(this.#e)?this.#e.join(","):String(this.#e)}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.#d(e[this.responseIdentifier]);this.#e=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",o=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,o);e[this.responseIdentifier]=a}return e}#b(e){return e&&e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(///g,"/").replace(/`/g,"`").replace(/=/g,"=")}#f(e){let t={};for(let[i,o]of Object.entries(e))typeof o=="string"?t[i]=this.#b(o):t[i]=o;return t}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage),this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null)}sendMessageToIframe(e,t){let i=this.iframe?.contentWindow;if(!this._iframeLoaded||!i){this._pendingMessages.push({method:e,params:t});return}i.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:e,params:t},"*")}#y(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),this.#x(),this.#p()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent();try{let i=new Blob([t],{type:"text/html"});this._iframeObjectUrl=URL.createObjectURL(i),this.iframe.src=this._iframeObjectUrl}catch{let i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`}this.appendChild(this.iframe)}#p(){let e=this.#l(this.#u(this.#f({...this.dataset}))),t=this.context?.state?.[this.responseIdentifier],i=typeof t=="string"&&t.length>0?t:null,o={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Ki(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:e,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#v(),boundTo:i?null:this.boundTo,state:i};this.sendMessageToIframe("initialize",o)}#v(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let o of i)e.push({id:o.getAttribute("id"),primaryPath:o.getAttribute("primary-path"),fallbackPath:o.getAttribute("fallback-path")})}return e}#x(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=Array.from(this.querySelectorAll("qti-stylesheet"));if(t.length){let o=t.map(n=>n.outerHTML).join(`
|
|
4770
|
+
`);this.sendMessageToIframe("setStylesheets",o)}let i=this.querySelector("properties");i&&this.sendMessageToIframe("setProperties",i.innerHTML)}#q(){}connectedCallback(){super.connectedCallback(),this.#i=null,this.#o="",this.response=this.responseVariable?.value??null,window.addEventListener("message",this.handleIframeMessage),this.createIframe()}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.#a()),i=JSON.stringify(this.#c()),o=this.dataset.baseUrl?this.dataset.baseUrl.startsWith("/")?`${window.location.origin}${this.dataset.baseUrl}`:this.dataset.baseUrl:"",n=this.dataset.forwardConsole==="true",a=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1",l=a?`${window.location.origin}/cdn/index.js`:"https://unpkg.com/@citolab/qti-components/cdn",c=a?`${window.location.origin}/dist/item.css`:"https://unpkg.com/@citolab/qti-components@latest/dist/item.css",p=this.dataset.componentsCdnUrl||l,h=this.dataset.componentsCssUrl||c,m=`
|
|
4648
4771
|
font-family: ${e.getPropertyValue("font-family")};
|
|
4649
4772
|
font-size: ${e.getPropertyValue("font-size")};
|
|
4650
4773
|
line-height: ${e.getPropertyValue("line-height")};
|
|
@@ -4657,7 +4780,7 @@ CES.load();
|
|
|
4657
4780
|
<title>QTI PCI Container</title>
|
|
4658
4781
|
<base href="${window.location.origin}" />
|
|
4659
4782
|
<script type="module">
|
|
4660
|
-
import '
|
|
4783
|
+
import '${p}';
|
|
4661
4784
|
</script>
|
|
4662
4785
|
<style>
|
|
4663
4786
|
body, html {
|
|
@@ -4667,7 +4790,7 @@ CES.load();
|
|
|
4667
4790
|
height: auto;
|
|
4668
4791
|
overflow: hidden;
|
|
4669
4792
|
/* Add the extracted font styles here */
|
|
4670
|
-
${
|
|
4793
|
+
${m}
|
|
4671
4794
|
};
|
|
4672
4795
|
.qti-customInteraction {
|
|
4673
4796
|
width: 100%;
|
|
@@ -4682,7 +4805,7 @@ CES.load();
|
|
|
4682
4805
|
min-height: 50px;
|
|
4683
4806
|
}
|
|
4684
4807
|
</style>
|
|
4685
|
-
<link href="
|
|
4808
|
+
<link href="${h}" rel="stylesheet" />
|
|
4686
4809
|
<script src="${this.requireJsUrl}"></script>
|
|
4687
4810
|
<script>
|
|
4688
4811
|
const forwardConsole = ${n?"true":"false"};
|
|
@@ -4735,7 +4858,7 @@ CES.load();
|
|
|
4735
4858
|
catchError: true,
|
|
4736
4859
|
waitSeconds: 30,
|
|
4737
4860
|
paths: window.requirePaths,
|
|
4738
|
-
baseUrl: '${
|
|
4861
|
+
baseUrl: '${o}',
|
|
4739
4862
|
shim: window.requireShim,
|
|
4740
4863
|
onNodeCreated: function (node, config, moduleName, url) {
|
|
4741
4864
|
// Add error handler to script node
|
|
@@ -4919,6 +5042,12 @@ CES.load();
|
|
|
4919
5042
|
.replace('https:/', 'https://');
|
|
4920
5043
|
}
|
|
4921
5044
|
|
|
5045
|
+
function ensureDirectoryBasePath(basePath) {
|
|
5046
|
+
if (!basePath) return basePath;
|
|
5047
|
+
if (basePath.endsWith('/')) return basePath;
|
|
5048
|
+
return basePath + '/';
|
|
5049
|
+
}
|
|
5050
|
+
|
|
4922
5051
|
|
|
4923
5052
|
|
|
4924
5053
|
function combineRequireResolvePaths(path1, path2, baseUrl) {
|
|
@@ -4943,8 +5072,7 @@ CES.load();
|
|
|
4943
5072
|
module.fallbackPath,
|
|
4944
5073
|
config.baseUrl
|
|
4945
5074
|
);
|
|
4946
|
-
window.requirePaths[module.id] = currentPaths
|
|
4947
|
-
.concat(newPath)
|
|
5075
|
+
window.requirePaths[module.id] = newPath.concat(currentPaths)
|
|
4948
5076
|
.filter((value, index, self) => self.indexOf(value) === index);
|
|
4949
5077
|
}
|
|
4950
5078
|
});
|
|
@@ -5015,59 +5143,7 @@ CES.load();
|
|
|
5015
5143
|
}
|
|
5016
5144
|
pciInstance.getInstance(dom, pciConfig, restoredState || undefined);
|
|
5017
5145
|
} else {
|
|
5018
|
-
|
|
5019
|
-
const restoreTAOConfig = dataset => {
|
|
5020
|
-
const config = {};
|
|
5021
|
-
const parseDataAttributes = () => {
|
|
5022
|
-
const result = {};
|
|
5023
|
-
|
|
5024
|
-
// Separate direct attributes from nested ones
|
|
5025
|
-
Object.entries(dataset || {}).forEach(([key, value]) => {
|
|
5026
|
-
if (!key.includes('__')) {
|
|
5027
|
-
// Direct attributes (like version)
|
|
5028
|
-
result[key] = value;
|
|
5029
|
-
}
|
|
5030
|
-
});
|
|
5031
|
-
|
|
5032
|
-
// Parse nested attributes
|
|
5033
|
-
const nestedData = {};
|
|
5034
|
-
|
|
5035
|
-
Object.entries(dataset || {}).forEach(([key, value]) => {
|
|
5036
|
-
const parts = key.split('__');
|
|
5037
|
-
if (parts.length > 1) {
|
|
5038
|
-
const [group, index, prop] = parts;
|
|
5039
|
-
nestedData[group] = nestedData[group] || {};
|
|
5040
|
-
nestedData[group][index] = nestedData[group][index] || {};
|
|
5041
|
-
nestedData[group][index][prop] = value;
|
|
5042
|
-
}
|
|
5043
|
-
});
|
|
5044
|
-
|
|
5045
|
-
// Convert nested groups to arrays
|
|
5046
|
-
Object.entries(nestedData).forEach(([key, group]) => {
|
|
5047
|
-
result[key] = Object.values(group);
|
|
5048
|
-
});
|
|
5049
|
-
return result;
|
|
5050
|
-
};
|
|
5051
|
-
const data = parseDataAttributes();
|
|
5052
|
-
for (const key in data) {
|
|
5053
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
5054
|
-
const value = data[key];
|
|
5055
|
-
if (key === 'config') {
|
|
5056
|
-
config[key] = JSON.parse(value);
|
|
5057
|
-
} else {
|
|
5058
|
-
config[key] = value;
|
|
5059
|
-
}
|
|
5060
|
-
}
|
|
5061
|
-
}
|
|
5062
|
-
return config;
|
|
5063
|
-
};
|
|
5064
|
-
const taoConfig = restoreTAOConfig(config.dataAttributes);
|
|
5065
|
-
|
|
5066
|
-
this.pciInstance.initialize(
|
|
5067
|
-
this.customInteractionTypeIdentifier,
|
|
5068
|
-
(this.markupEl || this.container).firstElementChild || this.markupEl || this.container,
|
|
5069
|
-
Object.keys(taoConfig).length ? taoConfig : null
|
|
5070
|
-
);
|
|
5146
|
+
this.notifyError('Loaded PCI module has no getInstance().');
|
|
5071
5147
|
}
|
|
5072
5148
|
},
|
|
5073
5149
|
notifyReady: () => {
|
|
@@ -5078,9 +5154,20 @@ CES.load();
|
|
|
5078
5154
|
|
|
5079
5155
|
function getResolvablePathString(path, basePath) {
|
|
5080
5156
|
path = path.replace(/\\.js$/, '');
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5157
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(path) || !basePath) {
|
|
5158
|
+
return path;
|
|
5159
|
+
}
|
|
5160
|
+
|
|
5161
|
+
if (path.startsWith('/') && !path.startsWith('//')) {
|
|
5162
|
+
path = path.slice(1);
|
|
5163
|
+
}
|
|
5164
|
+
|
|
5165
|
+
try {
|
|
5166
|
+
const resolved = new URL(path, ensureDirectoryBasePath(basePath)).toString();
|
|
5167
|
+
return resolved.replace(/\\.js$/, '');
|
|
5168
|
+
} catch (error) {
|
|
5169
|
+
return removeDoubleSlashes(ensureDirectoryBasePath(basePath) + path);
|
|
5170
|
+
}
|
|
5084
5171
|
}
|
|
5085
5172
|
|
|
5086
5173
|
// Load the PCI module
|
|
@@ -5565,13 +5652,13 @@ CES.load();
|
|
|
5565
5652
|
<body>
|
|
5566
5653
|
<div id="pci-container"></div>
|
|
5567
5654
|
</body>
|
|
5568
|
-
</html>`}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t.cardinality==="single"?"":[];let i=`correct-response-container-${this.responseIdentifier}`,
|
|
5655
|
+
</html>`}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t.cardinality==="single"?"":[];let i=`correct-response-container-${this.responseIdentifier}`,o=this.parentElement?.querySelectorAll(`#${i}`);if(o&&o.forEach(m=>{m.remove()}),e)this.disable();else{this.enable();return}if(!e||!t?.correctResponse)return;let n=document.createElement("div");n.id=i,n.className="pci-correct-response-container",n.style.position="relative",n.style.marginTop="20px",n.style.border="2px solid green",n.style.padding="16px",n.style.borderRadius="4px",n.style.backgroundColor="rgba(0, 128, 0, 0.05)";let a=document.createElement("div");a.textContent="Correct Response:",a.style.fontWeight="bold",a.style.marginBottom="10px",a.style.color="green",n.appendChild(a);let l=document.createElement("qti-portable-custom-interaction");Array.from(this.attributes).forEach(m=>{m.name!=="id"&&m.name!=="response-identifier"&&l.setAttribute(m.name,m.value)});let c=this.responseIdentifier;l.responseIdentifier=`${c}-correct`,Array.from(this.children).forEach(m=>{let y=m.cloneNode(!0);l.appendChild(y)});let p=t.correctResponse,h=l.connectedCallback;l.connectedCallback=function(){h.call(this);let m=()=>{let y=this.responseVariablesToQtiVariableJSON(p,t.cardinality,t.baseType);this.sendMessageToIframe("setBoundTo",{[c]:y}),this.sendMessageToIframe("setState",{state:"review"})};this._iframeLoaded?m():this.addEventListener("qti-portable-custom-interaction-loaded",m,{once:!0})},l.style.pointerEvents="none",n.appendChild(l),this.after(n)}disable(){if(this.#m={pointerEvents:this.style.pointerEvents,position:this.style.position},this.sendMessageToIframe("setState",{state:"disabled"}),!this.querySelector(".pci-interaction-overlay")){let t=document.createElement("div");t.className="pci-interaction-overlay",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(200, 200, 200, 0.3)",t.style.zIndex="100",t.style.pointerEvents="all",t.style.cursor="not-allowed",getComputedStyle(this).position==="static"&&(this.style.position="relative"),this.appendChild(t)}}enable(){let e=this.querySelector(".pci-interaction-overlay");e&&e.remove(),this.#m&&(this.#m.pointerEvents&&(this.style.pointerEvents=this.#m.pointerEvents),this.#m.position&&(this.style.position=this.#m.position),this.#m=null),this.sendMessageToIframe("setState",{state:"interacting"})}#m;render(){return x`
|
|
5569
5656
|
<slot></slot>
|
|
5570
|
-
${this._errorMessage?
|
|
5657
|
+
${this._errorMessage?x`<div style="color:red">
|
|
5571
5658
|
<h1>Error</h1>
|
|
5572
5659
|
${this._errorMessage}
|
|
5573
5660
|
</div>`:""}
|
|
5574
|
-
`}};
|
|
5661
|
+
`}};d([b({type:String,attribute:"module"})],Z.prototype,"module",2),d([b({type:String,attribute:"custom-interaction-type-identifier"})],Z.prototype,"customInteractionTypeIdentifier",2),d([b({type:String,attribute:"data-require-paths"})],Z.prototype,"requirePathsJson",2),d([b({type:String,attribute:"data-require-shim"})],Z.prototype,"requireShimJson",2),d([b({type:String,attribute:"data-require-js-url"})],Z.prototype,"requireJsUrl",2),d([b({type:String,attribute:"data-base-url"})],Z.prototype,"baseUrl",2),d([b({type:Boolean,attribute:"data-use-default-paths"})],Z.prototype,"useDefaultPaths",2),d([R()],Z.prototype,"_errorMessage",2),d([P({context:G,subscribe:!0}),R()],Z.prototype,"context",2),d([P({context:Xt,subscribe:!0}),R()],Z.prototype,"qtiContext",2),d([R()],Z.prototype,"response",2);var Vo=class extends Z{#e=!1;async getIFrameContent(){return new Promise(r=>{let e=`get-content-${Date.now()}`,t=i=>{let{data:o}=i;o?.source==="qti-pci-iframe"&&(!o?.responseIdentifier||o?.responseIdentifier===this.responseIdentifier)&&o?.method==="getContentResponse"&&o?.messageId===e&&(window.removeEventListener("message",t),r(o.content))};window.addEventListener("message",t),this.sendMessageToIframe("getContent",{messageId:e}),setTimeout(()=>{window.removeEventListener("message",t),r("")},5e3)})}setTestContext(r){this.context=r,this.updateComplete.then(()=>{this.value=r?.variables?.find(e=>e.identifier===this.responseIdentifier).value})}async recreateIframe(){this.#e=!0;try{return this.iframe&&(this._iframeLoaded=!1,this.iframe.remove()),this._pendingMessages=[],this.createIframe(),new Promise(r=>{let e=()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",e),r()};this.addEventListener("qti-portable-custom-interaction-loaded",e),setTimeout(()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",e),r()},5e3)})}finally{this.#e=!1}}disconnectedCallback(){this.#e||super.disconnectedCallback()}async iFrameMouseClick(r,e){return new Promise(t=>{let i=`click-${Date.now()}`,o=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="clickResponse"&&a?.messageId===i&&(window.removeEventListener("message",o),t())};window.addEventListener("message",o),this.sendMessageToIframe("simulateClick",{x:r,y:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",o),t()},5e3)})}async iFrameClickOnElement(r){return new Promise(e=>{let t=`click-selector-${Date.now()}`,i=o=>{let{data:n}=o;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="clickSelectorResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("clickOnSelector",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}async iFrameClickOnElementByText(r){return new Promise(e=>{let t=`click-text-${Date.now()}`,i=o=>{let{data:n}=o;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="clickTextResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("clickOnElementByText",{text:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}async iFrameSetValueElement(r,e){return new Promise(t=>{let i=`set-value-${Date.now()}`,o=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueResponse"&&a?.messageId===i&&(window.removeEventListener("message",o),t(a.success))};window.addEventListener("message",o),this.sendMessageToIframe("setValueElement",{selector:r,value:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",o),t(!1)},5e3)})}async iFrameGetBoundingClientRect(r){return new Promise(e=>{let t=`get-bounding-rect-${Date.now()}`,i=o=>{let{data:n}=o;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="getBoundingRectResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.rect??null))};window.addEventListener("message",i),this.sendMessageToIframe("getBoundingRect",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(null)},5e3)})}async iFrameSetValueElementByText(r,e){return new Promise(t=>{let i=`set-value-text-${Date.now()}`,o=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueByTextResponse"&&a?.messageId===i&&(window.removeEventListener("message",o),t(a.success))};window.addEventListener("message",o),this.sendMessageToIframe("setValueElementByText",{text:r,value:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",o),t(!1)},5e3)})}async iFrameMousedownOnElement(r){return new Promise(e=>{let t=`mousedown-selector-${Date.now()}`,i=o=>{let{data:n}=o;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="mousedownSelectorResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("mousedownOnSelector",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}generateIframeContent(){let r=super.generateIframeContent(),e=`
|
|
5575
5662
|
// Test helper functions for QtiPortableCustomInteractionTest
|
|
5576
5663
|
// Base iframe implementation already provides PCIManager.getContent
|
|
5577
5664
|
|
|
@@ -5764,56 +5851,56 @@ CES.load();
|
|
|
5764
5851
|
}
|
|
5765
5852
|
},
|
|
5766
5853
|
true
|
|
5767
|
-
);`,t=r.lastIndexOf("</script>");return r.substring(0,t)+e+r.substring(t)}};customElements.define("qti-portable-custom-interaction",
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5854
|
+
);`,t=r.lastIndexOf("</script>");return r.substring(0,t)+e+r.substring(t)}};customElements.define("qti-portable-custom-interaction",Z);customElements.define("qti-portable-custom-interaction-test",Vo);var Jl=S`
|
|
5855
|
+
:host {
|
|
5856
|
+
display: block;
|
|
5857
|
+
}
|
|
5858
|
+
::slotted(img) {
|
|
5859
|
+
position: absolute;
|
|
5860
|
+
cursor: move;
|
|
5861
|
+
user-select: none;
|
|
5862
|
+
left: 50%;
|
|
5863
|
+
transform: translateX(-50%);
|
|
5864
|
+
}
|
|
5865
|
+
`;var No=class extends C{static{this.styles=Jl}render(){return x`<slot></slot>`}};var Yl=S`
|
|
5866
|
+
:host {
|
|
5867
|
+
display: inline-block;
|
|
5868
|
+
position: relative;
|
|
5869
|
+
}
|
|
5870
|
+
`;var Ho=class extends C{static{this.styles=Yl}render(){return x`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(r){r.preventDefault();let e=r.clientX-this.startX,t=r.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=r.clientX,this.startY=r.clientY}firstUpdated(r){super.firstUpdated(r),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};customElements.define("qti-position-object-interaction",No);customElements.define("qti-position-object-stage",Ho);var Kl="important",gd=" !"+Kl,Bs=ae(class extends ke{constructor(s){if(super(s),s.type!==tt.ATTRIBUTE||s.name!=="style"||s.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce(((r,e)=>{let t=s[e];return t==null?r:r+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(s,[r]){let{style:e}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(r)),this.render(r);for(let t of this.ft)r[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in r){let i=r[t];if(i!=null){this.ft.add(t);let o=typeof i=="string"&&i.endsWith(gd);t.includes("-")||o?e.setProperty(t,o?i.slice(0,-11):i,o?Kl:""):e[t]=i}}return X}});var Zl=S`
|
|
5871
|
+
:host {
|
|
5872
|
+
display: block;
|
|
5873
|
+
}
|
|
5874
|
+
point-container {
|
|
5875
|
+
display: block;
|
|
5876
|
+
position: relative;
|
|
5877
|
+
width: fit-content;
|
|
5878
|
+
}
|
|
5792
5879
|
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5880
|
+
::slotted(img) {
|
|
5881
|
+
max-width: 100%;
|
|
5882
|
+
height: auto;
|
|
5883
|
+
display: block;
|
|
5884
|
+
}
|
|
5885
|
+
`;var Qe=class extends ${constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this.#e=null;this.#t=1;this.#r=1;this.#i=0;this.#o=0;this.#s=e=>{if(this.disabled)return;if(!this.#e){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.#a();let t=this.#e.getBoundingClientRect(),i=(e.clientX-t.left)*this.#t,o=(e.clientY-t.top)*this.#r,n=`${i.toFixed()} ${o.toFixed()}`;this.maxChoices===1?this.response=[n]:(this.maxChoices===0||(this.response||[]).length<this.maxChoices)&&(this.response=[...this.response||[],n]),this.saveResponse(this.response)};this.#n=()=>{this.#a()}}static{this.styles=Zl}#e;#t;#r;#i;#o;#s;connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.#n)}#n;get responsePoints(){return(this.response||[]).filter(e=>e).map(e=>{let[t,i]=e.split(" ").map(Number);return{x:t,y:i}})}toggleCandidateCorrection(e){this._responseCorrection=[],e&&this.responsePoints.forEach(t=>{let i=this.responseVariable.areaMapping.areaMapEntries.some(o=>K.isPointInArea(`${t.x} ${t.y}`,`${o.shape},${o.coords}`,this.responseVariable.baseType));this._responseCorrection.push(i)})}toggleCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctAreas=[];return}let i=t.areaMapping,o=[];if(!i||i.areaMapEntries.length===0)if(t.correctResponse){let n=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];if(n.length===0||n.find(a=>a.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),o=n.map(a=>({shape:"circle",coords:a.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else o=i.areaMapEntries;this._correctAreas=o.map(n=>({coords:n.coords,shape:n.shape}))}updated(e){super.updated(e);let t=this.#e;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.#a(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let o=i.dataset.coord,n=i.dataset.shape;o&&n&>(n,o.split(",").map(a=>+a),t,i)}))}render(){return x` <slot name="prompt"></slot>
|
|
5799
5886
|
<point-container>
|
|
5800
|
-
${
|
|
5887
|
+
${br((this.response||[]).filter(e=>e),e=>e,(e,t)=>{let[i,o]=e.split(" ").map(Number),n=i/(this.#i||1)*100,a=o/(this.#o||1)*100,l=16,c=l/(this.#i||1)*100,p=l/(this.#o||1)*100,h="";return this._responseCorrection[t]===!0?h=" correct":this._responseCorrection[t]===!1&&(h=" incorrect"),x`
|
|
5801
5888
|
<button
|
|
5802
|
-
part="point${
|
|
5803
|
-
style=${
|
|
5889
|
+
part="point${h}"
|
|
5890
|
+
style=${Bs({pointerEvents:this.maxChoices===1?"none":"auto",position:"absolute",transform:"translate(-50%, -50%)",left:`${n}%`,top:`${a}%`,width:`min(${c}%, 1rem)`,height:`min(${p}%, 1rem)`,minWidth:`min(${c}%, 1rem)`,minHeight:`min(${p}%, 1rem)`,borderRadius:"50%",background:"red"})}
|
|
5804
5891
|
aria-label="Remove point at ${e}"
|
|
5805
5892
|
?disabled=${this.disabled}
|
|
5806
|
-
@click=${
|
|
5893
|
+
@click=${m=>{m.stopPropagation(),this.response=(this.response||[]).filter((y,v)=>v!==t),this.saveResponse(this.response)}}
|
|
5807
5894
|
></button>
|
|
5808
5895
|
`})}
|
|
5809
|
-
${
|
|
5810
|
-
style=${
|
|
5896
|
+
${br(this._correctAreas?.filter(e=>e)||[],e=>e,(e,t)=>x`<div
|
|
5897
|
+
style=${Bs({position:"absolute",pointerEvents:"none",backgroundColor:"var(--qti-correct)",opacity:"0.5"})}
|
|
5811
5898
|
data-coord="${e.coords}"
|
|
5812
5899
|
alt=${`correct-response-${t+1}`}
|
|
5813
5900
|
data-shape="${e.shape}"
|
|
5814
5901
|
></div>`)}
|
|
5815
5902
|
<slot></slot>
|
|
5816
|
-
</point-container>`}validate(){return this.response!==null&&this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}#a(){this.#
|
|
5903
|
+
</point-container>`}validate(){return this.response!==null&&this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}#a(){this.#i=this.#e.getAttribute("width")?parseFloat(this.#e.getAttribute("width")):this.#e.naturalWidth,this.#o=this.#e.getAttribute("height")?parseFloat(this.#e.getAttribute("height")):this.#e.naturalHeight;let e=this.#e.getBoundingClientRect();this.#t=e.width===0?1:this.#i/e.width,this.#r=e.height===0?1:this.#o/e.height}firstUpdated(){this.#e=this.querySelector("img"),this.#e?(this.#a(),this.#e.addEventListener("click",this.#s)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.#n),this.#e&&this.#e.removeEventListener("click",this.#s)}};d([b({type:Number,attribute:"max-choices"})],Qe.prototype,"maxChoices",2),d([b({type:Number,attribute:"min-choices"})],Qe.prototype,"minChoices",2),d([R()],Qe.prototype,"response",2),d([R()],Qe.prototype,"_correctAreas",2),d([R()],Qe.prototype,"_responseCorrection",2);customElements.define("qti-select-point-interaction",Qe);var ec=S`
|
|
5817
5904
|
:host {
|
|
5818
5905
|
display: block;
|
|
5819
5906
|
--show-bounds: true;
|
|
@@ -5893,7 +5980,7 @@ CES.load();
|
|
|
5893
5980
|
text-align: center;
|
|
5894
5981
|
color: #6b7280; /* text-gray-500 */
|
|
5895
5982
|
}
|
|
5896
|
-
`;var
|
|
5983
|
+
`;var xt=class extends ${constructor(){super(...arguments);this.#e=0;this.#t=null;this.min=0;this.max=100;this.step=1}static{this.styles=ec}#e;#t;validate(){return!0}connectedCallback(){super.connectedCallback(),this.#r(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this.#e.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this.#r(t)}toggleCorrectResponse(e){let t=this.responseVariable;if(t?.correctResponse){if(e){this._correctResponse=t.correctResponse.toString();let i=parseFloat(t.correctResponse.toString());if(isNaN(i))this.#t=null;else{this.#t=i;let o=(this.#t-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${o}%`)}}else this.#t=null;this.requestUpdate()}}#r(e){let t=this.#e;if(this.#e=Math.min(this.max,Math.max(this.min,e)),this.#e===t)return;let i=(this.#e-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${i}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return x`
|
|
5897
5984
|
<slot name="prompt"></slot>
|
|
5898
5985
|
<div id="slider" part="slider">
|
|
5899
5986
|
<div id="bounds" part="bounds">
|
|
@@ -5903,19 +5990,19 @@ CES.load();
|
|
|
5903
5990
|
|
|
5904
5991
|
<div id="ticks" part="ticks"></div>
|
|
5905
5992
|
|
|
5906
|
-
<div id="rail" part="rail" @mousedown=${this.#
|
|
5993
|
+
<div id="rail" part="rail" @mousedown=${this.#i} @touchstart=${this.#o}>
|
|
5907
5994
|
<div id="knob" part="knob">
|
|
5908
5995
|
<div id="value" part="value">${this.response}</div>
|
|
5909
5996
|
</div>
|
|
5910
5997
|
|
|
5911
|
-
${this.#t!==null?
|
|
5998
|
+
${this.#t!==null?x`
|
|
5912
5999
|
<div id="knob-correct" part="knob-correct">
|
|
5913
6000
|
<div id="value" part="value">${this.#t}</div>
|
|
5914
6001
|
</div>
|
|
5915
6002
|
`:null}
|
|
5916
6003
|
</div>
|
|
5917
6004
|
</div>
|
|
5918
|
-
`}#
|
|
6005
|
+
`}#i(e){this.#s(e.pageX);let t=o=>this.#n(o.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.#a()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}#o(e){this.#s(e.touches[0].pageX);let t=o=>this.#n(o.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this.#a()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}#s(e){this.#n(e)}#n(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,o=Math.min(1,Math.max(0,i/t.width)),n=this.min+Math.round(o*(this.max-this.min)/this.step)*this.step;this.#r(n)}#a(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};d([Ht("#rail")],xt.prototype,"_rail",2),d([b({type:Number,attribute:"lower-bound"})],xt.prototype,"min",2),d([b({type:Number,attribute:"upper-bound"})],xt.prototype,"max",2),d([b({type:Number,attribute:"step"})],xt.prototype,"step",2);customElements.define("qti-slider-interaction",xt);var tc=()=>new zs,zs=class{},Us=new WeakMap,rT=ae(class extends it{render(s){return N}update(s,[r]){let e=r!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=r,this.ht=s.options?.host,this.rt(this.ct=s.element)),N}rt(s){if(this.isConnected||(s=void 0),typeof this.G=="function"){let r=this.ht??globalThis,e=Us.get(r);e===void 0&&(e=new WeakMap,Us.set(r,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?Us.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var rc=S`
|
|
5919
6006
|
:host {
|
|
5920
6007
|
display: inline-block;
|
|
5921
6008
|
}
|
|
@@ -6023,7 +6110,7 @@ CES.load();
|
|
|
6023
6110
|
bottom: 0;
|
|
6024
6111
|
}
|
|
6025
6112
|
}
|
|
6026
|
-
`;var
|
|
6113
|
+
`;var Ee=class extends ${constructor(){super(...arguments);this.inputRef=tc();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=rc}get value(){return this.response||null}set value(e){this.response=e||null}get correctness(){let e=this.responseVariable;if(!e)return null;if(e.value===null)return"incorrect";if(e.mapping){let t=e.mapping.mapEntries.reduce((i,o)=>Math.max(o.mappedValue,i),0);for(let i of e.mapping.mapEntries){let o=i.mapKey,n=e.value;if(i.caseSensitive||(o=o.toLowerCase(),n=n.toLowerCase()),o===n)return i.mappedValue===t?"correct":i.mappedValue<=(e.mapping.defaultValue||0)?"incorrect":"partially-correct"}}return e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!0}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(e&&t?.correctResponse){let i=t.correctResponse.toString();this._correctResponse=i}else this._correctResponse=null}render(){return x`
|
|
6027
6114
|
<input
|
|
6028
6115
|
part="input"
|
|
6029
6116
|
name="${this.responseIdentifier}"
|
|
@@ -6034,107 +6121,29 @@ CES.load();
|
|
|
6034
6121
|
@keyup="${this.textChanged}"
|
|
6035
6122
|
@change="${this.textChanged}"
|
|
6036
6123
|
type="${this.patternMask=="[0-9]*"?"number":"text"}"
|
|
6037
|
-
placeholder="${
|
|
6124
|
+
placeholder="${Me(this.placeholderText?this.placeholderText:void 0)}"
|
|
6038
6125
|
.value="${this.response}"
|
|
6039
|
-
pattern="${
|
|
6126
|
+
pattern="${Me(this.patternMask?this.patternMask:void 0)}"
|
|
6040
6127
|
maxlength=${1e3}
|
|
6041
6128
|
?disabled="${this.disabled}"
|
|
6042
6129
|
?readonly="${this.readonly}"
|
|
6043
6130
|
/>
|
|
6044
|
-
${this._correctResponse?
|
|
6045
|
-
`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.#e(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}#e(e){this.setAttribute("empty",e===""?"true":"false")}};
|
|
6046
|
-
:host {
|
|
6047
|
-
display: block;
|
|
6048
|
-
margin: 1em 0;
|
|
6049
|
-
}
|
|
6050
|
-
input[type='file'] {
|
|
6051
|
-
display: block;
|
|
6052
|
-
margin-top: 0.5em;
|
|
6053
|
-
}
|
|
6054
|
-
`]}render(){return f`
|
|
6055
|
-
<div>
|
|
6056
|
-
<slot name="prompt"></slot>
|
|
6057
|
-
<input type="file" @change="${this.#i}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
|
|
6058
|
-
</div>
|
|
6059
|
-
`}async#i(r){let e=r.target;e.files&&e.files.length>0&&(this.#e=e.files[0],this.#t=await this.#r(this.#e),this.saveResponse(this.#t),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this.#t}})))}#r(r){return new Promise((e,t)=>{let i=new FileReader;i.onload=()=>e(i.result),i.onerror=()=>t(i.error),i.readAsDataURL(r)})}};customElements.define("qti-upload-interaction",ms);var hs=class extends b{static{this.styles=y`
|
|
6060
|
-
:host {
|
|
6061
|
-
display: flex;
|
|
6062
|
-
user-select: none;
|
|
6063
|
-
position: absolute;
|
|
6064
|
-
}
|
|
6065
|
-
`}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return f` <slot name="drags"></slot> `}};customElements.define("qti-associable-hotspot",hs);var ai=class extends b{constructor(){super(...arguments);this.tabindex=0}static{this.styles=y`
|
|
6066
|
-
:host {
|
|
6067
|
-
display: flex;
|
|
6068
|
-
user-select: none;
|
|
6069
|
-
}
|
|
6070
|
-
`}render(){return f` <slot name="drags"></slot>`}};c([u({type:Number,reflect:!0})],ai.prototype,"tabindex",2);customElements.define("qti-gap",ai);var li=class extends b{constructor(){super(...arguments);this.tabindex=0}static{this.styles=y`
|
|
6071
|
-
:host {
|
|
6072
|
-
display: flex;
|
|
6073
|
-
user-select: none;
|
|
6074
|
-
}
|
|
6075
|
-
`}connectedCallback(){this.setAttribute("slot","drags")}};c([u({type:Number,reflect:!0})],li.prototype,"tabindex",2);customElements.define("qti-gap-img",li);var rl={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function ue(o,r){class e extends o{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.internals.ariaChecked="false",this.disabled&&(this.tabIndex=-1),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${r}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${r}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||(s.code==="Space"||s.code==="Enter")&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${r}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return f`<slot></slot>`}}return c([u({type:String})],e.prototype,"identifier",2),c([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),c([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:rl})],e.prototype,"disabled",2),c([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:rl})],e.prototype,"readonly",2),c([O("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ci=class extends ue(b,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}static{this.styles=y`
|
|
6076
|
-
:host {
|
|
6077
|
-
display: inline-flex;
|
|
6078
|
-
user-select: none;
|
|
6079
|
-
}
|
|
6080
|
-
`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return f`<slot></slot>`}};c([u({type:Number,reflect:!0})],ci.prototype,"tabindex",2);customElements.define("qti-gap-text",ci);var tr=class extends ue(b,"qti-hotspot-choice"){static{this.styles=y`
|
|
6081
|
-
:host {
|
|
6082
|
-
display: flex;
|
|
6083
|
-
user-select: none;
|
|
6084
|
-
position: absolute;
|
|
6085
|
-
}
|
|
6086
|
-
`}};c([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],tr.prototype,"order",2),c([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],tr.prototype,"orderCorrect",2);customElements.define("qti-hotspot-choice",tr);var fs=class extends ue(b,"qti-hottext"){static{this.styles=y`
|
|
6087
|
-
:host {
|
|
6088
|
-
display: flex;
|
|
6089
|
-
user-select: none;
|
|
6090
|
-
}
|
|
6091
|
-
`}render(){return f`<div part="ch"><div part="cha"></div></div>
|
|
6092
|
-
<slot></slot> `}};customElements.define("qti-hottext",fs);var rc=y`
|
|
6131
|
+
${this._correctResponse?x`<div part="correct">${this._correctResponse}</div>`:N}
|
|
6132
|
+
`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.#e(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}#e(e){this.setAttribute("empty",e===""?"true":"false")}};d([b({type:Number,attribute:"expected-length"})],Ee.prototype,"expectedLength",2),d([b({type:String,attribute:"pattern-mask"})],Ee.prototype,"patternMask",2),d([b({type:String,attribute:"placeholder-text"})],Ee.prototype,"placeholderText",2),d([b({type:String,attribute:"data-patternmask-message"})],Ee.prototype,"dataPatternmaskMessage",2),d([R()],Ee.prototype,"response",2),d([Ht("input")],Ee.prototype,"_input",2),d([U("response",{waitUntilFirstUpdate:!0})],Ee.prototype,"_handleValueChange",2);customElements.define("qti-text-entry-interaction",Ee);var ic=S`
|
|
6093
6133
|
:host {
|
|
6094
6134
|
display: block;
|
|
6095
|
-
|
|
6135
|
+
margin: 1em 0;
|
|
6096
6136
|
}
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
}
|
|
6101
|
-
`,il=rc;var di=class extends ue(b,"qti-inline-choice"){static{this.styles=il}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.#e),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this.#e)}render(){return f` <slot></slot> `}#e(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};c([u({type:String})],di.prototype,"identifier",2);customElements.define("qti-inline-choice",di);var gs=class extends b{render(){return f`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",gs);var Ct=class extends ue(b,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}static{this.styles=y`
|
|
6102
|
-
:host {
|
|
6103
|
-
display: flex;
|
|
6104
|
-
user-select: none;
|
|
6105
|
-
}
|
|
6106
|
-
slot {
|
|
6107
|
-
width: 100%;
|
|
6108
|
-
display: block;
|
|
6109
|
-
}
|
|
6110
|
-
slot[name='qti-simple-associable-choice'] {
|
|
6111
|
-
width: auto;
|
|
6112
|
-
}
|
|
6113
|
-
`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return f`
|
|
6114
|
-
<slot part="slot"></slot>
|
|
6115
|
-
<slot part="dropslot" name="qti-simple-associable-choice"></slot>
|
|
6116
|
-
`}};c([u({type:Number,attribute:"match-min"})],Ct.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],Ct.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ct.prototype,"fixed",2);customElements.define("qti-simple-associable-choice",Ct);var sl=y`
|
|
6117
|
-
:host {
|
|
6118
|
-
display: flex;
|
|
6119
|
-
align-items: center;
|
|
6120
|
-
user-select: none;
|
|
6121
|
-
}
|
|
6122
|
-
slot {
|
|
6123
|
-
width: 100%;
|
|
6124
|
-
display: flex;
|
|
6125
|
-
align-items: center;
|
|
6126
|
-
}
|
|
6127
|
-
[part='ch'] {
|
|
6128
|
-
display: flex;
|
|
6129
|
-
flex-shrink: 0;
|
|
6130
|
-
align-items: center;
|
|
6131
|
-
justify-content: center;
|
|
6137
|
+
input[type='file'] {
|
|
6138
|
+
display: block;
|
|
6139
|
+
margin-top: 0.5em;
|
|
6132
6140
|
}
|
|
6133
|
-
`;var
|
|
6134
|
-
|
|
6141
|
+
`;var Fo=class extends ${static{this.styles=ic}#e=null;#t=null;reset(){this.#e=null,this.#t=null,this.saveResponse(null)}validate(){return this.#t!==null}get response(){return this.#t}set response(r){if(typeof r=="string")this.#t=r,this.saveResponse(r);else if(r===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...$.properties}}render(){return x`
|
|
6142
|
+
<div>
|
|
6143
|
+
<slot name="prompt"></slot>
|
|
6144
|
+
<input type="file" @change="${this.#r}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
|
|
6135
6145
|
</div>
|
|
6136
|
-
${this.marker?f`<div id="label">${this.marker}</div>`:L}
|
|
6137
|
-
<slot part="slot"></slot>`}};c([u({type:String,attribute:"template-identifier"})],nt.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],nt.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],nt.prototype,"fixed",2),c([u({type:String,attribute:!1})],nt.prototype,"marker",2);customElements.define("qti-simple-choice",nt);var zT=async o=>{let r=o.substring(0,o.lastIndexOf("/")),e=await Cn().load(`${o}`).then(a=>a.assessmentTest()),t=await It().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await It().load(`${r}/${e.href}`).then(a=>a.items()),s=`${r}/${e.href}`,n=`${r}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:t,testURI:n,testURL:s,items:i,testIdentifier:e.identifier}},UT=async o=>ve().load(o).then(r=>r.htmlDoc().firstElementChild);var ke=class extends b{render(){return f`<slot></slot>`}process(){throw new Error("Not implemented")}};ke=c([C("qti-rule")],ke);var pi=class extends ke{get childExpression(){return this.firstElementChild}process(){let r=this.getAttribute("identifier"),e=this.context.variables.find(i=>i.identifier===r)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseFloat(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:vr(t)}})),t)}};c([u({type:String})],pi.prototype,"identifier",2),c([k({context:D,subscribe:!0}),w()],pi.prototype,"context",2);customElements.define("qti-lookup-outcome-value",pi);var fo=class extends ke{render(){return f`<slot></slot>`}process(){let r=[...this.children];for(let e=0;e<r.length;e++){let t=r[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",fo);var go=class extends ke{process(){let r=this.getAttribute("identifier");if(!r){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let i=new bo(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.#e(i)}}))}#e(r){return Array.isArray(r)?r.map(vr):r!==null?vr(r):null}},bo=class{constructor(r){this.expression=r}process(){let r=this.expression.calculate()??null;return r===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(r)?r.map(e=>e.value?e.value:e):r}};customElements.define("qti-set-outcome-value",go);var ui=class extends b{render(){return f`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let r=this.getSubRules();for(let e=0;e<r.length;e++)r[e].process()}};customElements.define("qti-response-else",ui);var mi=class extends ui{calculate(){return this.firstElementChild.calculate()}getSubRules(){let r=[];for(let e=1;e<this.children.length;e++)r.push(this.children[e]);return r}};customElements.define("qti-response-if",mi);var vo=class extends mi{render(){return f`${super.render()}`}};customElements.define("qti-response-else-if",vo);var bs=class extends ic(ce){calculate(){return this.calculateChildren(Array.from(this.children))}};bs=c([C("qti-and")],bs);function ic(o){return class extends o{calculateChildren(e){return e.map(i=>{let s=i;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=s.calculate(),a=!1;if(typeof n=="string")if(n==="true")a=!0;else if(n==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(a=n);return a}).every(i=>typeof i=="boolean"&&i)}}}var vs=class extends S{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],vs.prototype,"baseType",2);customElements.define("qti-base-value",vs);var yo=class extends S{getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let r=this.getVariables();if(!r||r?.length===0)return 0;let e=r[0];return e.value===null||e.value===void 0?0:e.cardinality!=="multiple"&&e.cardinality!=="ordered"?(console.error("qti-container-size requires multiple or ordered cardinality"),0):Array.isArray(e.value)?e.value.length:(console.error("qti-container-size: expected array value for multiple/ordered cardinality"),0)}};customElements.define("qti-container-size",yo);var xo=class extends ce{getResult(){let r=this.getVariables();if(this.children.length===2){let e=r[0],t=r[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,s=t.value;return i.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",xo);var qo=class extends S{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let r=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===r)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",qo);var rr=class extends S{constructor(){super(...arguments);this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let e=this.identifier.split("."),t=null,i;if(e.length===2)t=e[0],i=e[1];else if(e.length===1)i=e[0];else return console.error("qti-default: invalid identifier format"),null;if(t){let n=this._testContext.items.find(l=>l.identifier===t);if(console.debug(`itemContext: ${JSON.stringify(n)}`),!this._testContext||!n)return console.warn(`qti-default: item "${t}" not found in test context`),null;let a=this._testContext.items.find(l=>l.identifier===t)?.variables.find(l=>l.identifier===i);return a?a.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${t}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let s=this.context.variables.find(n=>n.identifier===i);return s?s.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};c([u({type:String})],rr.prototype,"identifier",2),c([k({context:D,subscribe:!0}),w()],rr.prototype,"context",2),c([w(),k({context:ye,subscribe:!0})],rr.prototype,"_testContext",2);customElements.define("qti-default",rr);var ys=class extends S{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),n=parseFloat(i.value);if(!isNaN(s)&&!isNaN(n))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};c([u({type:String})],ys.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",ys);var Co=class extends S{getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=r[0];if(e.cardinality!=="single")return console.error("qti-round requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-round requires numerical base-type (integer or float)"),null;let t=parseFloat(e.value);return isNaN(t)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(t)?Math.floor(t+.5):t===1/0?1/0:t===-1/0?-1/0:null}};customElements.define("qti-round",Co);var hi=class extends S{constructor(){super(...arguments);this.roundingMode="significantFigures";this.figures=3}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=e[0];if(t.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(t.value))return console.error("qti-round-to unexpected array value for single cardinality"),null;if(t.value===null||t.value===void 0)return null;if(t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-round-to requires numerical base-type"),null;let i=parseFloat(t.value);return isNaN(i)?null:isFinite(i)?this.figures<0?(console.error("qti-round-to: figures must be non-negative"),null):this.roundingMode==="significantFigures"&&this.figures<1?(console.error("qti-round-to: figures must be at least 1 for significantFigures mode"),null):this.roundingMode==="decimalPlaces"?this.#e(i,this.figures):this.#t(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}#e(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}#t(e,t){if(e===0)return 0;let i=Math.floor(Math.log10(Math.abs(e))),s=Math.pow(10,t-i-1);return Math.round(e*s)/s}};c([u({type:String,attribute:"rounding-mode"})],hi.prototype,"roundingMode",2),c([u({type:Number})],hi.prototype,"figures",2);customElements.define("qti-round-to",hi);var xs=class extends S{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):X.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],xs.prototype,"toleranceMode",2);customElements.define("qti-equal",xs);var wo=class extends S{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=[];for(let t of r){if(t.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(t.value===null||t.value===void 0)return null;if(t.cardinality==="single"){if(Array.isArray(t.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let i=parseInt(t.value,10);if(isNaN(i))return console.error("qti-gcd non-numerical value"),null;e.push(i)}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){if(!Array.isArray(t.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let i of t.value){if(i==null)return null;let s=parseInt(i,10);if(isNaN(s))return console.error("qti-gcd non-numerical value"),null;e.push(s)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this.#e(e)}#e(r){if(r.length===0)return 0;if(r.length===1)return Math.abs(r[0]);let e=Math.abs(r[0]);for(let t=1;t<r.length&&(e=this.#t(e,Math.abs(r[t])),e!==1);t++);return e}#t(r,e){if(r===0&&e===0)return 0;if(r===0)return e;if(e===0)return r;for(;e!==0;){let t=e;e=r%e,r=t}return r}};customElements.define("qti-gcd",wo);var Eo=class extends S{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",Eo);var To=class extends ce{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",To);var Ao=class extends S{getResult(){return null}};customElements.define("qti-null",Ao);var So=class extends S{getResult(){if(this.children.length===1){let r=this.getVariables();if(!r)return!0;let e=r[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",So);var ko=class extends S{getResult(){let r=this.getAttribute("field-identifier");if(!r)throw new Error("field-identifier attribute is required");if(Array.from(this.children).length!==1)throw new Error("qti-field-value must have exactly one child expression");let t=this.getVariables()[0];if(t.baseType!=="record"||t.value===null)throw new Error("qti-field-value child expression must return a record");let i=t.value[r];if(i===void 0)throw new Error(`Field "${r}" not found in record`);return i}};customElements.define("qti-field-value",ko);var Mo=class extends S{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Mo);var Io=class extends ce{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",Io);var qs=class extends S{getResult(){let r=this.context.variables.find(s=>s.identifier===this.identifier);if(!r||!r.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=r.mapping,t=Array.isArray(r.value)?r.value:[r.value],i=0;for(let s of t){let n=e.mapEntries.filter(l=>r.baseType==="string"&&!l.caseSensitive?X.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):X.compareSingleValues(l.mapKey,s,r.baseType)),a=n.reduce((l,d)=>l.mappedValue>d.mappedValue?l:d,n.length>0?n[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(i=Math.max(e.lowerBound,i)),e?.upperBound!==null&&e?.upperBound!==void 0&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],qs.prototype,"identifier",2);customElements.define("qti-map-response",qs);var Cs=class extends S{getResult(){let r=this.context.variables.find(n=>n.identifier===this.identifier);if(!r)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=r.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(r.value)?r.value:[r.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let i=0,s=new Set;for(let n of t)for(let a of e.areaMapEntries){if(s.has(a.coords))continue;X.isPointInArea(n,`${a.shape},${a.coords}`,r.baseType)&&(i+=a.mappedValue??0,s.add(a.coords))}return s.size<t.length&&(i+=e.defaultValue),e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],Cs.prototype,"identifier",2);customElements.define("qti-map-response-point",Cs);var ws=class extends S{constructor(){super(...arguments);this.name=""}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=[];for(let i of e){if(i.cardinality!=="single")return console.error("qti-math-operator requires single cardinality"),null;if(Array.isArray(i.value))return console.error("qti-math-operator unexpected array value for single cardinality"),null;if(i.value===null||i.value===void 0)return null;if(i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-math-operator requires numerical base-type"),null;let s=parseFloat(i.value);if(isNaN(s))return console.error("qti-math-operator non-numerical value"),null;t.push(s)}return this.#e(this.name,t)}#e(e,t){try{switch(e.toLowerCase()){case"sin":return t.length!==1?null:Math.sin(t[0]);case"cos":return t.length!==1?null:Math.cos(t[0]);case"tan":return t.length!==1?null:Math.tan(t[0]);case"asin":return t.length!==1||t[0]<-1||t[0]>1?null:Math.asin(t[0]);case"acos":return t.length!==1||t[0]<-1||t[0]>1?null:Math.acos(t[0]);case"atan":return t.length!==1?null:Math.atan(t[0]);case"sinh":return t.length!==1?null:Math.sinh(t[0]);case"cosh":return t.length!==1?null:Math.cosh(t[0]);case"tanh":return t.length!==1?null:Math.tanh(t[0]);case"log":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"ln":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"log10":return t.length!==1||t[0]<=0?null:Math.log10(t[0]);case"exp":return t.length!==1?null:Math.exp(t[0]);case"abs":return t.length!==1?null:Math.abs(t[0]);case"sqrt":return t.length!==1||t[0]<0?null:Math.sqrt(t[0]);case"signum":return t.length!==1?null:Math.sign(t[0]);case"floor":return t.length!==1?null:Math.floor(t[0]);case"ceil":return t.length!==1?null:Math.ceil(t[0]);case"round":return t.length!==1?null:Math.round(t[0]);case"atan2":return t.length!==2?null:Math.atan2(t[0],t[1]);case"pow":{if(t.length!==2)return null;let i=t[0],s=t[1];return i===0&&s<=0||i<0&&!Number.isInteger(s)?null:Math.pow(i,s)}case"log_base":{if(t.length!==2)return null;let i=t[0],s=t[1];return i<=0||s<=0||s===1?null:Math.log(i)/Math.log(s)}case"mod":return t.length!==2||t[1]===0?null:t[0]%t[1];case"max":return t.length<1?null:Math.max(...t);case"min":return t.length<1?null:Math.min(...t);default:return console.error(`qti-math-operator: unknown operation "${e}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${e}":`,i),null}}};c([u({type:String})],ws.prototype,"name",2);customElements.define("qti-math-operator",ws);var Ro=class o extends S{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return o.match(e,t)}return console.error("unexpected number of children in match"),null}static match(r,e){if(r.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(r.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):X.compareSingleValues(r.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;for(let t=0;t<r.value.length;t++)if(!X.compareSingleValues(e.value[t],r.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let s=null,n=[...r.value];for(let a of n)if(X.compareSingleValues(i,a,e.baseType)){s=a;break}if(s!==null)n.splice(n.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",Ro);var _o=class extends S{getResult(){let r=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=r;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",_o);var Lo=class extends S{getResult(){console.debug("qti-multiple getResult called",this.innerHTML);let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return r}};customElements.define("qti-multiple",Lo);var $o=class extends S{render(){return f`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",$o);var Oo=class extends ce{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),s=!1;if(typeof i=="string")if(i==="true")s=!0;else if(i==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(s=i);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Oo);var Po=class extends S{getResult(){let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return r}};customElements.define("qti-ordered",Po);var Vo=class extends S{getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let r=this.getVariables();if(!r||r.length!==2)return null;let[e,t]=r;if(e.cardinality!=="single"||t.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(t.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||t.value===null||t.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let i=parseFloat(e.value),s=parseFloat(t.value);if(isNaN(i)||isNaN(s))return console.error("qti-power: non-numerical values encountered"),null;if(i===0&&s<=0||i<0&&!Number.isInteger(s))return null;let n;try{n=Math.pow(i,s)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(n))return null;if(n===1/0||n===-1/0)return n;if(!isFinite(n)||Math.abs(n)>Number.MAX_VALUE||n!==0&&Math.abs(n)<Number.MIN_VALUE)return null;if(isFinite(n)&&n!==0){let a=Math.floor(Math.log10(Math.abs(n))),l=Math.max(0,14-a),d=Math.pow(10,l);n=Math.round(n*d)/d}return n}};customElements.define("qti-power",Vo);var fi=class extends b{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?L:f`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],fi.prototype,"identifier",2),c([k({context:D,subscribe:!0}),w()],fi.prototype,"context",2);customElements.define("qti-printed-variable",fi);var No=class extends S{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseFloat(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",No);var Es=class extends sc(S){getResult(){return this.calculateChildren(Array.from(this.children))}};function sc(o){return class extends o{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=i.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",Es);var Ts=class extends S{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return X.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],Ts.prototype,"caseSensitive",2);customElements.define("qti-string-match",Ts);var Do=class extends S{getResult(){return new Ho(Array.from(this.children)).calculate()}},Ho=class{constructor(r){this.expressions=r}calculate(){return this.expressions.filter(t=>t.calculate!==void 0).some(t=>t.calculate()===null)?null:this.expressions.map(t=>{let i=t.calculate();return Number.isNaN(i)?(console.error("unexpected value in qti-sum, expected number"),null):Number(i)}).reduce((t,i)=>t+i,0)}};customElements.define("qti-sum",Do);var zo=class extends S{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",zo);var ir=class extends S{constructor(){super(...arguments);this.min=0;this.max=10;this.step=1}getResult(){if(this.min>this.max)return console.error("qti-random-integer: min cannot be greater than max"),this.min;if(this.step<=0)return console.error("qti-random-integer: step must be positive"),this.min;let e=[],t=0;for(;;){let s=this.min+this.step*t;if(s>this.max)break;Number.isInteger(s)&&e.push(s),t++}if(e.length===0)return console.warn("qti-random-integer: no valid integer values in range"),Number.isInteger(this.min)?this.min:Math.floor(this.min);let i=Math.floor(Math.random()*e.length);return e[i]}getPossibleValues(){let e=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let t=0;for(;;){let i=this.min+this.step*t;if(i>this.max)break;Number.isInteger(i)&&e.push(i),t++}return e.length>0?e:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};c([u({type:Number})],ir.prototype,"min",2),c([u({type:Number})],ir.prototype,"max",2),c([u({type:Number})],ir.prototype,"step",2);customElements.define("qti-random-integer",ir);var Uo=class extends S{getResult(){let r=this.getVariables();if(r.length===1){let e=r[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",Uo);var Bo=class extends S{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):r[0].baseType!==r[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(s=>!e.value.includes(s))}return null}};customElements.define("qti-delete",Bo);var As,ol,gi=class extends S{constructor(){super(...arguments);T(this,As)}getResult(){if(!this.n)return console.error('qti-index: missing required attribute "n"'),null;if(this.children.length!==1)return console.error("qti-index: must have exactly one child container element"),null;let e=this.getVariables()[0];if(!e)return console.error("qti-index: missing container"),null;let t;if(!isNaN(Number(this.n)))t=Number(this.n);else{let i=I(this,As,ol).call(this,this.n);if(i===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;t=Number(i)}if(t<=0||!Number.isInteger(t))return console.error("qti-index: index must be a positive integer"),null;if(e.cardinality==="ordered"){let i=Array.isArray(e.value)?e.value:[e.value];return e.value===null||t>i.length?null:i[t-1]}else return console.error("qti-index: child must have ordered cardinality"),null}};As=new WeakSet,ol=function(e){let t=this.context.variables.find(i=>i.identifier===e)?.value;return t===null||isNaN(Number(t))?null:Number(t)},c([u({type:String})],gi.prototype,"n",2),gi=c([C("qti-index")],gi);export{_n as Correctness,Ws as INITIAL_SESSION_CONTEXT,Xs as INITIAL_TEST_CONTEXT,R as Interaction,Qs as IsNullOrUndefined,Pe as ItemContainer,xt as ItemCorrectResponseMode,Kt as ItemPrintVariables,he as ItemShowCandidateCorrection,fe as ItemShowCorrectResponse,bs as QtiAnd,ie as QtiAssessmentItem,Re as QtiAssessmentItemRef,_e as QtiAssessmentSection,Nt as QtiAssessmentStimulusRef,Zs as QtiAssessmentStimulusRefConnectedEvent,ht as QtiAssessmentTest,hs as QtiAssociableHotspot,ii as QtiAssociateInteraction,vs as QtiBaseValue,si as QtiChoiceInteraction,Vi as QtiCompanionMaterialsInfo,ce as QtiConditionExpression,yo as QtiContainerSize,xo as QtiContains,Ni as QtiContentBody,gt as QtiContextDeclaration,qo as QtiCorrect,Ve as QtiCustomInteraction,Mr as QtiCustomOperator,rr as QtiDefault,Bo as QtiDelete,et as QtiEndAttemptInteraction,xs as QtiEqual,ys as QtiEqualRounded,S as QtiExpression,ae as QtiExtendedTextInteraction,re as QtiFeedback,Rr as QtiFeedbackBlock,_r as QtiFeedbackInline,ko as QtiFieldValue,ai as QtiGap,li as QtiGapImg,os as QtiGapMatchInteraction,ci as QtiGapText,wo as QtiGcd,Ne as QtiGraphicAssociateInteraction,ns as QtiGraphicGapMatchInteraction,as as QtiGraphicOrderInteraction,Eo as QtiGt,To as QtiGte,tr as QtiHotspotChoice,ls as QtiHotspotInteraction,fs as QtiHottext,oi as QtiHottextInteraction,gi as QtiIndex,di as QtiInlineChoice,rt as QtiInlineChoiceInteraction,So as QtiIsNull,Zt as QtiItem,Lr as QtiItemBody,pi as QtiLookupOutcomeValue,Mo as QtiLt,Io as QtiLte,qs as QtiMapResponse,Cs as QtiMapResponsePoint,Ro as QtiMatch,it as QtiMatchInteraction,ws as QtiMathOperator,cs as QtiMediaInteraction,_o as QtiMember,ft as QtiModalFeedback,Lo as QtiMultiple,$o as QtiNot,Ao as QtiNull,Oo as QtiOr,st as QtiOrderInteraction,Po as QtiOrdered,we as QtiOutcomeDeclaration,B as QtiPortableCustomInteraction,ps as QtiPositionObjectInteraction,us as QtiPositionObjectStage,Vo as QtiPower,fi as QtiPrintedVariable,No as QtiProduct,gs as QtiPrompt,Uo as QtiRandom,ir as QtiRandomInteger,fo as QtiResponseCondition,$e as QtiResponseDeclaration,ui as QtiResponseElse,vo as QtiResponseElseIf,mi as QtiResponseIf,Or as QtiResponseProcessing,Co as QtiRound,hi as QtiRoundTo,Ce as QtiRubricBlock,Ln as QtiRuleElement,De as QtiSelectPointInteraction,go as QtiSetOutcomeValue,bo as QtiSetOutcomeValueRule,Ct as QtiSimpleAssociableChoice,nt as QtiSimpleChoice,ot as QtiSliderInteraction,Ts as QtiStringMatch,Di as QtiStylesheet,Es as QtiSubtract,Do as QtiSum,Ho as QtiSumExpression,Ee as QtiTemplateDeclaration,Pi as QtiTest,Pr as QtiTestFeedback,Le as QtiTestPart,ge as QtiTextEntryInteraction,ms as QtiUploadInteraction,zo as QtiVariable,Ot as QtiVariableDeclaration,X as ScoringHelper,Jr as TestCheckItem,Oe as TestContainer,Nr as TestEndAttempt,zt as TestItemLink,pe as TestNavigation,Je as TestNext,Fr as TestPagingButtonsStamp,Ke as TestPrev,Qr as TestPrintContext,Ft as TestPrintVariables,yt as TestScoringButtons,Wt as TestScoringFeedback,Xr as TestSectionButtonsStamp,jt as TestSectionLink,me as TestShowCorrectResponse,vt as TestStamp,J as TestView,Yr as TestViewToggle,N as computedContext,Be as computedItemContext,le as configContext,vr as convertNumberToUniversalFormat,Rl as decimalSeparator,UT as getItemByUri,zT as getManifestInfo,D as itemContext,Tn as itemContextVariables,ic as qtiAndMixin,Lt as qtiContext,sc as qtiSubtractMixin,ve as qtiTransformItem,Cn as qtiTransformManifest,It as qtiTransformTest,Oi as removeDoubleSlashes,Fe as sessionContext,ye as testContext};
|
|
6146
|
+
`}async#r(r){let e=r.target;e.files&&e.files.length>0&&(this.#e=e.files[0],this.#t=await this.#i(this.#e),this.saveResponse(this.#t),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this.#t}})))}#i(r){return new Promise((e,t)=>{let i=new FileReader;i.onload=()=>e(i.result),i.onerror=()=>t(i.error),i.readAsDataURL(r)})}};customElements.define("qti-upload-interaction",Fo);var sk=async s=>{let r=s.substring(0,s.lastIndexOf("/")),e=await Kn().load(`${s}`).then(a=>a.assessmentTest()),t=await jt().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await jt().load(`${r}/${e.href}`).then(a=>a.items()),o=`${r}/${e.href}`,n=`${r}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:t,testURI:n,testURL:o,items:i,testIdentifier:e.identifier}},nk=async s=>Ae().load(s).then(r=>r.htmlDoc().firstElementChild);var Oe=class extends C{render(){return x`<slot></slot>`}process(){throw new Error("Not implemented")}};Oe=d([k("qti-rule")],Oe);var ki=class extends Oe{get childExpression(){return this.firstElementChild}process(){let r=this.getAttribute("identifier"),e=this.context.variables.find(i=>i.identifier===r)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseFloat(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Pr(t)}})),t)}};d([b({type:String})],ki.prototype,"identifier",2),d([P({context:G,subscribe:!0}),R()],ki.prototype,"context",2);customElements.define("qti-lookup-outcome-value",ki);var js=class extends Oe{render(){return x`<slot></slot>`}process(){let r=[...this.children];for(let e=0;e<r.length;e++){let t=r[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",js);var Ws=class extends Oe{process(){let r=this.getAttribute("identifier");if(!r){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let i=new Gs(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.#e(i)}}))}#e(r){return Array.isArray(r)?r.map(Pr):r!==null?Pr(r):null}},Gs=class{constructor(r){this.expression=r}process(){let r=this.expression.calculate()??null;return r===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(r)?r.map(e=>e.value?e.value:e):r}};customElements.define("qti-set-outcome-value",Ws);var Mi=class extends C{render(){return x`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let r=this.getSubRules();for(let e=0;e<r.length;e++)r[e].process()}};customElements.define("qti-response-else",Mi);var Ri=class extends Mi{calculate(){return this.firstElementChild.calculate()}getSubRules(){let r=[];for(let e=1;e<this.children.length;e++)r.push(this.children[e]);return r}};customElements.define("qti-response-if",Ri);var Xs=class extends Ri{render(){return x`${super.render()}`}};customElements.define("qti-response-else-if",Xs);var Bo=class extends bd(fe){calculate(){return this.calculateChildren(Array.from(this.children))}};Bo=d([k("qti-and")],Bo);function bd(s){return class extends s{calculateChildren(e){return e.map(i=>{let o=i;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=o.calculate(),a=!1;if(typeof n=="string")if(n==="true")a=!0;else if(n==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(a=n);return a}).every(i=>typeof i=="boolean"&&i)}}}var Uo=class extends L{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};d([b({type:String,attribute:"base-type"})],Uo.prototype,"baseType",2);customElements.define("qti-base-value",Uo);var Qs=class extends L{getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let r=this.getVariables();if(!r||r?.length===0)return 0;let e=r[0];return e.value===null||e.value===void 0?0:e.cardinality!=="multiple"&&e.cardinality!=="ordered"?(console.error("qti-container-size requires multiple or ordered cardinality"),0):Array.isArray(e.value)?e.value.length:(console.error("qti-container-size: expected array value for multiple/ordered cardinality"),0)}};customElements.define("qti-container-size",Qs);var Js=class extends fe{getResult(){let r=this.getVariables();if(this.children.length===2){let e=r[0],t=r[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,o=t.value;return i.filter(l=>o.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",Js);var Ys=class extends L{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let r=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===r)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Ys);var vr=class extends L{constructor(){super(...arguments);this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let e=this.identifier.split("."),t=null,i;if(e.length===2)t=e[0],i=e[1];else if(e.length===1)i=e[0];else return console.error("qti-default: invalid identifier format"),null;if(t){let n=this._testContext.items.find(l=>l.identifier===t);if(console.debug(`itemContext: ${JSON.stringify(n)}`),!this._testContext||!n)return console.warn(`qti-default: item "${t}" not found in test context`),null;let a=this._testContext.items.find(l=>l.identifier===t)?.variables.find(l=>l.identifier===i);return a?a.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${t}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let o=this.context.variables.find(n=>n.identifier===i);return o?o.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};d([b({type:String})],vr.prototype,"identifier",2),d([P({context:G,subscribe:!0}),R()],vr.prototype,"context",2),d([R(),P({context:Ie,subscribe:!0})],vr.prototype,"_testContext",2);customElements.define("qti-default",vr);var zo=class extends L{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(t.value),n=parseFloat(i.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};d([b({type:String})],zo.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",zo);var Ks=class extends L{getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=r[0];if(e.cardinality!=="single")return console.error("qti-round requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-round requires numerical base-type (integer or float)"),null;let t=parseFloat(e.value);return isNaN(t)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(t)?Math.floor(t+.5):t===1/0?1/0:t===-1/0?-1/0:null}};customElements.define("qti-round",Ks);var _i=class extends L{constructor(){super(...arguments);this.roundingMode="significantFigures";this.figures=3}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=e[0];if(t.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(t.value))return console.error("qti-round-to unexpected array value for single cardinality"),null;if(t.value===null||t.value===void 0)return null;if(t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-round-to requires numerical base-type"),null;let i=parseFloat(t.value);return isNaN(i)?null:isFinite(i)?this.figures<0?(console.error("qti-round-to: figures must be non-negative"),null):this.roundingMode==="significantFigures"&&this.figures<1?(console.error("qti-round-to: figures must be at least 1 for significantFigures mode"),null):this.roundingMode==="decimalPlaces"?this.#e(i,this.figures):this.#t(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}#e(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}#t(e,t){if(e===0)return 0;let i=Math.floor(Math.log10(Math.abs(e))),o=Math.pow(10,t-i-1);return Math.round(e*o)/o}};d([b({type:String,attribute:"rounding-mode"})],_i.prototype,"roundingMode",2),d([b({type:Number})],_i.prototype,"figures",2);customElements.define("qti-round-to",_i);var jo=class extends L{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):K.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};d([b({type:String})],jo.prototype,"toleranceMode",2);customElements.define("qti-equal",jo);var Zs=class extends L{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=[];for(let t of r){if(t.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(t.value===null||t.value===void 0)return null;if(t.cardinality==="single"){if(Array.isArray(t.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let i=parseInt(t.value,10);if(isNaN(i))return console.error("qti-gcd non-numerical value"),null;e.push(i)}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){if(!Array.isArray(t.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let i of t.value){if(i==null)return null;let o=parseInt(i,10);if(isNaN(o))return console.error("qti-gcd non-numerical value"),null;e.push(o)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this.#e(e)}#e(r){if(r.length===0)return 0;if(r.length===1)return Math.abs(r[0]);let e=Math.abs(r[0]);for(let t=1;t<r.length&&(e=this.#t(e,Math.abs(r[t])),e!==1);t++);return e}#t(r,e){if(r===0&&e===0)return 0;if(r===0)return e;if(e===0)return r;for(;e!==0;){let t=e;e=r%e,r=t}return r}};customElements.define("qti-gcd",Zs);var en=class extends L{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",en);var tn=class extends fe{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",tn);var rn=class extends L{getResult(){return null}};customElements.define("qti-null",rn);var on=class extends L{getResult(){if(this.children.length===1){let r=this.getVariables();if(!r)return!0;let e=r[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",on);var sn=class extends L{getResult(){let r=this.getAttribute("field-identifier");if(!r)throw new Error("field-identifier attribute is required");if(Array.from(this.children).length!==1)throw new Error("qti-field-value must have exactly one child expression");let t=this.getVariables()[0];if(t.baseType!=="record"||t.value===null)throw new Error("qti-field-value child expression must return a record");let i=t.value[r];if(i===void 0)throw new Error(`Field "${r}" not found in record`);return i}};customElements.define("qti-field-value",sn);var nn=class extends L{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",nn);var an=class extends fe{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",an);var Wo=class extends L{getResult(){let r=this.context.variables.find(o=>o.identifier===this.identifier);if(!r||!r.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=r.mapping,t=Array.isArray(r.value)?r.value:[r.value],i=0;for(let o of t){let n=e.mapEntries.filter(l=>r.baseType==="string"&&!l.caseSensitive?K.compareSingleValues(l.mapKey.toLowerCase(),o.toLowerCase(),r.baseType):K.compareSingleValues(l.mapKey,o,r.baseType)),a=n.reduce((l,c)=>l.mappedValue>c.mappedValue?l:c,n.length>0?n[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(i=Math.max(e.lowerBound,i)),e?.upperBound!==null&&e?.upperBound!==void 0&&(i=Math.min(e.upperBound,i)),i}};d([b({type:String})],Wo.prototype,"identifier",2);customElements.define("qti-map-response",Wo);var Go=class extends L{getResult(){let r=this.context.variables.find(n=>n.identifier===this.identifier);if(!r)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=r.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(r.value)?r.value:[r.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let i=0,o=new Set;for(let n of t)for(let a of e.areaMapEntries){if(o.has(a.coords))continue;K.isPointInArea(n,`${a.shape},${a.coords}`,r.baseType)&&(i+=a.mappedValue??0,o.add(a.coords))}return o.size<t.length&&(i+=e.defaultValue),e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};d([b({type:String})],Go.prototype,"identifier",2);customElements.define("qti-map-response-point",Go);var Xo=class extends L{constructor(){super(...arguments);this.name=""}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=[];for(let i of e){if(i.cardinality!=="single")return console.error("qti-math-operator requires single cardinality"),null;if(Array.isArray(i.value))return console.error("qti-math-operator unexpected array value for single cardinality"),null;if(i.value===null||i.value===void 0)return null;if(i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-math-operator requires numerical base-type"),null;let o=parseFloat(i.value);if(isNaN(o))return console.error("qti-math-operator non-numerical value"),null;t.push(o)}return this.#e(this.name,t)}#e(e,t){try{switch(e.toLowerCase()){case"sin":return t.length!==1?null:Math.sin(t[0]);case"cos":return t.length!==1?null:Math.cos(t[0]);case"tan":return t.length!==1?null:Math.tan(t[0]);case"asin":return t.length!==1||t[0]<-1||t[0]>1?null:Math.asin(t[0]);case"acos":return t.length!==1||t[0]<-1||t[0]>1?null:Math.acos(t[0]);case"atan":return t.length!==1?null:Math.atan(t[0]);case"sinh":return t.length!==1?null:Math.sinh(t[0]);case"cosh":return t.length!==1?null:Math.cosh(t[0]);case"tanh":return t.length!==1?null:Math.tanh(t[0]);case"log":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"ln":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"log10":return t.length!==1||t[0]<=0?null:Math.log10(t[0]);case"exp":return t.length!==1?null:Math.exp(t[0]);case"abs":return t.length!==1?null:Math.abs(t[0]);case"sqrt":return t.length!==1||t[0]<0?null:Math.sqrt(t[0]);case"signum":return t.length!==1?null:Math.sign(t[0]);case"floor":return t.length!==1?null:Math.floor(t[0]);case"ceil":return t.length!==1?null:Math.ceil(t[0]);case"round":return t.length!==1?null:Math.round(t[0]);case"atan2":return t.length!==2?null:Math.atan2(t[0],t[1]);case"pow":{if(t.length!==2)return null;let i=t[0],o=t[1];return i===0&&o<=0||i<0&&!Number.isInteger(o)?null:Math.pow(i,o)}case"log_base":{if(t.length!==2)return null;let i=t[0],o=t[1];return i<=0||o<=0||o===1?null:Math.log(i)/Math.log(o)}case"mod":return t.length!==2||t[1]===0?null:t[0]%t[1];case"max":return t.length<1?null:Math.max(...t);case"min":return t.length<1?null:Math.min(...t);default:return console.error(`qti-math-operator: unknown operation "${e}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${e}":`,i),null}}};d([b({type:String})],Xo.prototype,"name",2);customElements.define("qti-math-operator",Xo);var ln=class s extends L{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return s.match(e,t)}return console.error("unexpected number of children in match"),null}static match(r,e){if(r.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(r.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):K.compareSingleValues(r.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;for(let t=0;t<r.value.length;t++)if(!K.compareSingleValues(e.value[t],r.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let o=null,n=[...r.value];for(let a of n)if(K.compareSingleValues(i,a,e.baseType)){o=a;break}if(o!==null)n.splice(n.indexOf(o),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",ln);var cn=class extends L{getResult(){let r=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=r;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",cn);var dn=class extends L{getResult(){console.debug("qti-multiple getResult called",this.innerHTML);let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return r}};customElements.define("qti-multiple",dn);var pn=class extends L{render(){return x`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",pn);var un=class extends fe{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),o=!1;if(typeof i=="string")if(i==="true")o=!0;else if(i==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(o=i);return o}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",un);var mn=class extends L{getResult(){let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return r}};customElements.define("qti-ordered",mn);var hn=class extends L{getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let r=this.getVariables();if(!r||r.length!==2)return null;let[e,t]=r;if(e.cardinality!=="single"||t.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(t.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||t.value===null||t.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let i=parseFloat(e.value),o=parseFloat(t.value);if(isNaN(i)||isNaN(o))return console.error("qti-power: non-numerical values encountered"),null;if(i===0&&o<=0||i<0&&!Number.isInteger(o))return null;let n;try{n=Math.pow(i,o)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(n))return null;if(n===1/0||n===-1/0)return n;if(!isFinite(n)||Math.abs(n)>Number.MAX_VALUE||n!==0&&Math.abs(n)<Number.MIN_VALUE)return null;if(isFinite(n)&&n!==0){let a=Math.floor(Math.log10(Math.abs(n))),l=Math.max(0,14-a),c=Math.pow(10,l);n=Math.round(n*c)/c}return n}};customElements.define("qti-power",hn);var Li=class extends C{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?N:x`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};d([b({type:String})],Li.prototype,"identifier",2),d([P({context:G,subscribe:!0}),R()],Li.prototype,"context",2);customElements.define("qti-printed-variable",Li);var fn=class extends L{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseFloat(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",fn);var Qo=class extends vd(L){getResult(){return this.calculateChildren(Array.from(this.children))}};function vd(s){return class extends s{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=i.calculate();return Number.isNaN(o)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(o)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",Qo);var Jo=class extends L{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let o=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return K.compareSingleValues(o,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};d([b({type:String,attribute:"case-sensitive"})],Jo.prototype,"caseSensitive",2);customElements.define("qti-string-match",Jo);var gn=class extends L{getResult(){return new bn(Array.from(this.children)).calculate()}},bn=class{constructor(r){this.expressions=r}calculate(){return this.expressions.filter(t=>t.calculate!==void 0).some(t=>t.calculate()===null)?null:this.expressions.map(t=>{let i=t.calculate();return Number.isNaN(i)?(console.error("unexpected value in qti-sum, expected number"),null):Number(i)}).reduce((t,i)=>t+i,0)}};customElements.define("qti-sum",gn);var vn=class extends L{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",vn);var yr=class extends L{constructor(){super(...arguments);this.min=0;this.max=10;this.step=1}getResult(){if(this.min>this.max)return console.error("qti-random-integer: min cannot be greater than max"),this.min;if(this.step<=0)return console.error("qti-random-integer: step must be positive"),this.min;let e=[],t=0;for(;;){let o=this.min+this.step*t;if(o>this.max)break;Number.isInteger(o)&&e.push(o),t++}if(e.length===0)return console.warn("qti-random-integer: no valid integer values in range"),Number.isInteger(this.min)?this.min:Math.floor(this.min);let i=Math.floor(Math.random()*e.length);return e[i]}getPossibleValues(){let e=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let t=0;for(;;){let i=this.min+this.step*t;if(i>this.max)break;Number.isInteger(i)&&e.push(i),t++}return e.length>0?e:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};d([b({type:Number})],yr.prototype,"min",2),d([b({type:Number})],yr.prototype,"max",2),d([b({type:Number})],yr.prototype,"step",2);customElements.define("qti-random-integer",yr);var yn=class extends L{getResult(){let r=this.getVariables();if(r.length===1){let e=r[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",yn);var xn=class extends L{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):r[0].baseType!==r[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(o=>!e.value.includes(o))}return null}};customElements.define("qti-delete",xn);var Yo,oc,Pi=class extends L{constructor(){super(...arguments);_(this,Yo)}getResult(){if(!this.n)return console.error('qti-index: missing required attribute "n"'),null;if(this.children.length!==1)return console.error("qti-index: must have exactly one child container element"),null;let e=this.getVariables()[0];if(!e)return console.error("qti-index: missing container"),null;let t;if(!isNaN(Number(this.n)))t=Number(this.n);else{let i=D(this,Yo,oc).call(this,this.n);if(i===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;t=Number(i)}if(t<=0||!Number.isInteger(t))return console.error("qti-index: index must be a positive integer"),null;if(e.cardinality==="ordered"){let i=Array.isArray(e.value)?e.value:[e.value];return e.value===null||t>i.length?null:i[t-1]}else return console.error("qti-index: child must have ordered cardinality"),null}};Yo=new WeakSet,oc=function(e){let t=this.context.variables.find(i=>i.identifier===e)?.value;return t===null||isNaN(Number(t))?null:Number(t)},d([b({type:String})],Pi.prototype,"n",2),Pi=d([k("qti-index")],Pi);export{la as Correctness,vs as INITIAL_SESSION_CONTEXT,ys as INITIAL_TEST_CONTEXT,$ as Interaction,qs as IsNullOrUndefined,We as ItemContainer,Pt as ItemCorrectResponseMode,mr as ItemPrintVariables,xe as ItemShowCandidateCorrection,qe as ItemShowCorrectResponse,Bo as QtiAnd,ce as QtiAssessmentItem,Fe as QtiAssessmentItemRef,Be as QtiAssessmentSection,Zt as QtiAssessmentStimulusRef,Ss as QtiAssessmentStimulusRefConnectedEvent,It as QtiAssessmentTest,Co as QtiAssociableHotspot,Si as QtiAssociateInteraction,Uo as QtiBaseValue,Ti as QtiChoiceInteraction,eo as QtiCompanionMaterialsInfo,fe as QtiConditionExpression,Qs as QtiContainerSize,Js as QtiContains,to as QtiContentBody,Mt as QtiContextDeclaration,Ys as QtiCorrect,Ge as QtiCustomInteraction,jr as QtiCustomOperator,vr as QtiDefault,xn as QtiDelete,ft as QtiEndAttemptInteraction,jo as QtiEqual,zo as QtiEqualRounded,L as QtiExpression,me as QtiExtendedTextInteraction,le as QtiFeedback,Gr as QtiFeedbackBlock,Xr as QtiFeedbackInline,sn as QtiFieldValue,yi as QtiGap,xi as QtiGapImg,Lo as QtiGapMatchInteraction,qi as QtiGapText,Zs as QtiGcd,Xe as QtiGraphicAssociateInteraction,Po as QtiGraphicGapMatchInteraction,Do as QtiGraphicOrderInteraction,en as QtiGt,tn as QtiGte,fr as QtiHotspotChoice,$o as QtiHotspotInteraction,Eo as QtiHottext,Ai as QtiHottextInteraction,Pi as QtiIndex,wi as QtiInlineChoice,bt as QtiInlineChoiceInteraction,on as QtiIsNull,hr as QtiItem,Qr as QtiItemBody,ki as QtiLookupOutcomeValue,nn as QtiLt,an as QtiLte,Wo as QtiMapResponse,Go as QtiMapResponsePoint,ln as QtiMatch,vt as QtiMatchInteraction,Xo as QtiMathOperator,Oo as QtiMediaInteraction,cn as QtiMember,kt as QtiModalFeedback,dn as QtiMultiple,pn as QtiNot,rn as QtiNull,un as QtiOr,yt as QtiOrderInteraction,mn as QtiOrdered,_e as QtiOutcomeDeclaration,Z as QtiPortableCustomInteraction,No as QtiPositionObjectInteraction,Ho as QtiPositionObjectStage,hn as QtiPower,Li as QtiPrintedVariable,fn as QtiProduct,So as QtiPrompt,yn as QtiRandom,yr as QtiRandomInteger,js as QtiResponseCondition,ze as QtiResponseDeclaration,Mi as QtiResponseElse,Xs as QtiResponseElseIf,Ri as QtiResponseIf,Yr as QtiResponseProcessing,Ks as QtiRound,_i as QtiRoundTo,Re as QtiRubricBlock,ca as QtiRuleElement,Qe as QtiSelectPointInteraction,Ws as QtiSetOutcomeValue,Gs as QtiSetOutcomeValueRule,Dt as QtiSimpleAssociableChoice,ct as QtiSimpleChoice,xt as QtiSliderInteraction,Jo as QtiStringMatch,ro as QtiStylesheet,Qo as QtiSubtract,gn as QtiSum,bn as QtiSumExpression,Le as QtiTemplateDeclaration,Zi as QtiTest,Kr as QtiTestFeedback,Ue as QtiTestPart,Ee as QtiTextEntryInteraction,Fo as QtiUploadInteraction,vn as QtiVariable,Jt as QtiVariableDeclaration,K as ScoringHelper,mi as TestCheckItem,je as TestContainer,ei as TestEndAttempt,rr as TestItemLink,be as TestNavigation,at as TestNext,ni as TestPagingButtonsStamp,lt as TestPrev,pi as TestPrintContext,sr as TestPrintVariables,Lt as TestScoringButtons,ar as TestScoringFeedback,ci as TestSectionButtonsStamp,nr as TestSectionLink,ye as TestShowCorrectResponse,_t as TestStamp,ie as TestView,ui as TestViewToggle,W as computedContext,Ze as computedItemContext,he as configContext,Pr as convertNumberToUniversalFormat,kc as decimalSeparator,nk as getItemByUri,sk as getManifestInfo,G as itemContext,ta as itemContextVariables,bd as qtiAndMixin,Xt as qtiContext,vd as qtiSubtractMixin,Ae as qtiTransformItem,Kn as qtiTransformManifest,jt as qtiTransformTest,Ki as removeDoubleSlashes,et as sessionContext,Ie as testContext};
|
|
6138
6147
|
/*! Bundled license information:
|
|
6139
6148
|
|
|
6140
6149
|
@lit-labs/ssr-dom-shim/lib/element-internals.js:
|