@citolab/qti-components 7.20.2 → 7.20.3
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 +81 -63
- package/dist/{chunk-5R3SZ6YB.js → chunk-VEPXXFFW.js} +70 -61
- package/dist/chunk-VEPXXFFW.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/interactions.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-5R3SZ6YB.js.map +0 -1
package/cdn/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var Ds=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var Vs=(o,r)=>{for(var e in r)Ds(o,e,{get:r[e],enumerable:!0})};var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?vn(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&Ds(r,e,i),i};var Ns=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 ne=function(o,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"?o!==r||!i:!r.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?i.call(o,e):i?i.value=e:r.set(o,e),e},N=function(o,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?o!==r||!t:!r.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(o):t?t.value:r.get(o)},at,qr,Cr,kt,_i,Mt,wr,Xe,It,Re,Er,Hs,zs=o=>typeof o=="boolean"?o:o?.capture??!1;var Ti=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=zs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);if(s===void 0)s=new Map,i.set(r,s);else if(s.has(e))return;let n=typeof t=="object"&&t?t:{};n.signal?.addEventListener("abort",()=>this.removeEventListener(r,e,t)),s.set(e,n??{})}removeEventListener(r,e,t){if(e==null)return;let i=zs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);s!==void 0&&(s.delete(e),s.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,s=!1,n=0,a=null,l=null,d=null,p=r.stopPropagation,m=r.stopImmediatePropagation;Object.defineProperties(r,{target:{get(){return a??l},...
|
|
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=qn(),this.__pendingWhenDefineds.set(r,t)),t.promise}},Cn=Mi;var Fs=new Cn;var $t=globalThis,_r=$t.ShadowRoot&&($t.ShadyCSS===void 0||$t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Li=Symbol(),js=new WeakMap,Pt=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Li)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(_r&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=js.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&js.set(e,r))}return r}toString(){return this.cssText}},Ws=o=>new Pt(typeof o=="string"?o:o+"",void 0,Li),y=(o,...r)=>{let e=o.length===1?o[0]:r.reduce(((t,i,s)=>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)+o[s+1]),o[0]);return new Pt(e,o,Li)},Xs=(o,r)=>{if(_r)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=$t.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},$i=_r||$t.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return Ws(e)})(o):o;var{is:wn,defineProperty:En,getOwnPropertyDescriptor:_n,getOwnPropertyNames:Tn,getOwnPropertySymbols:Sn,getPrototypeOf:An}=Object,Vt=globalThis;Vt.customElements??=Fs;var Gs=Vt.trustedTypes,Rn=Gs?Gs.emptyScript:"",kn=Vt.reactiveElementPolyfillSupport,Ot=(o,r)=>o,Dt={toAttribute(o,r){switch(r){case Boolean:o=o?Rn:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,r){let e=o;switch(r){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},Tr=(o,r)=>!wn(o,r),
|
|
1
|
+
var Ds=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var Vs=(o,r)=>{for(var e in r)Ds(o,e,{get:r[e],enumerable:!0})};var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?vn(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&Ds(r,e,i),i};var Ns=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 ne=function(o,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"?o!==r||!i:!r.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?i.call(o,e):i?i.value=e:r.set(o,e),e},N=function(o,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?o!==r||!t:!r.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(o):t?t.value:r.get(o)},at,qr,Cr,kt,_i,Mt,wr,Xe,It,Re,Er,Hs,zs=o=>typeof o=="boolean"?o:o?.capture??!1;var Ti=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=zs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);if(s===void 0)s=new Map,i.set(r,s);else if(s.has(e))return;let n=typeof t=="object"&&t?t:{};n.signal?.addEventListener("abort",()=>this.removeEventListener(r,e,t)),s.set(e,n??{})}removeEventListener(r,e,t){if(e==null)return;let i=zs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);s!==void 0&&(s.delete(e),s.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,s=!1,n=0,a=null,l=null,d=null,p=r.stopPropagation,m=r.stopImmediatePropagation;Object.defineProperties(r,{target:{get(){return a??l},...L},srcElement:{get(){return r.target},...L},currentTarget:{get(){return d},...L},eventPhase:{get(){return n},...L},composedPath:{value:()=>e,...L},stopPropagation:{value:()=>{i=!0,p.call(r)},...L},stopImmediatePropagation:{value:()=>{s=!0,m.call(r)},...L}});let h=(x,S,I)=>{typeof x=="function"?x(r):typeof x?.handleEvent=="function"&&x.handleEvent(r),S.once&&I.delete(x)},g=()=>(d=null,n=0,!r.defaultPrevented),v=e.slice().reverse();a=!this.__host||!r.composed?this:null;let w=x=>{for(l=this;l.__host&&x.includes(l.__host);)l=l.__host};for(let x of v){!a&&(!l||l===x.__host)&&w(v.slice(v.indexOf(x))),d=x,n=x===r.target?2:1;let S=x.__captureEventListeners.get(r.type);if(S){for(let[I,O]of S)if(h(I,O,S),s)return g()}if(i)return g()}let E=r.bubbles?e:[this];l=null;for(let x of E){!a&&(!l||x===l.__host)&&w(E.slice(0,E.indexOf(x)+1)),d=x,n=x===r.target?2:3;let S=x.__eventListeners.get(r.type);if(S){for(let[I,O]of S)if(h(I,O,S),s)return g()}if(i)return g()}return g()}},Si=Ti;var L={__proto__:null};L.enumerable=!0;Object.freeze(L);var Ai=(Re=class{constructor(r,e={}){if(at.set(this,!1),qr.set(this,!1),Cr.set(this,!1),kt.set(this,!1),_i.set(this,Date.now()),Mt.set(this,!1),wr.set(this,void 0),Xe.set(this,void 0),It.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:s}=e;ne(this,at,!!i,"f"),ne(this,qr,!!t,"f"),ne(this,Cr,!!s,"f"),ne(this,wr,`${r}`,"f"),ne(this,Xe,null,"f"),ne(this,It,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){ne(this,kt,!0,"f")}get target(){return N(this,Xe,"f")}get currentTarget(){return N(this,Xe,"f")}get srcElement(){return N(this,Xe,"f")}get type(){return N(this,wr,"f")}get cancelable(){return N(this,at,"f")}get defaultPrevented(){return N(this,at,"f")&&N(this,kt,"f")}get timeStamp(){return N(this,_i,"f")}composedPath(){return N(this,It,"f")?[N(this,Xe,"f")]:[]}get returnValue(){return!N(this,at,"f")||!N(this,kt,"f")}get bubbles(){return N(this,qr,"f")}get composed(){return N(this,Cr,"f")}get eventPhase(){return N(this,It,"f")?Re.AT_TARGET:Re.NONE}get cancelBubble(){return N(this,Mt,"f")}set cancelBubble(r){r&&ne(this,Mt,!0,"f")}stopPropagation(){ne(this,Mt,!0,"f")}get isTrusted(){return!1}},at=new WeakMap,qr=new WeakMap,Cr=new WeakMap,kt=new WeakMap,_i=new WeakMap,Mt=new WeakMap,wr=new WeakMap,Xe=new WeakMap,It=new WeakMap,Re.NONE=0,Re.CAPTURING_PHASE=1,Re.AT_TARGET=2,Re.BUBBLING_PHASE=3,Re);Object.defineProperties(Ai.prototype,{initEvent:L,stopImmediatePropagation:L,preventDefault:L,target:L,currentTarget:L,srcElement:L,type:L,cancelable:L,defaultPrevented:L,timeStamp:L,composedPath:L,returnValue:L,bubbles:L,composed:L,eventPhase:L,cancelBubble:L,stopPropagation:L,isTrusted:L});var Us=(Hs=class extends Ai{constructor(r,e={}){super(r,e),Er.set(this,void 0),ne(this,Er,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return N(this,Er,"f")}},Er=new WeakMap,Hs);Object.defineProperties(Us.prototype,{detail:L});var Ri=Ai,ki=Us;globalThis.Event??=Ri;globalThis.CustomEvent??=ki;var Bs=new WeakMap,Lt=o=>{let r=Bs.get(o);return r===void 0&&Bs.set(o,r=new Map),r},yn=class extends Si{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(Lt(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){Lt(this).set(r,String(e))}removeAttribute(r){Lt(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 Lt(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 Ns(this);return this.__internals=r,r}getAttribute(r){return Lt(this).get(r)??null}};var xn=class extends yn{},Ii=xn;globalThis.litServerRoot??=Object.defineProperty(new Ii,"localName",{get(){return"lit-server-root"}});function qn(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var Mi=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=qn(),this.__pendingWhenDefineds.set(r,t)),t.promise}},Cn=Mi;var Fs=new Cn;var $t=globalThis,_r=$t.ShadowRoot&&($t.ShadyCSS===void 0||$t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Li=Symbol(),js=new WeakMap,Pt=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Li)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(_r&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=js.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&js.set(e,r))}return r}toString(){return this.cssText}},Ws=o=>new Pt(typeof o=="string"?o:o+"",void 0,Li),y=(o,...r)=>{let e=o.length===1?o[0]:r.reduce(((t,i,s)=>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)+o[s+1]),o[0]);return new Pt(e,o,Li)},Xs=(o,r)=>{if(_r)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=$t.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},$i=_r||$t.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return Ws(e)})(o):o;var{is:wn,defineProperty:En,getOwnPropertyDescriptor:_n,getOwnPropertyNames:Tn,getOwnPropertySymbols:Sn,getPrototypeOf:An}=Object,Vt=globalThis;Vt.customElements??=Fs;var Gs=Vt.trustedTypes,Rn=Gs?Gs.emptyScript:"",kn=Vt.reactiveElementPolyfillSupport,Ot=(o,r)=>o,Dt={toAttribute(o,r){switch(r){case Boolean:o=o?Rn:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,r){let e=o;switch(r){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},Tr=(o,r)=>!wn(o,r),Ys={attribute:!0,type:String,converter:Dt,reflect:!1,useDefault:!1,hasChanged:Tr};Symbol.metadata??=Symbol("metadata"),Vt.litPropertyMetadata??=new WeakMap;var ve=class extends(globalThis.HTMLElement??Ii){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=Ys){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&&En(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=_n(this.prototype,r)??{get(){return this[e]},set(n){this[e]=n}};return{get:i,set(n){let a=i?.call(this);s?.call(this,n),this.requestUpdate(r,a,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(r){return this.elementProperties.get(r)??Ys}static _$Ei(){if(this.hasOwnProperty(Ot("elementProperties")))return;let r=An(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Ot("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ot("properties"))){let e=this.properties,t=[...Tn(e),...Sn(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($i(i))}else r!==void 0&&e.push($i(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 Xs(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 s=(t.converter?.toAttribute!==void 0?t.converter:Dt).toAttribute(e,t.type);this._$Em=r,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(r,e){let t=this.constructor,i=t._$Eh.get(r);if(i!==void 0&&this._$Em!==i){let s=t.getPropertyOptions(i),n=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Dt;this._$Em=i;let a=n.fromAttribute(e,s.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(r,e,t){if(r!==void 0){let i=this.constructor,s=this[r];if(t??=i.getPropertyOptions(r),!((t.hasChanged??Tr)(s,e)||t.useDefault&&t.reflect&&s===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:s},n){t&&!(this._$Ej??=new Map).has(r)&&(this._$Ej.set(r,n??e??this[r]),s!==!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,s]of this._$Ep)this[i]=s;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[i,s]of t){let{wrapped:n}=s,a=this[i];n!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,s,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){}};ve.elementStyles=[],ve.shadowRootOptions={mode:"open"},ve[Ot("elementProperties")]=new Map,ve[Ot("finalized")]=new Map,kn?.({ReactiveElement:ve}),(Vt.reactiveElementVersions??=[]).push("2.1.1");var Lr=globalThis,Sr=Lr.trustedTypes,Qs=Sr?Sr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Oi="$lit$",ye=`lit$${Math.random().toFixed(9).slice(2)}$`,Di="?"+ye,Mn=`<${Di}>`,Qe=Lr.document===void 0?{createTreeWalker:()=>({})}:document,Ht=()=>Qe.createComment(""),zt=o=>o===null||typeof o!="object"&&typeof o!="function",Vi=Array.isArray,ro=o=>Vi(o)||typeof o?.[Symbol.iterator]=="function",Pi=`[
|
|
3
3
|
\f\r]`,Nt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Js=/-->/g,Ks=/>/g,Ge=RegExp(`>|${Pi}(?:([^\\s"'>=/]+)(${Pi}*=${Pi}*(?:[^
|
|
4
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Zs=/'/g,eo=/"/g,io=/^(?:script|style|textarea|title)$/i,Ni=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),f=Ni(1),$r=Ni(2),La=Ni(3),O=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),to=new WeakMap,Qe=Ye.createTreeWalker(Ye,129);function so(o,r){if(!Vi(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ys!==void 0?Ys.createHTML(r):r}var oo=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Nt;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===Nt?p[1]==="!--"?n=Js:p[1]!==void 0?n=Ks:p[2]!==void 0?(io.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=Ge):p[3]!==void 0&&(n=Ge):n===Ge?p[0]===">"?(n=i??Nt,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?Ge:p[3]==='"'?eo:Zs):n===eo||n===Zs?n=Ge:n===Js||n===Ks?n=Nt:(n=Ge,i=void 0);let g=n===Ge&&o[a+1].startsWith("/>")?" ":"";s+=n===Nt?l+Mn:m>=0?(t.push(d),l.slice(0,m)+Oi+l.slice(m)+ye+g):l+ye+(m===-2?a:g)}return[so(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Ut=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]=oo(r,e);if(this.el=o.createElement(d,t),Qe.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=Qe.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Oi)){let h=p[n++],g=i.getAttribute(m).split(ye),v=/([.?@])?(.*)/.exec(h);l.push({type:1,index:s,name:v[2],strings:g,ctor:v[1]==="."?Rr:v[1]==="?"?kr:v[1]==="@"?Mr:Ke}),i.removeAttribute(m)}else m.startsWith(ye)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(io.test(i.tagName)){let m=i.textContent.split(ye),h=m.length-1;if(h>0){i.textContent=Sr?Sr.emptyScript:"";for(let g=0;g<h;g++)i.append(m[g],Ht()),Qe.nextNode(),l.push({type:2,index:++s});i.append(m[h],Ht())}}}else if(i.nodeType===8)if(i.data===Di)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(ye,m+1))!==-1;)l.push({type:7,index:s}),m+=ye.length-1}s++}}static createElement(r,e){let t=Ye.createElement("template");return t.innerHTML=r,t}};function Je(o,r,e=o,t){if(r===O)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=zt(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=Je(o,i._$AS(o,r.values),i,t)),r}var Ar=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??Ye).importNode(e,!0);Qe.currentNode=i;let s=Qe.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new lt(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new Ir(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=Qe.nextNode(),n++)}return Qe.currentNode=Ye,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++}},lt=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=k,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=Je(this,r,e),zt(r)?r===k||r==null||r===""?(this._$AH!==k&&this._$AR(),this._$AH=k):r!==this._$AH&&r!==O&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):ro(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!==k&&zt(this._$AH)?this._$AA.nextSibling.data=r:this.T(Ye.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=Ut.createElement(so(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Ar(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=to.get(r.strings);return e===void 0&&to.set(r.strings,e=new Ut(r)),e}k(r){Vi(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(Ht()),this.O(Ht()),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))}},Ke=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=k,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=k}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=Je(this,r,e,0),n=!zt(r)||r!==this._$AH&&r!==O,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=Je(this,a[t+l],e,l),d===O&&(d=this._$AH[l]),n||=!zt(d)||d!==this._$AH[l],d===k?r=k:r!==k&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Rr=class extends Ke{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===k?void 0:r}},kr=class extends Ke{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==k)}},Mr=class extends Ke{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Je(this,r,e,0)??k)===O)return;let t=this._$AH,i=r===k&&t!==k||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==k&&(t===k||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)}},Ir=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){Je(this,r)}},H={M:Oi,P:ye,A:Di,C:1,L:oo,R:Ar,D:ro,V:Je,I:lt,H:Ke,N:kr,U:Mr,B:Rr,F:Ir},In=Lr.litHtmlPolyfillSupport;In?.(Ut,lt),(Lr.litHtmlVersions??=[]).push("3.3.1");var Hi=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new lt(r.insertBefore(Ht(),s),s,void 0,e??{})}return i._$AI(o),i};var zi=globalThis,b=class extends ve{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=Hi(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return O}};b._$litElement$=!0,b.finalized=!0,zi.litElementHydrateSupport?.({LitElement:b});var Ln=zi.litElementPolyfillSupport;Ln?.({LitElement:b});(zi.litElementVersions??=[]).push("4.2.1");var q=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var $n={attribute:!0,type:String,converter:Dt,reflect:!1,hasChanged:Tr},Pn=(o=$n,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"?Pn(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 ke=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function ct(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 ke(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 ke(e,t,{get(){return s(this)}})}}function no(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return ke(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 ao(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=co(t,i);t.replaceWith(s)})}function lo(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=co(e,n);e.replaceWith(a)}})})}function co(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 po(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 dt(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 pt(o){return new DOMParser().parseFromString(o,"text/xml")}function uo(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(uo(e.childNodes[i],r));return t}return o.cloneNode(!1)}function ut(o){let r=document.createDocumentFragment();for(let e=0;e<o.childNodes.length;e++)r.appendChild(uo(o.childNodes[e],document));return r}function mt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("[src],[href],[primary-path]").forEach(e=>{let t="";e.getAttribute("src")&&(t="src"),e.getAttribute("href")&&(t="href"),e.getAttribute("primary-path")&&(t="primary-path");let i=e.getAttribute(t)?.trim();if(!/^(data:|https?:|blob:)/.test(i)){let s=r+encodeURI(i);e.setAttribute(t,s)}})}function mo(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 ho(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function fo(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 ae=(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))):dt(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=pt(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 C=v.getAttribute("primary-configuration");if(C)try{let T=await s(i,`/${C}`),x=Array.from(v.querySelectorAll("qti-interaction-module"));for(let S of x){let L=S.getAttribute("id");if(L&&T.paths&&T.paths[L]){let D=T.paths[L],W=Array.isArray(D)?D[0]:D;if(S.setAttribute("primary-path",W),p&&p.paths&&p.paths[L]){let V=p.paths[L];Array.isArray(V)?S.setAttribute("fallback-path",V[0]):S.setAttribute("fallback-path",V)}}}if(T.paths){for(let S in T.paths)if(!v.querySelector(`qti-interaction-module[id="${S}"]`)){let D=r.createElement("qti-interaction-module");D.setAttribute("id",S);let W=Array.isArray(T.paths[S])?T.paths[S][0]:T.paths[S];if(D.setAttribute("primary-path",W),p&&p.paths&&p.paths[S]){let V=p.paths[S];Array.isArray(V)?D.setAttribute("fallback-path",V[0]):D.setAttribute("fallback-path",V)}v.appendChild(D)}}T.urlArgs&&v.setAttribute("url-args",T.urlArgs)}catch(T){console.warn(`Failed to load primary configuration: ${C}`,T)}}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 C in d.paths){let T=d.paths[C],x="";p&&p.paths&&p.paths[C]&&(x=p.paths[C]);let S=Array.isArray(T)?T:[T],L=Array.isArray(x)?x:[x],D=S.map((W,V)=>{let bn=L.length>V?L[V]:"";return{primaryPath:W,fallbackPath:bn}});for(let W of L)D.some(V=>V.fallbackPath===W)||D.push({primaryPath:S.length>0?S[0]:W,fallbackPath:W});for(let W of D){let V=r.createElement("qti-interaction-module");W.fallbackPath&&V.setAttribute("fallback-path",W.fallbackPath),V.setAttribute("id",C),V.setAttribute("primary-path",W.primaryPath),v&&v.appendChild(V)}}}}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=fo(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((x,S)=>({element:x,fixed:x.hasAttribute("fixed")&&x.getAttribute("fixed")==="true",originalOrder:S})).filter(x=>x.fixed),h=p.filter(x=>!x.hasAttribute("fixed")||x.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,C=0;for(;!v&&C<20;){C++;for(let x=h.length-1;x>0;x--){let S=Math.floor(Math.random()*(x+1));[h[x],h[S]]=[h[S],h[x]]}v=!h.every((x,S)=>x===g[S])}if(!v)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let T=0;for(let x of h)x.parentElement.insertBefore(x,m[T]?.element),T++;for(let x of m)x.element.parentElement.insertBefore(x.element,h[x.originalOrder])}}return t},extendElementName:(i,s)=>(ao(r,i,s),t),extendElementsWithClass:(i="extend")=>(lo(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 mo(r),t},stripStyleSheets(){return ho(r),t},html(){return e!==null&&mt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(ut(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&mt(r,e.substring(0,e.lastIndexOf("/"))),ut(r)},xmlDoc(){return r}};return t};var go=()=>{let o,r={async load(e,t){return new Promise(i=>{dt(e,t).then(s=>(o=s,i(r)))})},parse(e){o=pt(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var ht=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{dt(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=pt(e),r},path:e=>(mt(o,e),r),fn(e){return e(o),r},items(){return po(o)},html(){return new XMLSerializer().serializeToString(ut(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return ut(o)},xmlDoc(){return o}};return r};var bo=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 ae(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 ae().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 vo=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 Me=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 ft=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 Me(this.context,this.host,this.t,this.subscribe))}};var Pr=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 Ui=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},gt=class extends Pr{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 Me(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 Ui(this.context,this.host))}};function X({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 gt(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new gt(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 _({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new ft(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new ft(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var Ie=Symbol("computedItemContext");var $=Symbol("computedContext");var Z=Symbol("configContext");var yo=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var P=Symbol("item");var Or=Symbol("qtiContext");var Bi={view:"candidate"},Le=Symbol("testContext");var Fi={items:[],testOutcomeVariables:[]},le=Symbol("testContext");function Dr(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 x of m)x.type==="childList"&&(x.addedNodes.forEach(S=>{if(S.nodeType!==1)return;let L=S;L.matches?.(o)&&h.push(L),h.push(...L.querySelectorAll?.(o)??[])}),x.removedNodes.forEach(S=>{if(S.nodeType!==1)return;let L=S;L.matches?.(o)&&g.push(L),g.push(...L.querySelectorAll?.(o)??[])}));let v=x=>Array.from(new Set(x)),C=v(h),T=v(g);(C.length||T.length)&&n.call(this,C,T)},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 M(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 $e={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},G=o=>(...r)=>({_$litDirective$:o,values:r}),ce=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:On}=H,qo=o=>o===null||typeof o!="object"&&typeof o!="function";var Co=o=>o.strings===void 0,xo=()=>document.createComment(""),bt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(xo(),i),n=t.insertBefore(xo(),i);e=new On(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},Pe=(o,r,e=o)=>(o._$AI(r,e),o),Dn={},wo=(o,r=Dn)=>o._$AH=r,Eo=o=>o._$AH,Vr=o=>{o._$AR(),o._$AA.remove()};var Bt=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),Bt(t,r);return!0},Nr=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},_o=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),Hn(r)}};function Vn(o){this._$AN!==void 0?(Nr(this),this._$AM=o,_o(this)):this._$AM=o}function Nn(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++)Bt(t[s],!1),Nr(t[s]);else t!=null&&(Bt(t,!1),Nr(t));else Bt(this,o)}var Hn=o=>{o.type==$e.CHILD&&(o._$AP??=Nn,o._$AQ??=Vn)},Oe=class extends ce{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),_o(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(Bt(this,r),Nr(this))}setValue(r){if(Co(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 ji=class extends Oe{constructor(){super(...arguments);this.prevData={}}render(e){return k}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},k}apply(e){let t=this.filterArgs(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.filterArgs(e):{};for(let n in t)(!s||!(n in s))&&i.removeAttribute(n)}filterArgs(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)))}},Bc=G(ji);var To=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(To||{}),A=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([_({context:P,subscribe:!0})],A.prototype,"_context",2),c([_({context:Z,subscribe:!0})],A.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],A.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],A.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],A.prototype,"readonly",2),c([u({type:String})],A.prototype,"name",2),c([u({type:String,attribute:"correct-response",reflect:!0})],A.prototype,"correctResponseAttr",1),c([u({type:Boolean,attribute:"show-correct-response",reflect:!0})],A.prototype,"showCorrectResponse",2),c([M("showCorrectResponse",{waitUntilFirstUpdate:!0})],A.prototype,"_handleShowCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],A.prototype,"showFullCorrectResponse",2),c([M("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],A.prototype,"_handleShowFullCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],A.prototype,"showCandidateCorrection",2),c([M("showCandidateCorrection",{waitUntilFirstUpdate:!0})],A.prototype,"_handleShowCandidateCorrectionChange",2),c([w()],A.prototype,"_isFullCorrectResponse",2),c([w()],A.prototype,"_correctResponse",2);var vt=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 E=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`
|
|
4
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Zs=/'/g,eo=/"/g,io=/^(?:script|style|textarea|title)$/i,Ni=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),f=Ni(1),$r=Ni(2),La=Ni(3),D=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),to=new WeakMap,Ye=Qe.createTreeWalker(Qe,129);function so(o,r){if(!Vi(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Qs!==void 0?Qs.createHTML(r):r}var oo=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Nt;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===Nt?p[1]==="!--"?n=Js:p[1]!==void 0?n=Ks:p[2]!==void 0?(io.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=Ge):p[3]!==void 0&&(n=Ge):n===Ge?p[0]===">"?(n=i??Nt,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?Ge:p[3]==='"'?eo:Zs):n===eo||n===Zs?n=Ge:n===Js||n===Ks?n=Nt:(n=Ge,i=void 0);let g=n===Ge&&o[a+1].startsWith("/>")?" ":"";s+=n===Nt?l+Mn:m>=0?(t.push(d),l.slice(0,m)+Oi+l.slice(m)+ye+g):l+ye+(m===-2?a:g)}return[so(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Ut=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]=oo(r,e);if(this.el=o.createElement(d,t),Ye.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=Ye.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Oi)){let h=p[n++],g=i.getAttribute(m).split(ye),v=/([.?@])?(.*)/.exec(h);l.push({type:1,index:s,name:v[2],strings:g,ctor:v[1]==="."?Rr:v[1]==="?"?kr:v[1]==="@"?Mr:Ke}),i.removeAttribute(m)}else m.startsWith(ye)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(io.test(i.tagName)){let m=i.textContent.split(ye),h=m.length-1;if(h>0){i.textContent=Sr?Sr.emptyScript:"";for(let g=0;g<h;g++)i.append(m[g],Ht()),Ye.nextNode(),l.push({type:2,index:++s});i.append(m[h],Ht())}}}else if(i.nodeType===8)if(i.data===Di)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(ye,m+1))!==-1;)l.push({type:7,index:s}),m+=ye.length-1}s++}}static createElement(r,e){let t=Qe.createElement("template");return t.innerHTML=r,t}};function Je(o,r,e=o,t){if(r===D)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=zt(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=Je(o,i._$AS(o,r.values),i,t)),r}var Ar=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??Qe).importNode(e,!0);Ye.currentNode=i;let s=Ye.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new lt(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new Ir(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=Ye.nextNode(),n++)}return Ye.currentNode=Qe,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++}},lt=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=k,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=Je(this,r,e),zt(r)?r===k||r==null||r===""?(this._$AH!==k&&this._$AR(),this._$AH=k):r!==this._$AH&&r!==D&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):ro(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!==k&&zt(this._$AH)?this._$AA.nextSibling.data=r:this.T(Qe.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=Ut.createElement(so(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Ar(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=to.get(r.strings);return e===void 0&&to.set(r.strings,e=new Ut(r)),e}k(r){Vi(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(Ht()),this.O(Ht()),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))}},Ke=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=k,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=k}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=Je(this,r,e,0),n=!zt(r)||r!==this._$AH&&r!==D,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=Je(this,a[t+l],e,l),d===D&&(d=this._$AH[l]),n||=!zt(d)||d!==this._$AH[l],d===k?r=k:r!==k&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Rr=class extends Ke{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===k?void 0:r}},kr=class extends Ke{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==k)}},Mr=class extends Ke{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Je(this,r,e,0)??k)===D)return;let t=this._$AH,i=r===k&&t!==k||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==k&&(t===k||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)}},Ir=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){Je(this,r)}},H={M:Oi,P:ye,A:Di,C:1,L:oo,R:Ar,D:ro,V:Je,I:lt,H:Ke,N:kr,U:Mr,B:Rr,F:Ir},In=Lr.litHtmlPolyfillSupport;In?.(Ut,lt),(Lr.litHtmlVersions??=[]).push("3.3.1");var Hi=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new lt(r.insertBefore(Ht(),s),s,void 0,e??{})}return i._$AI(o),i};var zi=globalThis,b=class extends ve{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=Hi(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return D}};b._$litElement$=!0,b.finalized=!0,zi.litElementHydrateSupport?.({LitElement:b});var Ln=zi.litElementPolyfillSupport;Ln?.({LitElement:b});(zi.litElementVersions??=[]).push("4.2.1");var q=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var $n={attribute:!0,type:String,converter:Dt,reflect:!1,hasChanged:Tr},Pn=(o=$n,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"?Pn(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 C(o){return u({...o,state:!0,attribute:!1})}var ke=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function ct(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 ke(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 ke(e,t,{get(){return s(this)}})}}function no(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return ke(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 ao(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=co(t,i);t.replaceWith(s)})}function lo(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=co(e,n);e.replaceWith(a)}})})}function co(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 po(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 dt(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 pt(o){return new DOMParser().parseFromString(o,"text/xml")}function uo(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(uo(e.childNodes[i],r));return t}return o.cloneNode(!1)}function ut(o){let r=document.createDocumentFragment();for(let e=0;e<o.childNodes.length;e++)r.appendChild(uo(o.childNodes[e],document));return r}function mt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("[src],[href],[primary-path]").forEach(e=>{let t="";e.getAttribute("src")&&(t="src"),e.getAttribute("href")&&(t="href"),e.getAttribute("primary-path")&&(t="primary-path");let i=e.getAttribute(t)?.trim();if(!/^(data:|https?:|blob:)/.test(i)){let s=r+encodeURI(i);e.setAttribute(t,s)}})}function mo(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 ho(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function fo(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 ae=(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))):dt(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=pt(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 w=v.getAttribute("primary-configuration");if(w)try{let E=await s(i,`/${w}`),x=Array.from(v.querySelectorAll("qti-interaction-module"));for(let S of x){let I=S.getAttribute("id");if(I&&E.paths&&E.paths[I]){let O=E.paths[I],W=Array.isArray(O)?O[0]:O;if(S.setAttribute("primary-path",W),p&&p.paths&&p.paths[I]){let V=p.paths[I];Array.isArray(V)?S.setAttribute("fallback-path",V[0]):S.setAttribute("fallback-path",V)}}}if(E.paths){for(let S in E.paths)if(!v.querySelector(`qti-interaction-module[id="${S}"]`)){let O=r.createElement("qti-interaction-module");O.setAttribute("id",S);let W=Array.isArray(E.paths[S])?E.paths[S][0]:E.paths[S];if(O.setAttribute("primary-path",W),p&&p.paths&&p.paths[S]){let V=p.paths[S];Array.isArray(V)?O.setAttribute("fallback-path",V[0]):O.setAttribute("fallback-path",V)}v.appendChild(O)}}E.urlArgs&&v.setAttribute("url-args",E.urlArgs)}catch(E){console.warn(`Failed to load primary configuration: ${w}`,E)}}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 w in d.paths){let E=d.paths[w],x="";p&&p.paths&&p.paths[w]&&(x=p.paths[w]);let S=Array.isArray(E)?E:[E],I=Array.isArray(x)?x:[x],O=S.map((W,V)=>{let bn=I.length>V?I[V]:"";return{primaryPath:W,fallbackPath:bn}});for(let W of I)O.some(V=>V.fallbackPath===W)||O.push({primaryPath:S.length>0?S[0]:W,fallbackPath:W});for(let W of O){let V=r.createElement("qti-interaction-module");W.fallbackPath&&V.setAttribute("fallback-path",W.fallbackPath),V.setAttribute("id",w),V.setAttribute("primary-path",W.primaryPath),v&&v.appendChild(V)}}}}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=fo(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((x,S)=>({element:x,fixed:x.hasAttribute("fixed")&&x.getAttribute("fixed")==="true",originalOrder:S})).filter(x=>x.fixed),h=p.filter(x=>!x.hasAttribute("fixed")||x.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,w=0;for(;!v&&w<20;){w++;for(let x=h.length-1;x>0;x--){let S=Math.floor(Math.random()*(x+1));[h[x],h[S]]=[h[S],h[x]]}v=!h.every((x,S)=>x===g[S])}if(!v)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let E=0;for(let x of h)x.parentElement.insertBefore(x,m[E]?.element),E++;for(let x of m)x.element.parentElement.insertBefore(x.element,h[x.originalOrder])}}return t},extendElementName:(i,s)=>(ao(r,i,s),t),extendElementsWithClass:(i="extend")=>(lo(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 mo(r),t},stripStyleSheets(){return ho(r),t},html(){return e!==null&&mt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(ut(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&mt(r,e.substring(0,e.lastIndexOf("/"))),ut(r)},xmlDoc(){return r}};return t};var go=()=>{let o,r={async load(e,t){return new Promise(i=>{dt(e,t).then(s=>(o=s,i(r)))})},parse(e){o=pt(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var ht=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{dt(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=pt(e),r},path:e=>(mt(o,e),r),fn(e){return e(o),r},items(){return po(o)},html(){return new XMLSerializer().serializeToString(ut(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return ut(o)},xmlDoc(){return o}};return r};var bo=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 ae(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 ae().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 vo=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 Me=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 ft=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 Me(this.context,this.host,this.t,this.subscribe))}};var Pr=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 Ui=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},gt=class extends Pr{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 Me(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 Ui(this.context,this.host))}};function X({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 gt(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new gt(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 T({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new ft(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new ft(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var Ie=Symbol("computedItemContext");var $=Symbol("computedContext");var Z=Symbol("configContext");var yo=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var P=Symbol("item");var Or=Symbol("qtiContext");var Bi={view:"candidate"},Le=Symbol("testContext");var Fi={items:[],testOutcomeVariables:[]},le=Symbol("testContext");function Dr(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 x of m)x.type==="childList"&&(x.addedNodes.forEach(S=>{if(S.nodeType!==1)return;let I=S;I.matches?.(o)&&h.push(I),h.push(...I.querySelectorAll?.(o)??[])}),x.removedNodes.forEach(S=>{if(S.nodeType!==1)return;let I=S;I.matches?.(o)&&g.push(I),g.push(...I.querySelectorAll?.(o)??[])}));let v=x=>Array.from(new Set(x)),w=v(h),E=v(g);(w.length||E.length)&&n.call(this,w,E)},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 M(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 $e={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},G=o=>(...r)=>({_$litDirective$:o,values:r}),ce=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:On}=H,qo=o=>o===null||typeof o!="object"&&typeof o!="function";var Co=o=>o.strings===void 0,xo=()=>document.createComment(""),bt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(xo(),i),n=t.insertBefore(xo(),i);e=new On(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},Pe=(o,r,e=o)=>(o._$AI(r,e),o),Dn={},wo=(o,r=Dn)=>o._$AH=r,Eo=o=>o._$AH,Vr=o=>{o._$AR(),o._$AA.remove()};var Bt=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),Bt(t,r);return!0},Nr=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},_o=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),Hn(r)}};function Vn(o){this._$AN!==void 0?(Nr(this),this._$AM=o,_o(this)):this._$AM=o}function Nn(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++)Bt(t[s],!1),Nr(t[s]);else t!=null&&(Bt(t,!1),Nr(t));else Bt(this,o)}var Hn=o=>{o.type==$e.CHILD&&(o._$AP??=Nn,o._$AQ??=Vn)},Oe=class extends ce{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),_o(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(Bt(this,r),Nr(this))}setValue(r){if(Co(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 ji=class extends Oe{constructor(){super(...arguments);this.prevData={}}render(e){return k}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},k}apply(e){let t=this.filterArgs(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.filterArgs(e):{};for(let n in t)(!s||!(n in s))&&i.removeAttribute(n)}filterArgs(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)))}},Bc=G(ji);var To=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(To||{}),A=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([T({context:P,subscribe:!0})],A.prototype,"_context",2),c([T({context:Z,subscribe:!0})],A.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],A.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],A.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],A.prototype,"readonly",2),c([u({type:String})],A.prototype,"name",2),c([u({type:String,attribute:"correct-response",reflect:!0})],A.prototype,"correctResponseAttr",1),c([u({type:Boolean,attribute:"show-correct-response",reflect:!0})],A.prototype,"showCorrectResponse",2),c([M("showCorrectResponse",{waitUntilFirstUpdate:!0})],A.prototype,"_handleShowCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],A.prototype,"showFullCorrectResponse",2),c([M("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],A.prototype,"_handleShowFullCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],A.prototype,"showCandidateCorrection",2),c([M("showCandidateCorrection",{waitUntilFirstUpdate:!0})],A.prototype,"_handleShowCandidateCorrectionChange",2),c([C()],A.prototype,"_isFullCorrectResponse",2),c([C()],A.prototype,"_correctResponse",2);var vt=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 _=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`
|
|
5
5
|
slot {
|
|
6
6
|
display: none;
|
|
7
7
|
}
|
|
8
8
|
`}render(){return f`<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")}};c([w()],E.prototype,"result",2),c([_({context:P,subscribe:!0}),w()],E.prototype,"context",2),c([_({context:Or,subscribe:!0}),w()],E.prototype,"qtiContext",2);var ee=class extends E{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var zn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Ft=o=>{if(typeof o=="string")return o;let r=zn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Wi(o){return o==null}function Hr(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var Q=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=!Wi(this.identifier)&&!Wi(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],Q.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],Q.prototype,"outcomeIdentifier",2),c([u({type:String})],Q.prototype,"identifier",2),c([u({type:String,attribute:!1})],Q.prototype,"showStatus",2),c([_({context:P,subscribe:!0}),w()],Q.prototype,"_context",2);var So=class extends b{};var z=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 Xi=o=>{class r extends o{constructor(...i){super(...i);this.testContext=Fi;this.sessionContext=Bi;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=Fi,this.sessionContext=Bi,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}),X({context:le})],r.prototype,"testContext",2),c([u({attribute:!1,type:Object}),X({context:Le})],r.prototype,"sessionContext",2),r},Ao=class extends Xi(b){};var Ro=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 zr=class extends bo(vo(Ro(Xi(b)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return f`<slot></slot>`}};zr=c([q("qti-test")],zr);var ko={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},xe=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})],xe.prototype,"category",2),c([u({type:String})],xe.prototype,"identifier",2),c([u({type:Boolean,converter:ko})],xe.prototype,"required",2),c([u({type:Boolean,converter:ko})],xe.prototype,"fixed",2),c([u({type:String})],xe.prototype,"href",2),c([u({type:Object,attribute:!1})],xe.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",xe);var Gi={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},qe=class extends b{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){this._title=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})],qe.prototype,"identifier",2),c([u({type:String})],qe.prototype,"required",2),c([u({type:Boolean,converter:Gi})],qe.prototype,"fixed",2),c([u({type:Boolean,converter:Gi})],qe.prototype,"visible",2),c([u({type:Boolean,converter:Gi,attribute:"keep-together"})],qe.prototype,"keepTogether",2),c([_({context:le,subscribe:!0})],qe.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",qe);var et=class extends b{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=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>`}};c([u({type:String})],et.prototype,"identifier",2),c([u({type:String})],et.prototype,"title",1),c([_({context:le,subscribe:!0})],et.prototype,"_testContext",2),et=c([q("qti-assessment-test")],et);var Ce=class extends b{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";this._title=""}get title(){return this._title}set title(e){this._title=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>`}};c([u({type:String})],Ce.prototype,"identifier",2),c([u({type:String})],Ce.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Ce.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Ce.prototype,"submissionMode",2),Ce=c([q("qti-test-part")],Ce);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ce);var Y=class extends b{constructor(){super(...arguments);this._templateProcessing=null;this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={variables:yo};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()};this._handleUpdateResponseVariable=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 this._itemTitle}set title(e){this._itemTitle=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=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.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=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return f`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),this._processTemplates()})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){for(let t of this._interactionElements)t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of this._interactionElements)t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}_processTemplates(){this._templateProcessing=this.querySelector("qti-template-processing"),this._templateProcessing&&this._templateProcessing.process()}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(n=>n.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing"),s=!!(i&&typeof i.process=="function");return s&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),s}resetResponses(){this._context=this._initialContext}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",this._getCompletionStatus())}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]})},this._feedbackElements.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=this._interactionElements.every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};c([u({type:String})],Y.prototype,"identifier",2),c([u({type:String})],Y.prototype,"adaptive",2),c([u({type:String})],Y.prototype,"timeDependent",2),c([u({type:String})],Y.prototype,"title",1),c([u({type:Boolean})],Y.prototype,"disabled",2),c([M("disabled",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],Y.prototype,"readonly",2),c([M("readonly",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleReadonlyChange",2),c([X({context:P})],Y.prototype,"_context",2),Y=c([q("qti-assessment-item")],Y);var Qi=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"}},yt=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 Qi(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)}}};c([u({type:String})],yt.prototype,"identifier",2),c([u({type:String})],yt.prototype,"href",2),yt=c([q("qti-assessment-stimulus-ref")],yt);var Ur=class extends b{};Ur=c([q("qti-companion-materials-info")],Ur);var jt=class extends b{render(){return f`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let r=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",r?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let r={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,r,e)}};c([_({context:P,subscribe:!0}),w()],jt.prototype,"_context",2),jt=c([q("qti-custom-operator")],jt);var Wt=class extends Q{render(){return f` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Wt.styles=y`
|
|
9
|
+
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([C()],_.prototype,"result",2),c([T({context:P,subscribe:!0}),C()],_.prototype,"context",2),c([T({context:Or,subscribe:!0}),C()],_.prototype,"qtiContext",2);var ee=class extends _{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var zn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Ft=o=>{if(typeof o=="string")return o;let r=zn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Wi(o){return o==null}function Hr(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var Y=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=!Wi(this.identifier)&&!Wi(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],Y.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],Y.prototype,"outcomeIdentifier",2),c([u({type:String})],Y.prototype,"identifier",2),c([u({type:String,attribute:!1})],Y.prototype,"showStatus",2),c([T({context:P,subscribe:!0}),C()],Y.prototype,"_context",2);var So=class extends b{};var z=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 Xi=o=>{class r extends o{constructor(...i){super(...i);this.testContext=Fi;this.sessionContext=Bi;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=Fi,this.sessionContext=Bi,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}),X({context:le})],r.prototype,"testContext",2),c([u({attribute:!1,type:Object}),X({context:Le})],r.prototype,"sessionContext",2),r},Ao=class extends Xi(b){};var Ro=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 zr=class extends bo(vo(Ro(Xi(b)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return f`<slot></slot>`}};zr=c([q("qti-test")],zr);var ko={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},xe=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})],xe.prototype,"category",2),c([u({type:String})],xe.prototype,"identifier",2),c([u({type:Boolean,converter:ko})],xe.prototype,"required",2),c([u({type:Boolean,converter:ko})],xe.prototype,"fixed",2),c([u({type:String})],xe.prototype,"href",2),c([u({type:Object,attribute:!1})],xe.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",xe);var Gi={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},qe=class extends b{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){this._title=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})],qe.prototype,"identifier",2),c([u({type:String})],qe.prototype,"required",2),c([u({type:Boolean,converter:Gi})],qe.prototype,"fixed",2),c([u({type:Boolean,converter:Gi})],qe.prototype,"visible",2),c([u({type:Boolean,converter:Gi,attribute:"keep-together"})],qe.prototype,"keepTogether",2),c([T({context:le,subscribe:!0})],qe.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",qe);var et=class extends b{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=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>`}};c([u({type:String})],et.prototype,"identifier",2),c([u({type:String})],et.prototype,"title",1),c([T({context:le,subscribe:!0})],et.prototype,"_testContext",2),et=c([q("qti-assessment-test")],et);var Ce=class extends b{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";this._title=""}get title(){return this._title}set title(e){this._title=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>`}};c([u({type:String})],Ce.prototype,"identifier",2),c([u({type:String})],Ce.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Ce.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Ce.prototype,"submissionMode",2),Ce=c([q("qti-test-part")],Ce);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ce);var Q=class extends b{constructor(){super(...arguments);this._templateProcessing=null;this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={variables:yo};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()};this._handleUpdateResponseVariable=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 this._itemTitle}set title(e){this._itemTitle=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=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.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=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return f`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),this._processTemplates()})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){for(let t of this._interactionElements)t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of this._interactionElements)t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}_processTemplates(){this._templateProcessing=this.querySelector("qti-template-processing"),this._templateProcessing&&this._templateProcessing.process()}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(n=>n.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing"),s=!!(i&&typeof i.process=="function");return s&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),s}resetResponses(){this._context=this._initialContext}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",this._getCompletionStatus())}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]})},this._feedbackElements.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=this._interactionElements.every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};c([u({type:String})],Q.prototype,"identifier",2),c([u({type:String})],Q.prototype,"adaptive",2),c([u({type:String})],Q.prototype,"timeDependent",2),c([u({type:String})],Q.prototype,"title",1),c([u({type:Boolean})],Q.prototype,"disabled",2),c([M("disabled",{waitUntilFirstUpdate:!0})],Q.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],Q.prototype,"readonly",2),c([M("readonly",{waitUntilFirstUpdate:!0})],Q.prototype,"_handleReadonlyChange",2),c([X({context:P})],Q.prototype,"_context",2),Q=c([q("qti-assessment-item")],Q);var Yi=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"}},yt=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 Yi(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)}}};c([u({type:String})],yt.prototype,"identifier",2),c([u({type:String})],yt.prototype,"href",2),yt=c([q("qti-assessment-stimulus-ref")],yt);var Ur=class extends b{};Ur=c([q("qti-companion-materials-info")],Ur);var jt=class extends b{render(){return f`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let r=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",r?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let r={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,r,e)}};c([T({context:P,subscribe:!0}),C()],jt.prototype,"_context",2),jt=c([q("qti-custom-operator")],jt);var Wt=class extends Y{render(){return f` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Wt.styles=y`
|
|
10
10
|
:host {
|
|
11
11
|
display: block;
|
|
12
12
|
}
|
|
@@ -16,14 +16,14 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
16
16
|
.off {
|
|
17
17
|
display: none;
|
|
18
18
|
}
|
|
19
|
-
`,Wt=c([q("qti-feedback-block")],Wt);var de=o=>o??k;var Xt=class extends
|
|
19
|
+
`,Wt=c([q("qti-feedback-block")],Wt);var de=o=>o??k;var Xt=class extends Y{constructor(){super(...arguments);this.render=()=>f` <slot part="feedback" class="${de(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Xt.styles=y`
|
|
20
20
|
.on {
|
|
21
21
|
display: inline-block;
|
|
22
22
|
}
|
|
23
23
|
.off {
|
|
24
24
|
display: none;
|
|
25
25
|
}
|
|
26
|
-
`,Xt=c([q("qti-feedback-inline")],Xt);var tt=class extends
|
|
26
|
+
`,Xt=c([q("qti-feedback-inline")],Xt);var tt=class extends Y{render(){return f`
|
|
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;">
|
|
@@ -81,11 +81,11 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
81
81
|
:host {
|
|
82
82
|
display: none;
|
|
83
83
|
}
|
|
84
|
-
`],c([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),c([u({type:String})],we.prototype,"identifier",2),c([u({type:String})],we.prototype,"cardinality",2),c([
|
|
84
|
+
`],c([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),c([u({type:String})],we.prototype,"identifier",2),c([u({type:String})],we.prototype,"cardinality",2),c([T({context:P,subscribe:!0}),C()],we.prototype,"itemContext",2),we=c([q("qti-response-declaration")],we);var ue=class extends vt{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return f`${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 s=parseFloat(i.getAttribute("source-value")),n=parseFloat(i.getAttribute("target-value"));(isNaN(s)||isNaN(n))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,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}}))}};ue.styles=[y`
|
|
85
85
|
:host {
|
|
86
86
|
display: none;
|
|
87
87
|
}
|
|
88
|
-
`],c([u({type:String,attribute:"base-type"})],ue.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],ue.prototype,"externalScored",2),c([u({type:String})],ue.prototype,"identifier",2),c([u({type:String})],ue.prototype,"cardinality",2),c([
|
|
88
|
+
`],c([u({type:String,attribute:"base-type"})],ue.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],ue.prototype,"externalScored",2),c([u({type:String})],ue.prototype,"identifier",2),c([u({type:String})],ue.prototype,"cardinality",2),c([T({context:P,subscribe:!0}),C()],ue.prototype,"itemContext",2),ue=c([q("qti-outcome-declaration")],ue);var Io=`<qti-response-processing>
|
|
89
89
|
<qti-response-condition>
|
|
90
90
|
<qti-response-if>
|
|
91
91
|
<qti-match>
|
|
@@ -134,15 +134,15 @@ 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 Yt=class extends b{render(){return f`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(r){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(Lo).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString($o).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(Io).firstElementChild.firstElementChild);break}}}fragmentFromString(r){return document.createRange().createContextualFragment(r)}};Yt.styles=[y`
|
|
138
138
|
:host {
|
|
139
139
|
display: none;
|
|
140
140
|
}
|
|
141
|
-
`],
|
|
141
|
+
`],Yt=c([q("qti-response-processing")],Yt);var Qt=class extends tt{render(){return f``}};Qt.styles=y`
|
|
142
142
|
:host {
|
|
143
143
|
color: gray;
|
|
144
144
|
}
|
|
145
|
-
`,
|
|
145
|
+
`,Qt=c([q("qti-test-feedback")],Qt);var te=class extends b{constructor(){super();this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-interaction-changed",this._handleInteractionChanged.bind(this)),this.addEventListener("test-end-attempt",this._handleTestEndAttempt.bind(this)),this.addEventListener("test-show-correct-response",this._handleTestShowCorrectResponse.bind(this)),this.addEventListener("test-show-candidate-correction",this._handleTestShowCandidateCorrection.bind(this)),this.addEventListener("test-update-outcome-variable",this._handleTestUpdateOutcomeVariable.bind(this))}_handleTestEndAttempt(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,s=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,s)}_handleTestShowCorrectResponse(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)}_handleTestShowCandidateCorrection(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)}_handleTestUpdateOutcomeVariable(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)}_handleInteractionChanged(e){if(this.autoScoreItems){let t=e.composedPath()[0].closest("qti-assessment-item"),i=t.variables.find(s=>s.identifier==="SCORE");if(i&&i.externalScored===null&&t.adaptive==="false"){let s=this.configContext?.reportValidityAfterScoring===!0;t.processResponse(!0,s)}}}render(){return f`<slot></slot>`}_handleTestConnected(e){if(this._testElement=e.detail,!this.qtiContext.QTI_CONTEXT?.testIdentifier){let s=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.qtiContext={QTI_CONTEXT:{...s,testIdentifier:this._testElement.identifier,environmentIdentifier:s.environmentIdentifier||"default"}}}this._testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=this._extractDefaultValues(s);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(this._testElement?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:this._testElement.identifier,title:this._testElement.title,view:this._sessionContext?.view,testParts:i.map(s=>{let n=[...s.querySelectorAll("qti-assessment-section")];return{active:!1,identifier:s.identifier,navigationMode:s.navigationMode,submissionMode:s.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(d=>({...this.initContext?.find(p=>p.identifier===d.identifier),active:!1,identifier:d.identifier,categories:d.category?d.category?.split(" "):[],href:d.href,variables:[]}))}})}})}}_extractDefaultValues(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",d=n.textContent?.trim()||"";if(a){let p=d;switch(l){case"integer":p=parseInt(d,10);break;case"float":case"duration":p=parseFloat(d);break;case"boolean":p=d.toLowerCase()==="true";break;default:p=d;break}t[a]=p}}),t}_handleItemConnected(e){let t=e.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(s=>({...s,items:s.items.map(n=>{if(n.identifier!==t.parentElement.getAttribute("identifier"))return n;let l=t.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),d=t.querySelectorAll("qti-response-declaration"),p=Array.from(d).some(v=>v.querySelector("qti-correct-response")),m=Array.from(d).some(v=>{let w=v.querySelector("qti-mapping"),E=v.querySelector("qti-area-mapping");return w?.querySelector("qti-map-entry")||E?.querySelector("qti-area-map-entry")}),h=p||m,g=!!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:h,hasResponseProcessing:g}})}))}))}}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(s=>({...s,active:this._sessionContext?.navSectionId===s.identifier||!1,completed:s.items.every(n=>this._testContext.items.find(a=>a.identifier===n.identifier)?.variables.find(a=>a.identifier==="completionStatus").value==="completed"),items:s.items.map(n=>{let a=this._testContext?.items.find(S=>S.identifier===n.identifier),l={...n,...a,...this.initContext?.find(S=>S.identifier===n.identifier)},d=l.variables?.find(S=>S.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=l.variables?.find(S=>S.identifier==="completionStatus")?.value,h=l.variables?.find(S=>S.identifier==="RESPONSE")?.value||"",g=l.variables?.find(S=>S.identifier==="numAttempts")?.value||0,v=this._sessionContext?.navItemRefId===l.identifier||!1,w=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,E=n.variables?.find(S=>S.identifier=="MAXSCORE")?.value,x=E==null?null:parseFloat(E?.toString());return{...l,completionStatus:m,numAttempts:g,score:p,response:h,index:w,active:v,maxScore:x}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};c([u({type:String})],te.prototype,"identifier",2),c([C()],te.prototype,"initContext",2),c([C(),X({context:Or})],te.prototype,"qtiContext",2),c([C(),X({context:Z})],te.prototype,"configContext",2),c([C(),T({context:le,subscribe:!0})],te.prototype,"_testContext",2),c([C(),T({context:Le,subscribe:!0})],te.prototype,"_sessionContext",2),c([C(),X({context:$})],te.prototype,"computedContext",2),c([u({type:Boolean,attribute:"auto-score-items"})],te.prototype,"autoScoreItems",2),te=c([q("test-navigation")],te);var Po=y`
|
|
146
146
|
display: inline-flex;
|
|
147
147
|
align-items: center;
|
|
148
148
|
cursor: pointer;
|
|
@@ -165,14 +165,14 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
165
165
|
:host([disabled]) {
|
|
166
166
|
${F};
|
|
167
167
|
}
|
|
168
|
-
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],De.prototype,"_internalDisabled",2),c([
|
|
168
|
+
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],De.prototype,"_internalDisabled",2),c([T({context:$,subscribe:!0})],De.prototype,"computedContext",2),c([M("computedContext")],De.prototype,"_handleTestElementChange",1),De=c([q("test-next")],De);var Ve=class extends b{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 f`<slot></slot>`}};Ve.styles=y`
|
|
169
169
|
:host {
|
|
170
170
|
${B};
|
|
171
171
|
}
|
|
172
172
|
:host([disabled]) {
|
|
173
173
|
${F};
|
|
174
174
|
}
|
|
175
|
-
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Ve.prototype,"_internalDisabled",2),c([
|
|
175
|
+
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Ve.prototype,"_internalDisabled",2),c([T({context:$,subscribe:!0})],Ve.prototype,"computedContext",2),c([M("computedContext")],Ve.prototype,"_handleTestElementChange",1),Ve=c([q("test-prev")],Ve);var j=class extends b{constructor(){super(...arguments);this.label="view";this._handleViewOptionsChange=()=>{this.updateViewOptions()};this._viewOptions=j.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),this.updateViewOptions()}updateViewOptions(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>j.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=j.DEFAULT_VIEW_OPTIONS}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return f`
|
|
176
176
|
<label part="label" for="viewSelect">${this.label}</label>
|
|
177
177
|
<select
|
|
178
178
|
part="select"
|
|
@@ -181,7 +181,7 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
181
181
|
>
|
|
182
182
|
${this._viewOptions.map(e=>f`<option value="${e}" ?selected=${e===this.sessionContext.view}>${e}</option>`)}
|
|
183
183
|
</select>
|
|
184
|
-
`}};j.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([
|
|
184
|
+
`}};j.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([T({context:Le,subscribe:!0})],j.prototype,"sessionContext",2),c([u({type:String})],j.prototype,"label",2),c([u({type:String,attribute:"view-options"})],j.prototype,"viewOptions",2),c([M("viewOptions",{waitUntilFirstUpdate:!0})],j.prototype,"_handleViewOptionsChange",2),c([C()],j.prototype,"_viewOptions",2),j=c([q("test-view")],j);var xt=class extends b{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 f` <slot></slot> `}};xt.styles=y`
|
|
185
185
|
:host {
|
|
186
186
|
${B};
|
|
187
187
|
}
|
|
@@ -202,8 +202,8 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
202
202
|
:host([disabled]) {
|
|
203
203
|
${F};
|
|
204
204
|
}
|
|
205
|
-
`,c([
|
|
206
|
-
`;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),Xr=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;Fn(this.#t);)this.#e(!0);if(Xn(this.#t))return this.#l();if(Vo(this.#t))return this.#d();if(Kt(this.#t))return this.#p();if(this.#t===46)return this.#a();if(this.#t===44)return this.#u();if(this.#t===58)return this.#c();if(Gn(this.#t))return this.#h();if(Qn(this.#t))return this.#f();if(this.#e(),this.#t!==void 0)throw new Error(`Expected end of input, got ${this.#t}`)}#e(r){this.#n++,this.#n<this.#s.length?(this.#t=this.#s.charCodeAt(this.#n),r===!0&&(this.#i=this.#n)):this.#t=void 0}#r(r=0){let e=this.#s.substring(this.#i,this.#n+r);return r===0&&this.#o(),e}#o(){this.#i=this.#n}#l(){let r="unterminated string",e=this.#t;for(this.#e(!0);this.#t!==e;){if(this.#t===void 0)throw new Error(r);if(this.#t===92&&(this.#e(),this.#t===void 0))throw new Error(r);this.#e()}let t=me(R.STRING,Yn(this.#r()));return this.#e(),t}#d(){do this.#e();while(jn(this.#t));let r=this.#r(),e=Wn(r)?R.KEYWORD:R.IDENTIFIER;return me(e,r)}#p(){do this.#e();while(Kt(this.#t));return this.#t===46?this.#a():me(R.INTEGER,this.#r())}#a(){return this.#e(),Kt(this.#t)?this.#m():(this.#o(),me(R.DOT,".",Wr))}#u(){return this.#e(!0),me(R.COMMA,",")}#c(){return this.#e(!0),me(R.COLON,":")}#m(){do this.#e();while(Kt(this.#t));return me(R.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if(Bn.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),me(R.ARROW,r);Un.indexOf(r)!==-1&&this.#e()}return r=this.#r(),me(R.OPERATOR,r,Yi[r])}#f(){let r=String.fromCharCode(this.#t),e=me(R.GROUPER,r,Yi[r]);return this.#e(!0),e}};var Ji=(o,r)=>new Zt(o,r).parse(),Zt=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new Xr(r),this.#i=e}parse(){return this.#r(),this.#o()}#r(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#t?.kind} (${this.#t?.value})`);let t=this.#n.nextToken();this.#t=t,this.#s=t?.kind,this.#e=t?.value}_matches(r,e){return!(r&&this.#s!==r||e&&this.#e!==e)}#o(){if(!this.#t)return this.#i.empty();let r=this.#a();return r===void 0?void 0:this.#l(r,0)}#l(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#t;)if(this._matches(R.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(R.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(R.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(R.KEYWORD))break;if(this._matches(R.OPERATOR)&&this.#t.precedence>=e)r=this.#e==="?"?this.#u(r):this.#p(r,this.#t);else break}return r}#d(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}`)}#p(r,e){if(Do.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===R.OPERATOR||this.#s===R.DOT||this.#s===R.GROUPER)&&this.#t.precedence>e.precedence;)t=this.#l(t,this.#t.precedence);return this.#i.binary(r,e.value,t)}#a(){if(this._matches(R.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(R.INTEGER))return this.#b(r);if(this._matches(R.DECIMAL))return this.#v(r)}if(Oo.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),Wr);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(R.OPERATOR,"?");let e=this.#o();this.#r(R.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case R.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw jr.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case R.IDENTIFIER:return this.#f();case R.STRING:return this.#C();case R.INTEGER:return this.#b();case R.DECIMAL:return this.#v();case R.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case R.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(R.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(R.COMMA));return this.#r(R.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(R.GROUPER,"}"))break;let e=this.#e;(this._matches(R.STRING)||this._matches(R.IDENTIFIER))&&this.#r(),this.#r(R.COLON),r[e]=this.#o()}while(this._matches(R.COMMA));return this.#r(R.GROUPER,"}"),this.#i.map(r)}#f(){let r=this.#e;if(r==="true")return this.#r(),this.#i.literal(!0);if(r==="false")return this.#r(),this.#i.literal(!1);if(r==="null")return this.#r(),this.#i.literal(null);if(r==="undefined")return this.#r(),this.#i.literal(void 0);let e=this.#y(),t=this.#g();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(R.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(R.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(R.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(R.COMMA));return this.#r(R.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(R.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(R.ARROW)){this.#r();let e=this.#o(),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.#e);return this.#r(),r}#b(r=""){let e=this.#i.literal(parseInt(`${r}${this.#e}`,10));return this.#r(),e}#v(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#e}`));return this.#r(),e}};var{hasOwn:No,fromEntries:Jn}=Object,Kn={"+":(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)},Zn={"+":o=>o,"-":o=>-o,"!":o=>!o},Gr=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=Zn[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=Kn[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=Jn(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return No(a,p)&&(a[p]=m),d[p]=m},get(d,p){return No(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var Ki=null,Ho={boundAttributeSuffix:H.M,marker:H.P,markerMatch:H.A,HTML_RESULT:H.C,getTemplateHtml:H.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){Ki??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Ki))return void(e[Ki]=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=O;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:H.V,AttributePart:H.H,PropertyPart:H.B,BooleanAttributePart:H.N,EventPart:H.U,ElementPart:H.F,TemplateInstance:H.R,isIterable:H.D,ChildPart:H.I};var{AttributePart:ea,PropertyPart:ta,BooleanAttributePart:ra,EventPart:ia}=Ho,es=new Gr,Zi=new Map,zo=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),Qr=(o,r)=>{let e=Zi.get(o);if(e===void 0){if(Zi.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new Zt(t,es).parse(),Zi.set(o,e)}}return e?.evaluate(r)},sa=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&Qr(i,r))return Yr(o,r,e,t)},Uo=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,Bo=o=>/(?:\\{{)|(?:\\}})/g.test(o),er=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),oa=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=Qr(i,r);if(!s[Symbol.iterator])return k;let n=tr(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}},jo={if:sa,repeat:oa},he=(o,r=jo,e={},t)=>{let s=tr(o).renderers;if(t){let a=tr(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(h,g,v)=>Yr(t,h,g,v)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>Yr(o,n,r,e)};var Yr=(o,r,e=jo,t={})=>{let i=tr(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}},Fo=new Map,tr=o=>{let r=Fo.get(o);return r===void 0&&Fo.set(o,r=na(o)),r},na=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,C,T)=>{let x=n.getAttribute("data"),S=x===null?void 0:Qr(x,v);return(g?Qr(h,v):T[p])?.(S,C,T)}}else l!==null?m=(h,g,v)=>{let C=g[l];return C?.(n,h,g,v)}:(d==="super"?r.renderers.super=(h,g,v)=>{let C=v.super,T=tr(n);return v={...v,...T.renderers},C(h,g,v)}:r.renderers[d]=(h,g,v)=>Yr(n,h,g,v),m=(h,g,v)=>{let C=v[d];return C?.(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(Uo);if(p.length===1){Bo(d)&&n.setAttribute(l,er(d));continue}n.removeAttribute(l);let m=l,h=ea,g=l[0];g==="."?(m=zo(l.substring(1)),h=ta):g==="?"?(m=l.substring(1),h=ra):g==="@"&&(m=zo(l.substring(1)),h=ia);let v=[er(p[0])],C=[];for(let T=1;T<p.length;T+=2){let x=p[T];C.push(Ji(x,es)),v.push(er(p[T+1]))}r.parts.push({type:1,index:i,name:m,strings:v,ctor:h,update:(T,x,S)=>C.map(L=>L.evaluate(T))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(Uo);l.length>1?n.textContent=er(l[0]):Bo(a)&&(n.textContent=er(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=Ji(p,es);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 rr=class extends b{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=he(r)}render(){if(!this.computedContext)return f``;let r=this.computedContext.testParts.flatMap(e=>e.sections.flatMap(t=>t.items));return f` ${r.map(e=>this.myTemplate({item:e,view:this.computedContext.view}))} `}};c([_({context:$,subscribe:!0})],rr.prototype,"computedContext",2),rr=c([q("test-paging-buttons-stamp")],rr);var Jr=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},Kr=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 Wo=o=>!qo(o)&&typeof o.then=="function",Xo=1073741823,ts=class extends Oe{constructor(){super(...arguments),this._$Cwt=Xo,this._$Cbt=[],this._$CK=new Jr(this),this._$CX=new Kr}render(...r){return r.find((e=>!Wo(e)))??O}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(!Wo(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Xo,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 O}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},Zr=G(ts);var ei=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
|
|
205
|
+
`,c([T({context:$,subscribe:!0})],re.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],re.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],re.prototype,"disabled",2),c([u({type:String})],re.prototype,"showCorrectText",2),c([u({type:String})],re.prototype,"hideCorrectText",2),c([u({type:String})],re.prototype,"noCorrectResponseText",2),re=c([q("test-show-correct-response")],re);var jr=["this"],Oo=["+","-","!"],Do=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Qi={"!":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},Wr=13;var Un=["==","!=","<=",">=","||","&&","??","|>"],Bn=["===","!=="],R;(function(o){o[o.STRING=1]="STRING",o[o.IDENTIFIER=2]="IDENTIFIER",o[o.DOT=3]="DOT",o[o.COMMA=4]="COMMA",o[o.COLON=5]="COLON",o[o.INTEGER=6]="INTEGER",o[o.DECIMAL=7]="DECIMAL",o[o.OPERATOR=8]="OPERATOR",o[o.GROUPER=9]="GROUPER",o[o.KEYWORD=10]="KEYWORD",o[o.ARROW=11]="ARROW"})(R||(R={}));var me=(o,r,e=0)=>({kind:o,value:r,precedence:e}),Fn=o=>o===9||o===10||o===13||o===32,Vo=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),jn=o=>Vo(o)||Kt(o),Wn=o=>jr.indexOf(o)!==-1,Xn=o=>o===34||o===39,Kt=o=>48<=o&&o<=57,Gn=o=>o===43||o===45||o===42||o===47||o===33||o===38||o===37||o===60||o===61||o===62||o===63||o===94||o===124,Yn=o=>o===40||o===41||o===91||o===93||o===123||o===125,Qn=o=>o.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
|
|
206
|
+
`;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),Xr=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;Fn(this.#t);)this.#e(!0);if(Xn(this.#t))return this.#l();if(Vo(this.#t))return this.#d();if(Kt(this.#t))return this.#p();if(this.#t===46)return this.#a();if(this.#t===44)return this.#u();if(this.#t===58)return this.#c();if(Gn(this.#t))return this.#h();if(Yn(this.#t))return this.#f();if(this.#e(),this.#t!==void 0)throw new Error(`Expected end of input, got ${this.#t}`)}#e(r){this.#n++,this.#n<this.#s.length?(this.#t=this.#s.charCodeAt(this.#n),r===!0&&(this.#i=this.#n)):this.#t=void 0}#r(r=0){let e=this.#s.substring(this.#i,this.#n+r);return r===0&&this.#o(),e}#o(){this.#i=this.#n}#l(){let r="unterminated string",e=this.#t;for(this.#e(!0);this.#t!==e;){if(this.#t===void 0)throw new Error(r);if(this.#t===92&&(this.#e(),this.#t===void 0))throw new Error(r);this.#e()}let t=me(R.STRING,Qn(this.#r()));return this.#e(),t}#d(){do this.#e();while(jn(this.#t));let r=this.#r(),e=Wn(r)?R.KEYWORD:R.IDENTIFIER;return me(e,r)}#p(){do this.#e();while(Kt(this.#t));return this.#t===46?this.#a():me(R.INTEGER,this.#r())}#a(){return this.#e(),Kt(this.#t)?this.#m():(this.#o(),me(R.DOT,".",Wr))}#u(){return this.#e(!0),me(R.COMMA,",")}#c(){return this.#e(!0),me(R.COLON,":")}#m(){do this.#e();while(Kt(this.#t));return me(R.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if(Bn.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),me(R.ARROW,r);Un.indexOf(r)!==-1&&this.#e()}return r=this.#r(),me(R.OPERATOR,r,Qi[r])}#f(){let r=String.fromCharCode(this.#t),e=me(R.GROUPER,r,Qi[r]);return this.#e(!0),e}};var Ji=(o,r)=>new Zt(o,r).parse(),Zt=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new Xr(r),this.#i=e}parse(){return this.#r(),this.#o()}#r(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#t?.kind} (${this.#t?.value})`);let t=this.#n.nextToken();this.#t=t,this.#s=t?.kind,this.#e=t?.value}_matches(r,e){return!(r&&this.#s!==r||e&&this.#e!==e)}#o(){if(!this.#t)return this.#i.empty();let r=this.#a();return r===void 0?void 0:this.#l(r,0)}#l(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#t;)if(this._matches(R.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(R.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(R.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(R.KEYWORD))break;if(this._matches(R.OPERATOR)&&this.#t.precedence>=e)r=this.#e==="?"?this.#u(r):this.#p(r,this.#t);else break}return r}#d(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}`)}#p(r,e){if(Do.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===R.OPERATOR||this.#s===R.DOT||this.#s===R.GROUPER)&&this.#t.precedence>e.precedence;)t=this.#l(t,this.#t.precedence);return this.#i.binary(r,e.value,t)}#a(){if(this._matches(R.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(R.INTEGER))return this.#b(r);if(this._matches(R.DECIMAL))return this.#v(r)}if(Oo.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),Wr);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(R.OPERATOR,"?");let e=this.#o();this.#r(R.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case R.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw jr.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case R.IDENTIFIER:return this.#f();case R.STRING:return this.#C();case R.INTEGER:return this.#b();case R.DECIMAL:return this.#v();case R.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case R.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(R.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(R.COMMA));return this.#r(R.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(R.GROUPER,"}"))break;let e=this.#e;(this._matches(R.STRING)||this._matches(R.IDENTIFIER))&&this.#r(),this.#r(R.COLON),r[e]=this.#o()}while(this._matches(R.COMMA));return this.#r(R.GROUPER,"}"),this.#i.map(r)}#f(){let r=this.#e;if(r==="true")return this.#r(),this.#i.literal(!0);if(r==="false")return this.#r(),this.#i.literal(!1);if(r==="null")return this.#r(),this.#i.literal(null);if(r==="undefined")return this.#r(),this.#i.literal(void 0);let e=this.#y(),t=this.#g();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(R.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(R.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(R.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(R.COMMA));return this.#r(R.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(R.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(R.ARROW)){this.#r();let e=this.#o(),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.#e);return this.#r(),r}#b(r=""){let e=this.#i.literal(parseInt(`${r}${this.#e}`,10));return this.#r(),e}#v(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#e}`));return this.#r(),e}};var{hasOwn:No,fromEntries:Jn}=Object,Kn={"+":(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)},Zn={"+":o=>o,"-":o=>-o,"!":o=>!o},Gr=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=Zn[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=Kn[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=Jn(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return No(a,p)&&(a[p]=m),d[p]=m},get(d,p){return No(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var Ki=null,Ho={boundAttributeSuffix:H.M,marker:H.P,markerMatch:H.A,HTML_RESULT:H.C,getTemplateHtml:H.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){Ki??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Ki))return void(e[Ki]=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=D;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:H.V,AttributePart:H.H,PropertyPart:H.B,BooleanAttributePart:H.N,EventPart:H.U,ElementPart:H.F,TemplateInstance:H.R,isIterable:H.D,ChildPart:H.I};var{AttributePart:ea,PropertyPart:ta,BooleanAttributePart:ra,EventPart:ia}=Ho,es=new Gr,Zi=new Map,zo=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),Yr=(o,r)=>{let e=Zi.get(o);if(e===void 0){if(Zi.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new Zt(t,es).parse(),Zi.set(o,e)}}return e?.evaluate(r)},sa=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&Yr(i,r))return Qr(o,r,e,t)},Uo=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,Bo=o=>/(?:\\{{)|(?:\\}})/g.test(o),er=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),oa=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=Yr(i,r);if(!s[Symbol.iterator])return k;let n=tr(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}},jo={if:sa,repeat:oa},he=(o,r=jo,e={},t)=>{let s=tr(o).renderers;if(t){let a=tr(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(h,g,v)=>Qr(t,h,g,v)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>Qr(o,n,r,e)};var Qr=(o,r,e=jo,t={})=>{let i=tr(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}},Fo=new Map,tr=o=>{let r=Fo.get(o);return r===void 0&&Fo.set(o,r=na(o)),r},na=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,w,E)=>{let x=n.getAttribute("data"),S=x===null?void 0:Yr(x,v);return(g?Yr(h,v):E[p])?.(S,w,E)}}else l!==null?m=(h,g,v)=>{let w=g[l];return w?.(n,h,g,v)}:(d==="super"?r.renderers.super=(h,g,v)=>{let w=v.super,E=tr(n);return v={...v,...E.renderers},w(h,g,v)}:r.renderers[d]=(h,g,v)=>Qr(n,h,g,v),m=(h,g,v)=>{let w=v[d];return w?.(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(Uo);if(p.length===1){Bo(d)&&n.setAttribute(l,er(d));continue}n.removeAttribute(l);let m=l,h=ea,g=l[0];g==="."?(m=zo(l.substring(1)),h=ta):g==="?"?(m=l.substring(1),h=ra):g==="@"&&(m=zo(l.substring(1)),h=ia);let v=[er(p[0])],w=[];for(let E=1;E<p.length;E+=2){let x=p[E];w.push(Ji(x,es)),v.push(er(p[E+1]))}r.parts.push({type:1,index:i,name:m,strings:v,ctor:h,update:(E,x,S)=>w.map(I=>I.evaluate(E))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(Uo);l.length>1?n.textContent=er(l[0]):Bo(a)&&(n.textContent=er(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=Ji(p,es);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 rr=class extends b{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=he(r)}render(){if(!this.computedContext)return f``;let r=this.computedContext.testParts.flatMap(e=>e.sections.flatMap(t=>t.items));return f` ${r.map(e=>this.myTemplate({item:e,view:this.computedContext.view}))} `}};c([T({context:$,subscribe:!0})],rr.prototype,"computedContext",2),rr=c([q("test-paging-buttons-stamp")],rr);var Jr=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},Kr=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 Wo=o=>!qo(o)&&typeof o.then=="function",Xo=1073741823,ts=class extends Oe{constructor(){super(...arguments),this._$Cwt=Xo,this._$Cbt=[],this._$CK=new Jr(this),this._$CX=new Kr}render(...r){return r.find((e=>!Wo(e)))??D}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(!Wo(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Xo,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 D}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},Zr=G(ts);var ei=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
|
|
207
207
|
|
|
208
208
|
:root,
|
|
209
209
|
:host {
|
|
@@ -3948,7 +3948,7 @@ div.full-correct-response-inline {
|
|
|
3948
3948
|
${this.templateContent}
|
|
3949
3949
|
<slot></slot>
|
|
3950
3950
|
${Zr(this.testDoc,f`<span>Loading...</span>`)}
|
|
3951
|
-
`}};c([u({type:String,attribute:"test-url"})],Ee.prototype,"testURL",2),c([
|
|
3951
|
+
`}};c([u({type:String,attribute:"test-url"})],Ee.prototype,"testURL",2),c([C()],Ee.prototype,"testDoc",2),c([C()],Ee.prototype,"testXML",2),c([M("testURL",{waitUntilFirstUpdate:!0})],Ee.prototype,"handleTestURLChange",1),c([M("testXML",{waitUntilFirstUpdate:!0})],Ee.prototype,"handleTestXMLChange",1),Ee=c([q("test-container")],Ee);var qt=class extends b{render(){let r=this.computedContext?.testParts.flatMap(s=>s.sections.flatMap(n=>n.items)).find(s=>s.active);if(!r||!r.variables)return f``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>f`
|
|
3952
3952
|
<h3>${n}</h3>
|
|
3953
3953
|
<table>
|
|
3954
3954
|
<thead>
|
|
@@ -3995,15 +3995,15 @@ div.full-correct-response-inline {
|
|
|
3995
3995
|
margin-top: 20px;
|
|
3996
3996
|
font-size: 16px;
|
|
3997
3997
|
}
|
|
3998
|
-
`,c([
|
|
3998
|
+
`,c([T({context:$,subscribe:!0})],qt.prototype,"computedContext",2),qt=c([q("test-print-item-variables")],qt);var ir=class extends b{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=he(r)}render(){if(!this.computedContext)return f``;let r=this.computedContext.testParts.flatMap(e=>e.sections);return f` ${r.map(e=>this.myTemplate({item:e}))} `}};c([T({context:$,subscribe:!0})],ir.prototype,"computedContext",2),ir=c([q("test-section-buttons-stamp")],ir);var Ct=class extends b{constructor(){super();this.sectionId=null;this.addEventListener("click",()=>this._requestItem(this.sectionId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"section",id:e}}))}render(){return f` <slot></slot> `}};Ct.styles=y`
|
|
3999
3999
|
:host {
|
|
4000
4000
|
${B};
|
|
4001
4001
|
}
|
|
4002
4002
|
:host([disabled]) {
|
|
4003
4003
|
${F};
|
|
4004
4004
|
}
|
|
4005
|
-
`,c([u({type:String,attribute:"section-id"})],Ct.prototype,"sectionId",2),Ct=c([q("test-section-link")],Ct);var sr=class extends b{render(){return f` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([
|
|
4006
|
-
${this.myTemplate?this.myTemplate(this.stampContext):k}`}};c([u({type:Boolean,reflect:!0})],it.prototype,"debug",2),c([
|
|
4005
|
+
`,c([u({type:String,attribute:"section-id"})],Ct.prototype,"sectionId",2),Ct=c([q("test-section-link")],Ct);var sr=class extends b{render(){return f` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([C(),T({context:$,subscribe:!0})],sr.prototype,"computedContext",2),sr=c([q("test-print-context")],sr);var it=class extends b{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=he(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(h=>h.active),i=t?.sections.find(h=>h.active),s=i?.items.find(h=>h.active),{variables:n,...a}=s||{};if(!t||!i||!s)return;let l={...t,items:t.sections.flatMap(h=>h.items.map(({variables:g,...v})=>v)),sections:t.sections.map(h=>({...h,items:h.items.map(({variables:g,...v})=>v)}))},d={...i,items:i.items.map(({variables:h,...g})=>g)},{testParts:p,...m}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:a,activeSection:d,activeTestpart:l,test:m},this.dispatchEvent(new CustomEvent("qti-stamp-context-updated",{detail:this.stampContext,bubbles:!0}))}render(){return f` ${this.debug?f`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:k}
|
|
4006
|
+
${this.myTemplate?this.myTemplate(this.stampContext):k}`}};c([u({type:Boolean,reflect:!0})],it.prototype,"debug",2),c([C(),T({context:$,subscribe:!0})],it.prototype,"computedContext",2),c([C()],it.prototype,"stampContext",2),it=c([q("test-stamp")],it);var st=class extends b{constructor(){super();this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&this._changeOutcomeScore(i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=he(e)}_changeOutcomeScore(e){let s=(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:s,outcomeVariableId:"SCORE",value:e},bubbles:!0}))}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return f``;let t=e.variables.find(l=>l.identifier=="MAXSCORE")?.value,i=e.variables.find(l=>l.identifier=="SCORE"),s=i?.value,n=i?.externalScored!=="human";if(!t||!i)return k;let a=[...Array(Number(t)+1).keys()];return f`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):k}`}};c([u({type:String,attribute:"view"})],st.prototype,"view",2),c([u({type:Boolean})],st.prototype,"disabled",2),c([T({context:$,subscribe:!0})],st.prototype,"computedContext",2),st=c([q("test-scoring-buttons")],st);var or=class extends b{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=he(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 f`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):k}`}};c([T({context:Le,subscribe:!0})],or.prototype,"sessionContext",2),or=c([q("test-view-toggle")],or);var wt=class extends b{constructor(){super(...arguments);this.view=null}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return f``;if(e.category==="dep-informational")return f`<div>${this.dataset.informational}</div>`;let t=e?.variables.find(l=>l.identifier==="completionStatus")?.value,i=e?.variables.find(l=>l.identifier=="SCORE"),s=parseFloat(i?.value),n=e.externalScored;return f`<div>${t!=="completed"?this.dataset.textNoResponse:!n&&s!==void 0&&!Number.isNaN(s)?s>0?this.dataset.textCorrect:this.dataset.textIncorrect:n==="externalMachine"?Number.isNaN(s)||s===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${s===0?"geen punten":s==1?"\xE9\xE9n punt":`${s} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:n==="human"?Number.isNaN(s)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};c([T({context:$,subscribe:!0})],wt.prototype,"computedContext",2),c([u({type:String,attribute:"view"})],wt.prototype,"view",2),wt=c([q("test-scoring-feedback")],wt);var nr=class extends b{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 f` <slot></slot> `}};nr.styles=y`
|
|
4007
4007
|
:host {
|
|
4008
4008
|
${B};
|
|
4009
4009
|
}
|
|
@@ -4014,7 +4014,7 @@ div.full-correct-response-inline {
|
|
|
4014
4014
|
${this.templateContent}
|
|
4015
4015
|
<slot></slot>
|
|
4016
4016
|
${Zr(this.itemDoc,f`<span>Loading...</span>`)}
|
|
4017
|
-
`}};c([u({type:String,attribute:"item-url"})],_e.prototype,"itemURL",2),c([
|
|
4017
|
+
`}};c([u({type:String,attribute:"item-url"})],_e.prototype,"itemURL",2),c([C()],_e.prototype,"itemDoc",2),c([C()],_e.prototype,"itemXML",2),c([M("itemURL",{waitUntilFirstUpdate:!0})],_e.prototype,"handleItemURLChange",1),c([M("itemXML",{waitUntilFirstUpdate:!0})],_e.prototype,"handleItemXMLChange",1),_e=c([q("item-container")],_e);var ot=class extends b{constructor(){super(...arguments);this.label="Correct response mode";this._options={internal:"Internal",full:"Full (copy)"}}_switchMode(e){this.dispatchEvent(new CustomEvent("item-switch-correct-response-mode",{detail:e,bubbles:!0}))}render(){return f`
|
|
4018
4018
|
<label part="label" for="modeSelect">${this.label}</label>
|
|
4019
4019
|
<select
|
|
4020
4020
|
part="select"
|
|
@@ -4025,7 +4025,7 @@ div.full-correct-response-inline {
|
|
|
4025
4025
|
${this._options[e]}
|
|
4026
4026
|
</option>`)}
|
|
4027
4027
|
</select>
|
|
4028
|
-
`}};c([
|
|
4028
|
+
`}};c([T({context:Z,subscribe:!0})],ot.prototype,"itemContext",2),c([u({type:String})],ot.prototype,"label",2),c([C()],ot.prototype,"_options",2),ot=c([q("item-correct-response-mode")],ot);var Go=y`
|
|
4029
4029
|
display: inline-flex;
|
|
4030
4030
|
align-items: center;
|
|
4031
4031
|
cursor: pointer;
|
|
@@ -4048,14 +4048,14 @@ div.full-correct-response-inline {
|
|
|
4048
4048
|
:host([disabled]) {
|
|
4049
4049
|
${ri};
|
|
4050
4050
|
}
|
|
4051
|
-
`,c([
|
|
4051
|
+
`,c([T({context:Ie,subscribe:!0})],ie.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],ie.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],ie.prototype,"disabled",2),c([u({type:String})],ie.prototype,"showCandidateCorrectionText",2),c([u({type:String})],ie.prototype,"hideCandidateCorrectionText",2),c([u({type:String})],ie.prototype,"noCorrectResponseText",2),ie=c([q("item-show-candidate-correction")],ie);var se=class extends b{constructor(){super(...arguments);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";this._hasCorrectResponse=!1;this._previousActiveItem=""}updated(){if(!this._hasCorrectResponse||this._previousActiveItem!==this.computedContext?.identifier){this._previousActiveItem=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);this._hasCorrectResponse=e||t}this.disabled=!this._hasCorrectResponse}_toggleState(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-correct-response",{detail:!this.shown,bubbles:!0}))}_getDisplayedText(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return f` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `}};se.styles=y`
|
|
4052
4052
|
:host {
|
|
4053
4053
|
${ti};
|
|
4054
4054
|
}
|
|
4055
4055
|
:host([disabled]) {
|
|
4056
4056
|
${ri};
|
|
4057
4057
|
}
|
|
4058
|
-
`,c([
|
|
4058
|
+
`,c([T({context:Ie,subscribe:!0})],se.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],se.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],se.prototype,"disabled",2),c([u({type:String})],se.prototype,"showCorrectText",2),c([u({type:String})],se.prototype,"hideCorrectText",2),c([u({type:String})],se.prototype,"noCorrectResponseText",2),se=c([q("item-show-correct-response")],se);var Et=class extends b{render(){let r=this.computedContext;if(!r||!r.variables)return f``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>f`
|
|
4059
4059
|
<h3>${n}</h3>
|
|
4060
4060
|
<table>
|
|
4061
4061
|
<thead>
|
|
@@ -4102,7 +4102,7 @@ div.full-correct-response-inline {
|
|
|
4102
4102
|
margin-top: 20px;
|
|
4103
4103
|
font-size: 16px;
|
|
4104
4104
|
}
|
|
4105
|
-
`,c([_({context:Ie,subscribe:!0})],Et.prototype,"computedContext",2),Et=c([q("item-print-variables")],Et);var _t=class extends b{constructor(){super();this.configContext={};this._onItemContextChanged=this._handleItemContextChanged.bind(this);this._onAssessmentItemConnected=this._handleAssessmentItemConnected.bind(this);this._onHandleShowCorrectResponse=this._handleShowCorrectResponse.bind(this);this._onHandleShowCandidateCorrection=this._handleShowCandidateCorrection.bind(this);this._onHandleSwitchCorrectResponseMode=this._handleSwitchCorrectResponseMode.bind(this);this.addEventListener("qti-item-context-updated",this._onItemContextChanged),this.addEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected),this.addEventListener("item-show-correct-response",this._onHandleShowCorrectResponse),this.addEventListener("item-show-candidate-correction",this._onHandleShowCandidateCorrection),this.addEventListener("item-switch-correct-response-mode",this._onHandleSwitchCorrectResponseMode)}_handleItemContextChanged(e){this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])}_handleAssessmentItemConnected(e){let t=e.detail._context.variables;this._qtiAssessmentItem=e.detail,this.computedContext=this.computedContext?.identifier===this._qtiAssessmentItem.identifier?{...this.computedContext,title:this._qtiAssessmentItem.title}:{identifier:this._qtiAssessmentItem.identifier,title:this._qtiAssessmentItem.title,adaptive:this._qtiAssessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier,t||[])}_handleShowCorrectResponse(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCorrectResponse(e.detail)}_handleShowCandidateCorrection(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCandidateCorrection(e.detail)}_handleSwitchCorrectResponseMode(e){this._handleShowCorrectResponse(new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}}_updateItemVariablesInTestContext(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}}render(){return f`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this._onItemContextChanged),this.removeEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected)}};c([w(),X({context:Ie})],_t.prototype,"computedContext",2),c([w(),X({context:Z})],_t.prototype,"configContext",2),_t=c([q("qti-item")],_t);var Yo=(o,r,e)=>{class t extends o{}return t};var fe=(o,r,e,t)=>{class i extends Yo(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:C,height:T}=await this.measureIntrinsicSize(v);h=Math.max(h,T),g=Math.max(g,C)}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 C=v.shadowRoot?.querySelector('slot[part="dropslot"]');C&&(C.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(C=>C.getAttribute("identifier")===h),v=m.find(C=>C.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),C=this.calculateOverlapArea(l,v);C>p&&(p=C,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),C=Math.hypot(l.left-v.left,l.top-v.top);C<h&&(h=C,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.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(T=>Array.from(T.children).some(x=>x===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),C=this.draggables.filter(T=>T.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));v!==0&&C.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([Dr(t)],i.prototype,"handleDraggableContainerChange",1),c([Dr(r)],i.prototype,"handleDraggablesChange",1),c([Dr(e)],i.prototype,"handleDroppablesChange",1),i};var Jo=y`
|
|
4105
|
+
`,c([T({context:Ie,subscribe:!0})],Et.prototype,"computedContext",2),Et=c([q("item-print-variables")],Et);var _t=class extends b{constructor(){super();this.configContext={};this._onItemContextChanged=this._handleItemContextChanged.bind(this);this._onAssessmentItemConnected=this._handleAssessmentItemConnected.bind(this);this._onHandleShowCorrectResponse=this._handleShowCorrectResponse.bind(this);this._onHandleShowCandidateCorrection=this._handleShowCandidateCorrection.bind(this);this._onHandleSwitchCorrectResponseMode=this._handleSwitchCorrectResponseMode.bind(this);this.addEventListener("qti-item-context-updated",this._onItemContextChanged),this.addEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected),this.addEventListener("item-show-correct-response",this._onHandleShowCorrectResponse),this.addEventListener("item-show-candidate-correction",this._onHandleShowCandidateCorrection),this.addEventListener("item-switch-correct-response-mode",this._onHandleSwitchCorrectResponseMode)}_handleItemContextChanged(e){this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])}_handleAssessmentItemConnected(e){let t=e.detail._context.variables;this._qtiAssessmentItem=e.detail,this.computedContext=this.computedContext?.identifier===this._qtiAssessmentItem.identifier?{...this.computedContext,title:this._qtiAssessmentItem.title}:{identifier:this._qtiAssessmentItem.identifier,title:this._qtiAssessmentItem.title,adaptive:this._qtiAssessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier,t||[])}_handleShowCorrectResponse(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCorrectResponse(e.detail)}_handleShowCandidateCorrection(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCandidateCorrection(e.detail)}_handleSwitchCorrectResponseMode(e){this._handleShowCorrectResponse(new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}}_updateItemVariablesInTestContext(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}}render(){return f`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this._onItemContextChanged),this.removeEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected)}};c([C(),X({context:Ie})],_t.prototype,"computedContext",2),c([C(),X({context:Z})],_t.prototype,"configContext",2),_t=c([q("qti-item")],_t);var Qo=(o,r,e)=>{class t extends o{}return t};var fe=(o,r,e,t)=>{class i extends Qo(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:w,height:E}=await this.measureIntrinsicSize(v);h=Math.max(h,E),g=Math.max(g,w)}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 w=v.shadowRoot?.querySelector('slot[part="dropslot"]');w&&(w.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(w=>w.getAttribute("identifier")===h),v=m.find(w=>w.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),w=this.calculateOverlapArea(l,v);w>p&&(p=w,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),w=Math.hypot(l.left-v.left,l.top-v.top);w<h&&(h=w,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.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(E=>Array.from(E.children).some(x=>x===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),w=this.draggables.filter(E=>E.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));v!==0&&w.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([Dr(t)],i.prototype,"handleDraggableContainerChange",1),c([Dr(r)],i.prototype,"handleDraggablesChange",1),c([Dr(e)],i.prototype,"handleDroppablesChange",1),i};var Jo=y`
|
|
4106
4106
|
:host {
|
|
4107
4107
|
display: block; /* necessary to calculate scaling position */
|
|
4108
4108
|
}
|
|
@@ -4145,7 +4145,7 @@ div.full-correct-response-inline {
|
|
|
4145
4145
|
</div>`)}
|
|
4146
4146
|
|
|
4147
4147
|
<div role="alert" part="message" id="validation-message"></div>
|
|
4148
|
-
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};c([
|
|
4148
|
+
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};c([C()],ar.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ar);var Ne=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];this._mutationObserver=null;this._validationMessageShown=!1;this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(s,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(s,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(s){this.maxChoices>1&&(typeof s=="string"||s===null)?this.response=s?s.toString().split(","):[]:this.response=s||""}toggleInternalCorrectResponse(s){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"),s&&a.length>0&&(a.includes(l.identifier)?l.internals.states.add("correct-response"):l.internals.states.add("incorrect-response"))})}}toggleCandidateCorrection(s){let n=this.correctResponse;if(!n)return;let a=Array.isArray(n)?n:[n],l=this.response,d=Array.isArray(l)?l:l?[l]:[];this._choiceElements.forEach(p=>{p.internals.states.delete("candidate-correct"),p.internals.states.delete("candidate-incorrect"),s&&d.includes(p.identifier)&&(a.includes(p.identifier)?p.internals.states.add("candidate-correct"):p.internals.states.add("candidate-incorrect"))}),super.toggleCandidateCorrection(s)}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 s=new Set(this._choiceElements);this._choiceElements=Array.from(this.querySelectorAll(r)),this._choiceElements.forEach(a=>{s.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 d=this._choiceElements.find(p=>this.contains(p))||this;return this._internals.setValidity(a?{}:{customError:!0},l,d),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(s=>{this._setInputType(s)})}_setInputType(s){if(this._internals.role=this.maxChoices===1?"radiogroup":null,s.internals){let n=this.maxChoices===1?"radio":"checkbox";s.internals.role=n,s.internals.states.delete(n==="radio"?"checkbox":"radio"),s.internals.states.add(n)}}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1?this._choiceElements.forEach(n=>{n.identifier!==s.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(s,n){s.internals?.states&&(n?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let n=this._getChoiceChecked(s);this._setChoiceChecked(s,!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 s=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(n=>{let a=s.includes(n.identifier);this._setChoiceChecked(n,a)})}}return c([ct("#validation-message")],e.prototype,"_validationMessageElement",2),c([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),c([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),c([M("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),c([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),c([M("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),c([C()],e.prototype,"response",2),c([M("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),c([C(),T({context:Z,subscribe:!0})],e.prototype,"_configContext",2),e};var Ko=(o,r)=>{class e extends o{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"]}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}_addLabels(){let s=this._classes.some(a=>this._allLabels.includes(a)||this._allLabelSuffixes.includes(a)),n=a=>!isNaN(+a);if(s){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(d=>d).map((d,p)=>({el:d,order:n(d.style.order)?+d.style.order:p+1})).sort((d,p)=>d.order-p.order).map(d=>d.el);for(let d=0;d<l.length;d++)l[d].marker=this._getLabel(d+1)}}_getLabel(s){let n=this._classes.filter(d=>this._allLabels.includes(d)).pop(),a=this._classes.filter(d=>this._allLabelSuffixes.includes(d)).pop();!n&&a&&(n="qti-labels-upper-alpha");let l="";switch(n){case"qti-labels-decimal":l=`${s}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+s-1)}`;break}return a==="qti-labels-suffix-period"?l+=".":a==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return c([u({type:String})],e.prototype,"class",1),e};var Zo={};Vs(Zo,{default:()=>rs});var rs=y`
|
|
4149
4149
|
:host {
|
|
4150
4150
|
display: block;
|
|
4151
4151
|
}
|
|
@@ -4287,33 +4287,51 @@ window.CES = {
|
|
|
4287
4287
|
};
|
|
4288
4288
|
CES.load();
|
|
4289
4289
|
`,la=`
|
|
4290
|
-
|
|
4290
|
+
(function() {
|
|
4291
|
+
var blobUrlReceived = null;
|
|
4292
|
+
|
|
4293
|
+
const createIframe = () => {
|
|
4294
|
+
if (!blobUrlReceived || !document.body) return;
|
|
4295
|
+
var n = document.createElement('iframe');
|
|
4296
|
+
n.frameBorder = '0';
|
|
4297
|
+
n.scrolling = 'no';
|
|
4298
|
+
n.src = blobUrlReceived;
|
|
4299
|
+
n.style.width = '100%';
|
|
4300
|
+
n.style.height = '100%';
|
|
4301
|
+
document.body.appendChild(n);
|
|
4302
|
+
};
|
|
4303
|
+
|
|
4291
4304
|
const handleMessage = (event) => {
|
|
4292
4305
|
if (event.data.type === 'blobUrl') {
|
|
4293
|
-
|
|
4294
|
-
var n = document.createElement('iframe');
|
|
4295
|
-
n.frameBorder = '0';
|
|
4296
|
-
n.scrolling = 'no';
|
|
4297
|
-
n.src = blobUrl;
|
|
4298
|
-
n.style.width = '100%';
|
|
4299
|
-
n.style.height = '100%';
|
|
4300
|
-
document.body.appendChild(n);
|
|
4306
|
+
blobUrlReceived = event.data.data;
|
|
4301
4307
|
window.removeEventListener('message', handleMessage);
|
|
4308
|
+
createIframe();
|
|
4302
4309
|
}
|
|
4303
4310
|
};
|
|
4311
|
+
|
|
4304
4312
|
window.addEventListener('message', handleMessage);
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
w
|
|
4309
|
-
|
|
4310
|
-
w
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
+
|
|
4314
|
+
// Wait for document ready before requesting blobUrl
|
|
4315
|
+
const requestBlobUrl = () => {
|
|
4316
|
+
let w = window.parent;
|
|
4317
|
+
while (w) {
|
|
4318
|
+
w.postMessage({ type: 'getBlobUrl' }, '*');
|
|
4319
|
+
if (w !== w.parent) {
|
|
4320
|
+
w = w.parent;
|
|
4321
|
+
} else {
|
|
4322
|
+
w = null;
|
|
4323
|
+
}
|
|
4313
4324
|
}
|
|
4314
|
-
}
|
|
4315
|
-
|
|
4316
|
-
|
|
4325
|
+
};
|
|
4326
|
+
|
|
4327
|
+
if (document.readyState === 'loading') {
|
|
4328
|
+
document.addEventListener('DOMContentLoaded', requestBlobUrl);
|
|
4329
|
+
} else {
|
|
4330
|
+
requestBlobUrl();
|
|
4331
|
+
}
|
|
4332
|
+
})();
|
|
4333
|
+
`,Te=class extends A{constructor(){super();this.rawResponse="";this._manifestUrl=null;this._resourceBaseUrl=null;this._errorMessage=null;this._contentBlobUrl=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data;if(!e){let i=this.querySelector("object[data]");if(i){e=i.getAttribute("data");let s=i.getAttribute("width"),n=i.getAttribute("height");s&&this.setAttribute("width",s),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:Hr((this.baseItemUrl||"")+"/"+e);this._manifestUrl=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(m=>e.addEventListener("load",()=>m(),{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],s=this.getBaseCandidates(),n=await this.resolveResourceWithFallback(i,s),a=n.url;if(n.baseUrl&&!this._resourceBaseUrl&&(this._resourceBaseUrl=n.baseUrl),!0){let m="";if(this.manifest.media&&this.manifest.media.length>0){let h=this.manifest.media[0],g=await this.resolveResourceWithFallback(h,s,{returnText:!0});if(m=g.url,g.baseUrl&&!this._resourceBaseUrl&&(this._resourceBaseUrl=g.baseUrl),g.text){let v=g.text;if(!(v.includes("postToParentWindows")||v.includes("window.CES"))){let x="<script>"+is+"</script>",S=v.indexOf("<head>");S!==-1?v=v.slice(0,S+6)+x+v.slice(S+6):v=x+v}let E=new Blob([v],{type:"text/html"});this._contentBlobUrl=URL.createObjectURL(E)}}else{let h=this.data||"manifest.json",g=h.includes("/")?h.substring(0,h.lastIndexOf("/")):"",v=g?`${g}/index.html`:"index.html",w=await this.resolveResourceWithFallback(v,s,{returnText:!0});if(m=w.url,w.baseUrl&&!this._resourceBaseUrl&&(this._resourceBaseUrl=w.baseUrl),w.text){let E=w.text;if(!(E.includes("postToParentWindows")||E.includes("window.CES"))){let I="<script>"+is+"</script>",O=E.indexOf("<head>");O!==-1?E=E.slice(0,O+6)+I+E.slice(O+6):E=I+E}let S=new Blob([E],{type:"text/html"});this._contentBlobUrl=URL.createObjectURL(S)}}if(m&&!this._contentBlobUrl)try{let h=await fetch(m);if(h.ok){let g=await h.text();if(!(g.includes("postToParentWindows")||g.includes("window.CES"))){let E="<script>"+is+"</script>",x=g.indexOf("<head>");x!==-1?g=g.slice(0,x+6)+E+g.slice(x+6):g=E+g}let w=new Blob([g],{type:"text/html"});this._contentBlobUrl=URL.createObjectURL(w)}else console.error(`Failed to fetch index.html: ${h.status}`)}catch(h){console.error(`Error fetching index.html: ${h}`)}}let d=`<script>${la}</script>`;window.addEventListener("message",this.handlePostMessage);let p=`
|
|
4334
|
+
<!DOCTYPE html>
|
|
4317
4335
|
<html>
|
|
4318
4336
|
<head>
|
|
4319
4337
|
${a?`<link href='${a}' rel="stylesheet" />`:""}
|
|
@@ -4321,7 +4339,7 @@ CES.load();
|
|
|
4321
4339
|
</head>
|
|
4322
4340
|
<body></body>
|
|
4323
4341
|
</html>
|
|
4324
|
-
|
|
4342
|
+
`;e.srcdoc=p}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),i=[...e,...t];for(let s of i){let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;l&&this.getInnerIFrames(l,i)}catch(l){console.error("Error accessing nested iframe:",l)}}return i.forEach((s,n)=>{i.indexOf(s)!==n&&i.splice(n,1)}),i}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(s=>{t.push(s);let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;this.getInnerIFrames(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",n)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let i=this.getIFrames();for(let s of i)s.contentWindow&&s.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.rawResponse=i,this.saveResponse(i));break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getBlobUrl":{this._contentBlobUrl&&(this.postToWindowAndIframes("blobUrl",this._contentBlobUrl),e.source&&e.source!==window&&e.source.postMessage({type:"blobUrl",data:this._contentBlobUrl},"*"));break}case"getMedia":{let s=this.getBaseCandidates(),n=this.manifest.media.map(a=>{if(a.startsWith("http")||a.startsWith("blob"))return a;let l=this._resourceBaseUrl||s[0];return l?new URL(a,l.endsWith("/")?l:`${l}/`).toString():a});this.postToWindowAndIframes("mediaData",n);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){if(!this.rawResponse)return!1;if(Array.isArray(this.rawResponse)){if(this.rawResponse.length===0)return!1;for(let e of this.rawResponse)if(e!==""&&e!==null)return!0}return!0}get response(){return this.rawResponse||null}set response(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else if(Array.isArray(e))this.rawResponse=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 f`<iframe
|
|
4325
4343
|
width=${this.getAttribute("width")}
|
|
4326
4344
|
height=${this.getAttribute("height")}
|
|
4327
4345
|
frameborder="0"
|
|
@@ -4332,7 +4350,7 @@ CES.load();
|
|
|
4332
4350
|
${this._errorMessage&&f`<div style="color:red">
|
|
4333
4351
|
<h1>Error</h1>
|
|
4334
4352
|
${this._errorMessage}
|
|
4335
|
-
</div>`}`}getBaseCandidates(){let t=[this._resourceBaseUrl,this.baseRefUrl,this.baseItemUrl,this.getManifestBaseUrl()].filter(Boolean).map(s=>new URL(s,window.location.href).toString()),i=this.getManifestParentBaseUrl();return i&&t.push(i),[...new Set(t)]}getManifestBaseUrl(){return this._manifestUrl?new URL(".",this._manifestUrl).toString():null}getManifestParentBaseUrl(){return this._manifestUrl?new URL("..",this._manifestUrl).toString():null}async resolveResourceWithFallback(e,t,i={}){if(!e)return{url:"",baseUrl:null};if(e.startsWith("http")||e.startsWith("blob"))return{url:e,baseUrl:null};for(let s of t){let n=new URL(s,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 d=await l.text();return{url:a,baseUrl:n,text:d}}return{url:a,baseUrl:n}}}catch{}}return{url:"",baseUrl:null}}};c([u({type:String,attribute:"data"})],Te.prototype,"data",2),c([u({type:String,attribute:"data-base-item"})],Te.prototype,"baseItemUrl",2),c([u({type:String,attribute:"data-base-ref"})],Te.prototype,"baseRefUrl",2),c([u({type:String,attribute:"id"})],Te.prototype,"id",2),c([
|
|
4353
|
+
</div>`}`}getBaseCandidates(){let t=[this._resourceBaseUrl,this.baseRefUrl,this.baseItemUrl,this.getManifestBaseUrl()].filter(Boolean).map(s=>new URL(s,window.location.href).toString()),i=this.getManifestParentBaseUrl();return i&&t.push(i),[...new Set(t)]}getManifestBaseUrl(){return this._manifestUrl?new URL(".",this._manifestUrl).toString():null}getManifestParentBaseUrl(){return this._manifestUrl?new URL("..",this._manifestUrl).toString():null}async resolveResourceWithFallback(e,t,i={}){if(!e)return{url:"",baseUrl:null};if(e.startsWith("http")||e.startsWith("blob"))return{url:e,baseUrl:null};for(let s of t){let n=new URL(s,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 d=await l.text();return{url:a,baseUrl:n,text:d}}return{url:a,baseUrl:n}}}catch{}}return{url:"",baseUrl:null}}};c([u({type:String,attribute:"data"})],Te.prototype,"data",2),c([u({type:String,attribute:"data-base-item"})],Te.prototype,"baseItemUrl",2),c([u({type:String,attribute:"data-base-ref"})],Te.prototype,"baseRefUrl",2),c([u({type:String,attribute:"id"})],Te.prototype,"id",2),c([C()],Te.prototype,"_errorMessage",2);customElements.define("qti-custom-interaction",Te);var He=class extends b{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return f`<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"}}))}};c([u({type:String,attribute:"response-identifier"})],He.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],He.prototype,"disabled",2),c([u({type:String,attribute:"count-attempt"})],He.prototype,"countAttempt",2),c([u({type:String})],He.prototype,"title",2);customElements.define("qti-end-attempt-interaction",He);var en=y`
|
|
4336
4354
|
/* PK: display host as block, else design will be collapsed */
|
|
4337
4355
|
:host {
|
|
4338
4356
|
display: block;
|
|
@@ -4359,7 +4377,7 @@ CES.load();
|
|
|
4359
4377
|
?disabled="${this.disabled}"
|
|
4360
4378
|
?readonly="${this.readonly}"
|
|
4361
4379
|
.value=${this.response}
|
|
4362
|
-
></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")}};c([
|
|
4380
|
+
></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")}};c([C()],J.prototype,"_rows",2),c([u({type:Number,attribute:"expected-length"})],J.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],J.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],J.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],J.prototype,"dataPatternmaskMessage",2),c([u({type:String,attribute:"class"})],J.prototype,"classNames",2),c([M("classNames")],J.prototype,"handleclassNamesChange",1),c([C()],J.prototype,"response",2),c([M("response",{waitUntilFirstUpdate:!0})],J.prototype,"_handleResponseChange",2);customElements.define("qti-extended-text-interaction",J);var tn=y`
|
|
4363
4381
|
:host {
|
|
4364
4382
|
display: flex;
|
|
4365
4383
|
align-items: flex-start;
|
|
@@ -4396,7 +4414,7 @@ CES.load();
|
|
|
4396
4414
|
`;var ii=class extends fe(A,"qti-gap-text","qti-gap","slot[part='drags']"){static{this.styles=tn}render(){return f`<slot name="prompt"> </slot>
|
|
4397
4415
|
<slot part="drags" name="drags"></slot>
|
|
4398
4416
|
<slot part="drops"></slot>
|
|
4399
|
-
<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,d=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&d){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,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()})}getMatches(r){if(!r.correctResponse)return[];let e=Array.isArray(r.correctResponse)?r.correctResponse:[r.correctResponse],t=[];return e&&e.forEach(i=>{let s=i.split(" ");t.push({source:s[0],target:s[1]})}),t}toggleCandidateCorrection(r){let e=this.responseVariable;if(!e?.correctResponse)return;let t=this.getMatches(e);Array.from(this.querySelectorAll("qti-gap")).forEach(s=>{let n=s.getAttribute("identifier"),a=t.filter(d=>d.target===n);s.querySelectorAll("qti-gap-text").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!r)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}};customElements.define("qti-gap-match-interaction",ii);var rn=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},Tt=G(class extends ce{constructor(o){if(super(o),o.type!==$e.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,r,e){let t;e===void 0?e=r:r!==void 0&&(t=r);let i=[],s=[],n=0;for(let a of o)i[n]=t?t(a,n):n,s[n]=e(a,n),n++;return{values:s,keys:i}}render(o,r,e){return this.dt(o,r,e).values}update(o,[r,e,t]){let i=Eo(o),{values:s,keys:n}=this.dt(r,e,t);if(!Array.isArray(i))return this.ut=n,s;let a=this.ut??=[],l=[],d,p,m=0,h=i.length-1,g=0,v=s.length-1;for(;m<=h&&g<=v;)if(i[m]===null)m++;else if(i[h]===null)h--;else if(a[m]===n[g])l[g]=Pe(i[m],s[g]),m++,g++;else if(a[h]===n[v])l[v]=Pe(i[h],s[v]),h--,v--;else if(a[m]===n[v])l[v]=Pe(i[m],s[v]),bt(o,l[v+1],i[m]),m++,v--;else if(a[h]===n[g])l[g]=Pe(i[h],s[g]),bt(o,i[m],i[h]),h--,g++;else if(d===void 0&&(d=rn(n,g,v),p=rn(a,m,h)),d.has(a[m]))if(d.has(a[h])){let
|
|
4417
|
+
<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,d=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&d){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,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()})}getMatches(r){if(!r.correctResponse)return[];let e=Array.isArray(r.correctResponse)?r.correctResponse:[r.correctResponse],t=[];return e&&e.forEach(i=>{let s=i.split(" ");t.push({source:s[0],target:s[1]})}),t}toggleCandidateCorrection(r){let e=this.responseVariable;if(!e?.correctResponse)return;let t=this.getMatches(e);Array.from(this.querySelectorAll("qti-gap")).forEach(s=>{let n=s.getAttribute("identifier"),a=t.filter(d=>d.target===n);s.querySelectorAll("qti-gap-text").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!r)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}};customElements.define("qti-gap-match-interaction",ii);var rn=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},Tt=G(class extends ce{constructor(o){if(super(o),o.type!==$e.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,r,e){let t;e===void 0?e=r:r!==void 0&&(t=r);let i=[],s=[],n=0;for(let a of o)i[n]=t?t(a,n):n,s[n]=e(a,n),n++;return{values:s,keys:i}}render(o,r,e){return this.dt(o,r,e).values}update(o,[r,e,t]){let i=Eo(o),{values:s,keys:n}=this.dt(r,e,t);if(!Array.isArray(i))return this.ut=n,s;let a=this.ut??=[],l=[],d,p,m=0,h=i.length-1,g=0,v=s.length-1;for(;m<=h&&g<=v;)if(i[m]===null)m++;else if(i[h]===null)h--;else if(a[m]===n[g])l[g]=Pe(i[m],s[g]),m++,g++;else if(a[h]===n[v])l[v]=Pe(i[h],s[v]),h--,v--;else if(a[m]===n[v])l[v]=Pe(i[m],s[v]),bt(o,l[v+1],i[m]),m++,v--;else if(a[h]===n[g])l[g]=Pe(i[h],s[g]),bt(o,i[m],i[h]),h--,g++;else if(d===void 0&&(d=rn(n,g,v),p=rn(a,m,h)),d.has(a[m]))if(d.has(a[h])){let w=p.get(n[g]),E=w!==void 0?i[w]:null;if(E===null){let x=bt(o,i[m]);Pe(x,s[g]),l[g]=x}else l[g]=Pe(E,s[g]),bt(o,i[m],E),i[w]=null;g++}else Vr(i[h]),h--;else Vr(i[m]),m++;for(;g<=v;){let w=bt(o,l[v+1]);Pe(w,s[g]),l[g++]=w}for(;m<=h;){let w=i[m++];w!==null&&Vr(w)}return this.ut=n,wo(o,l),D}});function ze(o,r,e,t){let i=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,s=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(o){case"circle":{if(r.length!==3){console.error("Invalid circle coordinates:",r);return}let[n,a,l]=r,d=n/i*100,p=a/s*100,m=l/i*100,h=l/s*100;t.style.left=d-m+"%",t.style.top=p-h+"%",t.style.width=2*m+"%",t.style.height=2*h+"%",t.style.borderRadius="50%"}break;case"rect":{if(r.length!==4){console.error("Invalid rectangle coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,h=l/i*100,g=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=h-p+"%",t.style.height=g-m+"%"}break;case"ellipse":{if(r.length!==4){console.error("Invalid ellipse coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,h=l/i*100,g=d/s*100;t.style.left=p-h+"%",t.style.top=m-g+"%",t.style.width=2*h+"%",t.style.height=2*g+"%",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 x=0;x<r.length;x+=2)n.push({x:r[x],y:r[x+1]});let a=Math.min(...n.map(x=>x.x)),l=Math.max(...n.map(x=>x.x)),d=Math.min(...n.map(x=>x.y)),p=Math.max(...n.map(x=>x.y)),m=a/i*100,h=d/s*100,g=l/i*100,v=p/s*100;t.style.left=m+"%",t.style.top=h+"%",t.style.width=g-m+"%",t.style.height=v-h+"%";let E=n.map(x=>({x:(x.x-a)/(l-a)*100,y:(x.y-d)/(p-d)*100})).map(x=>`${x.x}% ${x.y}%`).join(",");t.style.clipPath=`polygon(${E})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var sn=y`
|
|
4400
4418
|
slot:not([name='prompt']) {
|
|
4401
4419
|
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4402
4420
|
display: block;
|
|
@@ -4463,7 +4481,7 @@ CES.load();
|
|
|
4463
4481
|
</svg>
|
|
4464
4482
|
<slot></slot>
|
|
4465
4483
|
</line-container>
|
|
4466
|
-
<div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));ze(n,a,t,i)}firstUpdated(){this.hotspots=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.hotspots.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.startPoint?this.endPoint||(this.endPoint=t.target,this._response=this.getResponseArray(),this._response=[...this._response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};c([
|
|
4484
|
+
<div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));ze(n,a,t,i)}firstUpdated(){this.hotspots=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.hotspots.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.startPoint?this.endPoint||(this.endPoint=t.target,this._response=this.getResponseArray(),this._response=[...this._response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};c([C()],Se.prototype,"_correctLines",2),c([C()],Se.prototype,"startCoord",2),c([C()],Se.prototype,"mouseCoord",2),c([no({selector:"img"})],Se.prototype,"grImage",2),c([C()],Se.prototype,"_response",2);customElements.define("qti-graphic-associate-interaction",Se);var on=y`
|
|
4467
4485
|
:host {
|
|
4468
4486
|
display: flex;
|
|
4469
4487
|
align-items: flex-start;
|
|
@@ -4553,7 +4571,7 @@ CES.load();
|
|
|
4553
4571
|
<slot name="prompt"></slot>
|
|
4554
4572
|
<slot></slot>
|
|
4555
4573
|
`}getImageLoadPromise(e){return this.imageLoadPromise||(e.naturalWidth>0&&e.naturalHeight>0?this.imageLoadPromise=Promise.resolve(e):this.imageLoadPromise=new Promise(t=>{let i=()=>{e.removeEventListener("load",i),t(e)};e.addEventListener("load",i)})),this.imageLoadPromise}async positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(d=>parseInt(d)),l=await this.getImageLoadPromise(t);ze(n,a,l,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};customElements.define("qti-hotspot-interaction",ni);var cr=class extends Ne(A,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>f`<slot></slot>
|
|
4556
|
-
<div part="message" role="alert" id="validation-message"></div>`}get classObject(){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.updateHostClasses()}updated(e){super.updated(e),this.updateHostClasses()}updateHostClasses(){let e=Object.keys(this.classObject).join(" ");this.className=e}};c([u({type:String,reflect:!0})],cr.prototype,"class",2);customElements.define("qti-hottext-interaction",cr);var dr=class extends ce{constructor(r){if(super(r),this.it=k,r.type!==$e.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===k||r==null)return this._t=void 0,this.it=r;if(r===
|
|
4574
|
+
<div part="message" role="alert" id="validation-message"></div>`}get classObject(){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.updateHostClasses()}updated(e){super.updated(e),this.updateHostClasses()}updateHostClasses(){let e=Object.keys(this.classObject).join(" ");this.className=e}};c([u({type:String,reflect:!0})],cr.prototype,"class",2);customElements.define("qti-hottext-interaction",cr);var dr=class extends ce{constructor(r){if(super(r),this.it=k,r.type!==$e.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===k||r==null)return this._t=void 0,this.it=r;if(r===D)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:[]}}};dr.directiveName="unsafeHTML",dr.resultType=1;var Ue=G(dr);var K=class K extends A{constructor(){super(...arguments);this.options=[];this.correctOption="";this._dropdownOpen=!1;this.dataPrompt="";this._onNativeChange=e=>{if(this.readonly)return;let t=e.target.value;this._selectValue(t)};this._onToggleCustomDropdown=()=>{this.disabled||this.readonly||this._setDropdownOpen(!this._dropdownOpen)};this._onCustomTriggerKeyDown=e=>{this.disabled||this.readonly||(e.key==="ArrowDown"||e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._setDropdownOpen(!0))};this._onCustomMenuKeyDown=e=>{if(!this._dropdownOpen)return;if(e.key==="Escape"){e.preventDefault(),this._setDropdownOpen(!1),this._focusTrigger();return}let t=Array.from(this.renderRoot.querySelectorAll('button[part="option"]')),i=this.renderRoot.activeElement,s=t.findIndex(n=>n===i);e.key==="ArrowDown"&&(e.preventDefault(),t[Math.min(t.length-1,Math.max(0,s+1))]?.focus()),e.key==="ArrowUp"&&(e.preventDefault(),t[Math.max(0,s-1)]?.focus())};this._onDocumentPointerDown=e=>{if(!this._dropdownOpen)return;let t=e.composedPath?.();t&&t.includes(this)||this._setDropdownOpen(!1)};this._onDocumentKeyDown=e=>{this._dropdownOpen&&e.key==="Escape"&&(e.preventDefault(),this._setDropdownOpen(!1),this._focusTrigger())}}get isInline(){return!0}static{this._supportsCustomizableSelectCache=null}static get styles(){return[y`
|
|
4557
4575
|
:host {
|
|
4558
4576
|
display: inline-block;
|
|
4559
4577
|
vertical-align: baseline;
|
|
@@ -4800,7 +4818,7 @@ CES.load();
|
|
|
4800
4818
|
`:null}
|
|
4801
4819
|
`}
|
|
4802
4820
|
${Ue(this.correctOption)}
|
|
4803
|
-
`}connectedCallback(){super.connectedCallback(),this._updateOptions(),this._supportsCustomizableSelect()||(document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),document.addEventListener("keydown",this._onDocumentKeyDown,!0))}disconnectedCallback(){super.disconnectedCallback(),this._supportsCustomizableSelect()||(document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown,!0))}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_selectedOption(){return this.options.find(e=>e.selected)??this.options[0]}_supportsCustomizableSelect(){if(K._supportsCustomizableSelectCache!==null)return K._supportsCustomizableSelectCache;if(typeof CSS>"u"||typeof CSS.supports!="function")return K._supportsCustomizableSelectCache=!1,!1;let e=CSS.supports("selector(::picker(select))")||CSS.supports("selector(select::picker(select))"),t=CSS.supports("appearance: base-select")||CSS.supports("-webkit-appearance: base-select");if(!e||!t)return K._supportsCustomizableSelectCache=!1,!1;try{let i=document.createElement("div");i.style.position="absolute",i.style.top="-9999px",i.style.left="-9999px";let s=document.createElement("select");s.style.appearance="base-select",s.style.webkitAppearance="base-select";let n=document.createElement("button");n.type="button";let a=document.createElement("selectedcontent");a.textContent="probe",n.appendChild(a);let l=document.createElement("option");l.value="probe",l.textContent="probe",s.appendChild(n),s.appendChild(l),i.appendChild(s),(document.body||document.documentElement).appendChild(i);let d=n.getBoundingClientRect();i.remove();let p=d.width>0&&d.height>0;return K._supportsCustomizableSelectCache=p,p}catch{return K._supportsCustomizableSelectCache=!1,!1}}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select",i=this.options.find(a=>a.selected)?.value??"",s=[{textContent:t,value:"",selected:i===""},...e.map(a=>{let l=a.getAttribute("identifier")??"";return{textContent:a.innerHTML,value:l,selected:l!==""&&l===i}})],n=s.some(a=>a.selected);this.options=n?s:s.map((a,l)=>({...a,selected:l===0}))}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this._setDropdownOpen(!1),this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){let t=e??"";this.options=this.options.map(i=>({...i,selected:i.value===t}))}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(s=>t===s.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>`}_selectValue(e){this.options=this.options.map(t=>({...t,selected:t.value===e})),this.saveResponse(e),this._setDropdownOpen(!1)}_setDropdownOpen(e){this._dropdownOpen!==e&&(this._dropdownOpen=e,e&&this.updateComplete.then(()=>{this._positionCustomMenu(),this.renderRoot.querySelector('button[part="option"][aria-selected="true"]')?.focus()}))}_focusTrigger(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}_positionCustomMenu(){if(!this._dropdownOpen)return;let e=this.renderRoot.querySelector('[part="menu"]'),t=this.renderRoot.querySelector('button[part="trigger"]');if(!e||!t)return;e.dataset.placement="bottom",e.style.setProperty("--qti-menu-shift-x","0px"),e.style.setProperty("--qti-menu-shift-y","0px");let i=document.documentElement?.clientWidth||window.innerWidth,s=document.documentElement?.clientHeight||window.innerHeight,n=8,a=t.getBoundingClientRect(),l=e.getBoundingClientRect(),d=s-a.bottom,p=a.top;l.bottom>s-n&&p>d&&(e.dataset.placement="top",l=e.getBoundingClientRect());let m=0;if(l.right>i-n?m=i-n-l.right:l.left<n&&(m=n-l.left),m!==0){let h=e.offsetWidth>0?l.width/e.offsetWidth:1,g=Number.isFinite(h)&&h!==0?m/h:m;e.style.setProperty("--qti-menu-shift-x",`${g}px`)}}};c([
|
|
4821
|
+
`}connectedCallback(){super.connectedCallback(),this._updateOptions(),this._supportsCustomizableSelect()||(document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),document.addEventListener("keydown",this._onDocumentKeyDown,!0))}disconnectedCallback(){super.disconnectedCallback(),this._supportsCustomizableSelect()||(document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown,!0))}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_selectedOption(){return this.options.find(e=>e.selected)??this.options[0]}_supportsCustomizableSelect(){if(K._supportsCustomizableSelectCache!==null)return K._supportsCustomizableSelectCache;if(typeof CSS>"u"||typeof CSS.supports!="function")return K._supportsCustomizableSelectCache=!1,!1;let e=CSS.supports("selector(::picker(select))")||CSS.supports("selector(select::picker(select))"),t=CSS.supports("appearance: base-select")||CSS.supports("-webkit-appearance: base-select");if(!e||!t)return K._supportsCustomizableSelectCache=!1,!1;try{let i=document.createElement("div");i.style.position="absolute",i.style.top="-9999px",i.style.left="-9999px";let s=document.createElement("select");s.style.appearance="base-select",s.style.webkitAppearance="base-select";let n=document.createElement("button");n.type="button";let a=document.createElement("selectedcontent");a.textContent="probe",n.appendChild(a);let l=document.createElement("option");l.value="probe",l.textContent="probe",s.appendChild(n),s.appendChild(l),i.appendChild(s),(document.body||document.documentElement).appendChild(i);let d=n.getBoundingClientRect();i.remove();let p=d.width>0&&d.height>0;return K._supportsCustomizableSelectCache=p,p}catch{return K._supportsCustomizableSelectCache=!1,!1}}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select",i=this.options.find(a=>a.selected)?.value??"",s=[{textContent:t,value:"",selected:i===""},...e.map(a=>{let l=a.getAttribute("identifier")??"";return{textContent:a.innerHTML,value:l,selected:l!==""&&l===i}})],n=s.some(a=>a.selected);this.options=n?s:s.map((a,l)=>({...a,selected:l===0}))}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this._setDropdownOpen(!1),this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){let t=e??"";this.options=this.options.map(i=>({...i,selected:i.value===t}))}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(s=>t===s.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>`}_selectValue(e){this.options=this.options.map(t=>({...t,selected:t.value===e})),this.saveResponse(e),this._setDropdownOpen(!1)}_setDropdownOpen(e){this._dropdownOpen!==e&&(this._dropdownOpen=e,e&&this.updateComplete.then(()=>{this._positionCustomMenu(),this.renderRoot.querySelector('button[part="option"][aria-selected="true"]')?.focus()}))}_focusTrigger(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}_positionCustomMenu(){if(!this._dropdownOpen)return;let e=this.renderRoot.querySelector('[part="menu"]'),t=this.renderRoot.querySelector('button[part="trigger"]');if(!e||!t)return;e.dataset.placement="bottom",e.style.setProperty("--qti-menu-shift-x","0px"),e.style.setProperty("--qti-menu-shift-y","0px");let i=document.documentElement?.clientWidth||window.innerWidth,s=document.documentElement?.clientHeight||window.innerHeight,n=8,a=t.getBoundingClientRect(),l=e.getBoundingClientRect(),d=s-a.bottom,p=a.top;l.bottom>s-n&&p>d&&(e.dataset.placement="top",l=e.getBoundingClientRect());let m=0;if(l.right>i-n?m=i-n-l.right:l.left<n&&(m=n-l.left),m!==0){let h=e.offsetWidth>0?l.width/e.offsetWidth:1,g=Number.isFinite(h)&&h!==0?m/h:m;e.style.setProperty("--qti-menu-shift-x",`${g}px`)}}};c([C()],K.prototype,"options",2),c([C()],K.prototype,"correctOption",2),c([C()],K.prototype,"_dropdownOpen",2),c([u({attribute:"data-prompt",type:String})],K.prototype,"dataPrompt",2),c([T({context:Z,subscribe:!0}),u({attribute:!1})],K.prototype,"configContext",2);var ai=K;customElements.define("qti-inline-choice-interaction",ai);var ln=y`
|
|
4804
4822
|
slot:not([hidden]) {
|
|
4805
4823
|
/* slot where the */
|
|
4806
4824
|
display: flex;
|
|
@@ -4839,7 +4857,7 @@ CES.load();
|
|
|
4839
4857
|
|
|
4840
4858
|
${this.sourceChoices.map(i=>f`<tr part="row">
|
|
4841
4859
|
<td part="c-header">${Ue(i.innerHTML)}</td>
|
|
4842
|
-
${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),l=`${n} ${a}`,d=(this.response||[]).filter(
|
|
4860
|
+
${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),l=`${n} ${a}`,d=(this.response||[]).filter(w=>w.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,m=i.matchMax===1?"radio":"checkbox",h=!!this.correctOptions?.find(w=>w.source===n&&w.target===a),g=m==="radio"?`rb ${p?"rb-checked":""} ${t?h?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?h?"cb-correct":"cb-incorrect":""}`,v=this.correctOptions?.length>0?!0:i.matchMax===1?!1:i.matchMax!==0&&d>=i.matchMax&&!p;return f`<td part="input-cell">
|
|
4843
4861
|
<div
|
|
4844
4862
|
class="input-container"
|
|
4845
4863
|
style="position: relative; width: 24px; height: 24px; margin: 0 auto;"
|
|
@@ -4850,8 +4868,8 @@ CES.load();
|
|
|
4850
4868
|
name=${n}
|
|
4851
4869
|
value=${l}
|
|
4852
4870
|
.disabled=${v}
|
|
4853
|
-
@change=${
|
|
4854
|
-
@click=${
|
|
4871
|
+
@change=${w=>this.handleRadioChange(w)}
|
|
4872
|
+
@click=${w=>i.matchMax===1?this.handleRadioClick(w):null}
|
|
4855
4873
|
/>
|
|
4856
4874
|
${m==="checkbox"&&p?f`
|
|
4857
4875
|
<svg
|
|
@@ -4869,7 +4887,7 @@ CES.load();
|
|
|
4869
4887
|
`:k}
|
|
4870
4888
|
|
|
4871
4889
|
<div role="alert" part="message" id="validation-message"></div>
|
|
4872
|
-
`}};c([u({type:String})],Be.prototype,"class",2),c([
|
|
4890
|
+
`}};c([u({type:String})],Be.prototype,"class",2),c([C()],Be.prototype,"_response",2),c([u({type:String,attribute:"response-identifier"})],Be.prototype,"responseIdentifier",2),c([C()],Be.prototype,"correctOptions",2);customElements.define("qti-match-interaction",Be);var li=class extends A{constructor(){super();this._value=null}reset(){this._value=null}validate(){return!0}get response(){return this._value?this._value.toString():null}set response(e){if(e)if(!isNaN(parseInt(e?.toString())))this._value=parseInt(e.toString());else throw new Error(`Value must be a number ${e}`)}static get properties(){return{...A.properties,step:{type:Number,attribute:"step",default:10}}}static{this.styles=[y``]}render(){return f` <slot name="prompt"></slot>
|
|
4873
4891
|
<slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};customElements.define("qti-media-interaction",li);var cn=y`
|
|
4874
4892
|
[part='drags'] {
|
|
4875
4893
|
display: flex;
|
|
@@ -4934,7 +4952,7 @@ CES.load();
|
|
|
4934
4952
|
<div part="drops">
|
|
4935
4953
|
${[...Array(this.nrChoices)].map((t,i)=>f`<drop-list role="region" part="drop-list" identifier="droplist${i}"></drop-list>`)}
|
|
4936
4954
|
</div>
|
|
4937
|
-
</div>`}toggleCorrectResponse(e){let t=this.responseVariable;if(this.shadowRoot.querySelectorAll(".correct-option").forEach(i=>i.remove()),e&&t?.correctResponse){let s=(Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse]).map(l=>l.split(" ")[0]),n=new Set;this.querySelectorAll("qti-simple-choice").forEach((l,d)=>{let p=l.getAttribute("identifier");if(!p||!s.includes(p)||n.has(p))return;n.add(p);let m=l.textContent?.trim();if(!m)return;let h=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!h)return;let g=document.createElement("span");g.classList.add("correct-option"),g.textContent=m,g.style.border="1px solid var(--qti-correct)",g.style.borderRadius="4px",g.style.padding="2px 4px",g.style.display="inline-block",g.style.marginTop="4px",h.insertAdjacentElement("afterend",g)})}}getValue(e){return e?.map((t,i)=>`${t} droplist${i}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let s=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(){super.firstUpdated(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};c([
|
|
4955
|
+
</div>`}toggleCorrectResponse(e){let t=this.responseVariable;if(this.shadowRoot.querySelectorAll(".correct-option").forEach(i=>i.remove()),e&&t?.correctResponse){let s=(Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse]).map(l=>l.split(" ")[0]),n=new Set;this.querySelectorAll("qti-simple-choice").forEach((l,d)=>{let p=l.getAttribute("identifier");if(!p||!s.includes(p)||n.has(p))return;n.add(p);let m=l.textContent?.trim();if(!m)return;let h=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!h)return;let g=document.createElement("span");g.classList.add("correct-option"),g.textContent=m,g.style.border="1px solid var(--qti-correct)",g.style.borderRadius="4px",g.style.padding="2px 4px",g.style.display="inline-block",g.style.marginTop="4px",h.insertAdjacentElement("afterend",g)})}}getValue(e){return e?.map((t,i)=>`${t} droplist${i}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let s=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(){super.firstUpdated(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};c([C()],Fe.prototype,"nrChoices",2),c([C()],Fe.prototype,"correctResponses",2),c([C()],Fe.prototype,"showCorrectResponses",2),c([u({type:String})],Fe.prototype,"orientation",2);customElements.define("qti-order-interaction",Fe);var dn=y`
|
|
4938
4956
|
::slotted(qti-interaction-markup) {
|
|
4939
4957
|
display: none;
|
|
4940
4958
|
}
|
|
@@ -5668,7 +5686,7 @@ CES.load();
|
|
|
5668
5686
|
<h1>Error</h1>
|
|
5669
5687
|
${this._errorMessage}
|
|
5670
5688
|
</div>`:""}
|
|
5671
|
-
`}};c([u({type:String,attribute:"module"})],U.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],U.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],U.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],U.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],U.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],U.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],U.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],U.prototype,"useDefaultPaths",2),c([
|
|
5689
|
+
`}};c([u({type:String,attribute:"module"})],U.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],U.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],U.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],U.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],U.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],U.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],U.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],U.prototype,"useDefaultPaths",2),c([C()],U.prototype,"_errorMessage",2),c([T({context:P,subscribe:!0}),C()],U.prototype,"context",2),c([C()],U.prototype,"response",2);var ci=class extends U{constructor(){super(...arguments);this._recreatingIframe=!1}async getIFrameContent(){return new Promise(e=>{let t=`get-content-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="getContentResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.content))};window.addEventListener("message",i),this.sendMessageToIframe("getContent",{messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e("")},5e3)})}setTestContext(e){this.context=e,this.updateComplete.then(()=>{this.value=e?.variables?.find(t=>t.identifier===this.responseIdentifier).value})}async recreateIframe(){this._recreatingIframe=!0;try{return this.iframe&&(this._iframeLoaded=!1,this.iframe.remove()),this._pendingMessages=[],this.createIframe(),new Promise(e=>{let t=()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",t),e()};this.addEventListener("qti-portable-custom-interaction-loaded",t),setTimeout(()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",t),e()},5e3)})}finally{this._recreatingIframe=!1}}disconnectedCallback(){this._recreatingIframe||super.disconnectedCallback()}async iFrameMouseClick(e,t){return new Promise(i=>{let s=`click-${Date.now()}`,n=a=>{let{data:l}=a;l?.source==="qti-pci-iframe"&&(!l?.responseIdentifier||l?.responseIdentifier===this.responseIdentifier)&&l?.method==="clickResponse"&&l?.messageId===s&&(window.removeEventListener("message",n),i())};window.addEventListener("message",n),this.sendMessageToIframe("simulateClick",{x:e,y:t,messageId:s}),setTimeout(()=>{window.removeEventListener("message",n),i()},5e3)})}async iFrameClickOnElement(e){return new Promise(t=>{let i=`click-selector-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="clickSelectorResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t(a.success))};window.addEventListener("message",s),this.sendMessageToIframe("clickOnSelector",{selector:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t(!1)},5e3)})}async iFrameClickOnElementByText(e){return new Promise(t=>{let i=`click-text-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="clickTextResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t(a.success))};window.addEventListener("message",s),this.sendMessageToIframe("clickOnElementByText",{text:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t(!1)},5e3)})}async iFrameSetValueElement(e,t){return new Promise(i=>{let s=`set-value-${Date.now()}`,n=a=>{let{data:l}=a;l?.source==="qti-pci-iframe"&&(!l?.responseIdentifier||l?.responseIdentifier===this.responseIdentifier)&&l?.method==="setValueResponse"&&l?.messageId===s&&(window.removeEventListener("message",n),i(l.success))};window.addEventListener("message",n),this.sendMessageToIframe("setValueElement",{selector:e,value:t,messageId:s}),setTimeout(()=>{window.removeEventListener("message",n),i(!1)},5e3)})}async iFrameSetValueElementByText(e,t){return new Promise(i=>{let s=`set-value-text-${Date.now()}`,n=a=>{let{data:l}=a;l?.source==="qti-pci-iframe"&&(!l?.responseIdentifier||l?.responseIdentifier===this.responseIdentifier)&&l?.method==="setValueByTextResponse"&&l?.messageId===s&&(window.removeEventListener("message",n),i(l.success))};window.addEventListener("message",n),this.sendMessageToIframe("setValueElementByText",{text:e,value:t,messageId:s}),setTimeout(()=>{window.removeEventListener("message",n),i(!1)},5e3)})}async iFrameMousedownOnElement(e){return new Promise(t=>{let i=`mousedown-selector-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="mousedownSelectorResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t(a.success))};window.addEventListener("message",s),this.sendMessageToIframe("mousedownOnSelector",{selector:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t(!1)},5e3)})}generateIframeContent(){let e=super.generateIframeContent(),t=`
|
|
5672
5690
|
// Test helper functions for QtiPortableCustomInteractionTest
|
|
5673
5691
|
// Base iframe implementation already provides PCIManager.getContent
|
|
5674
5692
|
|
|
@@ -5877,7 +5895,7 @@ CES.load();
|
|
|
5877
5895
|
display: inline-block;
|
|
5878
5896
|
position: relative;
|
|
5879
5897
|
}
|
|
5880
|
-
`]}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",di);customElements.define("qti-position-object-stage",pi);var pn="important",ca=" !"+pn,ss=G(class extends ce{constructor(o){if(super(o),o.type!==$e.ATTRIBUTE||o.name!=="style"||o.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(o){return Object.keys(o).reduce(((r,e)=>{let t=o[e];return t==null?r:r+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(o,[r]){let{style:e}=o.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 s=typeof i=="string"&&i.endsWith(ca);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?pn:""):e[t]=i}}return
|
|
5898
|
+
`]}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",di);customElements.define("qti-position-object-stage",pi);var pn="important",ca=" !"+pn,ss=G(class extends ce{constructor(o){if(super(o),o.type!==$e.ATTRIBUTE||o.name!=="style"||o.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(o){return Object.keys(o).reduce(((r,e)=>{let t=o[e];return t==null?r:r+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(o,[r]){let{style:e}=o.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 s=typeof i=="string"&&i.endsWith(ca);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?pn:""):e[t]=i}}return D}});var Ae=class extends A{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOriginal=0;this._imageHeightOriginal=0;this._onImageClick=e=>{if(this.disabled)return;if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),i=(e.clientX-t.left)*this._scaleX,s=(e.clientY-t.top)*this._scaleY,n=`${i.toFixed()} ${s.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._onResize=()=>{this.calculateScale()}}static{this.styles=[y`
|
|
5881
5899
|
:host {
|
|
5882
5900
|
display: block;
|
|
5883
5901
|
}
|
|
@@ -5910,7 +5928,7 @@ CES.load();
|
|
|
5910
5928
|
data-shape="${e.shape}"
|
|
5911
5929
|
></div>`)}
|
|
5912
5930
|
<slot></slot>
|
|
5913
|
-
</point-container>`}validate(){return this.response!==null&&this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}calculateScale(){this._imageWidthOriginal=this._imgElement.getAttribute("width")?parseFloat(this._imgElement.getAttribute("width")):this._imgElement.naturalWidth,this._imageHeightOriginal=this._imgElement.getAttribute("height")?parseFloat(this._imgElement.getAttribute("height")):this._imgElement.naturalHeight;let e=this._imgElement.getBoundingClientRect();this._scaleX=e.width===0?1:this._imageWidthOriginal/e.width,this._scaleY=e.height===0?1:this._imageHeightOriginal/e.height}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?(this.calculateScale(),this._imgElement.addEventListener("click",this._onImageClick)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onResize),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};c([u({type:Number,attribute:"max-choices"})],Ae.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],Ae.prototype,"minChoices",2),c([
|
|
5931
|
+
</point-container>`}validate(){return this.response!==null&&this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}calculateScale(){this._imageWidthOriginal=this._imgElement.getAttribute("width")?parseFloat(this._imgElement.getAttribute("width")):this._imgElement.naturalWidth,this._imageHeightOriginal=this._imgElement.getAttribute("height")?parseFloat(this._imgElement.getAttribute("height")):this._imgElement.naturalHeight;let e=this._imgElement.getBoundingClientRect();this._scaleX=e.width===0?1:this._imageWidthOriginal/e.width,this._scaleY=e.height===0?1:this._imageHeightOriginal/e.height}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?(this.calculateScale(),this._imgElement.addEventListener("click",this._onImageClick)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onResize),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};c([u({type:Number,attribute:"max-choices"})],Ae.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],Ae.prototype,"minChoices",2),c([C()],Ae.prototype,"response",2),c([C()],Ae.prototype,"_correctAreas",2),c([C()],Ae.prototype,"_responseCorrection",2);customElements.define("qti-select-point-interaction",Ae);var un=y`
|
|
5914
5932
|
:host {
|
|
5915
5933
|
display: block;
|
|
5916
5934
|
--show-bounds: true;
|
|
@@ -6139,7 +6157,7 @@ CES.load();
|
|
|
6139
6157
|
?readonly="${this.readonly}"
|
|
6140
6158
|
/>
|
|
6141
6159
|
${this._correctResponse?f`<div part="correct">${this._correctResponse}</div>`:k}
|
|
6142
|
-
`}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))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};c([u({type:Number,attribute:"expected-length"})],oe.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],oe.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],oe.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],oe.prototype,"dataPatternmaskMessage",2),c([
|
|
6160
|
+
`}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))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};c([u({type:Number,attribute:"expected-length"})],oe.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],oe.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],oe.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],oe.prototype,"dataPatternmaskMessage",2),c([C()],oe.prototype,"response",2),c([ct("input")],oe.prototype,"_input",2),c([M("response",{waitUntilFirstUpdate:!0})],oe.prototype,"_handleValueChange",2);customElements.define("qti-text-entry-interaction",oe);var ui=class extends A{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get response(){return this._base64}set response(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...A.properties}}static{this.styles=[y`
|
|
6143
6161
|
:host {
|
|
6144
6162
|
display: block;
|
|
6145
6163
|
margin: 1em 0;
|
|
@@ -6227,7 +6245,7 @@ CES.load();
|
|
|
6227
6245
|
<div part="cha"></div>
|
|
6228
6246
|
</div>
|
|
6229
6247
|
${this.marker?f`<div id="label">${this.marker}</div>`:k}
|
|
6230
|
-
<slot part="slot"></slot>`}};c([u({type:String,attribute:"template-identifier"})],We.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],We.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],We.prototype,"fixed",2),c([u({type:String,attribute:!1})],We.prototype,"marker",2);customElements.define("qti-simple-choice",We);var LE=async o=>{let r=o.substring(0,o.lastIndexOf("/")),e=await go().load(`${o}`).then(a=>a.assessmentTest()),t=await ht().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await ht().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}},$E=async o=>ae().load(o).then(r=>r.htmlDoc().firstElementChild);var be=class extends b{render(){return f`<slot></slot>`}process(){throw new Error("Not implemented")}};be=c([q("qti-rule")],be);var fr=class extends be{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:Ft(t)}})),t)}};c([u({type:String})],fr.prototype,"identifier",2),c([_({context:P,subscribe:!0}),w()],fr.prototype,"context",2);customElements.define("qti-lookup-outcome-value",fr);var ls=class extends be{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",ls);var cs=class extends be{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 ds(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.formatValue(i)}}))}formatValue(r){return Array.isArray(r)?r.map(Ft):r!==null?Ft(r):null}},ds=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",cs);var gr=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",gr);var br=class extends gr{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",br);var ps=class extends br{render(){return f`${super.render()}`}};customElements.define("qti-response-else-if",ps);var gi=class extends da(ee){calculate(){return this.calculateChildren(Array.from(this.children))}};gi=c([q("qti-and")],gi);function da(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 bi=class extends E{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],bi.prototype,"baseType",2);customElements.define("qti-base-value",bi);var us=class extends E{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",us);var ms=class extends ee{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",ms);var hs=class extends E{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",hs);var At=class extends E{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})],At.prototype,"identifier",2),c([_({context:P,subscribe:!0}),w()],At.prototype,"context",2),c([w(),_({context:le,subscribe:!0})],At.prototype,"_testContext",2);customElements.define("qti-default",At);var vi=class extends E{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})],vi.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",vi);var fs=class extends E{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",fs);var vr=class extends E{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._roundToDecimalPlaces(i,this.figures):this._roundToSignificantFigures(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}_roundToDecimalPlaces(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}_roundToSignificantFigures(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"})],vr.prototype,"roundingMode",2),c([u({type:Number})],vr.prototype,"figures",2);customElements.define("qti-round-to",vr);var yi=class extends E{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):z.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],yi.prototype,"toleranceMode",2);customElements.define("qti-equal",yi);var gs=class extends E{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._calculateGcd(e)}_calculateGcd(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._gcdTwoNumbers(e,Math.abs(r[t])),e!==1);t++);return e}_gcdTwoNumbers(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",gs);var bs=class extends E{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",bs);var vs=class extends ee{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",vs);var ys=class extends E{getResult(){return null}};customElements.define("qti-null",ys);var xs=class extends E{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",xs);var qs=class extends E{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",qs);var Cs=class extends E{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",Cs);var ws=class extends ee{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",ws);var xi=class extends E{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?z.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):z.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})],xi.prototype,"identifier",2);customElements.define("qti-map-response",xi);var qi=class extends E{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;z.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})],qi.prototype,"identifier",2);customElements.define("qti-map-response-point",qi);var Ci=class extends E{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._performOperation(this.name,t)}_performOperation(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})],Ci.prototype,"name",2);customElements.define("qti-math-operator",Ci);var Es=class o extends E{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):z.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(!z.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(z.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",Es);var _s=class extends E{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",_s);var Ts=class extends E{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",Ts);var Ss=class extends E{render(){return f`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Ss);var As=class extends ee{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",As);var Rs=class extends E{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",Rs);var ks=class extends E{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",ks);var yr=class extends b{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?k:f`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],yr.prototype,"identifier",2),c([_({context:P,subscribe:!0}),w()],yr.prototype,"context",2);customElements.define("qti-printed-variable",yr);var Ms=class extends E{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",Ms);var wi=class extends pa(E){getResult(){return this.calculateChildren(Array.from(this.children))}};function pa(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",wi);var Ei=class extends E{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 z.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],Ei.prototype,"caseSensitive",2);customElements.define("qti-string-match",Ei);var Is=class extends E{constructor(){super(),this._expression=new Ls(Array.from(this.children))}getResult(){return this._expression.calculate()}},Ls=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",Is);var $s=class extends E{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",$s);var Rt=class extends E{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})],Rt.prototype,"min",2),c([u({type:Number})],Rt.prototype,"max",2),c([u({type:Number})],Rt.prototype,"step",2);customElements.define("qti-random-integer",Rt);var Ps=class extends E{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",Ps);var Os=class extends E{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",Os);var xr=class extends E{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 r=this.getVariables()[0];if(!r)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let t=this.lookupVariableValue(this.n);if(t===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(t)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(r.cardinality==="ordered"){let t=Array.isArray(r.value)?r.value:[r.value];return r.value===null||e>t.length?null:t[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}lookupVariableValue(r){let e=this.context.variables.find(t=>t.identifier===r)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};c([u({type:String})],xr.prototype,"n",2),xr=c([q("qti-index")],xr);export{To as Correctness,Bi as INITIAL_SESSION_CONTEXT,Fi as INITIAL_TEST_CONTEXT,A as Interaction,Wi as IsNullOrUndefined,_e as ItemContainer,ot as ItemCorrectResponseMode,Et as ItemPrintVariables,ie as ItemShowCandidateCorrection,se as ItemShowCorrectResponse,gi as QtiAnd,Y as QtiAssessmentItem,xe as QtiAssessmentItemRef,qe as QtiAssessmentSection,yt as QtiAssessmentStimulusRef,Qi as QtiAssessmentStimulusRefConnectedEvent,et as QtiAssessmentTest,mi as QtiAssociableHotspot,ar as QtiAssociateInteraction,bi as QtiBaseValue,lr as QtiChoiceInteraction,Ur as QtiCompanionMaterialsInfo,ee as QtiConditionExpression,us as QtiContainerSize,ms as QtiContains,Br as QtiContentBody,hs as QtiCorrect,Te as QtiCustomInteraction,jt as QtiCustomOperator,At as QtiDefault,Os as QtiDelete,He as QtiEndAttemptInteraction,yi as QtiEqual,vi as QtiEqualRounded,E as QtiExpression,J as QtiExtendedTextInteraction,Q as QtiFeedback,Wt as QtiFeedbackBlock,Xt as QtiFeedbackInline,qs as QtiFieldValue,pr as QtiGap,ur as QtiGapImg,ii as QtiGapMatchInteraction,mr as QtiGapText,gs as QtiGcd,Se as QtiGraphicAssociateInteraction,si as QtiGraphicGapMatchInteraction,oi as QtiGraphicOrderInteraction,bs as QtiGt,vs as QtiGte,St as QtiHotspotChoice,ni as QtiHotspotInteraction,hi as QtiHottext,cr as QtiHottextInteraction,xr as QtiIndex,hr as QtiInlineChoice,ai as QtiInlineChoiceInteraction,xs as QtiIsNull,_t as QtiItem,Gt as QtiItemBody,fr as QtiLookupOutcomeValue,Cs as QtiLt,ws as QtiLte,xi as QtiMapResponse,qi as QtiMapResponsePoint,Es as QtiMatch,Be as QtiMatchInteraction,Ci as QtiMathOperator,li as QtiMediaInteraction,_s as QtiMember,tt as QtiModalFeedback,Ts as QtiMultiple,Ss as QtiNot,ys as QtiNull,As as QtiOr,Fe as QtiOrderInteraction,Rs as QtiOrdered,ue as QtiOutcomeDeclaration,U as QtiPortableCustomInteraction,di as QtiPositionObjectInteraction,pi as QtiPositionObjectStage,ks as QtiPower,yr as QtiPrintedVariable,Ms as QtiProduct,fi as QtiPrompt,Ps as QtiRandom,Rt as QtiRandomInteger,ls as QtiResponseCondition,we as QtiResponseDeclaration,gr as QtiResponseElse,ps as QtiResponseElseIf,br as QtiResponseIf,Qt as QtiResponseProcessing,fs as QtiRound,vr as QtiRoundTo,pe as QtiRubricBlock,So as QtiRuleElement,Ae as QtiSelectPointInteraction,cs as QtiSetOutcomeValue,ds as QtiSetOutcomeValueRule,nt as QtiSimpleAssociableChoice,We as QtiSimpleChoice,je as QtiSliderInteraction,Ei as QtiStringMatch,Fr as QtiStylesheet,wi as QtiSubtract,Is as QtiSum,Ls as QtiSumExpression,zr as QtiTest,Yt as QtiTestFeedback,Ce as QtiTestPart,oe as QtiTextEntryInteraction,ui as QtiUploadInteraction,$s as QtiVariable,vt as QtiVariableDeclaration,z as ScoringHelper,nr as TestCheckItem,Ee as TestContainer,Jt as TestEndAttempt,xt as TestItemLink,te as TestNavigation,De as TestNext,rr as TestPagingButtonsStamp,Ve as TestPrev,sr as TestPrintContext,qt as TestPrintVariables,st as TestScoringButtons,wt as TestScoringFeedback,ir as TestSectionButtonsStamp,Ct as TestSectionLink,re as TestShowCorrectResponse,it as TestStamp,j as TestView,or as TestViewToggle,Ko as VocabularyMixin,$ as computedContext,Ie as computedItemContext,Z as configContext,Ft as convertNumberToUniversalFormat,zn as decimalSeparator,$E as getItemByUri,LE as getManifestInfo,P as itemContext,yo as itemContextVariables,da as qtiAndMixin,Zo as qtiChoiceInteractionStyles,Or as qtiContext,gn as qtiSimpleChoiceStyles,pa as qtiSubtractMixin,ae as qtiTransformItem,go as qtiTransformManifest,ht as qtiTransformTest,Hr as removeDoubleSlashes,Le as sessionContext,le as testContext};
|
|
6248
|
+
<slot part="slot"></slot>`}};c([u({type:String,attribute:"template-identifier"})],We.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],We.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],We.prototype,"fixed",2),c([u({type:String,attribute:!1})],We.prototype,"marker",2);customElements.define("qti-simple-choice",We);var LE=async o=>{let r=o.substring(0,o.lastIndexOf("/")),e=await go().load(`${o}`).then(a=>a.assessmentTest()),t=await ht().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await ht().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}},$E=async o=>ae().load(o).then(r=>r.htmlDoc().firstElementChild);var be=class extends b{render(){return f`<slot></slot>`}process(){throw new Error("Not implemented")}};be=c([q("qti-rule")],be);var fr=class extends be{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:Ft(t)}})),t)}};c([u({type:String})],fr.prototype,"identifier",2),c([T({context:P,subscribe:!0}),C()],fr.prototype,"context",2);customElements.define("qti-lookup-outcome-value",fr);var ls=class extends be{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",ls);var cs=class extends be{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 ds(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.formatValue(i)}}))}formatValue(r){return Array.isArray(r)?r.map(Ft):r!==null?Ft(r):null}},ds=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",cs);var gr=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",gr);var br=class extends gr{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",br);var ps=class extends br{render(){return f`${super.render()}`}};customElements.define("qti-response-else-if",ps);var gi=class extends da(ee){calculate(){return this.calculateChildren(Array.from(this.children))}};gi=c([q("qti-and")],gi);function da(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 bi=class extends _{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],bi.prototype,"baseType",2);customElements.define("qti-base-value",bi);var us=class extends _{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",us);var ms=class extends ee{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",ms);var hs=class extends _{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",hs);var At=class extends _{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})],At.prototype,"identifier",2),c([T({context:P,subscribe:!0}),C()],At.prototype,"context",2),c([C(),T({context:le,subscribe:!0})],At.prototype,"_testContext",2);customElements.define("qti-default",At);var vi=class extends _{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})],vi.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",vi);var fs=class extends _{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",fs);var vr=class extends _{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._roundToDecimalPlaces(i,this.figures):this._roundToSignificantFigures(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}_roundToDecimalPlaces(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}_roundToSignificantFigures(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"})],vr.prototype,"roundingMode",2),c([u({type:Number})],vr.prototype,"figures",2);customElements.define("qti-round-to",vr);var yi=class extends _{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):z.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],yi.prototype,"toleranceMode",2);customElements.define("qti-equal",yi);var gs=class extends _{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._calculateGcd(e)}_calculateGcd(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._gcdTwoNumbers(e,Math.abs(r[t])),e!==1);t++);return e}_gcdTwoNumbers(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",gs);var bs=class extends _{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",bs);var vs=class extends ee{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",vs);var ys=class extends _{getResult(){return null}};customElements.define("qti-null",ys);var xs=class extends _{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",xs);var qs=class extends _{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",qs);var Cs=class extends _{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",Cs);var ws=class extends ee{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",ws);var xi=class extends _{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?z.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):z.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})],xi.prototype,"identifier",2);customElements.define("qti-map-response",xi);var qi=class extends _{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;z.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})],qi.prototype,"identifier",2);customElements.define("qti-map-response-point",qi);var Ci=class extends _{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._performOperation(this.name,t)}_performOperation(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})],Ci.prototype,"name",2);customElements.define("qti-math-operator",Ci);var Es=class o extends _{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):z.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(!z.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(z.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",Es);var _s=class extends _{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",_s);var Ts=class extends _{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",Ts);var Ss=class extends _{render(){return f`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Ss);var As=class extends ee{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",As);var Rs=class extends _{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",Rs);var ks=class extends _{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",ks);var yr=class extends b{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?k:f`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],yr.prototype,"identifier",2),c([T({context:P,subscribe:!0}),C()],yr.prototype,"context",2);customElements.define("qti-printed-variable",yr);var Ms=class extends _{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",Ms);var wi=class extends pa(_){getResult(){return this.calculateChildren(Array.from(this.children))}};function pa(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",wi);var Ei=class extends _{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 z.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],Ei.prototype,"caseSensitive",2);customElements.define("qti-string-match",Ei);var Is=class extends _{constructor(){super(),this._expression=new Ls(Array.from(this.children))}getResult(){return this._expression.calculate()}},Ls=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",Is);var $s=class extends _{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",$s);var Rt=class extends _{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})],Rt.prototype,"min",2),c([u({type:Number})],Rt.prototype,"max",2),c([u({type:Number})],Rt.prototype,"step",2);customElements.define("qti-random-integer",Rt);var Ps=class extends _{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",Ps);var Os=class extends _{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",Os);var xr=class extends _{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 r=this.getVariables()[0];if(!r)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let t=this.lookupVariableValue(this.n);if(t===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(t)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(r.cardinality==="ordered"){let t=Array.isArray(r.value)?r.value:[r.value];return r.value===null||e>t.length?null:t[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}lookupVariableValue(r){let e=this.context.variables.find(t=>t.identifier===r)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};c([u({type:String})],xr.prototype,"n",2),xr=c([q("qti-index")],xr);export{To as Correctness,Bi as INITIAL_SESSION_CONTEXT,Fi as INITIAL_TEST_CONTEXT,A as Interaction,Wi as IsNullOrUndefined,_e as ItemContainer,ot as ItemCorrectResponseMode,Et as ItemPrintVariables,ie as ItemShowCandidateCorrection,se as ItemShowCorrectResponse,gi as QtiAnd,Q as QtiAssessmentItem,xe as QtiAssessmentItemRef,qe as QtiAssessmentSection,yt as QtiAssessmentStimulusRef,Yi as QtiAssessmentStimulusRefConnectedEvent,et as QtiAssessmentTest,mi as QtiAssociableHotspot,ar as QtiAssociateInteraction,bi as QtiBaseValue,lr as QtiChoiceInteraction,Ur as QtiCompanionMaterialsInfo,ee as QtiConditionExpression,us as QtiContainerSize,ms as QtiContains,Br as QtiContentBody,hs as QtiCorrect,Te as QtiCustomInteraction,jt as QtiCustomOperator,At as QtiDefault,Os as QtiDelete,He as QtiEndAttemptInteraction,yi as QtiEqual,vi as QtiEqualRounded,_ as QtiExpression,J as QtiExtendedTextInteraction,Y as QtiFeedback,Wt as QtiFeedbackBlock,Xt as QtiFeedbackInline,qs as QtiFieldValue,pr as QtiGap,ur as QtiGapImg,ii as QtiGapMatchInteraction,mr as QtiGapText,gs as QtiGcd,Se as QtiGraphicAssociateInteraction,si as QtiGraphicGapMatchInteraction,oi as QtiGraphicOrderInteraction,bs as QtiGt,vs as QtiGte,St as QtiHotspotChoice,ni as QtiHotspotInteraction,hi as QtiHottext,cr as QtiHottextInteraction,xr as QtiIndex,hr as QtiInlineChoice,ai as QtiInlineChoiceInteraction,xs as QtiIsNull,_t as QtiItem,Gt as QtiItemBody,fr as QtiLookupOutcomeValue,Cs as QtiLt,ws as QtiLte,xi as QtiMapResponse,qi as QtiMapResponsePoint,Es as QtiMatch,Be as QtiMatchInteraction,Ci as QtiMathOperator,li as QtiMediaInteraction,_s as QtiMember,tt as QtiModalFeedback,Ts as QtiMultiple,Ss as QtiNot,ys as QtiNull,As as QtiOr,Fe as QtiOrderInteraction,Rs as QtiOrdered,ue as QtiOutcomeDeclaration,U as QtiPortableCustomInteraction,di as QtiPositionObjectInteraction,pi as QtiPositionObjectStage,ks as QtiPower,yr as QtiPrintedVariable,Ms as QtiProduct,fi as QtiPrompt,Ps as QtiRandom,Rt as QtiRandomInteger,ls as QtiResponseCondition,we as QtiResponseDeclaration,gr as QtiResponseElse,ps as QtiResponseElseIf,br as QtiResponseIf,Yt as QtiResponseProcessing,fs as QtiRound,vr as QtiRoundTo,pe as QtiRubricBlock,So as QtiRuleElement,Ae as QtiSelectPointInteraction,cs as QtiSetOutcomeValue,ds as QtiSetOutcomeValueRule,nt as QtiSimpleAssociableChoice,We as QtiSimpleChoice,je as QtiSliderInteraction,Ei as QtiStringMatch,Fr as QtiStylesheet,wi as QtiSubtract,Is as QtiSum,Ls as QtiSumExpression,zr as QtiTest,Qt as QtiTestFeedback,Ce as QtiTestPart,oe as QtiTextEntryInteraction,ui as QtiUploadInteraction,$s as QtiVariable,vt as QtiVariableDeclaration,z as ScoringHelper,nr as TestCheckItem,Ee as TestContainer,Jt as TestEndAttempt,xt as TestItemLink,te as TestNavigation,De as TestNext,rr as TestPagingButtonsStamp,Ve as TestPrev,sr as TestPrintContext,qt as TestPrintVariables,st as TestScoringButtons,wt as TestScoringFeedback,ir as TestSectionButtonsStamp,Ct as TestSectionLink,re as TestShowCorrectResponse,it as TestStamp,j as TestView,or as TestViewToggle,Ko as VocabularyMixin,$ as computedContext,Ie as computedItemContext,Z as configContext,Ft as convertNumberToUniversalFormat,zn as decimalSeparator,$E as getItemByUri,LE as getManifestInfo,P as itemContext,yo as itemContextVariables,da as qtiAndMixin,Zo as qtiChoiceInteractionStyles,Or as qtiContext,gn as qtiSimpleChoiceStyles,pa as qtiSubtractMixin,ae as qtiTransformItem,go as qtiTransformManifest,ht as qtiTransformTest,Hr as removeDoubleSlashes,Le as sessionContext,le as testContext};
|
|
6231
6249
|
/*! Bundled license information:
|
|
6232
6250
|
|
|
6233
6251
|
@lit-labs/ssr-dom-shim/lib/element-internals.js:
|