@citolab/qti-components 7.17.0 → 7.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/index.global.js +1 -1
- package/cdn/index.js +629 -278
- package/custom-elements.json +139 -1950
- package/dist/base.d.ts +11 -11
- package/dist/base.js +1 -1
- package/dist/{chunk-VEV4DGPH.js → chunk-3OCDS5FG.js} +2 -2
- package/dist/{chunk-C2HQFI2C.js → chunk-5D7GD3JS.js} +763 -481
- package/dist/chunk-5D7GD3JS.js.map +1 -0
- package/dist/{chunk-W4SQRNWO.js → chunk-5J5P5GJY.js} +4 -8
- package/dist/{chunk-W4SQRNWO.js.map → chunk-5J5P5GJY.js.map} +1 -1
- package/dist/{chunk-RI47B4ZT.js → chunk-DO3QY5GP.js} +2 -2
- package/dist/{chunk-DWIRLYDS.js → chunk-FOWDOLXY.js} +2 -2
- package/dist/{chunk-INKI27D5.js → chunk-GMNH42S6.js} +27 -36
- package/dist/chunk-GMNH42S6.js.map +1 -0
- package/dist/{chunk-2DOYPVF5.js → chunk-HRVIMT5Y.js} +4 -4
- package/dist/{chunk-O4XIWHTF.js → chunk-IDW2ETV2.js} +27 -12
- package/dist/chunk-IDW2ETV2.js.map +1 -0
- package/dist/{chunk-F44CI35W.js → chunk-L4TXKTUA.js} +2 -2
- package/dist/{chunk-JEUY3MYB.js → chunk-VUSGFL4B.js} +21 -17
- package/dist/chunk-VUSGFL4B.js.map +1 -0
- package/dist/{chunk-352OTVTY.js → chunk-YAPCC4BO.js} +37 -25
- package/dist/chunk-YAPCC4BO.js.map +1 -0
- package/dist/{computed-item.context-CiddHLPz.d.ts → computed-item.context-DfsW_96S.d.ts} +1 -1
- package/dist/{computed.context-CH09_LCR.d.ts → computed.context-DHbxad0N.d.ts} +2 -2
- package/dist/{config.context-DAdkDDf5.d.ts → config.context-DUz2-kxN.d.ts} +1 -1
- package/dist/elements.d.ts +5 -3
- package/dist/elements.js +4 -4
- package/dist/index.d.ts +10 -10
- package/dist/index.js +11 -11
- package/dist/{interaction-C5Up6-68.d.ts → interaction-BLQjAZqN.d.ts} +4 -4
- package/dist/interactions.d.ts +50 -119
- package/dist/interactions.js +4 -4
- package/dist/{item.context-BRKXBC3m.d.ts → item.context-CkUeDcaO.d.ts} +6 -1
- package/dist/item.css +1 -5
- package/dist/item.d.ts +3 -3
- package/dist/item.js +5 -5
- package/dist/loader.d.ts +3 -3
- package/dist/loader.js +2 -2
- package/dist/processing.d.ts +4 -4
- package/dist/processing.js +2 -2
- package/dist/qti-components-jsx.d.ts +6448 -2802
- package/dist/{qti-feedback-B4cMzOcq.d.ts → qti-feedback-BNXgxua1.d.ts} +2 -2
- package/dist/{qti-rule-base-dL4opfvi.d.ts → qti-rule-base-BZSb0WTW.d.ts} +4 -4
- package/dist/{qti-transform-test-Bz9A3hmD.d.ts → qti-transform-test-C2fL4PtU.d.ts} +1 -1
- package/dist/{test.context-Bpw1HNAZ.d.ts → test.context-Oc_8ovbV.d.ts} +3 -3
- package/dist/test.d.ts +28 -28
- package/dist/test.js +7 -7
- package/dist/transformers.d.ts +1 -1
- package/dist/transformers.js +1 -1
- package/dist/{variables-CusMRnyJ.d.ts → variables-CMYcDbyW.d.ts} +2 -1
- package/package.json +9 -9
- package/dist/chunk-352OTVTY.js.map +0 -1
- package/dist/chunk-C2HQFI2C.js.map +0 -1
- package/dist/chunk-INKI27D5.js.map +0 -1
- package/dist/chunk-JEUY3MYB.js.map +0 -1
- package/dist/chunk-O4XIWHTF.js.map +0 -1
- package/dist/vscode.css-custom-data.json +0 -11
- package/dist/vscode.html-custom-data.json +0 -960
- /package/dist/{chunk-VEV4DGPH.js.map → chunk-3OCDS5FG.js.map} +0 -0
- /package/dist/{chunk-RI47B4ZT.js.map → chunk-DO3QY5GP.js.map} +0 -0
- /package/dist/{chunk-DWIRLYDS.js.map → chunk-FOWDOLXY.js.map} +0 -0
- /package/dist/{chunk-2DOYPVF5.js.map → chunk-HRVIMT5Y.js.map} +0 -0
- /package/dist/{chunk-F44CI35W.js.map → chunk-L4TXKTUA.js.map} +0 -0
package/cdn/index.js
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${r}" has already been used with this registry`);if(this.__reverseDefinitions.has(e))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(e)}`);e.__localName=r,this.__definitions.set(r,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,r),this.__pendingWhenDefineds.get(r)?.resolve(e),this.__pendingWhenDefineds.delete(r)}get(r){return this.__definitions.get(r)?.ctor}getName(r){return this.__reverseDefinitions.get(r)??null}upgrade(r){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(r){let e=this.__definitions.get(r);if(e)return e.ctor;let t=this.__pendingWhenDefineds.get(r);return t||(t=
|
|
3
|
-
\f\r]`,
|
|
4
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Bs=/'/g,js=/"/g,Gs=/^(?:script|style|textarea|title)$/i,Pi=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),h=Pi(1),Ur=Pi(2),wa=Pi(3),V=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),Ws=new WeakMap,Xe=Ge.createTreeWalker(Ge,129);function Ys(o,r){if(!$i(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return zs!==void 0?zs.createHTML(r):r}var Js=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Bt;for(let a=0;a<e;a++){let l=o[a],d,p,m=-1,f=0;for(;f<l.length&&(n.lastIndex=f,p=n.exec(l),p!==null);)f=n.lastIndex,n===Bt?p[1]==="!--"?n=Fs:p[1]!==void 0?n=Us:p[2]!==void 0?(Gs.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=We):p[3]!==void 0&&(n=We):n===We?p[0]===">"?(n=i??Bt,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?We:p[3]==='"'?js:Bs):n===js||n===Bs?n=We:n===Fs||n===Us?n=Bt:(n=We,i=void 0);let b=n===We&&o[a+1].startsWith("/>")?" ":"";s+=n===Bt?l+qn:m>=0?(t.push(d),l.slice(0,m)+Ii+l.slice(m)+ye+b):l+ye+(m===-2?a:b)}return[Ys(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Xt=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]=Js(r,e);if(this.el=o.createElement(d,t),Xe.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=Xe.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Ii)){let f=p[n++],b=i.getAttribute(m).split(ye),y=/([.?@])?(.*)/.exec(f);l.push({type:1,index:s,name:y[2],strings:b,ctor:y[1]==="."?Dr:y[1]==="?"?Nr:y[1]==="@"?Hr:Je}),i.removeAttribute(m)}else m.startsWith(ye)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(Gs.test(i.tagName)){let m=i.textContent.split(ye),f=m.length-1;if(f>0){i.textContent=Vr?Vr.emptyScript:"";for(let b=0;b<f;b++)i.append(m[b],jt()),Xe.nextNode(),l.push({type:2,index:++s});i.append(m[f],jt())}}}else if(i.nodeType===8)if(i.data===Li)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=Ge.createElement("template");return t.innerHTML=r,t}};function Ye(o,r,e=o,t){if(r===V)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=Wt(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=Ye(o,i._$AS(o,r.values),i,t)),r}var Or=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??Ge).importNode(e,!0);Xe.currentNode=i;let s=Xe.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new at(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new zr(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=Xe.nextNode(),n++)}return Xe.currentNode=Ge,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++}},at=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=Ye(this,r,e),Wt(r)?r===k||r==null||r===""?(this._$AH!==k&&this._$AR(),this._$AH=k):r!==this._$AH&&r!==V&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):Xs(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&&Wt(this._$AH)?this._$AA.nextSibling.data=r:this.T(Ge.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=Xt.createElement(Ys(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Or(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=Ws.get(r.strings);return e===void 0&&Ws.set(r.strings,e=new Xt(r)),e}k(r){$i(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(jt()),this.O(jt()),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))}},Je=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=Ye(this,r,e,0),n=!Wt(r)||r!==this._$AH&&r!==V,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=Ye(this,a[t+l],e,l),d===V&&(d=this._$AH[l]),n||=!Wt(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??"")}},Dr=class extends Je{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===k?void 0:r}},Nr=class extends Je{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==k)}},Hr=class extends Je{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Ye(this,r,e,0)??k)===V)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)}},zr=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){Ye(this,r)}},H={M:Ii,P:ye,A:Li,C:1,L:Js,R:Or,D:Xs,V:Ye,I:at,H:Je,N:Nr,U:Hr,B:Dr,F:zr},Cn=Fr.litHtmlPolyfillSupport;Cn?.(Xt,at),(Fr.litHtmlVersions??=[]).push("3.3.1");var Vi=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new at(r.insertBefore(jt(),s),s,void 0,e??{})}return i._$AI(o),i};var Oi=globalThis,v=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=Vi(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return V}};v._$litElement$=!0,v.finalized=!0,Oi.litElementHydrateSupport?.({LitElement:v});var En=Oi.litElementPolyfillSupport;En?.({LitElement:v});(Oi.litElementVersions??=[]).push("4.2.1");var g=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var wn={attribute:!0,type:String,converter:Ft,reflect:!1,hasChanged:Pr},_n=(o=wn,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"?_n(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 E(o){return u({...o,state:!0,attribute:!1})}var Le=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function lt(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 Le(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 Le(e,t,{get(){return s(this)}})}}function Ks(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return Le(r,e,{get(){let n=this.renderRoot?.querySelector(s),a=n?.assignedElements(o)??[];return i===void 0?a:a.filter((l=>l.matches(i)))}})}}var Tn=String.raw,An=Tn`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
5
|
-
<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes" />
|
|
6
|
-
<xsl:template match="@*|node()">
|
|
7
|
-
<xsl:copy>
|
|
8
|
-
<xsl:apply-templates select="@*|node()"/>
|
|
9
|
-
</xsl:copy>
|
|
10
|
-
</xsl:template>
|
|
11
|
-
|
|
12
|
-
<!-- remove existing namespaces -->
|
|
13
|
-
<xsl:template match="*">
|
|
14
|
-
<!-- remove element prefix -->
|
|
15
|
-
<xsl:element name="{local-name()}">
|
|
16
|
-
<!-- process attributes -->
|
|
17
|
-
<xsl:for-each select="@*">
|
|
18
|
-
<!-- remove attribute prefix -->
|
|
19
|
-
<xsl:attribute name="{local-name()}">
|
|
20
|
-
<xsl:value-of select="."/>
|
|
21
|
-
</xsl:attribute>
|
|
22
|
-
</xsl:for-each>
|
|
23
|
-
<xsl:apply-templates/>
|
|
24
|
-
</xsl:element>
|
|
25
|
-
</xsl:template>
|
|
26
|
-
</xsl:stylesheet>`;function Zs(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=eo(t,i);t.replaceWith(s)})}function Qs(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=eo(e,n);e.replaceWith(a)}})})}function eo(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 to(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 ct(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 dt(o){return new DOMParser().parseFromString(o,"text/xml")}function pt(o){let r=new XSLTProcessor,e=new DOMParser().parseFromString(An,"text/xml");return r.importStylesheet(e),r.transformToFragment(o,document)}function ut(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 ro(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 io(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function so(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 oe=(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))):ct(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=dt(i),t},path:i=>(ut(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),d=await s(i,"/modules/module_resolution.js"),p=await s(i,"/modules/fallback_module_resolution.js");if(l.length>0)for(let m of Array.from(l)){m.setAttribute("data-base-url",i);let f=m.getAttribute("custom-interaction-type-identifier");f&&a.includes(f)&&(f=f+a.length,m.setAttribute("custom-interaction-type-identifier",f),a.push(f)),f&&a.push(f);let b=m.querySelector("qti-interaction-modules");if(b&&b.getAttribute("primary-configuration")){let y=b.getAttribute("primary-configuration");if(y)try{let C=await s(i,`/${y}`),A=Array.from(b.querySelectorAll("qti-interaction-module"));for(let q of A){let T=q.getAttribute("id");if(T&&C.paths&&C.paths[T]){let M=C.paths[T],O=Array.isArray(M)?M[0]:M;if(q.setAttribute("primary-path",O),p&&p.paths&&p.paths[T]){let D=p.paths[T];Array.isArray(D)?q.setAttribute("fallback-path",D[0]):q.setAttribute("fallback-path",D)}}}if(C.paths){for(let q in C.paths)if(!b.querySelector(`qti-interaction-module[id="${q}"]`)){let M=r.createElement("qti-interaction-module");M.setAttribute("id",q);let O=Array.isArray(C.paths[q])?C.paths[q][0]:C.paths[q];if(M.setAttribute("primary-path",O),p&&p.paths&&p.paths[q]){let D=p.paths[q];Array.isArray(D)?M.setAttribute("fallback-path",D[0]):M.setAttribute("fallback-path",D)}b.appendChild(M)}}C.urlArgs&&b.setAttribute("url-args",C.urlArgs)}catch(C){console.warn(`Failed to load primary configuration: ${y}`,C)}}else if(d){m.querySelector("qti-interaction-modules")===null?(b=r.createElement("qti-interaction-modules"),m.appendChild(b)):b=m.querySelector("qti-interaction-modules");for(let y in d.paths){let C=d.paths[y],A="";p&&p.paths&&p.paths[y]&&(A=p.paths[y]);let q=Array.isArray(C)?C:[C],T=Array.isArray(A)?A:[A],M=q.map((O,D)=>{let nn=T.length>D?T[D]:"";return{primaryPath:O,fallbackPath:nn}});for(let O of T)M.some(D=>D.fallbackPath===O)||M.push({primaryPath:q.length>0?q[0]:O,fallbackPath:O});for(let O of M){let D=r.createElement("qti-interaction-module");O.fallbackPath&&D.setAttribute("fallback-path",O.fallbackPath),D.setAttribute("id",y),D.setAttribute("primary-path",O.primaryPath),b&&b.appendChild(D)}}}}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=so(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((q,T)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:T})).filter(q=>q.fixed),f=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(f.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let b=[...f],y=!1,C=0;for(;!y&&C<20;){C++;for(let q=f.length-1;q>0;q--){let T=Math.floor(Math.random()*(q+1));[f[q],f[T]]=[f[T],f[q]]}y=!f.every((q,T)=>q===b[T])}if(!y)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let A=0;for(let q of f)q.parentElement.insertBefore(q,m[A]?.element),A++;for(let q of m)q.element.parentElement.insertBefore(q.element,f[q.originalOrder])}}return t},extendElementName:(i,s)=>(Zs(r,i,s),t),extendElementsWithClass:(i="extend")=>(Qs(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 ro(r),t},stripStyleSheets(){return io(r),t},html(){return e!==null&&ut(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(pt(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&ut(r,e.substring(0,e.lastIndexOf("/"))),pt(r)},xmlDoc(){return r}};return t};var oo=()=>{let o,r={async load(e,t){return new Promise(i=>{ct(e,t).then(s=>(o=s,i(r)))})},parse(e){o=dt(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var mt=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{ct(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=dt(e),r},path:e=>(ut(o,e),r),fn(e){return e(o),r},items(){return to(o)},html(){return new XMLSerializer().serializeToString(pt(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return pt(o)},xmlDoc(){return o}};return r};var no=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._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){this._cancelPreviousNavigation();try{this._dispatchLoadingStarted(i.type,i.id),this._activeController=new AbortController,await this._executeNavigation(i.type,i.id)}catch(s){this._handleNavigationError(s,i.type,i.id)}finally{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){i==="item"?await this._navigateToItem(s):await this._navigateToSection(s)}async _navigateToItem(i){let s=this._findItemRef(i);this._updateSessionContext(s,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i]),await this._waitForLoadingComplete(),this._dispatchTestLoaded(this._loadResults)}async _navigateToSection(i){let n=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:i,navItemRefId:null};let a=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=a.length,await this._loadItems(a),await this._waitForLoadingComplete(),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(){for(;!this._loadingState.isComplete;)await new Promise(i=>setTimeout(i,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 f=Array.from(a).map(b=>b.cloneNode(!0));p.append(...f),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){if(!this._testElement||i.length===0)return;let s=i.map(l=>this._findItemRef(l));this._clearLoadedItems(),this._clearStimulusRef();let a=(await Promise.all(s.map(l=>this._loadSingleItem(l)))).filter(Boolean);a.forEach(({itemRef:l,doc:d})=>{l&&d&&(l.xmlDoc=d)}),this._loadResults=a}async _loadSingleItem(i){try{let s=await oe(this.cacheTransform).load(i.href,this._activeController?.signal);return this.postLoadTransformCallback&&(s=await this.postLoadTransformCallback(s,i)),{itemRef:i,doc:s.htmlDoc()}}catch(s){if(s.name==="AbortError")throw console.info(`Item load for ${i.identifier} was aborted`),s;return console.warn(`Failed to load item ${i.identifier}:`,s),null}}async _loadStimulus(i){return(await oe().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="")}_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 ao=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 $e=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 ht=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 $e(this.context,this.host,this.t,this.subscribe))}};var Br=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 Di=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},ft=class extends Br{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 $e(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 Di(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 ft(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new ft(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 ht(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new ht(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var Pe=Symbol("computedItemContext");var $=Symbol("computedContext");var J=Symbol("configContext");var lo=[{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 jr=Symbol("qtiContext");var Ni={view:"candidate"},Ve=Symbol("testContext");var Hi={items:[],testOutcomeVariables:[]},ne=Symbol("testContext");var co=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(co||{}),R=class extends v{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}get correctness(){let e=this.responseVariable;return!e||e.correctResponse===null?null:e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!1}get responseVariable(){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.responseVariable;if(!s)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t)}if(i)return;let a=this.cloneNode(!0),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.correctResponse)?[...s.correctResponse]:s.correctResponse}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t?.cardinality==="single"?"":[]}toggleCandidateCorrection(e){this.responseVariable&&(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}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e}}))}};c([_({context:P,subscribe:!0})],R.prototype,"_context",2),c([_({context:J,subscribe:!0})],R.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],R.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],R.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],R.prototype,"readonly",2),c([E()],R.prototype,"_isFullCorrectResponse",2),c([E()],R.prototype,"_correctResponse",2);var gt=class extends v{render(){return h`<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 w=class extends v{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=x`
|
|
1
|
+
var cn=Object.defineProperty;var dn=Object.getOwnPropertyDescriptor;var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?dn(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&&cn(r,e,i),i};var Ms=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 se=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},D=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)},ot,kr,Rr,$t,qi,Pt,Mr,je,Vt,Ie,Ir,Is,Ls=o=>typeof o=="boolean"?o:o?.capture??!1;var Ci=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=Ls(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=Ls(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=(q,T,M)=>{typeof q=="function"?q(r):typeof q?.handleEvent=="function"&&q.handleEvent(r),T.once&&M.delete(q)},b=()=>(d=null,n=0,!r.defaultPrevented),y=e.slice().reverse();a=!this.__host||!r.composed?this:null;let C=q=>{for(l=this;l.__host&&q.includes(l.__host);)l=l.__host};for(let q of y){!a&&(!l||l===q.__host)&&C(y.slice(y.indexOf(q))),d=q,n=q===r.target?2:1;let T=q.__captureEventListeners.get(r.type);if(T){for(let[M,O]of T)if(h(M,O,T),s)return b()}if(i)return b()}let S=r.bubbles?e:[this];l=null;for(let q of S){!a&&(!l||q===l.__host)&&C(S.slice(0,S.indexOf(q)+1)),d=q,n=q===r.target?2:3;let T=q.__eventListeners.get(r.type);if(T){for(let[M,O]of T)if(h(M,O,T),s)return b()}if(i)return b()}return b()}},Ei=Ci;var L={__proto__:null};L.enumerable=!0;Object.freeze(L);var wi=(Ie=class{constructor(r,e={}){if(ot.set(this,!1),kr.set(this,!1),Rr.set(this,!1),$t.set(this,!1),qi.set(this,Date.now()),Pt.set(this,!1),Mr.set(this,void 0),je.set(this,void 0),Vt.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;se(this,ot,!!i,"f"),se(this,kr,!!t,"f"),se(this,Rr,!!s,"f"),se(this,Mr,`${r}`,"f"),se(this,je,null,"f"),se(this,Vt,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){se(this,$t,!0,"f")}get target(){return D(this,je,"f")}get currentTarget(){return D(this,je,"f")}get srcElement(){return D(this,je,"f")}get type(){return D(this,Mr,"f")}get cancelable(){return D(this,ot,"f")}get defaultPrevented(){return D(this,ot,"f")&&D(this,$t,"f")}get timeStamp(){return D(this,qi,"f")}composedPath(){return D(this,Vt,"f")?[D(this,je,"f")]:[]}get returnValue(){return!D(this,ot,"f")||!D(this,$t,"f")}get bubbles(){return D(this,kr,"f")}get composed(){return D(this,Rr,"f")}get eventPhase(){return D(this,Vt,"f")?Ie.AT_TARGET:Ie.NONE}get cancelBubble(){return D(this,Pt,"f")}set cancelBubble(r){r&&se(this,Pt,!0,"f")}stopPropagation(){se(this,Pt,!0,"f")}get isTrusted(){return!1}},ot=new WeakMap,kr=new WeakMap,Rr=new WeakMap,$t=new WeakMap,qi=new WeakMap,Pt=new WeakMap,Mr=new WeakMap,je=new WeakMap,Vt=new WeakMap,Ie.NONE=0,Ie.CAPTURING_PHASE=1,Ie.AT_TARGET=2,Ie.BUBBLING_PHASE=3,Ie);Object.defineProperties(wi.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 $s=(Is=class extends wi{constructor(r,e={}){super(r,e),Ir.set(this,void 0),se(this,Ir,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return D(this,Ir,"f")}},Ir=new WeakMap,Is);Object.defineProperties($s.prototype,{detail:L});var _i=wi,Ti=$s;globalThis.Event??=_i;globalThis.CustomEvent??=Ti;var Ps=new WeakMap,Ot=o=>{let r=Ps.get(o);return r===void 0&&Ps.set(o,r=new Map),r},pn=class extends Ei{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(Ot(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){Ot(this).set(r,String(e))}removeAttribute(r){Ot(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 Ot(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 Ms(this);return this.__internals=r,r}getAttribute(r){return Ot(this).get(r)??null}};var un=class extends pn{},Si=un;globalThis.litServerRoot??=Object.defineProperty(new Si,"localName",{get(){return"lit-server-root"}});function mn(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var Ai=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=mn(),this.__pendingWhenDefineds.set(r,t)),t.promise}},hn=Ai;var Vs=new hn;var Nt=globalThis,Lr=Nt.ShadowRoot&&(Nt.ShadyCSS===void 0||Nt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ki=Symbol(),Os=new WeakMap,Dt=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==ki)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(Lr&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=Os.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&Os.set(e,r))}return r}toString(){return this.cssText}},Ns=o=>new Dt(typeof o=="string"?o:o+"",void 0,ki),x=(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 Dt(e,o,ki)},Ds=(o,r)=>{if(Lr)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=Nt.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},Ri=Lr||Nt.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return Ns(e)})(o):o;var{is:fn,defineProperty:gn,getOwnPropertyDescriptor:bn,getOwnPropertyNames:vn,getOwnPropertySymbols:yn,getPrototypeOf:xn}=Object,Ut=globalThis;Ut.customElements??=Vs;var Hs=Ut.trustedTypes,qn=Hs?Hs.emptyScript:"",Cn=Ut.reactiveElementPolyfillSupport,Ht=(o,r)=>o,zt={toAttribute(o,r){switch(r){case Boolean:o=o?qn: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}},$r=(o,r)=>!fn(o,r),zs={attribute:!0,type:String,converter:zt,reflect:!1,useDefault:!1,hasChanged:$r};Symbol.metadata??=Symbol("metadata"),Ut.litPropertyMetadata??=new WeakMap;var ve=class extends(globalThis.HTMLElement??Si){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=zs){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&&gn(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=bn(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)??zs}static _$Ei(){if(this.hasOwnProperty(Ht("elementProperties")))return;let r=xn(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Ht("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ht("properties"))){let e=this.properties,t=[...vn(e),...yn(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(Ri(i))}else r!==void 0&&e.push(Ri(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 Ds(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:zt).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:zt;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??$r)(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[Ht("elementProperties")]=new Map,ve[Ht("finalized")]=new Map,Cn?.({ReactiveElement:ve}),(Ut.reactiveElementVersions??=[]).push("2.1.1");var zr=globalThis,Pr=zr.trustedTypes,Us=Pr?Pr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Ii="$lit$",ye=`lit$${Math.random().toFixed(9).slice(2)}$`,Li="?"+ye,En=`<${Li}>`,Ge=zr.document===void 0?{createTreeWalker:()=>({})}:document,Bt=()=>Ge.createComment(""),jt=o=>o===null||typeof o!="object"&&typeof o!="function",$i=Array.isArray,Gs=o=>$i(o)||typeof o?.[Symbol.iterator]=="function",Mi=`[
|
|
3
|
+
\f\r]`,Ft=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Fs=/-->/g,Bs=/>/g,We=RegExp(`>|${Mi}(?:([^\\s"'>=/]+)(${Mi}*=${Mi}*(?:[^
|
|
4
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),js=/'/g,Ws=/"/g,Ys=/^(?:script|style|textarea|title)$/i,Pi=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),f=Pi(1),Ur=Pi(2),_a=Pi(3),V=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),Xs=new WeakMap,Xe=Ge.createTreeWalker(Ge,129);function Js(o,r){if(!$i(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Us!==void 0?Us.createHTML(r):r}var Ks=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Ft;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===Ft?p[1]==="!--"?n=Fs:p[1]!==void 0?n=Bs:p[2]!==void 0?(Ys.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=We):p[3]!==void 0&&(n=We):n===We?p[0]===">"?(n=i??Ft,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?We:p[3]==='"'?Ws:js):n===Ws||n===js?n=We:n===Fs||n===Bs?n=Ft:(n=We,i=void 0);let b=n===We&&o[a+1].startsWith("/>")?" ":"";s+=n===Ft?l+En:m>=0?(t.push(d),l.slice(0,m)+Ii+l.slice(m)+ye+b):l+ye+(m===-2?a:b)}return[Js(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Wt=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]=Ks(r,e);if(this.el=o.createElement(d,t),Xe.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=Xe.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Ii)){let h=p[n++],b=i.getAttribute(m).split(ye),y=/([.?@])?(.*)/.exec(h);l.push({type:1,index:s,name:y[2],strings:b,ctor:y[1]==="."?Or:y[1]==="?"?Nr:y[1]==="@"?Dr:Je}),i.removeAttribute(m)}else m.startsWith(ye)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(Ys.test(i.tagName)){let m=i.textContent.split(ye),h=m.length-1;if(h>0){i.textContent=Pr?Pr.emptyScript:"";for(let b=0;b<h;b++)i.append(m[b],Bt()),Xe.nextNode(),l.push({type:2,index:++s});i.append(m[h],Bt())}}}else if(i.nodeType===8)if(i.data===Li)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=Ge.createElement("template");return t.innerHTML=r,t}};function Ye(o,r,e=o,t){if(r===V)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=jt(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=Ye(o,i._$AS(o,r.values),i,t)),r}var Vr=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??Ge).importNode(e,!0);Xe.currentNode=i;let s=Xe.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new nt(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new Hr(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=Xe.nextNode(),n++)}return Xe.currentNode=Ge,i}p(r){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(r,t,e),e+=t.strings.length-2):t._$AI(r[e])),e++}},nt=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=R,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=Ye(this,r,e),jt(r)?r===R||r==null||r===""?(this._$AH!==R&&this._$AR(),this._$AH=R):r!==this._$AH&&r!==V&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):Gs(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!==R&&jt(this._$AH)?this._$AA.nextSibling.data=r:this.T(Ge.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=Wt.createElement(Js(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Vr(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=Xs.get(r.strings);return e===void 0&&Xs.set(r.strings,e=new Wt(r)),e}k(r){$i(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(Bt()),this.O(Bt()),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))}},Je=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=R,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=R}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=Ye(this,r,e,0),n=!jt(r)||r!==this._$AH&&r!==V,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=Ye(this,a[t+l],e,l),d===V&&(d=this._$AH[l]),n||=!jt(d)||d!==this._$AH[l],d===R?r=R:r!==R&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===R?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Or=class extends Je{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===R?void 0:r}},Nr=class extends Je{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==R)}},Dr=class extends Je{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Ye(this,r,e,0)??R)===V)return;let t=this._$AH,i=r===R&&t!==R||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==R&&(t===R||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)}},Hr=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){Ye(this,r)}},H={M:Ii,P:ye,A:Li,C:1,L:Ks,R:Vr,D:Gs,V:Ye,I:nt,H:Je,N:Nr,U:Dr,B:Or,F:Hr},wn=zr.litHtmlPolyfillSupport;wn?.(Wt,nt),(zr.litHtmlVersions??=[]).push("3.3.1");var Vi=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new nt(r.insertBefore(Bt(),s),s,void 0,e??{})}return i._$AI(o),i};var Oi=globalThis,v=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=Vi(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return V}};v._$litElement$=!0,v.finalized=!0,Oi.litElementHydrateSupport?.({LitElement:v});var _n=Oi.litElementPolyfillSupport;_n?.({LitElement:v});(Oi.litElementVersions??=[]).push("4.2.1");var g=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var Tn={attribute:!0,type:String,converter:zt,reflect:!1,hasChanged:$r},An=(o=Tn,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"?An(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 E(o){return u({...o,state:!0,attribute:!1})}var Le=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function at(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 Le(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 Le(e,t,{get(){return s(this)}})}}function Zs(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return Le(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 Qs(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=to(t,i);t.replaceWith(s)})}function eo(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=to(e,n);e.replaceWith(a)}})})}function to(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 ro(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 lt(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 ct(o){return new DOMParser().parseFromString(o,"text/xml")}function io(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(io(e.childNodes[i],r));return t}return o.cloneNode(!1)}function dt(o){let r=document.createDocumentFragment();for(let e=0;e<o.childNodes.length;e++)r.appendChild(io(o.childNodes[e],document));return r}function pt(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 so(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 oo(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function no(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 oe=(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))):lt(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=ct(i),t},path:i=>(pt(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),d=await s(i,"/modules/module_resolution.js"),p=await s(i,"/modules/fallback_module_resolution.js");if(l.length>0)for(let m of Array.from(l)){m.setAttribute("data-base-url",i);let h=m.getAttribute("custom-interaction-type-identifier");h&&a.includes(h)&&(h=h+a.length,m.setAttribute("custom-interaction-type-identifier",h),a.push(h)),h&&a.push(h);let b=m.querySelector("qti-interaction-modules");if(b&&b.getAttribute("primary-configuration")){let y=b.getAttribute("primary-configuration");if(y)try{let C=await s(i,`/${y}`),S=Array.from(b.querySelectorAll("qti-interaction-module"));for(let q of S){let T=q.getAttribute("id");if(T&&C.paths&&C.paths[T]){let M=C.paths[T],O=Array.isArray(M)?M[0]:M;if(q.setAttribute("primary-path",O),p&&p.paths&&p.paths[T]){let N=p.paths[T];Array.isArray(N)?q.setAttribute("fallback-path",N[0]):q.setAttribute("fallback-path",N)}}}if(C.paths){for(let q in C.paths)if(!b.querySelector(`qti-interaction-module[id="${q}"]`)){let M=r.createElement("qti-interaction-module");M.setAttribute("id",q);let O=Array.isArray(C.paths[q])?C.paths[q][0]:C.paths[q];if(M.setAttribute("primary-path",O),p&&p.paths&&p.paths[q]){let N=p.paths[q];Array.isArray(N)?M.setAttribute("fallback-path",N[0]):M.setAttribute("fallback-path",N)}b.appendChild(M)}}C.urlArgs&&b.setAttribute("url-args",C.urlArgs)}catch(C){console.warn(`Failed to load primary configuration: ${y}`,C)}}else if(d){m.querySelector("qti-interaction-modules")===null?(b=r.createElement("qti-interaction-modules"),m.appendChild(b)):b=m.querySelector("qti-interaction-modules");for(let y in d.paths){let C=d.paths[y],S="";p&&p.paths&&p.paths[y]&&(S=p.paths[y]);let q=Array.isArray(C)?C:[C],T=Array.isArray(S)?S:[S],M=q.map((O,N)=>{let ln=T.length>N?T[N]:"";return{primaryPath:O,fallbackPath:ln}});for(let O of T)M.some(N=>N.fallbackPath===O)||M.push({primaryPath:q.length>0?q[0]:O,fallbackPath:O});for(let O of M){let N=r.createElement("qti-interaction-module");O.fallbackPath&&N.setAttribute("fallback-path",O.fallbackPath),N.setAttribute("id",y),N.setAttribute("primary-path",O.primaryPath),b&&b.appendChild(N)}}}}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=no(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((q,T)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:T})).filter(q=>q.fixed),h=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(h.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let b=[...h],y=!1,C=0;for(;!y&&C<20;){C++;for(let q=h.length-1;q>0;q--){let T=Math.floor(Math.random()*(q+1));[h[q],h[T]]=[h[T],h[q]]}y=!h.every((q,T)=>q===b[T])}if(!y)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let S=0;for(let q of h)q.parentElement.insertBefore(q,m[S]?.element),S++;for(let q of m)q.element.parentElement.insertBefore(q.element,h[q.originalOrder])}}return t},extendElementName:(i,s)=>(Qs(r,i,s),t),extendElementsWithClass:(i="extend")=>(eo(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 so(r),t},stripStyleSheets(){return oo(r),t},html(){return e!==null&&pt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(dt(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&pt(r,e.substring(0,e.lastIndexOf("/"))),dt(r)},xmlDoc(){return r}};return t};var ao=()=>{let o,r={async load(e,t){return new Promise(i=>{lt(e,t).then(s=>(o=s,i(r)))})},parse(e){o=ct(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var ut=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{lt(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=ct(e),r},path:e=>(pt(o,e),r),fn(e){return e(o),r},items(){return ro(o)},html(){return new XMLSerializer().serializeToString(dt(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return dt(o)},xmlDoc(){return o}};return r};var lo=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(b=>b.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)}),this._loadResults=d)}async _loadSingleItem(i,s,n){try{let a=await oe(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 oe().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 co=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 $e=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 mt=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 $e(this.context,this.host,this.t,this.subscribe))}};var Fr=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 Ni=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},ht=class extends Fr{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 $e(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 Ni(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 ht(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new ht(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 mt(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new mt(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var Pe=Symbol("computedItemContext");var $=Symbol("computedContext");var J=Symbol("configContext");var po=[{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 Br=Symbol("qtiContext");var Di={view:"candidate"},Ve=Symbol("testContext");var Hi={items:[],testOutcomeVariables:[]},ne=Symbol("testContext");var uo=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(uo||{}),k=class extends v{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}get correctness(){let e=this.responseVariable;return!e||e.correctResponse===null?null:e.correctResponse===e.value?"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.responseVariable;if(!s)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t)}if(i)return;let a=this.cloneNode(!0),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.correctResponse)?[...s.correctResponse]:s.correctResponse}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t?.cardinality==="single"?"":[]}toggleCandidateCorrection(e){this.responseVariable&&(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}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}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})],k.prototype,"_context",2),c([_({context:J,subscribe:!0})],k.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],k.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],k.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],k.prototype,"readonly",2),c([E()],k.prototype,"_isFullCorrectResponse",2),c([E()],k.prototype,"_correctResponse",2);var ft=class extends v{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 w=class extends v{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=x`
|
|
27
5
|
slot {
|
|
28
6
|
display: none;
|
|
29
7
|
}
|
|
30
|
-
`}render(){return
|
|
31
|
-
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([E()],w.prototype,"result",2),c([_({context:P,subscribe:!0}),E()],w.prototype,"context",2),c([_({context:jr,subscribe:!0}),E()],w.prototype,"qtiContext",2);var K=class extends w{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Sn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Gt=o=>{if(typeof o=="string")return o;let r=Sn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function zi(o){return o==null}function Ze(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var G=class extends v{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=!zi(this.identifier)&&!zi(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"})],G.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],G.prototype,"outcomeIdentifier",2),c([u({type:String})],G.prototype,"identifier",2),c([u({type:String,attribute:!1})],G.prototype,"showStatus",2),c([_({context:P,subscribe:!0}),E()],G.prototype,"_context",2);var po=class extends v{};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,f]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=f}case"ellipse":{let[d,p,m,f]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let b=(i-d)**2/m**2,y=(s-p)**2/f**2;return b+y<=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 Fi=o=>{class r extends o{constructor(...i){super(...i);this.testContext=Hi;this.sessionContext=Ni;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(f=>f.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=Hi,this.sessionContext=Ni,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)})}_updateItemVariablesInTestContext(i,s){this.testContext={...this.testContext,items:this.testContext.items.map(n=>n.identifier!==i?n:{...n,variables:s.map(a=>{let l=n.variables.find(d=>d.identifier===a.identifier);return l?{...l,...a}:a})})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}}return c([u({attribute:!1,type:Object}),X({context:ne})],r.prototype,"testContext",2),c([u({attribute:!1,type:Object}),X({context:Ve})],r.prototype,"sessionContext",2),r},uo=class extends Fi(v){};var mo=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 Wr=class extends no(ao(mo(Fi(v)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return h`<slot></slot>`}};Wr=c([g("qti-test")],Wr);var ho={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},xe=class extends v{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:ho})],xe.prototype,"required",2),c([u({type:Boolean,converter:ho})],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 Ui={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},qe=class extends v{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 h`<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:Ui})],qe.prototype,"fixed",2),c([u({type:Boolean,converter:Ui})],qe.prototype,"visible",2),c([u({type:Boolean,converter:Ui,attribute:"keep-together"})],qe.prototype,"keepTogether",2),c([_({context:ne,subscribe:!0})],qe.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",qe);var Qe=class extends v{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 h` <slot></slot>`}};c([u({type:String})],Qe.prototype,"identifier",2),c([u({type:String})],Qe.prototype,"title",1),c([_({context:ne,subscribe:!0})],Qe.prototype,"_testContext",2),Qe=c([g("qti-assessment-test")],Qe);var Ce=class extends v{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 h` <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([g("qti-test-part")],Ce);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ce);function Xr(o,r){return(e,t)=>{let{connectedCallback:i,disconnectedCallback:s}=e;e.connectedCallback=function(){i.call(this);let n=this[t],a=m=>{let f=[],b=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&f.push(M),f.push(...M.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&b.push(M),b.push(...M.querySelectorAll?.(o)??[])}));let y=q=>Array.from(new Set(q)),C=y(f),A=y(b);(C.length||A.length)&&n.call(this,C,A)},l=new MutationObserver(a);l.observe(this,{childList:!0,subtree:!0});let d=this.shadowRoot?new MutationObserver(a):null;d?.observe(this.shadowRoot,{childList:!0,subtree:!0}),this.__lqObservers=[l,d].filter(m=>!!m),(async()=>{r?.waitUntilFirstUpdate&&"updateComplete"in this&&await this.updateComplete;let m=[...this.querySelectorAll(o),...this.shadowRoot?.querySelectorAll(o)??[]];m.length&&n.call(this,m,[])})()},e.disconnectedCallback=function(){s.call(this),this.__lqObservers?.forEach(n=>n.disconnect()),this.__lqObservers=void 0}}}function I(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 Y=class extends v{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:lo};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}=e.detail;this.updateResponseVariable(t,i),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))})}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 h`<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(s=>s.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing");return!i||!i.process?!1:(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}})),!0)}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([I("disabled",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],Y.prototype,"readonly",2),c([I("readonly",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleReadonlyChange",2),c([X({context:P})],Y.prototype,"_context",2),Y=c([g("qti-assessment-item")],Y);var Bi=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"}},bt=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Bi(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 oe().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})],bt.prototype,"identifier",2),c([u({type:String})],bt.prototype,"href",2),bt=c([g("qti-assessment-stimulus-ref")],bt);var Gr=class extends v{};Gr=c([g("qti-companion-materials-info")],Gr);var Yt=class extends v{render(){return h`<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}),E()],Yt.prototype,"_context",2),Yt=c([g("qti-custom-operator")],Yt);var Jt=class extends G{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Jt.styles=x`
|
|
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([E()],w.prototype,"result",2),c([_({context:P,subscribe:!0}),E()],w.prototype,"context",2),c([_({context:Br,subscribe:!0}),E()],w.prototype,"qtiContext",2);var K=class extends w{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Sn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Xt=o=>{if(typeof o=="string")return o;let r=Sn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function zi(o){return o==null}function jr(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var G=class extends v{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=!zi(this.identifier)&&!zi(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"})],G.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],G.prototype,"outcomeIdentifier",2),c([u({type:String})],G.prototype,"identifier",2),c([u({type:String,attribute:!1})],G.prototype,"showStatus",2),c([_({context:P,subscribe:!0}),E()],G.prototype,"_context",2);var mo=class extends v{};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 b=(i-d)**2/m**2,y=(s-p)**2/h**2;return b+y<=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 Ui=o=>{class r extends o{constructor(...i){super(...i);this.testContext=Hi;this.sessionContext=Di;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=Hi,this.sessionContext=Di,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)})}_updateItemVariablesInTestContext(i,s){this.testContext={...this.testContext,items:this.testContext.items.map(n=>n.identifier!==i?n:{...n,variables:s.map(a=>{let l=n.variables.find(d=>d.identifier===a.identifier);return l?{...l,...a}:a})})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}}return c([u({attribute:!1,type:Object}),X({context:ne})],r.prototype,"testContext",2),c([u({attribute:!1,type:Object}),X({context:Ve})],r.prototype,"sessionContext",2),r},ho=class extends Ui(v){};var fo=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 Wr=class extends lo(co(fo(Ui(v)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return f`<slot></slot>`}};Wr=c([g("qti-test")],Wr);var go={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},xe=class extends v{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:go})],xe.prototype,"required",2),c([u({type:Boolean,converter:go})],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 Fi={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},qe=class extends v{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:Fi})],qe.prototype,"fixed",2),c([u({type:Boolean,converter:Fi})],qe.prototype,"visible",2),c([u({type:Boolean,converter:Fi,attribute:"keep-together"})],qe.prototype,"keepTogether",2),c([_({context:ne,subscribe:!0})],qe.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",qe);var Ze=class extends v{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})],Ze.prototype,"identifier",2),c([u({type:String})],Ze.prototype,"title",1),c([_({context:ne,subscribe:!0})],Ze.prototype,"_testContext",2),Ze=c([g("qti-assessment-test")],Ze);var Ce=class extends v{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([g("qti-test-part")],Ce);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ce);function Xr(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=[],b=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&h.push(M),h.push(...M.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&b.push(M),b.push(...M.querySelectorAll?.(o)??[])}));let y=q=>Array.from(new Set(q)),C=y(h),S=y(b);(C.length||S.length)&&n.call(this,C,S)},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 I(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 Y=class extends v{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:po};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([I("disabled",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],Y.prototype,"readonly",2),c([I("readonly",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleReadonlyChange",2),c([X({context:P})],Y.prototype,"_context",2),Y=c([g("qti-assessment-item")],Y);var Bi=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"}},gt=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Bi(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 oe().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})],gt.prototype,"identifier",2),c([u({type:String})],gt.prototype,"href",2),gt=c([g("qti-assessment-stimulus-ref")],gt);var Gr=class extends v{};Gr=c([g("qti-companion-materials-info")],Gr);var Gt=class extends v{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}),E()],Gt.prototype,"_context",2),Gt=c([g("qti-custom-operator")],Gt);var Yt=class extends G{render(){return f` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Yt.styles=x`
|
|
32
10
|
:host {
|
|
33
11
|
display: block;
|
|
34
12
|
}
|
|
@@ -38,21 +16,21 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
38
16
|
.off {
|
|
39
17
|
display: none;
|
|
40
18
|
}
|
|
41
|
-
`,
|
|
19
|
+
`,Yt=c([g("qti-feedback-block")],Yt);var ae=o=>o??R;var Jt=class extends G{constructor(){super(...arguments);this.render=()=>f` <slot part="feedback" class="${ae(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Jt.styles=x`
|
|
42
20
|
.on {
|
|
43
21
|
display: inline-block;
|
|
44
22
|
}
|
|
45
23
|
.off {
|
|
46
24
|
display: none;
|
|
47
25
|
}
|
|
48
|
-
`,
|
|
26
|
+
`,Jt=c([g("qti-feedback-inline")],Jt);var Qe=class extends G{render(){return f`
|
|
49
27
|
<dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
|
|
50
28
|
<slot></slot>
|
|
51
29
|
<div style="margin-top: var(--qti-gap-size); text-align: center;">
|
|
52
30
|
<button class="button close-button" @click="${this.closeFeedback}">Close</button>
|
|
53
31
|
</div>
|
|
54
32
|
</dialog>
|
|
55
|
-
`}openFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&!r.open&&r.showModal()}closeFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&r.open&&(r.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(r){r.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};
|
|
33
|
+
`}openFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&!r.open&&r.showModal()}closeFeedback(){let r=this.shadowRoot?.querySelector("dialog");r&&r.open&&(r.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(r){r.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};Qe.styles=x`
|
|
56
34
|
.qti-dialog {
|
|
57
35
|
background: var(--qti-bg);
|
|
58
36
|
border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
|
|
@@ -91,23 +69,23 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
91
69
|
.button:focus {
|
|
92
70
|
outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
|
|
93
71
|
}
|
|
94
|
-
`,
|
|
72
|
+
`,Qe=c([g("qti-modal-feedback")],Qe);var bo=x`
|
|
95
73
|
:host {
|
|
96
74
|
display: block;
|
|
97
75
|
}
|
|
98
|
-
`;var
|
|
76
|
+
`;var Kt=class extends v{render(){return f`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};Kt.styles=bo,Kt=c([g("qti-item-body")],Kt);var Yr=class extends v{render(){return f`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Yr=c([g("qti-prompt")],Yr);var Jr=class extends v{render(){return f`<slot></slot>`}};Jr=c([g("qti-content-body")],Jr);var le=class extends v{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{let t=new CustomEvent("qti-rubric:discretionary-placement",{detail:{className:e,element:this},bubbles:!0,composed:!0,cancelable:!0});if(!this.dispatchEvent(t))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return f`<slot></slot>`}};le.styles=x`
|
|
99
77
|
:host {
|
|
100
78
|
display: block;
|
|
101
79
|
}
|
|
102
|
-
`,c([u({type:String})],le.prototype,"id",2),c([u({type:String})],le.prototype,"use",2),c([u({type:String})],le.prototype,"view",2),c([u({type:String,attribute:"class"})],le.prototype,"classNames",2),c([I("classNames",{waitUntilFirstUpdate:!0})],le.prototype,"handleclassNamesChange",1),le=c([g("qti-rubric-block")],le);var Kr=class extends v{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let s=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};Kr=c([g("qti-stylesheet")],Kr);var Ee=class extends
|
|
80
|
+
`,c([u({type:String})],le.prototype,"id",2),c([u({type:String})],le.prototype,"use",2),c([u({type:String})],le.prototype,"view",2),c([u({type:String,attribute:"class"})],le.prototype,"classNames",2),c([I("classNames",{waitUntilFirstUpdate:!0})],le.prototype,"handleclassNamesChange",1),le=c([g("qti-rubric-block")],le);var Kr=class extends v{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let s=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};Kr=c([g("qti-stylesheet")],Kr);var Ee=class extends ft{render(){let r=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return f`${JSON.stringify(r,null,2)}`}connectedCallback(){super.connectedCallback();let r=this.defaultValues(this.cardinality),e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,defaultValue:r,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};e.value=r,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let r,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)r=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){r=[];for(let i=0;i<t.length;i++)r.push(t[i].textContent.trim()),t[i].remove()}}return r}get mapping(){let r=this.querySelector("qti-mapping"),e=parseFloat(r?.getAttribute("lower-bound")),t=parseFloat(r?.getAttribute("upper-bound"));return{defaultValue:Number(r?.getAttribute("default-value"))||0,lowerBound:isNaN(e)?null:e,upperBound:isNaN(t)?null:t,mapEntries:Array.from(r?.querySelectorAll("qti-map-entry")||[]).map(s=>({mapKey:s.getAttribute("map-key")||"",mappedValue:Number(s.getAttribute("mapped-value"))||0,caseSensitive:s.hasAttribute("case-sensitive")?s.getAttribute("case-sensitive")!=="false":!1}))}}get areaMapping(){let r=this.querySelector("qti-area-mapping"),e=Number(r?.getAttribute("default-value"))||0,t=parseFloat(r?.getAttribute("lower-bound")),i=parseFloat(r?.getAttribute("upper-bound")),s=Array.from(r?.querySelectorAll("qti-area-map-entry")||[]).map(n=>({shape:n.getAttribute("shape")||"default",coords:n.getAttribute("coords")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,defaultValue:Number(n.getAttribute("default-value"))||0}));return{defaultValue:e,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,areaMapEntries:s}}};Ee.styles=[x`
|
|
103
81
|
:host {
|
|
104
82
|
display: none;
|
|
105
83
|
}
|
|
106
|
-
`],c([u({type:String,attribute:"base-type"})],Ee.prototype,"baseType",2),c([u({type:String})],Ee.prototype,"identifier",2),c([u({type:String})],Ee.prototype,"cardinality",2),c([_({context:P,subscribe:!0}),E()],Ee.prototype,"itemContext",2),Ee=c([g("qti-response-declaration")],Ee);var ce=class extends
|
|
84
|
+
`],c([u({type:String,attribute:"base-type"})],Ee.prototype,"baseType",2),c([u({type:String})],Ee.prototype,"identifier",2),c([u({type:String})],Ee.prototype,"cardinality",2),c([_({context:P,subscribe:!0}),E()],Ee.prototype,"itemContext",2),Ee=c([g("qti-response-declaration")],Ee);var ce=class extends ft{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}}))}};ce.styles=[x`
|
|
107
85
|
:host {
|
|
108
86
|
display: none;
|
|
109
87
|
}
|
|
110
|
-
`],c([u({type:String,attribute:"base-type"})],ce.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],ce.prototype,"externalScored",2),c([u({type:String})],ce.prototype,"identifier",2),c([u({type:String})],ce.prototype,"cardinality",2),c([_({context:P,subscribe:!0}),E()],ce.prototype,"itemContext",2),ce=c([g("qti-outcome-declaration")],ce);var
|
|
88
|
+
`],c([u({type:String,attribute:"base-type"})],ce.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],ce.prototype,"externalScored",2),c([u({type:String})],ce.prototype,"identifier",2),c([u({type:String})],ce.prototype,"cardinality",2),c([_({context:P,subscribe:!0}),E()],ce.prototype,"itemContext",2),ce=c([g("qti-outcome-declaration")],ce);var vo=`<qti-response-processing>
|
|
111
89
|
<qti-response-condition>
|
|
112
90
|
<qti-response-if>
|
|
113
91
|
<qti-match>
|
|
@@ -124,7 +102,7 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
124
102
|
</qti-set-outcome-value>
|
|
125
103
|
</qti-response-else>
|
|
126
104
|
</qti-response-condition>
|
|
127
|
-
</qti-response-processing>`,
|
|
105
|
+
</qti-response-processing>`,yo=`<qti-response-processing>
|
|
128
106
|
<qti-response-condition>
|
|
129
107
|
<qti-response-if>
|
|
130
108
|
<qti-is-null>
|
|
@@ -140,7 +118,7 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
140
118
|
</qti-set-outcome-value>
|
|
141
119
|
</qti-response-else>
|
|
142
120
|
</qti-response-condition>
|
|
143
|
-
</qti-response-processing>`,
|
|
121
|
+
</qti-response-processing>`,xo=`<qti-response-processing>
|
|
144
122
|
<qti-response-condition>
|
|
145
123
|
<qti-response-if>
|
|
146
124
|
<qti-is-null>
|
|
@@ -156,76 +134,76 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
156
134
|
</qti-set-outcome-value>
|
|
157
135
|
</qti-response-else>
|
|
158
136
|
</qti-response-condition>
|
|
159
|
-
</qti-response-processing>`;var
|
|
137
|
+
</qti-response-processing>`;var Zt=class extends v{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(yo).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(xo).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(vo).firstElementChild.firstElementChild);break}}}fragmentFromString(r){return document.createRange().createContextualFragment(r)}};Zt.styles=[x`
|
|
160
138
|
:host {
|
|
161
139
|
display: none;
|
|
162
140
|
}
|
|
163
|
-
`],
|
|
141
|
+
`],Zt=c([g("qti-response-processing")],Zt);var Qt=class extends Qe{render(){return f``}};Qt.styles=x`
|
|
164
142
|
:host {
|
|
165
143
|
color: gray;
|
|
166
144
|
}
|
|
167
|
-
`,
|
|
145
|
+
`,Qt=c([g("qti-test-feedback")],Qt);var Z=class extends v{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(y=>y.querySelector("qti-correct-response")),m=Array.from(d).some(y=>{let C=y.querySelector("qti-mapping"),S=y.querySelector("qti-area-mapping");return C?.querySelector("qti-map-entry")||S?.querySelector("qti-area-map-entry")}),h=p||m,b=!!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:b}})}))}))}}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(T=>T.identifier===n.identifier),l={...n,...a,...this.initContext?.find(T=>T.identifier===n.identifier)},d=l.variables?.find(T=>T.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=l.variables?.find(T=>T.identifier==="completionStatus")?.value,h=l.variables?.find(T=>T.identifier==="RESPONSE")?.value||"",b=l.variables?.find(T=>T.identifier==="numAttempts")?.value||0,y=this._sessionContext?.navItemRefId===l.identifier||!1,C=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,S=n.variables?.find(T=>T.identifier=="MAXSCORE")?.value,q=S==null?null:parseFloat(S?.toString());return{...l,completionStatus:m,numAttempts:b,score:p,response:h,index:C,active:y,maxScore:q}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};c([u({type:String})],Z.prototype,"identifier",2),c([E()],Z.prototype,"initContext",2),c([E(),X({context:Br})],Z.prototype,"qtiContext",2),c([E(),X({context:J})],Z.prototype,"configContext",2),c([E(),_({context:ne,subscribe:!0})],Z.prototype,"_testContext",2),c([E(),_({context:Ve,subscribe:!0})],Z.prototype,"_sessionContext",2),c([E(),X({context:$})],Z.prototype,"computedContext",2),c([u({type:Boolean,attribute:"auto-score-items"})],Z.prototype,"autoScoreItems",2),Z=c([g("test-navigation")],Z);var qo=x`
|
|
168
146
|
display: inline-flex;
|
|
169
147
|
align-items: center;
|
|
170
148
|
cursor: pointer;
|
|
171
149
|
padding: 0.5rem 1rem;
|
|
172
150
|
border-radius: 0.25rem;
|
|
173
151
|
user-select: none;
|
|
174
|
-
`,
|
|
152
|
+
`,F=x`
|
|
175
153
|
background-color: lightgray;
|
|
176
|
-
${
|
|
154
|
+
${qo};
|
|
177
155
|
`,B=x`
|
|
178
156
|
cursor: not-allowed;
|
|
179
157
|
opacity: 0.8;
|
|
180
|
-
`,
|
|
181
|
-
${
|
|
158
|
+
`,pm=x`
|
|
159
|
+
${qo};
|
|
182
160
|
border: 1px solid gray;
|
|
183
|
-
`;var Oe=class extends v{constructor(){super();this._internalDisabled=!0;this._internals=this.attachInternals(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex+1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}connectedCallback(){super.connectedCallback(),this.checkDisabled()}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex<0||this.itemIndex>=this.sectionItems?.length-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return
|
|
161
|
+
`;var Oe=class extends v{constructor(){super();this._internalDisabled=!0;this._internals=this.attachInternals(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex+1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}connectedCallback(){super.connectedCallback(),this.checkDisabled()}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex<0||this.itemIndex>=this.sectionItems?.length-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return f`<slot></slot>`}};Oe.styles=x`
|
|
184
162
|
:host {
|
|
185
|
-
${
|
|
163
|
+
${F};
|
|
186
164
|
}
|
|
187
165
|
:host([disabled]) {
|
|
188
166
|
${B};
|
|
189
167
|
}
|
|
190
|
-
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Oe.prototype,"_internalDisabled",2),c([_({context:$,subscribe:!0})],Oe.prototype,"computedContext",2),c([I("computedContext")],Oe.prototype,"_handleTestElementChange",1),Oe=c([g("test-next")],Oe);var
|
|
168
|
+
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Oe.prototype,"_internalDisabled",2),c([_({context:$,subscribe:!0})],Oe.prototype,"computedContext",2),c([I("computedContext")],Oe.prototype,"_handleTestElementChange",1),Oe=c([g("test-next")],Oe);var Ne=class extends v{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>`}};Ne.styles=x`
|
|
191
169
|
:host {
|
|
192
|
-
${
|
|
170
|
+
${F};
|
|
193
171
|
}
|
|
194
172
|
:host([disabled]) {
|
|
195
173
|
${B};
|
|
196
174
|
}
|
|
197
|
-
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],
|
|
175
|
+
`,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Ne.prototype,"_internalDisabled",2),c([_({context:$,subscribe:!0})],Ne.prototype,"computedContext",2),c([I("computedContext")],Ne.prototype,"_handleTestElementChange",1),Ne=c([g("test-prev")],Ne);var j=class extends v{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`
|
|
198
176
|
<label part="label" for="viewSelect">${this.label}</label>
|
|
199
177
|
<select
|
|
200
178
|
part="select"
|
|
201
179
|
id="viewSelect"
|
|
202
180
|
@change=${e=>{let t=e.target;this._switchView(t.value)}}
|
|
203
181
|
>
|
|
204
|
-
${this._viewOptions.map(e=>
|
|
182
|
+
${this._viewOptions.map(e=>f`<option value="${e}" ?selected=${e===this.sessionContext.view}>${e}</option>`)}
|
|
205
183
|
</select>
|
|
206
|
-
`}};j.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([_({context:Ve,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([I("viewOptions",{waitUntilFirstUpdate:!0})],j.prototype,"_handleViewOptionsChange",2),c([E()],j.prototype,"_viewOptions",2),j=c([g("test-view")],j);var
|
|
184
|
+
`}};j.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([_({context:Ve,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([I("viewOptions",{waitUntilFirstUpdate:!0})],j.prototype,"_handleViewOptionsChange",2),c([E()],j.prototype,"_viewOptions",2),j=c([g("test-view")],j);var bt=class extends v{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> `}};bt.styles=x`
|
|
207
185
|
:host {
|
|
208
|
-
${
|
|
186
|
+
${F};
|
|
209
187
|
}
|
|
210
188
|
:host([disabled]) {
|
|
211
189
|
${B};
|
|
212
190
|
}
|
|
213
|
-
`,c([u({type:String,attribute:"item-id"})],
|
|
191
|
+
`,c([u({type:String,attribute:"item-id"})],bt.prototype,"itemId",2),bt=c([g("test-item-link")],bt);var er=class extends v{constructor(){super(),this.addEventListener("click",()=>this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})))}render(){return f` <slot></slot> `}};er.styles=x`
|
|
214
192
|
:host {
|
|
215
|
-
${
|
|
193
|
+
${F};
|
|
216
194
|
}
|
|
217
195
|
:host([disabled]) {
|
|
218
196
|
${B};
|
|
219
197
|
}
|
|
220
|
-
`,
|
|
198
|
+
`,er=c([g("test-end-attempt")],er);var ee=class extends v{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"}willUpdate(e){let t=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(s=>s.items)).find(i=>i.active);if(this._previousActiveItem!==t&&(this.shown=!1,this._previousActiveItem=t),t){let i=!!t?.variables?.some(n=>n.correctResponse),s=!!t?.variables?.some(n=>n.mapping?.mapEntries?.length>0||n.areaMapping?.areaMapEntries?.length>0);this.disabled=!i&&!s}else this.disabled=!0}_toggleState(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-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> `}};ee.styles=x`
|
|
221
199
|
:host {
|
|
222
|
-
${
|
|
200
|
+
${F};
|
|
223
201
|
}
|
|
224
202
|
:host([disabled]) {
|
|
225
203
|
${B};
|
|
226
204
|
}
|
|
227
|
-
`,c([_({context:$,subscribe:!0})],ee.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"disabled",2),c([u({type:String})],ee.prototype,"showCorrectText",2),c([u({type:String})],ee.prototype,"hideCorrectText",2),c([u({type:String})],ee.prototype,"noCorrectResponseText",2),ee=c([g("test-show-correct-response")],ee);var Zr=["this"],
|
|
228
|
-
`;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),ei=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;Mn(this.#t);)this.#e(!0);if($n(this.#t))return this.#l();if(Co(this.#t))return this.#d();if(rr(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(Pn(this.#t))return this.#h();if(Vn(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=de(S.STRING,On(this.#r()));return this.#e(),t}#d(){do this.#e();while(In(this.#t));let r=this.#r(),e=Ln(r)?S.KEYWORD:S.IDENTIFIER;return de(e,r)}#p(){do this.#e();while(rr(this.#t));return this.#t===46?this.#a():de(S.INTEGER,this.#r())}#a(){return this.#e(),rr(this.#t)?this.#m():(this.#o(),de(S.DOT,".",Qr))}#u(){return this.#e(!0),de(S.COMMA,",")}#c(){return this.#e(!0),de(S.COLON,":")}#m(){do this.#e();while(rr(this.#t));return de(S.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if(kn.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),de(S.ARROW,r);Rn.indexOf(r)!==-1&&this.#e()}return r=this.#r(),de(S.OPERATOR,r,ji[r])}#f(){let r=String.fromCharCode(this.#t),e=de(S.GROUPER,r,ji[r]);return this.#e(!0),e}};var Wi=(o,r)=>new ir(o,r).parse(),ir=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new ei(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(S.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(S.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(S.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(S.KEYWORD))break;if(this._matches(S.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(qo.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===S.OPERATOR||this.#s===S.DOT||this.#s===S.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(S.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(S.INTEGER))return this.#b(r);if(this._matches(S.DECIMAL))return this.#v(r)}if(xo.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),Qr);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(S.OPERATOR,"?");let e=this.#o();this.#r(S.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case S.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw Zr.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case S.IDENTIFIER:return this.#f();case S.STRING:return this.#C();case S.INTEGER:return this.#b();case S.DECIMAL:return this.#v();case S.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case S.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(S.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(S.COMMA));return this.#r(S.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(S.GROUPER,"}"))break;let e=this.#e;(this._matches(S.STRING)||this._matches(S.IDENTIFIER))&&this.#r(),this.#r(S.COLON),r[e]=this.#o()}while(this._matches(S.COMMA));return this.#r(S.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(S.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(S.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(S.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(S.COMMA));return this.#r(S.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(S.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(S.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:Eo,fromEntries:Dn}=Object,Nn={"+":(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)},Hn={"+":o=>o,"-":o=>-o,"!":o=>!o},ti=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=Hn[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=Nn[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=Dn(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return Eo(a,p)&&(a[p]=m),d[p]=m},get(d,p){return Eo(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var Xi=null,wo={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){Xi??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Xi))return void(e[Xi]=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=V;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:zn,PropertyPart:Fn,BooleanAttributePart:Un,EventPart:Bn}=wo,Yi=new ti,Gi=new Map,_o=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ri=(o,r)=>{let e=Gi.get(o);if(e===void 0){if(Gi.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new ir(t,Yi).parse(),Gi.set(o,e)}}return e?.evaluate(r)},jn=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ri(i,r))return ii(o,r,e,t)},To=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,Ao=o=>/(?:\\{{)|(?:\\}})/g.test(o),sr=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Wn=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ri(i,r);if(!s[Symbol.iterator])return k;let n=or(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 b of n.parts){let y=b.update(p,e,t);b.type===1?m.push(...y):m.push(y)}let f={_$litType$:n,values:m};l.push(f)}return l}},Ro={if:jn,repeat:Wn},pe=(o,r=Ro,e={},t)=>{let s=or(o).renderers;if(t){let a=or(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(f,b,y)=>ii(t,f,b,y)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>ii(o,n,r,e)};var ii=(o,r,e=Ro,t={})=>{let i=or(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}},So=new Map,or=o=>{let r=So.get(o);return r===void 0&&So.set(o,r=Xn(o)),r},Xn=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 f=p.trim(),b=f.startsWith("{{")&&f.endsWith("}}");m=(y,C,A)=>{let q=n.getAttribute("data"),T=q===null?void 0:ri(q,y);return(b?ri(f,y):A[p])?.(T,C,A)}}else l!==null?m=(f,b,y)=>{let C=b[l];return C?.(n,f,b,y)}:(d==="super"?r.renderers.super=(f,b,y)=>{let C=y.super,A=or(n);return y={...y,...A.renderers},C(f,b,y)}:r.renderers[d]=(f,b,y)=>ii(n,f,b,y),m=(f,b,y)=>{let C=y[d];return C?.(f,b,y)});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(To);if(p.length===1){Ao(d)&&n.setAttribute(l,sr(d));continue}n.removeAttribute(l);let m=l,f=zn,b=l[0];b==="."?(m=_o(l.substring(1)),f=Fn):b==="?"?(m=l.substring(1),f=Un):b==="@"&&(m=_o(l.substring(1)),f=Bn);let y=[sr(p[0])],C=[];for(let A=1;A<p.length;A+=2){let q=p[A];C.push(Wi(q,Yi)),y.push(sr(p[A+1]))}r.parts.push({type:1,index:i,name:m,strings:y,ctor:f,update:(A,q,T)=>C.map(M=>M.evaluate(A))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(To);l.length>1?n.textContent=sr(l[0]):Ao(a)&&(n.textContent=sr(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=Wi(p,Yi);r.parts.push({type:2,index:++i,update:(b,y)=>m.evaluate(b)});let f=new Text(l[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(f,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=f,e.currentNode=f}}for(let n of s)n.remove();return r};var nr=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=pe(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections.flatMap(t=>t.items));return h` ${r.map(e=>this.myTemplate({item:e,view:this.computedContext.view}))} `}};c([_({context:$,subscribe:!0})],nr.prototype,"computedContext",2),nr=c([g("test-paging-buttons-stamp")],nr);var{I:Gn}=H,Mo=o=>o===null||typeof o!="object"&&typeof o!="function";var Io=o=>o.strings===void 0,ko=()=>document.createComment(""),yt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(ko(),i),n=t.insertBefore(ko(),i);e=new Gn(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},Ne=(o,r,e=o)=>(o._$AI(r,e),o),Yn={},Lo=(o,r=Yn)=>o._$AH=r,$o=o=>o._$AH,si=o=>{o._$AR(),o._$AA.remove()};var He={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},te=o=>(...r)=>({_$litDirective$:o,values:r}),ue=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 ar=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),ar(t,r);return!0},oi=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},Po=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),Zn(r)}};function Jn(o){this._$AN!==void 0?(oi(this),this._$AM=o,Po(this)):this._$AM=o}function Kn(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++)ar(t[s],!1),oi(t[s]);else t!=null&&(ar(t,!1),oi(t));else ar(this,o)}var Zn=o=>{o.type==He.CHILD&&(o._$AP??=Kn,o._$AQ??=Jn)},xt=class extends ue{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),Po(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(ar(this,r),oi(this))}setValue(r){if(Io(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 ni=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},ai=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 Vo=o=>!Mo(o)&&typeof o.then=="function",Oo=1073741823,Ji=class extends xt{constructor(){super(...arguments),this._$Cwt=Oo,this._$Cbt=[],this._$CK=new ni(this),this._$CX=new ai}render(...r){return r.find((e=>!Vo(e)))??V}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(!Vo(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Oo,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 V}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},li=te(Ji);var ci=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
|
|
205
|
+
`,c([_({context:$,subscribe:!0})],ee.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"disabled",2),c([u({type:String})],ee.prototype,"showCorrectText",2),c([u({type:String})],ee.prototype,"hideCorrectText",2),c([u({type:String})],ee.prototype,"noCorrectResponseText",2),ee=c([g("test-show-correct-response")],ee);var Zr=["this"],Co=["+","-","!"],Eo=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],ji={"!":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},Qr=13;var kn=["==","!=","<=",">=","||","&&","??","|>"],Rn=["===","!=="],A;(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"})(A||(A={}));var de=(o,r,e=0)=>({kind:o,value:r,precedence:e}),Mn=o=>o===9||o===10||o===13||o===32,wo=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),In=o=>wo(o)||tr(o),Ln=o=>Zr.indexOf(o)!==-1,$n=o=>o===34||o===39,tr=o=>48<=o&&o<=57,Pn=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,Vn=o=>o===40||o===41||o===91||o===93||o===123||o===125,On=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}}),ei=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;Mn(this.#t);)this.#e(!0);if($n(this.#t))return this.#l();if(wo(this.#t))return this.#d();if(tr(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(Pn(this.#t))return this.#h();if(Vn(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=de(A.STRING,On(this.#r()));return this.#e(),t}#d(){do this.#e();while(In(this.#t));let r=this.#r(),e=Ln(r)?A.KEYWORD:A.IDENTIFIER;return de(e,r)}#p(){do this.#e();while(tr(this.#t));return this.#t===46?this.#a():de(A.INTEGER,this.#r())}#a(){return this.#e(),tr(this.#t)?this.#m():(this.#o(),de(A.DOT,".",Qr))}#u(){return this.#e(!0),de(A.COMMA,",")}#c(){return this.#e(!0),de(A.COLON,":")}#m(){do this.#e();while(tr(this.#t));return de(A.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if(Rn.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),de(A.ARROW,r);kn.indexOf(r)!==-1&&this.#e()}return r=this.#r(),de(A.OPERATOR,r,ji[r])}#f(){let r=String.fromCharCode(this.#t),e=de(A.GROUPER,r,ji[r]);return this.#e(!0),e}};var Wi=(o,r)=>new rr(o,r).parse(),rr=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new ei(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(A.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(A.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(A.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(A.KEYWORD))break;if(this._matches(A.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(Eo.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===A.OPERATOR||this.#s===A.DOT||this.#s===A.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(A.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(A.INTEGER))return this.#b(r);if(this._matches(A.DECIMAL))return this.#v(r)}if(Co.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),Qr);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(A.OPERATOR,"?");let e=this.#o();this.#r(A.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case A.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw Zr.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case A.IDENTIFIER:return this.#f();case A.STRING:return this.#C();case A.INTEGER:return this.#b();case A.DECIMAL:return this.#v();case A.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case A.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(A.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(A.COMMA));return this.#r(A.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(A.GROUPER,"}"))break;let e=this.#e;(this._matches(A.STRING)||this._matches(A.IDENTIFIER))&&this.#r(),this.#r(A.COLON),r[e]=this.#o()}while(this._matches(A.COMMA));return this.#r(A.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(A.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(A.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(A.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(A.COMMA));return this.#r(A.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(A.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(A.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:_o,fromEntries:Nn}=Object,Dn={"+":(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)},Hn={"+":o=>o,"-":o=>-o,"!":o=>!o},ti=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=Hn[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=Dn[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=Nn(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return _o(a,p)&&(a[p]=m),d[p]=m},get(d,p){return _o(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var Xi=null,To={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){Xi??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Xi))return void(e[Xi]=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=V;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:zn,PropertyPart:Un,BooleanAttributePart:Fn,EventPart:Bn}=To,Yi=new ti,Gi=new Map,Ao=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ri=(o,r)=>{let e=Gi.get(o);if(e===void 0){if(Gi.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new rr(t,Yi).parse(),Gi.set(o,e)}}return e?.evaluate(r)},jn=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ri(i,r))return ii(o,r,e,t)},So=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,ko=o=>/(?:\\{{)|(?:\\}})/g.test(o),ir=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Wn=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ri(i,r);if(!s[Symbol.iterator])return R;let n=sr(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 b of n.parts){let y=b.update(p,e,t);b.type===1?m.push(...y):m.push(y)}let h={_$litType$:n,values:m};l.push(h)}return l}},Mo={if:jn,repeat:Wn},pe=(o,r=Mo,e={},t)=>{let s=sr(o).renderers;if(t){let a=sr(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(h,b,y)=>ii(t,h,b,y)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>ii(o,n,r,e)};var ii=(o,r,e=Mo,t={})=>{let i=sr(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}},Ro=new Map,sr=o=>{let r=Ro.get(o);return r===void 0&&Ro.set(o,r=Xn(o)),r},Xn=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(),b=h.startsWith("{{")&&h.endsWith("}}");m=(y,C,S)=>{let q=n.getAttribute("data"),T=q===null?void 0:ri(q,y);return(b?ri(h,y):S[p])?.(T,C,S)}}else l!==null?m=(h,b,y)=>{let C=b[l];return C?.(n,h,b,y)}:(d==="super"?r.renderers.super=(h,b,y)=>{let C=y.super,S=sr(n);return y={...y,...S.renderers},C(h,b,y)}:r.renderers[d]=(h,b,y)=>ii(n,h,b,y),m=(h,b,y)=>{let C=y[d];return C?.(h,b,y)});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(So);if(p.length===1){ko(d)&&n.setAttribute(l,ir(d));continue}n.removeAttribute(l);let m=l,h=zn,b=l[0];b==="."?(m=Ao(l.substring(1)),h=Un):b==="?"?(m=l.substring(1),h=Fn):b==="@"&&(m=Ao(l.substring(1)),h=Bn);let y=[ir(p[0])],C=[];for(let S=1;S<p.length;S+=2){let q=p[S];C.push(Wi(q,Yi)),y.push(ir(p[S+1]))}r.parts.push({type:1,index:i,name:m,strings:y,ctor:h,update:(S,q,T)=>C.map(M=>M.evaluate(S))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(So);l.length>1?n.textContent=ir(l[0]):ko(a)&&(n.textContent=ir(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=Wi(p,Yi);r.parts.push({type:2,index:++i,update:(b,y)=>m.evaluate(b)});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 or=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=pe(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})],or.prototype,"computedContext",2),or=c([g("test-paging-buttons-stamp")],or);var{I:Gn}=H,Lo=o=>o===null||typeof o!="object"&&typeof o!="function";var $o=o=>o.strings===void 0,Io=()=>document.createComment(""),vt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(Io(),i),n=t.insertBefore(Io(),i);e=new Gn(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},De=(o,r,e=o)=>(o._$AI(r,e),o),Yn={},Po=(o,r=Yn)=>o._$AH=r,Vo=o=>o._$AH,si=o=>{o._$AR(),o._$AA.remove()};var He={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},te=o=>(...r)=>({_$litDirective$:o,values:r}),ue=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 nr=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),nr(t,r);return!0},oi=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},Oo=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),Zn(r)}};function Jn(o){this._$AN!==void 0?(oi(this),this._$AM=o,Oo(this)):this._$AM=o}function Kn(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++)nr(t[s],!1),oi(t[s]);else t!=null&&(nr(t,!1),oi(t));else nr(this,o)}var Zn=o=>{o.type==He.CHILD&&(o._$AP??=Kn,o._$AQ??=Jn)},yt=class extends ue{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),Oo(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(nr(this,r),oi(this))}setValue(r){if($o(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 ni=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},ai=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 No=o=>!Lo(o)&&typeof o.then=="function",Do=1073741823,Ji=class extends yt{constructor(){super(...arguments),this._$Cwt=Do,this._$Cbt=[],this._$CK=new ni(this),this._$CX=new ai}render(...r){return r.find((e=>!No(e)))??V}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(!No(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Do,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 V}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},li=te(Ji);var ci=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
|
|
229
207
|
|
|
230
208
|
:root,
|
|
231
209
|
:host {
|
|
@@ -2045,8 +2023,6 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
2045
2023
|
text-orientation: upright;
|
|
2046
2024
|
}
|
|
2047
2025
|
|
|
2048
|
-
/* stylelint-disable number-max-precision */
|
|
2049
|
-
|
|
2050
2026
|
@layer qti-base {
|
|
2051
2027
|
.qti-layout-row {
|
|
2052
2028
|
display: flex;
|
|
@@ -2339,7 +2315,6 @@ qti-response-declaration {
|
|
|
2339
2315
|
}
|
|
2340
2316
|
}
|
|
2341
2317
|
|
|
2342
|
-
/* stylelint-disable-next-line no-descending-specificity */
|
|
2343
2318
|
& qti-simple-choice {
|
|
2344
2319
|
width: -moz-fit-content;
|
|
2345
2320
|
width: fit-content;
|
|
@@ -2348,7 +2323,6 @@ qti-response-declaration {
|
|
|
2348
2323
|
/* Keep the checkmark for non-hidden input controls */
|
|
2349
2324
|
&:state(correct-response),
|
|
2350
2325
|
&[data-correct-response='true'] {
|
|
2351
|
-
/* stylelint-disable-next-line no-descending-specificity */
|
|
2352
2326
|
&::after {
|
|
2353
2327
|
content: '\\02714';
|
|
2354
2328
|
color: var(--qti-correct);
|
|
@@ -2594,7 +2568,7 @@ qti-response-declaration {
|
|
|
2594
2568
|
&:focus {
|
|
2595
2569
|
box-shadow: 0 0 0 var(--qti-focus-border-width) var(--qti-focus-color);
|
|
2596
2570
|
}
|
|
2597
|
-
|
|
2571
|
+
|
|
2598
2572
|
&:state(candidate-correct) {
|
|
2599
2573
|
background-color: var(--qti-correct);
|
|
2600
2574
|
}
|
|
@@ -3967,11 +3941,11 @@ div.full-correct-response-inline {
|
|
|
3967
3941
|
margin-right: var(--qti-padding-horizontal);
|
|
3968
3942
|
padding: 0.2rem;
|
|
3969
3943
|
}
|
|
3970
|
-
`;var we=class extends v{constructor(){super(...arguments);this.testURL=null;this.testDoc=null;this.testXML=null;this.templateContent=null}async handleTestURLChange(){if(this.testURL)try{let e=await
|
|
3944
|
+
`;var we=class extends v{constructor(){super(...arguments);this.testURL=null;this.testDoc=null;this.testXML=null;this.templateContent=null}async handleTestURLChange(){if(this.testURL)try{let e=await ut().load(this.testURL),t=this.closest("qti-test");if(t?.postLoadTestTransformCallback){let s=e.htmlDoc().querySelector("qti-assessment-test");s&&(e=await t.postLoadTestTransformCallback(e,s))}this.testDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleTestXMLChange(){if(this.testXML)try{this.testDoc=ut().parse(this.testXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),this.initializeTemplateContent(),this.applyStyles(),this.testURL&&this.handleTestURLChange(),this.testXML&&this.handleTestXMLChange()}initializeTemplateContent(){let e=this.querySelector("template");this.templateContent=e?e.content:f``}applyStyles(){let e=new CSSStyleSheet;e.replaceSync(ci),this.shadowRoot.adoptedStyleSheets=[e]}render(){return f`
|
|
3971
3945
|
${this.templateContent}
|
|
3972
3946
|
<slot></slot>
|
|
3973
|
-
${li(this.testDoc,
|
|
3974
|
-
`}};c([u({type:String,attribute:"test-url"})],we.prototype,"testURL",2),c([E()],we.prototype,"testDoc",2),c([E()],we.prototype,"testXML",2),c([I("testURL",{waitUntilFirstUpdate:!0})],we.prototype,"handleTestURLChange",1),c([I("testXML",{waitUntilFirstUpdate:!0})],we.prototype,"handleTestXMLChange",1),we=c([g("test-container")],we);var
|
|
3947
|
+
${li(this.testDoc,f`<span>Loading...</span>`)}
|
|
3948
|
+
`}};c([u({type:String,attribute:"test-url"})],we.prototype,"testURL",2),c([E()],we.prototype,"testDoc",2),c([E()],we.prototype,"testXML",2),c([I("testURL",{waitUntilFirstUpdate:!0})],we.prototype,"handleTestURLChange",1),c([I("testXML",{waitUntilFirstUpdate:!0})],we.prototype,"handleTestXMLChange",1),we=c([g("test-container")],we);var xt=class extends v{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`
|
|
3975
3949
|
<h3>${n}</h3>
|
|
3976
3950
|
<table>
|
|
3977
3951
|
<thead>
|
|
@@ -3984,7 +3958,7 @@ div.full-correct-response-inline {
|
|
|
3984
3958
|
</tr>
|
|
3985
3959
|
</thead>
|
|
3986
3960
|
<tbody>
|
|
3987
|
-
${s.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return
|
|
3961
|
+
${s.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return f`
|
|
3988
3962
|
<tr>
|
|
3989
3963
|
<td>${a.identifier}</td>
|
|
3990
3964
|
<td>${Array.isArray(a.value)?a.value.join(", "):a.value}</td>
|
|
@@ -3995,9 +3969,9 @@ div.full-correct-response-inline {
|
|
|
3995
3969
|
`})}
|
|
3996
3970
|
</tbody>
|
|
3997
3971
|
</table>
|
|
3998
|
-
`;return
|
|
3972
|
+
`;return f`
|
|
3999
3973
|
${i(e,"Response Variables")} ${i(t,"Outcome Variables")}
|
|
4000
|
-
`}};
|
|
3974
|
+
`}};xt.styles=x`
|
|
4001
3975
|
table {
|
|
4002
3976
|
width: 100%;
|
|
4003
3977
|
border-collapse: collapse;
|
|
@@ -4018,37 +3992,37 @@ div.full-correct-response-inline {
|
|
|
4018
3992
|
margin-top: 20px;
|
|
4019
3993
|
font-size: 16px;
|
|
4020
3994
|
}
|
|
4021
|
-
`,c([_({context:$,subscribe:!0})],
|
|
3995
|
+
`,c([_({context:$,subscribe:!0})],xt.prototype,"computedContext",2),xt=c([g("test-print-item-variables")],xt);var ar=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=pe(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([_({context:$,subscribe:!0})],ar.prototype,"computedContext",2),ar=c([g("test-section-buttons-stamp")],ar);var qt=class extends v{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> `}};qt.styles=x`
|
|
4022
3996
|
:host {
|
|
4023
|
-
${
|
|
3997
|
+
${F};
|
|
4024
3998
|
}
|
|
4025
3999
|
:host([disabled]) {
|
|
4026
4000
|
${B};
|
|
4027
4001
|
}
|
|
4028
|
-
`,c([u({type:String,attribute:"section-id"})],
|
|
4029
|
-
${this.myTemplate?this.myTemplate(this.stampContext):
|
|
4002
|
+
`,c([u({type:String,attribute:"section-id"})],qt.prototype,"sectionId",2),qt=c([g("test-section-link")],qt);var lr=class extends v{render(){return f` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([E(),_({context:$,subscribe:!0})],lr.prototype,"computedContext",2),lr=c([g("test-print-context")],lr);var tt=class extends v{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=pe(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:b,...y})=>y)),sections:t.sections.map(h=>({...h,items:h.items.map(({variables:b,...y})=>y)}))},d={...i,items:i.items.map(({variables:h,...b})=>b)},{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>`:R}
|
|
4003
|
+
${this.myTemplate?this.myTemplate(this.stampContext):R}`}};c([u({type:Boolean,reflect:!0})],tt.prototype,"debug",2),c([E(),_({context:$,subscribe:!0})],tt.prototype,"computedContext",2),c([E()],tt.prototype,"stampContext",2),tt=c([g("test-stamp")],tt);var rt=class extends v{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=pe(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 R;let a=[...Array(Number(t)+1).keys()];return f`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):R}`}};c([u({type:String,attribute:"view"})],rt.prototype,"view",2),c([u({type:Boolean})],rt.prototype,"disabled",2),c([_({context:$,subscribe:!0})],rt.prototype,"computedContext",2),rt=c([g("test-scoring-buttons")],rt);var cr=class extends v{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=pe(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}):R}`}};c([_({context:Ve,subscribe:!0})],cr.prototype,"sessionContext",2),cr=c([g("test-view-toggle")],cr);var Ct=class extends v{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([_({context:$,subscribe:!0})],Ct.prototype,"computedContext",2),c([u({type:String,attribute:"view"})],Ct.prototype,"view",2),Ct=c([g("test-scoring-feedback")],Ct);var dr=class extends v{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> `}};dr.styles=x`
|
|
4030
4004
|
:host {
|
|
4031
|
-
${
|
|
4005
|
+
${F};
|
|
4032
4006
|
}
|
|
4033
4007
|
:host([disabled]) {
|
|
4034
4008
|
${B};
|
|
4035
4009
|
}
|
|
4036
|
-
`,
|
|
4010
|
+
`,dr=c([g("test-check-item")],dr);var _e=class extends v{constructor(){super(...arguments);this.itemURL=null;this.itemDoc=null;this.itemXML=null;this.templateContent=null}async handleItemURLChange(){if(this.itemURL)try{let e=await oe().load(this.itemURL);this.itemDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=oe().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),this.initializeTemplateContent(),this.applyStyles(),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}initializeTemplateContent(){let e=this.querySelector("template");this.templateContent=e?e.content:f``}applyStyles(){let e=new CSSStyleSheet;e.replaceSync(ci),this.shadowRoot.adoptedStyleSheets=[e]}render(){return f`
|
|
4037
4011
|
${this.templateContent}
|
|
4038
4012
|
<slot></slot>
|
|
4039
|
-
${li(this.itemDoc,
|
|
4040
|
-
`}};c([u({type:String,attribute:"item-url"})],_e.prototype,"itemURL",2),c([E()],_e.prototype,"itemDoc",2),c([E()],_e.prototype,"itemXML",2),c([I("itemURL",{waitUntilFirstUpdate:!0})],_e.prototype,"handleItemURLChange",1),c([I("itemXML",{waitUntilFirstUpdate:!0})],_e.prototype,"handleItemXMLChange",1),_e=c([g("item-container")],_e);var
|
|
4013
|
+
${li(this.itemDoc,f`<span>Loading...</span>`)}
|
|
4014
|
+
`}};c([u({type:String,attribute:"item-url"})],_e.prototype,"itemURL",2),c([E()],_e.prototype,"itemDoc",2),c([E()],_e.prototype,"itemXML",2),c([I("itemURL",{waitUntilFirstUpdate:!0})],_e.prototype,"handleItemURLChange",1),c([I("itemXML",{waitUntilFirstUpdate:!0})],_e.prototype,"handleItemXMLChange",1),_e=c([g("item-container")],_e);var it=class extends v{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`
|
|
4041
4015
|
<label part="label" for="modeSelect">${this.label}</label>
|
|
4042
4016
|
<select
|
|
4043
4017
|
part="select"
|
|
4044
4018
|
id="modeSelect"
|
|
4045
4019
|
@change=${e=>{let t=e.target;this._switchMode(t.value)}}
|
|
4046
4020
|
>
|
|
4047
|
-
${Object.keys(this._options).map(e=>
|
|
4021
|
+
${Object.keys(this._options).map(e=>f`<option value="${e}" ?selected=${e===this.itemContext?.correctResponseMode}>
|
|
4048
4022
|
${this._options[e]}
|
|
4049
4023
|
</option>`)}
|
|
4050
4024
|
</select>
|
|
4051
|
-
`}};c([_({context:J,subscribe:!0})],
|
|
4025
|
+
`}};c([_({context:J,subscribe:!0})],it.prototype,"itemContext",2),c([u({type:String})],it.prototype,"label",2),c([E()],it.prototype,"_options",2),it=c([g("item-correct-response-mode")],it);var Ho=x`
|
|
4052
4026
|
display: inline-flex;
|
|
4053
4027
|
align-items: center;
|
|
4054
4028
|
cursor: pointer;
|
|
@@ -4057,28 +4031,28 @@ div.full-correct-response-inline {
|
|
|
4057
4031
|
user-select: none;
|
|
4058
4032
|
`,di=x`
|
|
4059
4033
|
background-color: lightgray;
|
|
4060
|
-
${
|
|
4034
|
+
${Ho};
|
|
4061
4035
|
`,pi=x`
|
|
4062
4036
|
cursor: not-allowed;
|
|
4063
4037
|
opacity: 0.8;
|
|
4064
|
-
|
|
4065
|
-
${
|
|
4038
|
+
`,$g=x`
|
|
4039
|
+
${Ho};
|
|
4066
4040
|
border: 1px solid gray;
|
|
4067
|
-
`;var re=class extends v{constructor(){super();this.shown=!1;this.disabled=!1;this.showCandidateCorrectionText="Show candidate correction";this.hideCandidateCorrectionText="Hide candidate correction";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-candidate-correction",{detail:!this.shown,bubbles:!0}))}_getDisplayedText(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCandidateCorrectionText:this.showCandidateCorrectionText}render(){return
|
|
4041
|
+
`;var re=class extends v{constructor(){super();this.shown=!1;this.disabled=!1;this.showCandidateCorrectionText="Show candidate correction";this.hideCandidateCorrectionText="Hide candidate correction";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-candidate-correction",{detail:!this.shown,bubbles:!0}))}_getDisplayedText(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCandidateCorrectionText:this.showCandidateCorrectionText}render(){return f` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `}};re.styles=x`
|
|
4068
4042
|
:host {
|
|
4069
4043
|
${di};
|
|
4070
4044
|
}
|
|
4071
4045
|
:host([disabled]) {
|
|
4072
4046
|
${pi};
|
|
4073
4047
|
}
|
|
4074
|
-
`,c([_({context:Pe,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,"showCandidateCorrectionText",2),c([u({type:String})],re.prototype,"hideCandidateCorrectionText",2),c([u({type:String})],re.prototype,"noCorrectResponseText",2),re=c([g("item-show-candidate-correction")],re);var ie=class extends v{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
|
|
4048
|
+
`,c([_({context:Pe,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,"showCandidateCorrectionText",2),c([u({type:String})],re.prototype,"hideCandidateCorrectionText",2),c([u({type:String})],re.prototype,"noCorrectResponseText",2),re=c([g("item-show-candidate-correction")],re);var ie=class extends v{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> `}};ie.styles=x`
|
|
4075
4049
|
:host {
|
|
4076
4050
|
${di};
|
|
4077
4051
|
}
|
|
4078
4052
|
:host([disabled]) {
|
|
4079
4053
|
${pi};
|
|
4080
4054
|
}
|
|
4081
|
-
`,c([_({context:Pe,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,"showCorrectText",2),c([u({type:String})],ie.prototype,"hideCorrectText",2),c([u({type:String})],ie.prototype,"noCorrectResponseText",2),ie=c([g("item-show-correct-response")],ie);var
|
|
4055
|
+
`,c([_({context:Pe,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,"showCorrectText",2),c([u({type:String})],ie.prototype,"hideCorrectText",2),c([u({type:String})],ie.prototype,"noCorrectResponseText",2),ie=c([g("item-show-correct-response")],ie);var Et=class extends v{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`
|
|
4082
4056
|
<h3>${n}</h3>
|
|
4083
4057
|
<table>
|
|
4084
4058
|
<thead>
|
|
@@ -4091,7 +4065,7 @@ div.full-correct-response-inline {
|
|
|
4091
4065
|
</tr>
|
|
4092
4066
|
</thead>
|
|
4093
4067
|
<tbody>
|
|
4094
|
-
${s.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return
|
|
4068
|
+
${s.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return f`
|
|
4095
4069
|
<tr>
|
|
4096
4070
|
<td>${a.identifier}</td>
|
|
4097
4071
|
<td>${Array.isArray(a.value)?a.value.join(", "):a.value}</td>
|
|
@@ -4102,9 +4076,9 @@ div.full-correct-response-inline {
|
|
|
4102
4076
|
`})}
|
|
4103
4077
|
</tbody>
|
|
4104
4078
|
</table>
|
|
4105
|
-
`;return
|
|
4079
|
+
`;return f`
|
|
4106
4080
|
${i(e,"Response Variables")} ${i(t,"Outcome Variables")}
|
|
4107
|
-
`}};
|
|
4081
|
+
`}};Et.styles=x`
|
|
4108
4082
|
table {
|
|
4109
4083
|
width: 100%;
|
|
4110
4084
|
border-collapse: collapse;
|
|
@@ -4125,7 +4099,7 @@ div.full-correct-response-inline {
|
|
|
4125
4099
|
margin-top: 20px;
|
|
4126
4100
|
font-size: 16px;
|
|
4127
4101
|
}
|
|
4128
|
-
`,c([_({context:Pe,subscribe:!0})],wt.prototype,"computedContext",2),wt=c([g("item-print-variables")],wt);var _t=class extends v{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 h`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this._onItemContextChanged),this.removeEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected)}};c([E(),X({context:Pe})],_t.prototype,"computedContext",2),c([E(),X({context:J})],_t.prototype,"configContext",2),_t=c([g("qti-item")],_t);var Ho=(o,r,e)=>{class t extends o{}return t};var me=(o,r,e,t)=>{class i extends Ho(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.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")}}}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))}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(a){if(super.firstUpdated(a),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 d=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),p=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(m,[]),this.droppablesModified(p,[]),this.draggablesModified(d,[]),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(b=>this.resizeObserver?.observe(b))}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;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),f=0,b=0;for(let y of a){y.style.maxWidth=m+"px";let{width:C,height:A}=await this.measureIntrinsicSize(y);f=Math.max(f,A),b=Math.max(b,C)}p&&(p.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(min(${m}px,${b}px + 2 * var(--qti-dropzone-padding))), 1fr))`),l&&(l.style.minHeight=`${f}px`);for(let y of d){y.style.minHeight=`${f}px`,y.style.minWidth=`${b}px`;let C=y.shadowRoot?.querySelector('slot[part="dropslot"]');C&&(C.style.minHeight=`${f}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),f=parseFloat(p.paddingRight);return Math.min(this.MAX_DRAGGABLE_WIDTH,d.clientWidth-m-f)}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)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a),p={clientX:l,clientY:d};this.calculateDragDistance(p)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(p));let m=this.findClosestDropzone();this.currentDropTarget=m,m!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),m&&(this.activateDroppable(m),this.dispatchCustomEvent(m,"dragenter")),this.lastTarget=m),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),a.preventDefault()}}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(f=>f.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.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.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(f=>{if(f==="")return;let b=p.find(C=>C.getAttribute("identifier")===f),y=m.find(C=>C.getAttribute("identifier")===l);this.dropDraggableInDroppable(b,y)})}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(f=>f.getAttribute("identifier")),m=l.getAttribute("identifier");return p.map(f=>`${f} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,f)=>f.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;let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d,this.dragClone);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`}applyInteractionBoundaries(a,l,d){let p=this.getBoundingClientRect(),m=d.getBoundingClientRect(),f=m.width,b=m.height,y=Math.max(p.left,Math.min(a,p.right-f)),C=Math.max(p.top,Math.min(l,p.bottom-b));return{newLeft:y,newTop:C}}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}getDropzoneRect(a){return(a.shadowRoot?.querySelector('slot[part="dropslot"]')??a).getBoundingClientRect()}findClosestDropzone(){let a=this.allDropzones.filter(f=>!f.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let l=this.dragClone.getBoundingClientRect(),d=null,p=0,m=f=>{for(let b of f){let y=this.getDropzoneRect(b),C=this.calculateOverlapArea(l,y);C>p&&(p=C,d=b)}};if(m(this.droppables.filter(f=>!f.hasAttribute("disabled"))),d||m(this.dragContainers.filter(f=>!f.hasAttribute("disabled"))),!d){let f=Number.POSITIVE_INFINITY;for(let b of a){let y=this.getDropzoneRect(b),C=Math.hypot(l.left-y.left,l.top-y.top);C<f&&(f=C,d=b)}}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}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(q=>Array.from(q.children).some(T=>T===this.dragSource)),f=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-f.left,this.cloneOffset.y=d-f.top,this.dragClone=p.cloneNode(!0);let b=window.getComputedStyle(p);for(let q=0;q<b.length;q++){let T=b[q];this.dragClone.style.setProperty(T,b.getPropertyValue(T))}let y=p.getBoundingClientRect();this.dragClone.style.width=`${y.width}px`,this.dragClone.style.height=`${y.height}px`,f&&this.setDragCloneStyles(f),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let C=this.getMatchMaxValue(this.dragSource),A=this.draggables.filter(q=>q.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));C!==0&&A.length>=C?(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(f=>f.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([Xr(t)],i.prototype,"handleDraggableContainerChange",1),c([Xr(r)],i.prototype,"handleDraggablesChange",1),c([Xr(e)],i.prototype,"handleDroppablesChange",1),i};var zo=x`
|
|
4102
|
+
`,c([_({context:Pe,subscribe:!0})],Et.prototype,"computedContext",2),Et=c([g("item-print-variables")],Et);var wt=class extends v{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([E(),X({context:Pe})],wt.prototype,"computedContext",2),c([E(),X({context:J})],wt.prototype,"configContext",2),wt=c([g("qti-item")],wt);var Uo=(o,r,e)=>{class t extends o{}return t};var me=(o,r,e,t)=>{class i extends Uo(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.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")}}}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))}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(a){if(super.firstUpdated(a),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 d=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),p=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(m,[]),this.droppablesModified(p,[]),this.draggablesModified(d,[]),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(b=>this.resizeObserver?.observe(b))}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;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,b=0;for(let y of a){y.style.maxWidth=m+"px";let{width:C,height:S}=await this.measureIntrinsicSize(y);h=Math.max(h,S),b=Math.max(b,C)}p&&(p.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(min(${m}px,${b}px + 2 * var(--qti-dropzone-padding))), 1fr))`),l&&(l.style.minHeight=`${h}px`);for(let y of d){y.style.minHeight=`${h}px`,y.style.minWidth=`${b}px`;let C=y.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)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a),p={clientX:l,clientY:d};this.calculateDragDistance(p)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(p));let m=this.findClosestDropzone();this.currentDropTarget=m,m!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),m&&(this.activateDroppable(m),this.dispatchCustomEvent(m,"dragenter")),this.lastTarget=m),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),a.preventDefault()}}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.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.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 b=p.find(C=>C.getAttribute("identifier")===h),y=m.find(C=>C.getAttribute("identifier")===l);this.dropDraggableInDroppable(b,y)})}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;let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d,this.dragClone);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`}applyInteractionBoundaries(a,l,d){let p=this.getBoundingClientRect(),m=d.getBoundingClientRect(),h=m.width,b=m.height,y=Math.max(p.left,Math.min(a,p.right-h)),C=Math.max(p.top,Math.min(l,p.bottom-b));return{newLeft:y,newTop:C}}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}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.dragClone.getBoundingClientRect(),d=null,p=0,m=h=>{for(let b of h){let y=this.getDropzoneRect(b),C=this.calculateOverlapArea(l,y);C>p&&(p=C,d=b)}};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 b of a){let y=this.getDropzoneRect(b),C=Math.hypot(l.left-y.left,l.top-y.top);C<h&&(h=C,d=b)}}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}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(q=>Array.from(q.children).some(T=>T===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);let b=window.getComputedStyle(p);for(let q=0;q<b.length;q++){let T=b[q];this.dragClone.style.setProperty(T,b.getPropertyValue(T))}let y=p.getBoundingClientRect();this.dragClone.style.width=`${y.width}px`,this.dragClone.style.height=`${y.height}px`,h&&this.setDragCloneStyles(h),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let C=this.getMatchMaxValue(this.dragSource),S=this.draggables.filter(q=>q.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));C!==0&&S.length>=C?(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([Xr(t)],i.prototype,"handleDraggableContainerChange",1),c([Xr(r)],i.prototype,"handleDraggablesChange",1),c([Xr(e)],i.prototype,"handleDroppablesChange",1),i};var Fo=x`
|
|
4129
4103
|
:host {
|
|
4130
4104
|
display: block; /* necessary to calculate scaling position */
|
|
4131
4105
|
}
|
|
@@ -4159,16 +4133,16 @@ div.full-correct-response-inline {
|
|
|
4159
4133
|
rgb(0 0 0 / 0%) calc(50% + 1px)
|
|
4160
4134
|
);
|
|
4161
4135
|
}
|
|
4162
|
-
`;var
|
|
4136
|
+
`;var _t=class extends me(k,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return f` <slot name="prompt"></slot>
|
|
4163
4137
|
<slot name="qti-simple-associable-choice"></slot>
|
|
4164
4138
|
<div part="drop-container">
|
|
4165
|
-
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>
|
|
4139
|
+
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>f`<div part="associables-container">
|
|
4166
4140
|
<div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
|
|
4167
4141
|
<div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
|
|
4168
4142
|
</div>`)}
|
|
4169
4143
|
|
|
4170
4144
|
<div role="alert" part="message" id="validation-message"></div>
|
|
4171
|
-
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};
|
|
4145
|
+
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};_t.styles=Fo,c([E()],_t.prototype,"_childrenMap",2),_t=c([g("qti-associate-interaction")],_t);var ze=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];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.responseVariable;if(n?.correctResponse){let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse];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.responseVariable;if(!n?.correctResponse)return;let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse],l=Array.isArray(n.value)?n.value:[n.value];this._choiceElements.forEach(d=>{d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),s&&l.includes(d.identifier)&&(a.includes(d.identifier)?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${r}`,this._registerChoiceElement),this.addEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${r}`,this._registerChoiceElement),this.removeEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(d=>this._getChoiceChecked(d)),n=s.length,a=!0,l="";return 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"}.`),s.length>0&&this._internals.setValidity(a?{}:{customError:!0},l,s[n-1]||this._choiceElements[0]||this),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._internals.validity.valid}_registerChoiceElement(s){s.stopPropagation();let n=s.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(s){s.stopPropagation();let n=s.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.role=this.maxChoices===1?"radiogroup":null;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.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([at("#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([I("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),c([I("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),c([E()],e.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),c([E(),_({context:J,subscribe:!0})],e.prototype,"_configContext",2),e};var Bo=(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,reflect:!0})],e.prototype,"class",1),e};var jo=x`
|
|
4172
4146
|
:host {
|
|
4173
4147
|
display: block;
|
|
4174
4148
|
}
|
|
@@ -4238,19 +4212,113 @@ div.full-correct-response-inline {
|
|
|
4238
4212
|
:host(.qti-orientation-vertical) ::slotted(qti-simple-choice:nth-child(even)) {
|
|
4239
4213
|
grid-row: auto;
|
|
4240
4214
|
}
|
|
4241
|
-
`;var
|
|
4215
|
+
`;var Tt=class extends Bo(ze(k,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}_handleSlotChange(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return f`
|
|
4242
4216
|
<slot part="prompt" name="prompt"></slot>
|
|
4243
4217
|
<slot part="slot" @slotchange=${this._handleSlotChange}></slot>
|
|
4244
4218
|
<div part="message" role="alert" id="validation-message"></div>
|
|
4245
|
-
`}};
|
|
4219
|
+
`}};Tt.styles=jo,c([u({type:String})],Tt.prototype,"orientation",2),Tt=c([g("qti-choice-interaction")],Tt);var Ki=`
|
|
4220
|
+
const postToParentWindows = (type, data) => {
|
|
4221
|
+
window.top.postMessage(data ? { type, data } : { type }, '*');
|
|
4222
|
+
let w = window.parent;
|
|
4223
|
+
while (w) {
|
|
4224
|
+
if (w !== window.top) {
|
|
4225
|
+
w.postMessage({ type, data }, '*');
|
|
4226
|
+
}
|
|
4227
|
+
if (w !== w.parent) {
|
|
4228
|
+
w = w.parent;
|
|
4229
|
+
} else {
|
|
4230
|
+
w = null;
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
};
|
|
4234
|
+
|
|
4235
|
+
window.CES = {
|
|
4236
|
+
media: null,
|
|
4237
|
+
response: null,
|
|
4238
|
+
load: () => {
|
|
4239
|
+
let resolveCount = 0;
|
|
4240
|
+
|
|
4241
|
+
const handleMessage = (event) => {
|
|
4242
|
+
if (event.data.type === "mediaData") {
|
|
4243
|
+
const media = event.data.data;
|
|
4244
|
+
CES.media = media;
|
|
4245
|
+
resolveCount++;
|
|
4246
|
+
} else if (event.data.type === "responseData") {
|
|
4247
|
+
const response = event.data.data;
|
|
4248
|
+
if (response && Array.isArray(response) && response.length > 0) {
|
|
4249
|
+
// state is stored in the first element of the array
|
|
4250
|
+
CES.response = response[0];
|
|
4251
|
+
// Wait a short moment to ensure CES.response is set
|
|
4252
|
+
setTimeout(() => {
|
|
4253
|
+
// Re-create the Controller instance if it exists
|
|
4254
|
+
if (typeof Controller === 'function') {
|
|
4255
|
+
console.log("Re-creating Controller instance");
|
|
4256
|
+
ctrl = new Controller();
|
|
4257
|
+
}
|
|
4258
|
+
}, 50);
|
|
4259
|
+
} else {
|
|
4260
|
+
CES.response = response;
|
|
4261
|
+
}
|
|
4262
|
+
resolveCount++;
|
|
4263
|
+
}
|
|
4264
|
+
if (resolveCount === 2) {
|
|
4265
|
+
//window.removeEventListener("message", handleMessage);
|
|
4266
|
+
}
|
|
4267
|
+
};
|
|
4268
|
+
window.addEventListener("message", handleMessage);
|
|
4269
|
+
postToParentWindows("getMedia");
|
|
4270
|
+
postToParentWindows("getResponse");
|
|
4271
|
+
},
|
|
4272
|
+
setResponse: (data) => {
|
|
4273
|
+
postToParentWindows("setResponse", data);
|
|
4274
|
+
},
|
|
4275
|
+
getResponse: () => {
|
|
4276
|
+
return CES.response;
|
|
4277
|
+
},
|
|
4278
|
+
getMedia: () => {
|
|
4279
|
+
return CES.media;
|
|
4280
|
+
},
|
|
4281
|
+
setStageHeight: () => {
|
|
4282
|
+
postToParentWindows("setStageHeight");
|
|
4283
|
+
},
|
|
4284
|
+
};
|
|
4285
|
+
CES.load();
|
|
4286
|
+
`,ea=`
|
|
4287
|
+
window.onload = function () {
|
|
4288
|
+
const handleMessage = (event) => {
|
|
4289
|
+
if (event.data.type === 'blobUrl') {
|
|
4290
|
+
const blobUrl = event.data.data;
|
|
4291
|
+
var n = document.createElement('iframe');
|
|
4292
|
+
n.frameBorder = '0';
|
|
4293
|
+
n.scrolling = 'no';
|
|
4294
|
+
n.src = blobUrl;
|
|
4295
|
+
n.style.width = '100%';
|
|
4296
|
+
n.style.height = '100%';
|
|
4297
|
+
document.body.appendChild(n);
|
|
4298
|
+
window.removeEventListener('message', handleMessage);
|
|
4299
|
+
}
|
|
4300
|
+
};
|
|
4301
|
+
window.addEventListener('message', handleMessage);
|
|
4302
|
+
// Request the blob URL from parent
|
|
4303
|
+
let w = window.parent;
|
|
4304
|
+
while (w) {
|
|
4305
|
+
w.postMessage({ type: 'getBlobUrl' }, '*');
|
|
4306
|
+
if (w !== w.parent) {
|
|
4307
|
+
w = w.parent;
|
|
4308
|
+
} else {
|
|
4309
|
+
w = null;
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
};
|
|
4313
|
+
`,Te=class extends k{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:jr((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(){let t=this.shadowRoot.querySelector("#pciContainer").contentDocument;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();console.debug("[qti-custom-interaction] manifest url",this._manifestUrl),console.debug("[qti-custom-interaction] base candidates",s),console.debug("[qti-custom-interaction] refs",{cssRef:i,media:this.manifest.media});let n=await this.resolveResourceWithFallback(i,s),a=n.url;n.baseUrl&&!this._resourceBaseUrl&&(this._resourceBaseUrl=n.baseUrl),console.debug("[qti-custom-interaction] css resolved",n);let l=!0;if(console.debug("[qti-custom-interaction] using built-in ciBootstrap (skipping server bootstrap.js)"),l){let p="";if(this.manifest.media&&this.manifest.media.length>0){let m=this.manifest.media[0],h=await this.resolveResourceWithFallback(m,s,{returnText:!0});if(p=h.url,h.baseUrl&&!this._resourceBaseUrl&&(this._resourceBaseUrl=h.baseUrl),console.debug("[qti-custom-interaction] index resolved (media)",{url:h.url,baseUrl:h.baseUrl,hasText:!!h.text}),h.text){let b=h.text,y="<script>"+Ki+"</script>",C=b.indexOf("<head>");C!==-1?b=b.slice(0,C+6)+y+b.slice(C+6):b=y+b;let S=new Blob([b],{type:"text/html"});this._contentBlobUrl=URL.createObjectURL(S)}}else{let m=this.data||"manifest.json",h=m.includes("/")?m.substring(0,m.lastIndexOf("/")):"",b=h?`${h}/index.html`:"index.html",y=await this.resolveResourceWithFallback(b,s,{returnText:!0});if(p=y.url,y.baseUrl&&!this._resourceBaseUrl&&(this._resourceBaseUrl=y.baseUrl),console.debug("[qti-custom-interaction] index resolved (fallback)",{url:y.url,baseUrl:y.baseUrl,hasText:!!y.text}),y.text){let C=y.text,S="<script>"+Ki+"</script>",q=C.indexOf("<head>");q!==-1?C=C.slice(0,q+6)+S+C.slice(q+6):C=S+C;let T=new Blob([C],{type:"text/html"});this._contentBlobUrl=URL.createObjectURL(T)}}if(p&&!this._contentBlobUrl)try{let m=await fetch(p);if(m.ok){let h=await m.text(),b="<script>"+Ki+"</script>",y=h.indexOf("<head>");y!==-1?h=h.slice(0,y+6)+b+h.slice(y+6):h=b+h;let C=new Blob([h],{type:"text/html"});this._contentBlobUrl=URL.createObjectURL(C)}else console.error(`Failed to fetch index.html: ${m.status}`)}catch(m){console.error(`Error fetching index.html: ${m}`)}}let d=`<script>${ea}</script>`;console.debug("[qti-custom-interaction] using ciBootstrap inline script"),window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
|
|
4246
4314
|
<html>
|
|
4247
4315
|
<head>
|
|
4248
|
-
|
|
4249
|
-
|
|
4316
|
+
${a?`<link href='${a}' rel="stylesheet" />`:""}
|
|
4317
|
+
${d}
|
|
4250
4318
|
</head>
|
|
4251
4319
|
<body></body>
|
|
4252
4320
|
</html>
|
|
4253
|
-
`),t.close()}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"getMedia":{let s=this.manifest.media.map(
|
|
4321
|
+
`),t.close()}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&&t!=="setResponse"&&console.debug("[qti-custom-interaction] postMessage",{type:t,data:i}),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);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});console.debug("[qti-custom-interaction] mediaData",n),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
|
|
4254
4322
|
width=${this.getAttribute("width")}
|
|
4255
4323
|
height=${this.getAttribute("height")}
|
|
4256
4324
|
frameborder="0"
|
|
@@ -4258,10 +4326,10 @@ div.full-correct-response-inline {
|
|
|
4258
4326
|
id="pciContainer"
|
|
4259
4327
|
>
|
|
4260
4328
|
</iframe>
|
|
4261
|
-
${this._errorMessage&&
|
|
4329
|
+
${this._errorMessage&&f`<div style="color:red">
|
|
4262
4330
|
<h1>Error</h1>
|
|
4263
4331
|
${this._errorMessage}
|
|
4264
|
-
</div>`}`}};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([E()],Te.prototype,"_errorMessage",2),Te=c([g("qti-custom-interaction")],Te);var
|
|
4332
|
+
</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([E()],Te.prototype,"_errorMessage",2),Te=c([g("qti-custom-interaction")],Te);var Ue=class extends v{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"})],Ue.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],Ue.prototype,"disabled",2),c([u({type:String,attribute:"count-attempt"})],Ue.prototype,"countAttempt",2),c([u({type:String})],Ue.prototype,"title",2),Ue=c([g("qti-end-attempt-interaction")],Ue);var Wo=x`
|
|
4265
4333
|
/* PK: display host as block, else design will be collapsed */
|
|
4266
4334
|
:host {
|
|
4267
4335
|
display: block;
|
|
@@ -4272,7 +4340,7 @@ div.full-correct-response-inline {
|
|
|
4272
4340
|
height: 100%;
|
|
4273
4341
|
border: 0;
|
|
4274
4342
|
}
|
|
4275
|
-
`;var W=class extends
|
|
4343
|
+
`;var W=class extends k{constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}handleclassNamesChange(e,t){let i=t.split(" "),s=!1;if(i.forEach(n=>{if(n.startsWith("qti-height-lines-")){let a=n.replace("qti-height-lines-","");this._rows=parseInt(a),s=!0}}),!s&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,i=new RegExp(t);e.checkValidity()&&i.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}toggleCorrectResponse(){}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return f`<slot name="prompt"></slot
|
|
4276
4344
|
><textarea
|
|
4277
4345
|
part="textarea"
|
|
4278
4346
|
name="${this.responseIdentifier}"
|
|
@@ -4288,7 +4356,7 @@ div.full-correct-response-inline {
|
|
|
4288
4356
|
?disabled="${this.disabled}"
|
|
4289
4357
|
?readonly="${this.readonly}"
|
|
4290
4358
|
.value=${this.response}
|
|
4291
|
-
></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")}};W.styles=
|
|
4359
|
+
></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")}};W.styles=Wo,c([E()],W.prototype,"_rows",2),c([u({type:Number,attribute:"expected-length"})],W.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],W.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],W.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],W.prototype,"dataPatternmaskMessage",2),c([u({type:String,attribute:"class"})],W.prototype,"classNames",2),c([I("classNames")],W.prototype,"handleclassNamesChange",1),c([E()],W.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],W.prototype,"_handleResponseChange",2),W=c([g("qti-extended-text-interaction")],W);var Xo=x`
|
|
4292
4360
|
:host {
|
|
4293
4361
|
display: flex;
|
|
4294
4362
|
align-items: flex-start;
|
|
@@ -4322,10 +4390,10 @@ div.full-correct-response-inline {
|
|
|
4322
4390
|
border-radius: 0.3rem;
|
|
4323
4391
|
gap: 0.5rem;
|
|
4324
4392
|
}
|
|
4325
|
-
`;var
|
|
4393
|
+
`;var pr=class extends me(k,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return f`<slot name="prompt"> </slot>
|
|
4326
4394
|
<slot part="drags" name="drags"></slot>
|
|
4327
4395
|
<slot part="drops"></slot>
|
|
4328
|
-
<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")})})}};
|
|
4396
|
+
<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")})})}};pr.styles=Xo,pr=c([g("qti-gap-match-interaction")],pr);var Go=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},At=te(class extends ue{constructor(o){if(super(o),o.type!==He.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=Vo(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,b=0,y=s.length-1;for(;m<=h&&b<=y;)if(i[m]===null)m++;else if(i[h]===null)h--;else if(a[m]===n[b])l[b]=De(i[m],s[b]),m++,b++;else if(a[h]===n[y])l[y]=De(i[h],s[y]),h--,y--;else if(a[m]===n[y])l[y]=De(i[m],s[y]),vt(o,l[y+1],i[m]),m++,y--;else if(a[h]===n[b])l[b]=De(i[h],s[b]),vt(o,i[m],i[h]),h--,b++;else if(d===void 0&&(d=Go(n,b,y),p=Go(a,m,h)),d.has(a[m]))if(d.has(a[h])){let C=p.get(n[b]),S=C!==void 0?i[C]:null;if(S===null){let q=vt(o,i[m]);De(q,s[b]),l[b]=q}else l[b]=De(S,s[b]),vt(o,i[m],S),i[C]=null;b++}else si(i[h]),h--;else si(i[m]),m++;for(;b<=y;){let C=vt(o,l[y+1]);De(C,s[b]),l[b++]=C}for(;m<=h;){let C=i[m++];C!==null&&si(C)}return this.ut=n,Po(o,l),V}});function Fe(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,b=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=h-p+"%",t.style.height=b-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,b=d/s*100;t.style.left=p-h+"%",t.style.top=m-b+"%",t.style.width=2*h+"%",t.style.height=2*b+"%",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 q=0;q<r.length;q+=2)n.push({x:r[q],y:r[q+1]});let a=Math.min(...n.map(q=>q.x)),l=Math.max(...n.map(q=>q.x)),d=Math.min(...n.map(q=>q.y)),p=Math.max(...n.map(q=>q.y)),m=a/i*100,h=d/s*100,b=l/i*100,y=p/s*100;t.style.left=m+"%",t.style.top=h+"%",t.style.width=b-m+"%",t.style.height=y-h+"%";let S=n.map(q=>({x:(q.x-a)/(l-a)*100,y:(q.y-d)/(p-d)*100})).map(q=>`${q.x}% ${q.y}%`).join(",");t.style.clipPath=`polygon(${S})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var Yo=x`
|
|
4329
4397
|
slot:not([name='prompt']) {
|
|
4330
4398
|
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4331
4399
|
display: block;
|
|
@@ -4349,14 +4417,14 @@ div.full-correct-response-inline {
|
|
|
4349
4417
|
top: 0px;
|
|
4350
4418
|
left: 0px;
|
|
4351
4419
|
}
|
|
4352
|
-
`;var he=class extends
|
|
4420
|
+
`;var he=class extends k{constructor(){super();this.startPoint=null;this.endPoint=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._response=[],this._correctLines=[]}validate(){return this.response.length>0}set response(e){this._response=e}get response(){return this._response}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctLines=[];return}if(!t.correctResponse){console.error("No correct response found for this interaction.");return}let i=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];this._correctLines=i}render(){return f`<slot name="prompt"></slot>
|
|
4353
4421
|
<line-container>
|
|
4354
4422
|
<svg
|
|
4355
4423
|
width=${ae(this.grImage[0]?.width)}
|
|
4356
4424
|
height=${ae(this.grImage[0]?.height)}
|
|
4357
4425
|
viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
|
|
4358
4426
|
>
|
|
4359
|
-
${
|
|
4427
|
+
${At(this.response||[],e=>e,(e,t)=>Ur`
|
|
4360
4428
|
<line
|
|
4361
4429
|
part="line"
|
|
4362
4430
|
x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
|
|
@@ -4368,7 +4436,7 @@ div.full-correct-response-inline {
|
|
|
4368
4436
|
@click=${i=>{i.stopPropagation(),this._response=this._response.filter((s,n)=>n!==t),this.saveResponse(this.response)}}
|
|
4369
4437
|
/>
|
|
4370
4438
|
`)}
|
|
4371
|
-
${
|
|
4439
|
+
${At(this._correctLines||[],e=>e,(e,t)=>Ur`
|
|
4372
4440
|
<line
|
|
4373
4441
|
part="correct-line"
|
|
4374
4442
|
x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
|
|
@@ -4392,7 +4460,7 @@ div.full-correct-response-inline {
|
|
|
4392
4460
|
</svg>
|
|
4393
4461
|
<slot></slot>
|
|
4394
4462
|
</line-container>
|
|
4395
|
-
<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));
|
|
4463
|
+
<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));Fe(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.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)}};he.styles=Yo,c([E()],he.prototype,"_correctLines",2),c([E()],he.prototype,"startCoord",2),c([E()],he.prototype,"mouseCoord",2),c([Zs({selector:"img"})],he.prototype,"grImage",2),c([E()],he.prototype,"_response",2),he=c([g("qti-graphic-associate-interaction")],he);var Jo=x`
|
|
4396
4464
|
:host {
|
|
4397
4465
|
display: flex;
|
|
4398
4466
|
align-items: flex-start;
|
|
@@ -4446,10 +4514,10 @@ div.full-correct-response-inline {
|
|
|
4446
4514
|
user-select: none;
|
|
4447
4515
|
pointer-events: none;
|
|
4448
4516
|
}
|
|
4449
|
-
`;var
|
|
4517
|
+
`;var ur=class extends me(k,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return f` <slot name="prompt"></slot>
|
|
4450
4518
|
<slot part="image"></slot>
|
|
4451
4519
|
<slot part="drags" name="drags" class="hover-border"></slot>
|
|
4452
|
-
<div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),s=t.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,a,l]=s;e.style.left=n-l+"px",e.style.top=a-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[n,a,l,d]=s;e.style.left=n+"px",e.style.top=a+"px",e.style.width=l-n+"px",e.style.height=d-a+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};
|
|
4520
|
+
<div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),s=t.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,a,l]=s;e.style.left=n-l+"px",e.style.top=a-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[n,a,l,d]=s;e.style.left=n+"px",e.style.top=a+"px",e.style.width=l-n+"px",e.style.height=d-a+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ur.styles=Jo,ur=c([g("qti-graphic-gap-match-interaction")],ur);var Ko=x`
|
|
4453
4521
|
slot:not([name='prompt']) {
|
|
4454
4522
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4455
4523
|
display: block;
|
|
@@ -4460,11 +4528,11 @@ div.full-correct-response-inline {
|
|
|
4460
4528
|
pointer-events: none;
|
|
4461
4529
|
user-select: none;
|
|
4462
4530
|
}
|
|
4463
|
-
`;var
|
|
4531
|
+
`;var mr=class extends ze(k,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return f`
|
|
4464
4532
|
<slot name="prompt"></slot>
|
|
4465
4533
|
<slot></slot>
|
|
4466
4534
|
<div role="alert" part="message" id="validation-message"></div>
|
|
4467
|
-
`}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let n=this._choiceElements.filter(a=>a.order!=null).length;if(n>=s){this.choiceOrdering=!1;return}i.order=n+1}else{let n=i.order;i.order=null,this._choiceElements.forEach(a=>{a.order!=null&&a.order>n&&a.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e){let t=this.responseVariable,i=this._choiceElements;for(let s of i)if(e&&t?.correctResponse?.length>0&&Array.isArray(t.correctResponse)){let n=t.correctResponse.findIndex(a=>a===s.identifier);n>=0?s.orderCorrect=n+1:s.orderCorrect=null}else s.orderCorrect=null}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));
|
|
4535
|
+
`}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let n=this._choiceElements.filter(a=>a.order!=null).length;if(n>=s){this.choiceOrdering=!1;return}i.order=n+1}else{let n=i.order;i.order=null,this._choiceElements.forEach(a=>{a.order!=null&&a.order>n&&a.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e){let t=this.responseVariable,i=this._choiceElements;for(let s of i)if(e&&t?.correctResponse?.length>0&&Array.isArray(t.correctResponse)){let n=t.correctResponse.findIndex(a=>a===s.identifier);n>=0?s.orderCorrect=n+1:s.orderCorrect=null}else s.orderCorrect=null}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));Fe(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};mr.styles=Ko,mr=c([g("qti-graphic-order-interaction")],mr);var Zo=x`
|
|
4468
4536
|
slot:not([name='prompt']) {
|
|
4469
4537
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4470
4538
|
display: inline-block;
|
|
@@ -4478,11 +4546,11 @@ div.full-correct-response-inline {
|
|
|
4478
4546
|
user-select: none;
|
|
4479
4547
|
/* width:100%; */
|
|
4480
4548
|
}
|
|
4481
|
-
`;var
|
|
4549
|
+
`;var hr=class extends ze(k,"qti-hotspot-choice"){constructor(){super(...arguments);this.imageLoadPromise=null}render(){return f`
|
|
4482
4550
|
<slot name="prompt"></slot>
|
|
4483
4551
|
<slot></slot>
|
|
4484
|
-
`}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);
|
|
4485
|
-
<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})],
|
|
4552
|
+
`}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);Fe(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)}};hr.styles=Zo,hr=c([g("qti-hotspot-interaction")],hr);var fr=class extends ze(k,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>f`<slot></slot>
|
|
4553
|
+
<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})],fr.prototype,"class",2),fr=c([g("qti-hottext-interaction")],fr);var gr=class extends ue{constructor(r){if(super(r),this.it=R,r.type!==He.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===R||r==null)return this._t=void 0,this.it=r;if(r===V)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:[]}}};gr.directiveName="unsafeHTML",gr.resultType=1;var St=te(gr);var Ae=class extends k{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt=""}get isInline(){return!0}static get styles(){return[x`
|
|
4486
4554
|
:host {
|
|
4487
4555
|
display: inline-block;
|
|
4488
4556
|
}
|
|
@@ -4504,15 +4572,15 @@ div.full-correct-response-inline {
|
|
|
4504
4572
|
/* position-anchor: --infobox; */
|
|
4505
4573
|
/* top: anchor(bottom); */
|
|
4506
4574
|
}
|
|
4507
|
-
`]}render(){return
|
|
4575
|
+
`]}render(){return f`
|
|
4508
4576
|
<select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
|
|
4509
|
-
${this.options.map(e=>
|
|
4510
|
-
<option value="${e.value}" ?selected="${e.selected}">${
|
|
4577
|
+
${this.options.map(e=>f`
|
|
4578
|
+
<option value="${e.value}" ?selected="${e.selected}">${St(e.textContent)}</option>
|
|
4511
4579
|
`)}
|
|
4512
4580
|
</select>
|
|
4513
4581
|
|
|
4514
|
-
${
|
|
4515
|
-
`}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("on-dropdown-selected",this.choiceSelected)}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select";!this.options||this.options.length===0?this.options=[{textContent:t,value:"",selected:!1},...e.map(i=>({textContent:i.innerHTML,value:i.getAttribute("identifier"),selected:!1}))]:this.options=this.options.map(i=>i.value===""?{...i,textContent:t}:i)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleInternalCorrectResponse(e){if(this.correctResponse=e&&this.responseVariable?.correctResponse?.toString(),!this.correctResponse){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">${this.options.find(t=>this.correctResponse===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===t})),this.saveResponse(t)}};Ae.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],c([E()],Ae.prototype,"options",2),c([E()],Ae.prototype,"correctOption",2),c([u({attribute:"data-prompt",type:String})],Ae.prototype,"dataPrompt",2),c([_({context:J,subscribe:!0}),u({attribute:!1})],Ae.prototype,"configContext",2),Ae=c([g("qti-inline-choice-interaction")],Ae);var
|
|
4582
|
+
${St(this.correctOption)}
|
|
4583
|
+
`}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("on-dropdown-selected",this.choiceSelected)}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select";!this.options||this.options.length===0?this.options=[{textContent:t,value:"",selected:!1},...e.map(i=>({textContent:i.innerHTML,value:i.getAttribute("identifier"),selected:!1}))]:this.options=this.options.map(i=>i.value===""?{...i,textContent:t}:i)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleInternalCorrectResponse(e){if(this.correctResponse=e&&this.responseVariable?.correctResponse?.toString(),!this.correctResponse){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">${this.options.find(t=>this.correctResponse===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===t})),this.saveResponse(t)}};Ae.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],c([E()],Ae.prototype,"options",2),c([E()],Ae.prototype,"correctOption",2),c([u({attribute:"data-prompt",type:String})],Ae.prototype,"dataPrompt",2),c([_({context:J,subscribe:!0}),u({attribute:!1})],Ae.prototype,"configContext",2),Ae=c([g("qti-inline-choice-interaction")],Ae);var Qo=x`
|
|
4516
4584
|
slot:not([hidden]) {
|
|
4517
4585
|
/* slot where the */
|
|
4518
4586
|
display: flex;
|
|
@@ -4538,20 +4606,20 @@ div.full-correct-response-inline {
|
|
|
4538
4606
|
/* Make sure the drag and drop container slots have the same width */
|
|
4539
4607
|
flex: 1;
|
|
4540
4608
|
}
|
|
4541
|
-
`;var Se=class extends me(
|
|
4609
|
+
`;var Se=class extends me(k,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=null;this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,s=t.name,n=t.type;t.checked?(this.response?this.response.indexOf(i)===-1&&(n==="radio"&&(this.response=(this.response||[]).filter(a=>a.indexOf(s)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=t):(this.response=(this.response||[]).filter(a=>a!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.response)?[...this.response]:this.response}}))}}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.sourceChoices=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.targetChoices=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}getMatches(e){if(!e.correctResponse)return[];let t=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse],i=[];return t&&t.forEach(s=>{let n=s.split(" ");i.push({source:n[0],target:n[1]})}),i}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!t?.correctResponse){this.querySelectorAll(".correct-option").forEach(s=>s.remove());return}let i=this.getMatches(t);this.class.split(" ").includes("qti-match-tabular")?e?this.correctOptions=i||[]:this.correctOptions=null:e?(this.querySelectorAll(".correct-option").forEach(s=>s.remove()),this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.find(l=>l.target===n);if(a?.source){let d=this.querySelector(`qti-simple-associable-choice[identifier="${a.source}"]`)?.textContent?.trim();if(d&&!s.previousElementSibling?.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",s.insertAdjacentElement("beforebegin",p)}}})):this.correctOptions=null}toggleCandidateCorrection(e){let t=this.responseVariable;if(!t?.correctResponse)return;let i=this.getMatches(t);this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.filter(d=>d.target===n);s.querySelectorAll("qti-simple-associable-choice").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!e)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}render(){let e=this.class.split(" ").includes("qti-match-tabular"),t=this.correctOptions!==null;return f`
|
|
4542
4610
|
<slot name="prompt"></slot>
|
|
4543
4611
|
<slot ?hidden=${e}></slot>
|
|
4544
4612
|
|
|
4545
|
-
${e?
|
|
4613
|
+
${e?f`
|
|
4546
4614
|
<table part="table">
|
|
4547
4615
|
<tr part="r-header">
|
|
4548
4616
|
<td></td>
|
|
4549
|
-
${this.targetChoices.map(i=>
|
|
4617
|
+
${this.targetChoices.map(i=>f`<th part="r-header">${St(i.innerHTML)}</th>`)}
|
|
4550
4618
|
</tr>
|
|
4551
4619
|
|
|
4552
|
-
${this.sourceChoices.map(i=>
|
|
4553
|
-
<td part="c-header">${
|
|
4554
|
-
${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),l=`${n} ${a}`,d=(this.response||[]).filter(C=>C.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,m=i.matchMax===1?"radio":"checkbox",
|
|
4620
|
+
${this.sourceChoices.map(i=>f`<tr part="row">
|
|
4621
|
+
<td part="c-header">${St(i.innerHTML)}</td>
|
|
4622
|
+
${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),l=`${n} ${a}`,d=(this.response||[]).filter(C=>C.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,m=i.matchMax===1?"radio":"checkbox",h=!!this.correctOptions?.find(C=>C.source===n&&C.target===a),b=m==="radio"?`rb ${p?"rb-checked":""} ${t?h?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?h?"cb-correct":"cb-incorrect":""}`,y=this.correctOptions?.length>0?!0:i.matchMax===1?!1:i.matchMax!==0&&d>=i.matchMax&&!p;return f`<td part="input-cell">
|
|
4555
4623
|
<div
|
|
4556
4624
|
class="input-container"
|
|
4557
4625
|
style="position: relative; width: 24px; height: 24px; margin: 0 auto;"
|
|
@@ -4565,7 +4633,7 @@ div.full-correct-response-inline {
|
|
|
4565
4633
|
@change=${C=>this.handleRadioChange(C)}
|
|
4566
4634
|
@click=${C=>i.matchMax===1?this.handleRadioClick(C):null}
|
|
4567
4635
|
/>
|
|
4568
|
-
${m==="checkbox"&&p?
|
|
4636
|
+
${m==="checkbox"&&p?f`
|
|
4569
4637
|
<svg
|
|
4570
4638
|
part="checkmark"
|
|
4571
4639
|
viewBox="0 0 24 24"
|
|
@@ -4578,11 +4646,11 @@ div.full-correct-response-inline {
|
|
|
4578
4646
|
</td>`})}
|
|
4579
4647
|
</tr>`)}
|
|
4580
4648
|
</table>
|
|
4581
|
-
`:
|
|
4649
|
+
`:R}
|
|
4582
4650
|
|
|
4583
4651
|
<div role="alert" part="message" id="validation-message"></div>
|
|
4584
|
-
`}};Se.styles=
|
|
4585
|
-
<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)})}};
|
|
4652
|
+
`}};Se.styles=Qo,c([u({type:String})],Se.prototype,"class",2),c([E()],Se.prototype,"_response",2),c([u({type:String,attribute:"response-identifier"})],Se.prototype,"responseIdentifier",2),c([E()],Se.prototype,"correctOptions",2),Se=c([g("qti-match-interaction")],Se);var br=class extends k{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{...k.properties,step:{type:Number,attribute:"step",default:10}}}render(){return f` <slot name="prompt"></slot>
|
|
4653
|
+
<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)})}};br.styles=[x``],br=c([g("qti-media-interaction")],br);var en=x`
|
|
4586
4654
|
[part='drags'] {
|
|
4587
4655
|
display: flex;
|
|
4588
4656
|
align-items: flex-start;
|
|
@@ -4640,17 +4708,17 @@ div.full-correct-response-inline {
|
|
|
4640
4708
|
:host(.qti-choices-right) [part='container'] {
|
|
4641
4709
|
flex-direction: row-reverse;
|
|
4642
4710
|
}
|
|
4643
|
-
`;var
|
|
4711
|
+
`;var ke=class extends me(k,"qti-simple-choice","drop-list","slot[part='drags']"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),f` <slot name="prompt"> </slot>
|
|
4644
4712
|
<div part="container">
|
|
4645
4713
|
<slot part="drags"> </slot>
|
|
4646
4714
|
<div part="drops">
|
|
4647
|
-
${[...Array(this.nrChoices)].map((t,i)=>
|
|
4715
|
+
${[...Array(this.nrChoices)].map((t,i)=>f`<drop-list role="region" part="drop-list" identifier="droplist${i}"></drop-list>`)}
|
|
4648
4716
|
</div>
|
|
4649
|
-
</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
|
|
4717
|
+
</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 b=document.createElement("span");b.classList.add("correct-option"),b.textContent=m,b.style.border="1px solid var(--qti-correct)",b.style.borderRadius="4px",b.style.padding="2px 4px",b.style.display="inline-block",b.style.marginTop="4px",h.insertAdjacentElement("afterend",b)})}}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(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};ke.styles=en,c([E()],ke.prototype,"nrChoices",2),c([E()],ke.prototype,"correctResponses",2),c([E()],ke.prototype,"showCorrectResponses",2),c([u({type:String})],ke.prototype,"orientation",2),ke=c([g("qti-order-interaction")],ke);var tn=x`
|
|
4650
4718
|
::slotted(qti-interaction-markup) {
|
|
4651
4719
|
display: none;
|
|
4652
4720
|
}
|
|
4653
|
-
`;var F=class extends R{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._responseCheckInterval=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useIframe=!1;this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=[];this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe"))switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let i=this.convertQtiVariableJSON(t.params.value);this.response=i,this.validate(),this.saveResponse(this.response);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}};this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.response=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)t&&(n.paths[a]=this.getResolvablePath(n.paths[a],t));return n}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,t)):this.getResolvablePathString(e,t);this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let s in i)if(i.hasOwnProperty(s)){let n=i[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}addHyphenatedKeys(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let s=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let s={list:{}};return s.list[i]=e,s}else{let s={base:{}};return s.base[i]=e,s}}validate(){return!0}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){if(this.useIframe)return this._value?.toString()||null;{let e=this.pci?.getResponse();if(e){let t=this.convertQtiVariableJSON(e);return Array.isArray(t)?t.join(","):t}}return Array.isArray(this._value)?this._value.join(","):this._value?.toString()||null}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,s);e[this.responseIdentifier]=a}return e}unescapeHtml(e){return e&&e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(///g,"/").replace(/`/g,"`").replace(/=/g,"=")}unescapeDataAttributes(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.unescapeHtml(s):t[i]=s;return t}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.style.width="100%",this.dom.style.minHeight="50px",this.dom.style.display="block",this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys(this.unescapeDataAttributes({...this.dataset})),contextVariables:{},templateVariables:{},onready:i=>{this.pci=i;try{let s=new ResizeObserver(n=>{for(let a of n)a.contentRect&&a.contentRect.height>0&&(this.style.height=`${a.contentRect.height+20}px`)});s.observe(this.dom),this._resizeObserver=s}catch{console.warn("ResizeObserver not supported, falling back to static sizing")}},ondone:(i,s,n,a)=>{this.response=this.convertQtiVariableJSON(s),this.saveResponse(this.response)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let s=(n=>{let a={},d=(p=>{let m={};Object.entries(p.dataset).forEach(([b,y])=>{b.includes("__")||(m[b]=y)});let f={};return Object.entries(p.dataset).forEach(([b,y])=>{let C=b.split("__");if(C.length>1){let[A,q,T]=C;f[A]=f[A]||{},f[A][q]=f[A][q]||{},f[A][q][T]=y}}),Object.entries(f).forEach(([b,y])=>{m[b]=Object.values(y)}),m})(n);for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let m=d[p];p==="config"?a[p]=JSON.parse(m):a[p]=m}return a})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(s).length?s:null)}}disconnectedCallback(){if(super.disconnectedCallback(),this.useIframe)window.removeEventListener("message",this.handleIframeMessage);else{this.stopResponseCheck(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}}sendMessageToIframe(e,t){if(!this._iframeLoaded){this._pendingMessages.push({method:e,params:t});return}this.iframe.contentWindow.postMessage({source:"qti-portable-custom-interaction",method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`,this.appendChild(this.iframe)}sendIframeInitData(){let e={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Ze(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:this.boundTo};this.sendMessageToIframe("initialize",e)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let s of i)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){if(super.connectedCallback(),this.useIframe)window.addEventListener("message",this.handleIframeMessage),this.createIframe();else{define("qtiCustomInteractionContext",()=>({register:t=>{this.register(t)},notifyReady:()=>{}}));let e=this.buildRequireConfig();if(e){let t=requirejs.config(e);requirejs.onError=function(i){throw console.error("RequireJS error:",i),i.requireType==="timeout"&&console.error("Modules that timed out:",i.requireModules),i},t(["require"],i=>{try{i([this.module],()=>{},s=>{console.error("Error loading module:",s)})}catch(s){console.error("Error in require call:",s)}})}}}stopResponseCheck(){this._responseCheckInterval!==null&&(window.clearInterval(this._responseCheckInterval),this._responseCheckInterval=null)}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{...this.getFinalRequirePaths(),...window.requirePaths||{}},shim:{...this.getFinalRequireShim(),...window.requireShim||{}}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let s=i.querySelectorAll("qti-interaction-module");for(let n of s){let a=n.getAttribute("id"),l=n.getAttribute("primary-path"),d=n.getAttribute("fallback-path");if(a&&l){let p=d?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(d,t)):this.getResolvablePath(l,t),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,p)}}}return e}combineRequireResolvePaths(e,t){let i=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return i.concat(s).filter((n,a,l)=>l.indexOf(n)===a)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),i=JSON.stringify(this.getFinalRequireShim()),s=`
|
|
4721
|
+
`;var U=class extends k{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._iframeMessageOrigin=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=null;this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe")&&!(!this.iframe?.contentWindow||e.source!==this.iframe.contentWindow)&&!(t.responseIdentifier&&t.responseIdentifier!==this.responseIdentifier)){if(this._iframeMessageOrigin===null)this._iframeMessageOrigin=e.origin;else if(e.origin!==this._iframeMessageOrigin)return;switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let i=t?.params?.value,s=i&&typeof i=="object"?this.convertQtiVariableJSON(i):null,n=typeof t?.params?.state=="string"?t.params.state:null;if(s===null){let a=this.responseVariable?.cardinality==="single"?"":[];this.response=a,this.validate(),this.saveResponse(a,n);break}this.response=s,this.validate(),this.saveResponse(s,n);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}}};this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let s in i)if(i.hasOwnProperty(s)){let n=i[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}addHyphenatedKeys(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let s=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let s={list:{}};return s.list[i]=e,s}else{let s={base:{}};return s.base[i]=e,s}}validate(){return this.response===null||this.response===void 0?!1:Array.isArray(this.response)?this.response.length===0?!1:this.response.some(e=>e!==""&&e!==null&&e!==void 0):this.response!==""}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){return this._value===null||this._value===void 0?null:Array.isArray(this._value)?this._value.join(","):String(this._value)}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,s);e[this.responseIdentifier]=a}return e}unescapeHtml(e){return e&&e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(///g,"/").replace(/`/g,"`").replace(/=/g,"=")}unescapeDataAttributes(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.unescapeHtml(s):t[i]=s;return t}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage)}sendMessageToIframe(e,t){let i=this.iframe?.contentWindow;if(!this._iframeLoaded||!i){this._pendingMessages.push({method:e,params:t});return}i.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`,this.appendChild(this.iframe)}sendIframeInitData(){let e=this.addHyphenatedKeys(this.unescapeDataAttributes({...this.dataset})),t=this.context?.state?.[this.responseIdentifier],i=typeof t=="string"&&t.length>0?t:null,s={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:jr(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:e,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:i?null:this.boundTo,state:i};this.sendMessageToIframe("initialize",s)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let s of i)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){super.connectedCallback(),this.response=this.responseVariable?.value??null,window.addEventListener("message",this.handleIframeMessage),this.createIframe()}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),i=JSON.stringify(this.getFinalRequireShim()),s=`
|
|
4654
4722
|
font-family: ${e.getPropertyValue("font-family")};
|
|
4655
4723
|
font-size: ${e.getPropertyValue("font-size")};
|
|
4656
4724
|
line-height: ${e.getPropertyValue("line-height")};
|
|
@@ -4678,6 +4746,12 @@ div.full-correct-response-inline {
|
|
|
4678
4746
|
}
|
|
4679
4747
|
#pci-container {
|
|
4680
4748
|
width: 100%;
|
|
4749
|
+
}
|
|
4750
|
+
qti-interaction-markup {
|
|
4751
|
+
display: block;
|
|
4752
|
+
width: 100%;
|
|
4753
|
+
min-height: 50px;
|
|
4754
|
+
}
|
|
4681
4755
|
</style>
|
|
4682
4756
|
<script src="${this.requireJsUrl}"></script>
|
|
4683
4757
|
<script>
|
|
@@ -4712,14 +4786,15 @@ div.full-correct-response-inline {
|
|
|
4712
4786
|
console.error('Script error usually indicates a network or CORS issue with:', err.requireModules);
|
|
4713
4787
|
}
|
|
4714
4788
|
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4789
|
+
// Notify parent window about the error
|
|
4790
|
+
window.parent.postMessage({
|
|
4791
|
+
source: 'qti-pci-iframe',
|
|
4792
|
+
responseIdentifier: (window.PCIManager && window.PCIManager.responseIdentifier) || null,
|
|
4793
|
+
method: 'error',
|
|
4794
|
+
params: {
|
|
4795
|
+
message: 'RequireJS ' + err.requireType + ' error for modules: ' + err.requireModules,
|
|
4796
|
+
details: {
|
|
4797
|
+
type: err.requireType,
|
|
4723
4798
|
modules: err.requireModules,
|
|
4724
4799
|
error: err.toString()
|
|
4725
4800
|
}
|
|
@@ -4732,13 +4807,96 @@ div.full-correct-response-inline {
|
|
|
4732
4807
|
window.PCIManager = {
|
|
4733
4808
|
pciInstance: null,
|
|
4734
4809
|
container: null,
|
|
4810
|
+
markupEl: null,
|
|
4811
|
+
propertiesEl: null,
|
|
4735
4812
|
customInteractionTypeIdentifier: null,
|
|
4813
|
+
responseIdentifier: null,
|
|
4814
|
+
pendingBoundTo: null,
|
|
4815
|
+
pendingMarkup: null,
|
|
4816
|
+
pendingProperties: null,
|
|
4817
|
+
pendingState: null,
|
|
4818
|
+
interactionChangedViaEvent: false,
|
|
4819
|
+
eventBridgeAttached: false,
|
|
4820
|
+
lastResponseStr: null,
|
|
4821
|
+
hadResponse: false,
|
|
4736
4822
|
|
|
4737
4823
|
initialize: function(config) {
|
|
4738
4824
|
this.customInteractionTypeIdentifier = config.customInteractionTypeIdentifier;
|
|
4825
|
+
this.responseIdentifier = config.responseIdentifier;
|
|
4739
4826
|
this.container = document.getElementById('pci-container');
|
|
4740
4827
|
this.container.classList.add('qti-customInteraction');
|
|
4741
4828
|
|
|
4829
|
+
function qtiVariableHasValue(qtiVar) {
|
|
4830
|
+
if (!qtiVar) return false;
|
|
4831
|
+
if (qtiVar.base) {
|
|
4832
|
+
for (const k in qtiVar.base) {
|
|
4833
|
+
if (!Object.prototype.hasOwnProperty.call(qtiVar.base, k)) continue;
|
|
4834
|
+
const v = qtiVar.base[k];
|
|
4835
|
+
if (v !== null && v !== undefined && v !== '') return true;
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
if (qtiVar.list) {
|
|
4839
|
+
for (const k in qtiVar.list) {
|
|
4840
|
+
if (!Object.prototype.hasOwnProperty.call(qtiVar.list, k)) continue;
|
|
4841
|
+
const v = qtiVar.list[k];
|
|
4842
|
+
if (Array.isArray(v) && v.some(x => x !== null && x !== undefined && x !== '')) return true;
|
|
4843
|
+
}
|
|
4844
|
+
}
|
|
4845
|
+
if (Array.isArray(qtiVar.record) && qtiVar.record.length > 0) return true;
|
|
4846
|
+
return false;
|
|
4847
|
+
}
|
|
4848
|
+
|
|
4849
|
+
const initialBoundTo = config.boundTo && config.boundTo[this.responseIdentifier];
|
|
4850
|
+
this.hadResponse = qtiVariableHasValue(initialBoundTo);
|
|
4851
|
+
this.lastResponseStr = this.hadResponse ? JSON.stringify(initialBoundTo) : null;
|
|
4852
|
+
// Ensure expected DOM structure exists (markup + properties)
|
|
4853
|
+
this.markupEl = this.container.querySelector('qti-interaction-markup');
|
|
4854
|
+
if (!this.markupEl) {
|
|
4855
|
+
this.markupEl = document.createElement('qti-interaction-markup');
|
|
4856
|
+
this.container.appendChild(this.markupEl);
|
|
4857
|
+
}
|
|
4858
|
+
this.markupEl.classList.add('qti-customInteraction');
|
|
4859
|
+
this.propertiesEl = this.container.querySelector('properties');
|
|
4860
|
+
if (!this.propertiesEl) {
|
|
4861
|
+
this.propertiesEl = document.createElement('properties');
|
|
4862
|
+
this.propertiesEl.style.display = 'none';
|
|
4863
|
+
this.container.appendChild(this.propertiesEl);
|
|
4864
|
+
} else {
|
|
4865
|
+
this.propertiesEl.style.display = 'none';
|
|
4866
|
+
}
|
|
4867
|
+
|
|
4868
|
+
// Apply any markup/properties that arrived before initialization
|
|
4869
|
+
if (this.pendingMarkup !== null) {
|
|
4870
|
+
this.setMarkup(this.pendingMarkup);
|
|
4871
|
+
this.pendingMarkup = null;
|
|
4872
|
+
}
|
|
4873
|
+
if (this.pendingProperties !== null) {
|
|
4874
|
+
this.setProperties(this.pendingProperties);
|
|
4875
|
+
this.pendingProperties = null;
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4878
|
+
// Bridge qti-interaction-changed events (preferred over polling)
|
|
4879
|
+
if (!this.eventBridgeAttached) {
|
|
4880
|
+
this.eventBridgeAttached = true;
|
|
4881
|
+
const self = this;
|
|
4882
|
+
this.container.addEventListener(
|
|
4883
|
+
'qti-interaction-changed',
|
|
4884
|
+
function(evt) {
|
|
4885
|
+
try {
|
|
4886
|
+
self.interactionChangedViaEvent = true;
|
|
4887
|
+
const value = evt && evt.detail ? evt.detail.value : undefined;
|
|
4888
|
+
if (value !== undefined) {
|
|
4889
|
+
const state = self.pciInstance && typeof self.pciInstance.getState === 'function' ? self.pciInstance.getState() : null;
|
|
4890
|
+
self.notifyInteractionChanged(value, state);
|
|
4891
|
+
}
|
|
4892
|
+
} catch (e) {
|
|
4893
|
+
// ignore bridge errors, polling fallback may still work
|
|
4894
|
+
}
|
|
4895
|
+
},
|
|
4896
|
+
true
|
|
4897
|
+
);
|
|
4898
|
+
}
|
|
4899
|
+
|
|
4742
4900
|
function getResolvablePath(path, basePath) {
|
|
4743
4901
|
if (Array.isArray(path)) {
|
|
4744
4902
|
return path.map(p => getResolvablePathString(p, basePath));
|
|
@@ -4801,23 +4959,33 @@ div.full-correct-response-inline {
|
|
|
4801
4959
|
this.pciInstance = pciInstance;
|
|
4802
4960
|
// Configure PCI instance
|
|
4803
4961
|
const pciConfig = {
|
|
4804
|
-
properties:
|
|
4962
|
+
properties: config.properties || {},
|
|
4805
4963
|
contextVariables: config.contextVariables || {},
|
|
4806
4964
|
templateVariables: config.templateVariables || {},
|
|
4807
4965
|
onready: pciInstance => {
|
|
4808
4966
|
this.pciInstance = pciInstance;
|
|
4967
|
+
// Apply any pending updates that arrived before onready
|
|
4968
|
+
if (this.pendingBoundTo) {
|
|
4969
|
+
this.applyBoundTo(this.pendingBoundTo);
|
|
4970
|
+
this.pendingBoundTo = null;
|
|
4971
|
+
}
|
|
4972
|
+
if (this.pendingState && typeof this.pciInstance.setState === 'function') {
|
|
4973
|
+
this.pciInstance.setState(this.pendingState);
|
|
4974
|
+
this.pendingState = null;
|
|
4975
|
+
}
|
|
4809
4976
|
this.notifyReady();
|
|
4810
4977
|
},
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4978
|
+
ondone: (pciInstance, response, state, status) => {
|
|
4979
|
+
this.notifyInteractionChanged(response, typeof state === 'string' ? state : null);
|
|
4980
|
+
},
|
|
4981
|
+
responseIdentifier: config.responseIdentifier,
|
|
4982
|
+
boundTo: config.boundTo,
|
|
4983
|
+
};
|
|
4984
|
+
|
|
4985
|
+
if (pciInstance.getInstance) {
|
|
4986
|
+
const dom = this.markupEl || this.container;
|
|
4987
|
+
pciInstance.getInstance(dom, pciConfig, config.state || undefined);
|
|
4988
|
+
} else {
|
|
4821
4989
|
// TAO custom interaction initialization
|
|
4822
4990
|
const restoreTAOConfig = (dataset) => {
|
|
4823
4991
|
const config = {};
|
|
@@ -4825,7 +4993,7 @@ div.full-correct-response-inline {
|
|
|
4825
4993
|
const result = {};
|
|
4826
4994
|
|
|
4827
4995
|
// Separate direct attributes from nested ones
|
|
4828
|
-
Object.entries(dataset ||
|
|
4996
|
+
Object.entries(dataset || {}).forEach(([key, value]) => {
|
|
4829
4997
|
if (!key.includes('__')) {
|
|
4830
4998
|
// Direct attributes (like version)
|
|
4831
4999
|
result[key] = value;
|
|
@@ -4835,7 +5003,7 @@ div.full-correct-response-inline {
|
|
|
4835
5003
|
// Parse nested attributes
|
|
4836
5004
|
const nestedData = {};
|
|
4837
5005
|
|
|
4838
|
-
Object.entries(dataset ||
|
|
5006
|
+
Object.entries(dataset || {}).forEach(([key, value]) => {
|
|
4839
5007
|
const parts = key.split('__');
|
|
4840
5008
|
if (parts.length > 1) {
|
|
4841
5009
|
const [group, index, prop] = parts;
|
|
@@ -4868,17 +5036,13 @@ div.full-correct-response-inline {
|
|
|
4868
5036
|
|
|
4869
5037
|
this.pciInstance.initialize(
|
|
4870
5038
|
this.customInteractionTypeIdentifier,
|
|
4871
|
-
this.container.firstElementChild || this.container,
|
|
5039
|
+
(this.markupEl || this.container).firstElementChild || (this.markupEl || this.container),
|
|
4872
5040
|
Object.keys(taoConfig).length ? taoConfig : null
|
|
4873
5041
|
);
|
|
4874
5042
|
}
|
|
4875
5043
|
},
|
|
4876
5044
|
notifyReady: () => {
|
|
4877
|
-
|
|
4878
|
-
window.parent.postMessage({
|
|
4879
|
-
source: 'qti-pci-iframe',
|
|
4880
|
-
method: 'pciReady'
|
|
4881
|
-
}, '*');
|
|
5045
|
+
PCIManager.notifyReady();
|
|
4882
5046
|
}
|
|
4883
5047
|
};
|
|
4884
5048
|
});
|
|
@@ -4908,73 +5072,121 @@ div.full-correct-response-inline {
|
|
|
4908
5072
|
}
|
|
4909
5073
|
},
|
|
4910
5074
|
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
5075
|
+
notifyReady: function() {
|
|
5076
|
+
window.parent.postMessage({
|
|
5077
|
+
source: 'qti-pci-iframe',
|
|
5078
|
+
responseIdentifier: this.responseIdentifier,
|
|
5079
|
+
method: 'iframeReady'
|
|
5080
|
+
}, '*');
|
|
5081
|
+
},
|
|
5082
|
+
|
|
5083
|
+
notifyInteractionChanged: function(response, state) {
|
|
5084
|
+
window.parent.postMessage({
|
|
5085
|
+
source: 'qti-pci-iframe',
|
|
5086
|
+
responseIdentifier: this.responseIdentifier,
|
|
5087
|
+
method: 'interactionChanged',
|
|
5088
|
+
params: { value: response, state: state }
|
|
5089
|
+
}, '*');
|
|
5090
|
+
},
|
|
5091
|
+
|
|
5092
|
+
notifyError: function(message) {
|
|
5093
|
+
console.error('PCI Error:', message);
|
|
5094
|
+
window.parent.postMessage({
|
|
5095
|
+
source: 'qti-pci-iframe',
|
|
5096
|
+
responseIdentifier: this.responseIdentifier,
|
|
5097
|
+
method: 'error',
|
|
5098
|
+
params: { message: message }
|
|
5099
|
+
}, '*');
|
|
5100
|
+
},
|
|
4917
5101
|
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
5102
|
+
setMarkup: function(markupHtml) {
|
|
5103
|
+
if (!this.container) {
|
|
5104
|
+
this.container = document.getElementById('pci-container');
|
|
5105
|
+
}
|
|
5106
|
+
if (!this.container) {
|
|
5107
|
+
this.pendingMarkup = markupHtml;
|
|
5108
|
+
return;
|
|
5109
|
+
}
|
|
5110
|
+
this.markupEl = this.container.querySelector('qti-interaction-markup');
|
|
5111
|
+
if (!this.markupEl) {
|
|
5112
|
+
this.markupEl = document.createElement('qti-interaction-markup');
|
|
5113
|
+
this.container.appendChild(this.markupEl);
|
|
5114
|
+
}
|
|
5115
|
+
this.markupEl.classList.add('qti-customInteraction');
|
|
5116
|
+
this.markupEl.innerHTML = markupHtml || '';
|
|
4924
5117
|
},
|
|
4925
5118
|
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
5119
|
+
setProperties: function(propertiesHtml) {
|
|
5120
|
+
if (!this.container) {
|
|
5121
|
+
this.container = document.getElementById('pci-container');
|
|
5122
|
+
}
|
|
5123
|
+
if (!this.container) {
|
|
5124
|
+
this.pendingProperties = propertiesHtml;
|
|
5125
|
+
return;
|
|
5126
|
+
}
|
|
5127
|
+
this.propertiesEl = this.container.querySelector('properties');
|
|
5128
|
+
if (!this.propertiesEl) {
|
|
5129
|
+
this.propertiesEl = document.createElement('properties');
|
|
5130
|
+
this.container.appendChild(this.propertiesEl);
|
|
5131
|
+
}
|
|
5132
|
+
this.propertiesEl.style.display = 'none';
|
|
5133
|
+
this.propertiesEl.innerHTML = propertiesHtml || '';
|
|
4933
5134
|
},
|
|
4934
5135
|
|
|
4935
|
-
|
|
4936
|
-
this.
|
|
4937
|
-
this.
|
|
5136
|
+
applyBoundTo: function(boundTo) {
|
|
5137
|
+
if (!this.pciInstance || typeof this.pciInstance.setResponse !== 'function') return;
|
|
5138
|
+
const value = boundTo && (boundTo[this.responseIdentifier] || boundTo[Object.keys(boundTo)[0]]);
|
|
5139
|
+
if (value) this.pciInstance.setResponse(value);
|
|
4938
5140
|
},
|
|
5141
|
+
};
|
|
4939
5142
|
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
5143
|
+
// Set up message listener for communication with parent
|
|
5144
|
+
let expectedParentOrigin = null;
|
|
5145
|
+
window.addEventListener('message', function(event) {
|
|
5146
|
+
const { data } = event;
|
|
5147
|
+
|
|
5148
|
+
// Ensure the message is from our parent
|
|
5149
|
+
if (event.source !== window.parent || !data || data.source !== 'qti-portable-custom-interaction') {
|
|
5150
|
+
return;
|
|
5151
|
+
}
|
|
5152
|
+
if (expectedParentOrigin === null) {
|
|
5153
|
+
expectedParentOrigin = event.origin;
|
|
5154
|
+
} else if (event.origin !== expectedParentOrigin) {
|
|
5155
|
+
return;
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
function deepQuerySelector(root, selector) {
|
|
5159
|
+
if (!root) return null;
|
|
5160
|
+
try {
|
|
5161
|
+
const direct = root.querySelector ? root.querySelector(selector) : null;
|
|
5162
|
+
if (direct) return direct;
|
|
5163
|
+
} catch (e) {
|
|
5164
|
+
// ignore invalid selector for this root
|
|
4947
5165
|
}
|
|
4948
|
-
return
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
unescaped[key] = value
|
|
4955
|
-
.replace(/&/g, '&')
|
|
4956
|
-
.replace(/</g, '<')
|
|
4957
|
-
.replace(/>/g, '>')
|
|
4958
|
-
.replace(/"/g, '"')
|
|
4959
|
-
.replace(/'/g, "'")
|
|
4960
|
-
.replace(///g, '/')
|
|
4961
|
-
.replace(/`/g, '\`')
|
|
4962
|
-
.replace(/=/g, '=');
|
|
4963
|
-
} else {
|
|
4964
|
-
unescaped[key] = value;
|
|
5166
|
+
if (!root.querySelectorAll) return null;
|
|
5167
|
+
const nodes = root.querySelectorAll('*');
|
|
5168
|
+
for (const node of nodes) {
|
|
5169
|
+
if (node && node.shadowRoot) {
|
|
5170
|
+
const found = deepQuerySelector(node.shadowRoot, selector);
|
|
5171
|
+
if (found) return found;
|
|
4965
5172
|
}
|
|
4966
5173
|
}
|
|
4967
|
-
return
|
|
4968
|
-
}
|
|
4969
|
-
};
|
|
4970
|
-
|
|
4971
|
-
// Set up message listener for communication with parent
|
|
4972
|
-
window.addEventListener('message', function(event) {
|
|
4973
|
-
const { data } = event;
|
|
5174
|
+
return null;
|
|
5175
|
+
}
|
|
4974
5176
|
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
5177
|
+
function deepFindElementByExactText(root, text) {
|
|
5178
|
+
if (!root || !text) return null;
|
|
5179
|
+
if (root.querySelectorAll) {
|
|
5180
|
+
const nodes = root.querySelectorAll('*');
|
|
5181
|
+
for (const node of nodes) {
|
|
5182
|
+
if ((node.textContent || '').trim() === text) return node;
|
|
5183
|
+
if (node.shadowRoot) {
|
|
5184
|
+
const found = deepFindElementByExactText(node.shadowRoot, text);
|
|
5185
|
+
if (found) return found;
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
}
|
|
5189
|
+
return null;
|
|
4978
5190
|
}
|
|
4979
5191
|
|
|
4980
5192
|
switch(data.method) {
|
|
@@ -4987,22 +5199,140 @@ div.full-correct-response-inline {
|
|
|
4987
5199
|
break;
|
|
4988
5200
|
|
|
4989
5201
|
case 'setBoundTo':
|
|
4990
|
-
|
|
5202
|
+
if (PCIManager.pciInstance) {
|
|
5203
|
+
PCIManager.applyBoundTo(data.params);
|
|
5204
|
+
} else {
|
|
5205
|
+
PCIManager.pendingBoundTo = data.params;
|
|
5206
|
+
}
|
|
4991
5207
|
break;
|
|
4992
5208
|
|
|
4993
5209
|
case 'setProperties':
|
|
4994
|
-
|
|
5210
|
+
PCIManager.setProperties(data.params);
|
|
5211
|
+
break;
|
|
5212
|
+
|
|
5213
|
+
case 'setState':
|
|
5214
|
+
if (PCIManager.pciInstance && typeof PCIManager.pciInstance.setState === 'function') {
|
|
5215
|
+
PCIManager.pciInstance.setState((data.params && data.params.state) || data.params);
|
|
5216
|
+
} else {
|
|
5217
|
+
PCIManager.pendingState = (data.params && data.params.state) || data.params;
|
|
5218
|
+
}
|
|
5219
|
+
break;
|
|
5220
|
+
|
|
5221
|
+
case 'getContent': {
|
|
5222
|
+
const messageId = data.params && data.params.messageId;
|
|
5223
|
+
const collectShadowHtml = root => {
|
|
5224
|
+
const parts = [];
|
|
5225
|
+
if (!root || !root.querySelectorAll) return parts;
|
|
5226
|
+
const nodes = root.querySelectorAll('*');
|
|
5227
|
+
for (const node of nodes) {
|
|
5228
|
+
if (node && node.shadowRoot) {
|
|
5229
|
+
parts.push(node.shadowRoot.innerHTML || '');
|
|
5230
|
+
parts.push(...collectShadowHtml(node.shadowRoot));
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
return parts;
|
|
5234
|
+
};
|
|
5235
|
+
const shadowHtml = collectShadowHtml(document).join('\\n');
|
|
5236
|
+
window.parent.postMessage(
|
|
5237
|
+
{
|
|
5238
|
+
source: 'qti-pci-iframe',
|
|
5239
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5240
|
+
method: 'getContentResponse',
|
|
5241
|
+
messageId: messageId,
|
|
5242
|
+
content: (document.documentElement ? document.documentElement.outerHTML : '') + '\\n' + shadowHtml
|
|
5243
|
+
},
|
|
5244
|
+
'*'
|
|
5245
|
+
);
|
|
4995
5246
|
break;
|
|
5247
|
+
}
|
|
5248
|
+
|
|
5249
|
+
case 'simulateClick': {
|
|
5250
|
+
const messageId = data.params && data.params.messageId;
|
|
5251
|
+
const x = data.params && data.params.x;
|
|
5252
|
+
const y = data.params && data.params.y;
|
|
5253
|
+
const el = typeof x === 'number' && typeof y === 'number' ? document.elementFromPoint(x, y) : null;
|
|
5254
|
+
if (el && typeof el.click === 'function') el.click();
|
|
5255
|
+
window.parent.postMessage(
|
|
5256
|
+
{
|
|
5257
|
+
source: 'qti-pci-iframe',
|
|
5258
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5259
|
+
method: 'clickResponse',
|
|
5260
|
+
messageId: messageId
|
|
5261
|
+
},
|
|
5262
|
+
'*'
|
|
5263
|
+
);
|
|
5264
|
+
break;
|
|
5265
|
+
}
|
|
5266
|
+
|
|
5267
|
+
case 'clickOnSelector': {
|
|
5268
|
+
const messageId = data.params && data.params.messageId;
|
|
5269
|
+
const selector = data.params && data.params.selector;
|
|
5270
|
+
const el = selector ? deepQuerySelector(document, selector) : null;
|
|
5271
|
+
const success = !!el;
|
|
5272
|
+
if (el && typeof el.click === 'function') el.click();
|
|
5273
|
+
window.parent.postMessage(
|
|
5274
|
+
{
|
|
5275
|
+
source: 'qti-pci-iframe',
|
|
5276
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5277
|
+
method: 'clickSelectorResponse',
|
|
5278
|
+
messageId: messageId,
|
|
5279
|
+
success: success
|
|
5280
|
+
},
|
|
5281
|
+
'*'
|
|
5282
|
+
);
|
|
5283
|
+
break;
|
|
5284
|
+
}
|
|
5285
|
+
|
|
5286
|
+
case 'clickOnElementByText': {
|
|
5287
|
+
const messageId = data.params && data.params.messageId;
|
|
5288
|
+
const text = data.params && data.params.text;
|
|
5289
|
+
const target = text ? deepFindElementByExactText(document, text) : null;
|
|
5290
|
+
const success = !!target;
|
|
5291
|
+
if (target && typeof target.click === 'function') target.click();
|
|
5292
|
+
window.parent.postMessage(
|
|
5293
|
+
{
|
|
5294
|
+
source: 'qti-pci-iframe',
|
|
5295
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5296
|
+
method: 'clickTextResponse',
|
|
5297
|
+
messageId: messageId,
|
|
5298
|
+
success: success
|
|
5299
|
+
},
|
|
5300
|
+
'*'
|
|
5301
|
+
);
|
|
5302
|
+
break;
|
|
5303
|
+
}
|
|
5304
|
+
|
|
5305
|
+
case 'setValueElement': {
|
|
5306
|
+
const messageId = data.params && data.params.messageId;
|
|
5307
|
+
const selector = data.params && data.params.selector;
|
|
5308
|
+
const value = data.params && data.params.value;
|
|
5309
|
+
const el = selector ? deepQuerySelector(document, selector) : null;
|
|
5310
|
+
let success = false;
|
|
5311
|
+
if (el && 'value' in el) {
|
|
5312
|
+
try {
|
|
5313
|
+
el.value = value;
|
|
5314
|
+
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
5315
|
+
el.dispatchEvent(new Event('change', { bubbles: true }));
|
|
5316
|
+
success = true;
|
|
5317
|
+
} catch (e) {
|
|
5318
|
+
success = false;
|
|
5319
|
+
}
|
|
5320
|
+
}
|
|
5321
|
+
window.parent.postMessage(
|
|
5322
|
+
{
|
|
5323
|
+
source: 'qti-pci-iframe',
|
|
5324
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5325
|
+
method: 'setValueResponse',
|
|
5326
|
+
messageId: messageId,
|
|
5327
|
+
success: success
|
|
5328
|
+
},
|
|
5329
|
+
'*'
|
|
5330
|
+
);
|
|
5331
|
+
break;
|
|
5332
|
+
}
|
|
4996
5333
|
}
|
|
4997
5334
|
});
|
|
4998
5335
|
|
|
4999
|
-
// Notify parent that iframe has loaded
|
|
5000
|
-
window.addEventListener('load', function() {
|
|
5001
|
-
window.parent.postMessage({
|
|
5002
|
-
source: 'qti-pci-iframe',
|
|
5003
|
-
method: 'iframeLoaded'
|
|
5004
|
-
}, '*');
|
|
5005
|
-
});
|
|
5006
5336
|
let resizeTimeout;
|
|
5007
5337
|
let previousHeight = 0;
|
|
5008
5338
|
const notifyResize = () => {
|
|
@@ -5011,14 +5341,15 @@ div.full-correct-response-inline {
|
|
|
5011
5341
|
if (newHeight !== previousHeight) {
|
|
5012
5342
|
previousHeight = newHeight;
|
|
5013
5343
|
clearTimeout(resizeTimeout);
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5344
|
+
resizeTimeout = setTimeout(() => {
|
|
5345
|
+
window.parent.postMessage({
|
|
5346
|
+
source: 'qti-pci-iframe',
|
|
5347
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5348
|
+
method: 'resize',
|
|
5349
|
+
height: newHeight,
|
|
5350
|
+
width: container.scrollWidth
|
|
5351
|
+
}, '*');
|
|
5352
|
+
}, 100); // Adjust debounce time as needed
|
|
5022
5353
|
}
|
|
5023
5354
|
};
|
|
5024
5355
|
|
|
@@ -5052,18 +5383,43 @@ div.full-correct-response-inline {
|
|
|
5052
5383
|
});
|
|
5053
5384
|
let lastResponseStr = '';
|
|
5054
5385
|
setInterval(() => {
|
|
5386
|
+
if (PCIManager.interactionChangedViaEvent) return;
|
|
5055
5387
|
if (PCIManager.pciInstance && PCIManager.pciInstance.getResponse) {
|
|
5056
5388
|
const response = PCIManager.pciInstance.getResponse();
|
|
5389
|
+
if (response === undefined) {
|
|
5390
|
+
// Don't emit an initial empty on load; only emit a clear if we previously had a value
|
|
5391
|
+
if (!PCIManager.hadResponse) return;
|
|
5392
|
+
PCIManager.hadResponse = false;
|
|
5393
|
+
PCIManager.lastResponseStr = null;
|
|
5394
|
+
const state = PCIManager.pciInstance && typeof PCIManager.pciInstance.getState === 'function' ? PCIManager.pciInstance.getState() : null;
|
|
5395
|
+
window.parent.postMessage(
|
|
5396
|
+
{
|
|
5397
|
+
source: 'qti-pci-iframe',
|
|
5398
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5399
|
+
method: 'interactionChanged',
|
|
5400
|
+
params: { value: null, state: state }
|
|
5401
|
+
},
|
|
5402
|
+
'*'
|
|
5403
|
+
);
|
|
5404
|
+
return;
|
|
5405
|
+
}
|
|
5406
|
+
|
|
5057
5407
|
const responseStr = JSON.stringify(response);
|
|
5058
5408
|
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5409
|
+
if (responseStr !== PCIManager.lastResponseStr) {
|
|
5410
|
+
PCIManager.lastResponseStr = responseStr;
|
|
5411
|
+
PCIManager.hadResponse = true;
|
|
5412
|
+
const state = PCIManager.pciInstance && typeof PCIManager.pciInstance.getState === 'function' ? PCIManager.pciInstance.getState() : null;
|
|
5413
|
+
window.parent.postMessage(
|
|
5414
|
+
{
|
|
5415
|
+
source: 'qti-pci-iframe',
|
|
5416
|
+
responseIdentifier: PCIManager.responseIdentifier,
|
|
5417
|
+
method: 'interactionChanged',
|
|
5418
|
+
params: { value: response, state: state }
|
|
5419
|
+
},
|
|
5420
|
+
'*'
|
|
5421
|
+
);
|
|
5422
|
+
}
|
|
5067
5423
|
}
|
|
5068
5424
|
}, 500); // Check every 500ms
|
|
5069
5425
|
</script>
|
|
@@ -5071,24 +5427,19 @@ div.full-correct-response-inline {
|
|
|
5071
5427
|
<body>
|
|
5072
5428
|
<div id="pci-container"></div>
|
|
5073
5429
|
</body>
|
|
5074
|
-
</html>`}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t.cardinality==="single"?"":[];let i=`correct-response-container-${this.responseIdentifier}`,s=this.parentElement?.querySelectorAll(`#${i}`);if(s&&s.forEach(
|
|
5430
|
+
</html>`}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t.cardinality==="single"?"":[];let i=`correct-response-container-${this.responseIdentifier}`,s=this.parentElement?.querySelectorAll(`#${i}`);if(s&&s.forEach(h=>{h.remove()}),e)this.disable();else{this.enable();return}if(!e||!t?.correctResponse)return;let n=document.createElement("div");n.id=i,n.className="pci-correct-response-container",n.style.position="relative",n.style.marginTop="20px",n.style.border="2px solid green",n.style.padding="16px",n.style.borderRadius="4px",n.style.backgroundColor="rgba(0, 128, 0, 0.05)";let a=document.createElement("div");a.textContent="Correct Response:",a.style.fontWeight="bold",a.style.marginBottom="10px",a.style.color="green",n.appendChild(a);let l=document.createElement("qti-portable-custom-interaction");Array.from(this.attributes).forEach(h=>{h.name!=="id"&&h.name!=="response-identifier"&&l.setAttribute(h.name,h.value)});let d=this.responseIdentifier;l.responseIdentifier=`${d}-correct`,Array.from(this.children).forEach(h=>{let b=h.cloneNode(!0);l.appendChild(b)});let p=t.correctResponse,m=l.connectedCallback;l.connectedCallback=function(){m.call(this);let h=()=>this._iframeLoaded?(setTimeout(()=>{let b=this.responseVariablesToQtiVariableJSON(p,t.cardinality,t.baseType);this.sendMessageToIframe("setBoundTo",{[d]:b}),this.sendMessageToIframe("setState",{state:"review"})},1e3),!0):!1;if(!h()){let b=setInterval(()=>{h()&&clearInterval(b)},100);setTimeout(()=>{clearInterval(b)},1e4)}},l.style.pointerEvents="none",n.appendChild(l),this.after(n)}disable(){if(this._previousState={pointerEvents:this.style.pointerEvents,position:this.style.position},this.sendMessageToIframe("setState",{state:"disabled"}),!this.querySelector(".pci-interaction-overlay")){let t=document.createElement("div");t.className="pci-interaction-overlay",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(200, 200, 200, 0.3)",t.style.zIndex="100",t.style.pointerEvents="all",t.style.cursor="not-allowed",getComputedStyle(this).position==="static"&&(this.style.position="relative"),this.appendChild(t)}}enable(){let e=this.querySelector(".pci-interaction-overlay");e&&e.remove(),this._previousState&&(this._previousState.pointerEvents&&(this.style.pointerEvents=this._previousState.pointerEvents),this._previousState.position&&(this.style.position=this._previousState.position),this._previousState=null),this.sendMessageToIframe("setState",{state:"interacting"})}render(){return f`
|
|
5075
5431
|
<slot></slot>
|
|
5076
|
-
${this._errorMessage?
|
|
5432
|
+
${this._errorMessage?f`<div style="color:red">
|
|
5077
5433
|
<h1>Error</h1>
|
|
5078
5434
|
${this._errorMessage}
|
|
5079
5435
|
</div>`:""}
|
|
5080
|
-
`}};
|
|
5436
|
+
`}};U.styles=[tn,x`
|
|
5081
5437
|
:host {
|
|
5082
5438
|
display: block;
|
|
5083
5439
|
width: 100%;
|
|
5084
5440
|
min-height: 50px;
|
|
5085
5441
|
}
|
|
5086
|
-
|
|
5087
|
-
display: block;
|
|
5088
|
-
width: 100%;
|
|
5089
|
-
min-height: 50px;
|
|
5090
|
-
}
|
|
5091
|
-
`],c([u({type:String,attribute:"module"})],F.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],F.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],F.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],F.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],F.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],F.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-iframe"})],F.prototype,"useIframe",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],F.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],F.prototype,"useDefaultPaths",2),c([E()],F.prototype,"_errorMessage",2),c([_({context:P,subscribe:!0}),E()],F.prototype,"context",2),c([E()],F.prototype,"response",2),F=c([g("qti-portable-custom-interaction")],F);var Ki=class extends v{render(){return h`<slot></slot>`}static{this.styles=[x`
|
|
5442
|
+
`],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([E()],U.prototype,"_errorMessage",2),c([_({context:P,subscribe:!0}),E()],U.prototype,"context",2),c([E()],U.prototype,"response",2),U=c([g("qti-portable-custom-interaction")],U);var Zi=class extends v{render(){return f`<slot></slot>`}static{this.styles=[x`
|
|
5092
5443
|
:host {
|
|
5093
5444
|
display: block;
|
|
5094
5445
|
}
|
|
@@ -5099,24 +5450,24 @@ div.full-correct-response-inline {
|
|
|
5099
5450
|
left: 50%;
|
|
5100
5451
|
transform: translateX(-50%);
|
|
5101
5452
|
}
|
|
5102
|
-
`]}};customElements.define("qti-position-object-interaction",
|
|
5453
|
+
`]}};customElements.define("qti-position-object-interaction",Zi);var vr=class extends v{render(){return f`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(r){r.preventDefault();let e=r.clientX-this.startX,t=r.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=r.clientX,this.startY=r.clientY}firstUpdated(r){super.firstUpdated(r),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};vr.styles=[x`
|
|
5103
5454
|
:host {
|
|
5104
5455
|
display: inline-block;
|
|
5105
5456
|
position: relative;
|
|
5106
5457
|
}
|
|
5107
|
-
`],
|
|
5458
|
+
`],vr=c([g("qti-position-object-stage")],vr);var rn="important",ta=" !"+rn,Qi=te(class extends ue{constructor(o){if(super(o),o.type!==He.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(ta);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?rn:""):e[t]=i}}return V}});var fe=class extends k{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()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}get responsePoints(){return(this.response||[]).filter(e=>e).map(e=>{let[t,i]=e.split(" ").map(Number);return{x:t,y:i}})}toggleCandidateCorrection(e){this._responseCorrection=[],e&&this.responsePoints.forEach(t=>{let i=this.responseVariable.areaMapping.areaMapEntries.some(s=>z.isPointInArea(`${t.x} ${t.y}`,`${s.shape},${s.coords}`,this.responseVariable.baseType));this._responseCorrection.push(i)})}toggleCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctAreas=[];return}let i=t.areaMapping,s=[];if(!i||i.areaMapEntries.length===0)if(t.correctResponse){let n=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];if(n.length===0||n.find(a=>a.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),s=n.map(a=>({shape:"circle",coords:a.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else s=i.areaMapEntries;this._correctAreas=s.map(n=>({coords:n.coords,shape:n.shape}))}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let s=i.dataset.coord,n=i.dataset.shape;s&&n&&Fe(n,s.split(",").map(a=>+a),t,i)}))}render(){return f` <slot name="prompt"></slot>
|
|
5108
5459
|
<point-container>
|
|
5109
|
-
${
|
|
5460
|
+
${At((this.response||[]).filter(e=>e),e=>e,(e,t)=>{let[i,s]=e.split(" ").map(Number),n=i/(this._imageWidthOriginal||1)*100,a=s/(this._imageHeightOriginal||1)*100,l=16,d=l/(this._imageWidthOriginal||1)*100,p=l/(this._imageHeightOriginal||1)*100,m="";return this._responseCorrection[t]===!0?m=" correct":this._responseCorrection[t]===!1&&(m=" incorrect"),f`
|
|
5110
5461
|
<button
|
|
5111
5462
|
part="point${m}"
|
|
5112
|
-
style=${
|
|
5463
|
+
style=${Qi({pointerEvents:this.maxChoices===1?"none":"auto",position:"absolute",transform:"translate(-50%, -50%)",left:`${n}%`,top:`${a}%`,width:`min(${d}%, 1rem)`,height:`min(${p}%, 1rem)`,minWidth:`min(${d}%, 1rem)`,minHeight:`min(${p}%, 1rem)`,borderRadius:"50%",background:"red"})}
|
|
5113
5464
|
aria-label="Remove point at ${e}"
|
|
5114
5465
|
?disabled=${this.disabled}
|
|
5115
|
-
@click=${
|
|
5466
|
+
@click=${h=>{h.stopPropagation(),this.response=(this.response||[]).filter((b,y)=>y!==t),this.saveResponse(this.response)}}
|
|
5116
5467
|
></button>
|
|
5117
5468
|
`})}
|
|
5118
|
-
${
|
|
5119
|
-
style=${
|
|
5469
|
+
${At(this._correctAreas?.filter(e=>e)||[],e=>e,(e,t)=>f`<div
|
|
5470
|
+
style=${Qi({position:"absolute",pointerEvents:"none",backgroundColor:"var(--qti-correct)",opacity:"0.5"})}
|
|
5120
5471
|
data-coord="${e.coords}"
|
|
5121
5472
|
alt=${`correct-response-${t+1}`}
|
|
5122
5473
|
data-shape="${e.shape}"
|
|
@@ -5137,7 +5488,7 @@ div.full-correct-response-inline {
|
|
|
5137
5488
|
height: auto;
|
|
5138
5489
|
display: block;
|
|
5139
5490
|
}
|
|
5140
|
-
`],c([u({type:Number,attribute:"max-choices"})],fe.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],fe.prototype,"minChoices",2),c([E()],fe.prototype,"response",2),c([E()],fe.prototype,"_correctAreas",2),c([E()],fe.prototype,"_responseCorrection",2),fe=c([g("qti-select-point-interaction")],fe);var
|
|
5491
|
+
`],c([u({type:Number,attribute:"max-choices"})],fe.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],fe.prototype,"minChoices",2),c([E()],fe.prototype,"response",2),c([E()],fe.prototype,"_correctAreas",2),c([E()],fe.prototype,"_responseCorrection",2),fe=c([g("qti-select-point-interaction")],fe);var sn=x`
|
|
5141
5492
|
:host {
|
|
5142
5493
|
display: block;
|
|
5143
5494
|
--show-bounds: true;
|
|
@@ -5217,7 +5568,7 @@ div.full-correct-response-inline {
|
|
|
5217
5568
|
text-align: center;
|
|
5218
5569
|
color: #6b7280; /* text-gray-500 */
|
|
5219
5570
|
}
|
|
5220
|
-
`;var
|
|
5571
|
+
`;var Re=class extends k{constructor(){super(...arguments);this._value=0;this._correctResponseNumber=null;this.min=0;this.max=100;this.step=1}validate(){return!0}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this._value.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}toggleCorrectResponse(e){let t=this.responseVariable;if(t?.correctResponse){if(e){this._correctResponse=t.correctResponse.toString();let i=parseFloat(t.correctResponse.toString());if(isNaN(i))this._correctResponseNumber=null;else{this._correctResponseNumber=i;let s=(this._correctResponseNumber-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${s}%`)}}else this._correctResponseNumber=null;this.requestUpdate()}}_updateValue(e){let t=this._value;if(this._value=Math.min(this.max,Math.max(this.min,e)),this._value===t)return;let i=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${i}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return f`
|
|
5221
5572
|
<slot name="prompt"></slot>
|
|
5222
5573
|
<div id="slider" part="slider">
|
|
5223
5574
|
<div id="bounds" part="bounds">
|
|
@@ -5232,14 +5583,14 @@ div.full-correct-response-inline {
|
|
|
5232
5583
|
<div id="value" part="value">${this.response}</div>
|
|
5233
5584
|
</div>
|
|
5234
5585
|
|
|
5235
|
-
${this._correctResponseNumber!==null?
|
|
5586
|
+
${this._correctResponseNumber!==null?f`
|
|
5236
5587
|
<div id="knob-correct" part="knob-correct">
|
|
5237
5588
|
<div id="value" part="value">${this._correctResponseNumber}</div>
|
|
5238
5589
|
</div>
|
|
5239
5590
|
`:null}
|
|
5240
5591
|
</div>
|
|
5241
5592
|
</div>
|
|
5242
|
-
`}_onMouseDown(e){this._startDrag(e.pageX);let t=s=>this._onDrag(s.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=s=>this._onDrag(s.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,s=Math.min(1,Math.max(0,i/t.width)),n=this.min+Math.round(s*(this.max-this.min)/this.step)*this.step;this._updateValue(n)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};
|
|
5593
|
+
`}_onMouseDown(e){this._startDrag(e.pageX);let t=s=>this._onDrag(s.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=s=>this._onDrag(s.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,s=Math.min(1,Math.max(0,i/t.width)),n=this.min+Math.round(s*(this.max-this.min)/this.step)*this.step;this._updateValue(n)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};Re.styles=sn,c([at("#rail")],Re.prototype,"_rail",2),c([u({type:Number,attribute:"lower-bound"})],Re.prototype,"min",2),c([u({type:Number,attribute:"upper-bound"})],Re.prototype,"max",2),c([u({type:Number,attribute:"step"})],Re.prototype,"step",2),Re=c([g("qti-slider-interaction")],Re);var on=()=>new ts,ts=class{},es=new WeakMap,eq=te(class extends yt{render(o){return R}update(o,[r]){let e=r!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=r,this.ht=o.options?.host,this.rt(this.ct=o.element)),R}rt(o){if(this.isConnected||(o=void 0),typeof this.G=="function"){let r=this.ht??globalThis,e=es.get(r);e===void 0&&(e=new WeakMap,es.set(r,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,o),o!==void 0&&this.G.call(this.ht,o)}else this.G.value=o}get lt(){return typeof this.G=="function"?es.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var nn=x`
|
|
5243
5594
|
:host {
|
|
5244
5595
|
display: inline-block;
|
|
5245
5596
|
}
|
|
@@ -5347,7 +5698,7 @@ div.full-correct-response-inline {
|
|
|
5347
5698
|
bottom: 0;
|
|
5348
5699
|
}
|
|
5349
5700
|
}
|
|
5350
|
-
`;var Q=class extends
|
|
5701
|
+
`;var Q=class extends k{constructor(){super(...arguments);this.inputRef=on();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}get value(){return this.response||null}set value(e){this.response=e||null}get correctness(){let e=this.responseVariable;if(!e)return null;if(e.value===null)return"incorrect";if(e.mapping){let t=e.mapping.mapEntries.reduce((i,s)=>Math.max(s.mappedValue,i),0);for(let i of e.mapping.mapEntries){let s=i.mapKey,n=e.value;if(i.caseSensitive||(s=s.toLowerCase(),n=n.toLowerCase()),s===n)return i.mappedValue===t?"correct":i.mappedValue<=(e.mapping.defaultValue||0)?"incorrect":"partially-correct"}}return e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!0}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(e&&t?.correctResponse){let i=t.correctResponse.toString();this._correctResponse=i}else this._correctResponse=null}render(){return f`
|
|
5351
5702
|
<input
|
|
5352
5703
|
part="input"
|
|
5353
5704
|
name="${this.responseIdentifier}"
|
|
@@ -5365,13 +5716,13 @@ div.full-correct-response-inline {
|
|
|
5365
5716
|
?disabled="${this.disabled}"
|
|
5366
5717
|
?readonly="${this.readonly}"
|
|
5367
5718
|
/>
|
|
5368
|
-
${this._correctResponse?
|
|
5369
|
-
`}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")}};Q.styles=
|
|
5719
|
+
${this._correctResponse?f`<div part="correct">${this._correctResponse}</div>`:R}
|
|
5720
|
+
`}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")}};Q.styles=nn,c([u({type:Number,attribute:"expected-length"})],Q.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],Q.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],Q.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],Q.prototype,"dataPatternmaskMessage",2),c([E()],Q.prototype,"response",2),c([at("input")],Q.prototype,"_input",2),c([I("response",{waitUntilFirstUpdate:!0})],Q.prototype,"_handleValueChange",2),Q=c([g("qti-text-entry-interaction")],Q);var yr=class extends k{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{...k.properties}}render(){return f`
|
|
5370
5721
|
<div>
|
|
5371
5722
|
<slot name="prompt"></slot>
|
|
5372
5723
|
<input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
|
|
5373
5724
|
</div>
|
|
5374
|
-
`}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((t,i)=>{let s=new FileReader;s.onload=()=>t(s.result),s.onerror=()=>i(s.error),s.readAsDataURL(e)})}};
|
|
5725
|
+
`}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((t,i)=>{let s=new FileReader;s.onload=()=>t(s.result),s.onerror=()=>i(s.error),s.readAsDataURL(e)})}};yr.styles=[x`
|
|
5375
5726
|
:host {
|
|
5376
5727
|
display: block;
|
|
5377
5728
|
margin: 1em 0;
|
|
@@ -5380,33 +5731,33 @@ div.full-correct-response-inline {
|
|
|
5380
5731
|
display: block;
|
|
5381
5732
|
margin-top: 0.5em;
|
|
5382
5733
|
}
|
|
5383
|
-
`],
|
|
5734
|
+
`],yr=c([g("qti-upload-interaction")],yr);var kt=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};kt.styles=x`
|
|
5384
5735
|
:host {
|
|
5385
5736
|
display: flex;
|
|
5386
5737
|
user-select: none;
|
|
5387
5738
|
}
|
|
5388
|
-
`,c([u({type:Number,reflect:!0})],kt.prototype,"tabindex",2),kt=c([g("qti-gap-img")],kt);var
|
|
5739
|
+
`,c([u({type:Number,reflect:!0})],kt.prototype,"tabindex",2),kt=c([g("qti-gap-img")],kt);var an={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function ge(o,r){class e extends o{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${r}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${r}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${r}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return f`<slot></slot>`}}return c([u({type:String})],e.prototype,"identifier",2),c([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),c([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:an})],e.prototype,"disabled",2),c([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:an})],e.prototype,"readonly",2),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var Rt=class extends ge(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return f`<slot></slot>`}};Rt.styles=x`
|
|
5389
5740
|
:host {
|
|
5390
5741
|
display: inline-flex;
|
|
5391
5742
|
user-select: none;
|
|
5392
5743
|
}
|
|
5393
|
-
`,c([u({type:Number,reflect:!0})],
|
|
5744
|
+
`,c([u({type:Number,reflect:!0})],Rt.prototype,"tabindex",2),Rt=c([g("qti-gap-text")],Rt);var Mt=class extends v{constructor(){super(...arguments);this.tabindex=0}render(){return f` <slot name="drags"></slot>`}};Mt.styles=x`
|
|
5394
5745
|
:host {
|
|
5395
5746
|
display: flex;
|
|
5396
5747
|
user-select: none;
|
|
5397
5748
|
}
|
|
5398
|
-
`,c([u({type:Number,reflect:!0})],
|
|
5749
|
+
`,c([u({type:Number,reflect:!0})],Mt.prototype,"tabindex",2),Mt=c([g("qti-gap")],Mt);var xr=class extends v{static get styles(){return[x`
|
|
5399
5750
|
:host {
|
|
5400
5751
|
display: block;
|
|
5401
5752
|
cursor: pointer;
|
|
5402
5753
|
}
|
|
5403
|
-
`]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return
|
|
5404
|
-
<slot></slot> `}};
|
|
5754
|
+
`]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return f` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};c([u({type:String})],xr.prototype,"identifier",2),xr=c([g("qti-inline-choice")],xr);var qr=class extends ge(v,"qti-hottext"){render(){return f`<div part="ch"><div part="cha"></div></div>
|
|
5755
|
+
<slot></slot> `}};qr.styles=x`
|
|
5405
5756
|
:host {
|
|
5406
5757
|
display: flex;
|
|
5407
5758
|
user-select: none;
|
|
5408
5759
|
}
|
|
5409
|
-
`,
|
|
5760
|
+
`,qr=c([g("qti-hottext")],qr);var Be=class extends ge(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return f`
|
|
5410
5761
|
<slot part="slot"></slot>
|
|
5411
5762
|
<slot part="dropslot" name="qti-simple-associable-choice"></slot>
|
|
5412
5763
|
`}};Be.styles=x`
|
|
@@ -5421,10 +5772,10 @@ div.full-correct-response-inline {
|
|
|
5421
5772
|
slot[name='qti-simple-associable-choice'] {
|
|
5422
5773
|
width: auto;
|
|
5423
5774
|
}
|
|
5424
|
-
`,c([u({type:Number,attribute:"match-min"})],Be.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],Be.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Be.prototype,"fixed",2),Be=c([g("qti-simple-associable-choice")],Be);var Me=class extends ge(v,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return
|
|
5775
|
+
`,c([u({type:Number,attribute:"match-min"})],Be.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],Be.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Be.prototype,"fixed",2),Be=c([g("qti-simple-associable-choice")],Be);var Me=class extends ge(v,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return f`<div part="ch">
|
|
5425
5776
|
<div part="cha"></div>
|
|
5426
5777
|
</div>
|
|
5427
|
-
${this.marker?
|
|
5778
|
+
${this.marker?f`<div id="label">${this.marker}</div>`:R}
|
|
5428
5779
|
<slot part="slot"></slot>`}};Me.styles=x`
|
|
5429
5780
|
:host {
|
|
5430
5781
|
display: flex;
|
|
@@ -5442,19 +5793,19 @@ div.full-correct-response-inline {
|
|
|
5442
5793
|
align-items: center;
|
|
5443
5794
|
justify-content: center;
|
|
5444
5795
|
}
|
|
5445
|
-
`,c([u({type:String,attribute:"template-identifier"})],Me.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],Me.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Me.prototype,"fixed",2),c([u({type:String,attribute:!1})],Me.prototype,"marker",2),Me=c([g("qti-simple-choice")],Me);var
|
|
5796
|
+
`,c([u({type:String,attribute:"template-identifier"})],Me.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],Me.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Me.prototype,"fixed",2),c([u({type:String,attribute:!1})],Me.prototype,"marker",2),Me=c([g("qti-simple-choice")],Me);var st=class extends ge(v,"qti-hotspot-choice"){};st.styles=x`
|
|
5446
5797
|
:host {
|
|
5447
5798
|
display: flex;
|
|
5448
5799
|
user-select: none;
|
|
5449
5800
|
position: absolute;
|
|
5450
5801
|
}
|
|
5451
|
-
`,c([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],
|
|
5802
|
+
`,c([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],st.prototype,"order",2),c([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],st.prototype,"orderCorrect",2),st=c([g("qti-hotspot-choice")],st);var Cr=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return f` <slot name="drags"></slot> `}};Cr.styles=x`
|
|
5452
5803
|
:host {
|
|
5453
5804
|
display: flex;
|
|
5454
5805
|
user-select: none;
|
|
5455
5806
|
position: absolute;
|
|
5456
5807
|
}
|
|
5457
|
-
`,Er=c([g("qti-associable-hotspot")],Er);var WC=async o=>{let r=o.substring(0,o.lastIndexOf("/")),e=await oo().load(`${o}`).then(a=>a.assessmentTest()),t=await mt().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await mt().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}},XC=async o=>oe().load(o).then(r=>r.htmlDoc().firstElementChild);var be=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};be=c([g("qti-rule")],be);var wr=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:Gt(t)}})),t)}};c([u({type:String})],wr.prototype,"identifier",2),c([_({context:P,subscribe:!0}),E()],wr.prototype,"context",2);customElements.define("qti-lookup-outcome-value",wr);var ts=class extends be{render(){return h`<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",ts);var rs=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 is(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(Gt):r!==null?Gt(r):null}},is=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",rs);var _r=class extends v{render(){return h`<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",_r);var Tr=class extends _r{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",Tr);var ss=class extends Tr{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",ss);var ui=class extends ta(K){calculate(){return this.calculateChildren(Array.from(this.children))}};ui=c([g("qti-and")],ui);function ta(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 mi=class extends w{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],mi.prototype,"baseType",2);customElements.define("qti-base-value",mi);var os=class extends w{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",os);var ns=class extends K{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",ns);var as=class extends w{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",as);var Lt=class extends w{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})],Lt.prototype,"identifier",2),c([_({context:P,subscribe:!0}),E()],Lt.prototype,"context",2),c([E(),_({context:ne,subscribe:!0})],Lt.prototype,"_testContext",2);customElements.define("qti-default",Lt);var hi=class extends w{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})],hi.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",hi);var ls=class extends w{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",ls);var Ar=class extends w{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"})],Ar.prototype,"roundingMode",2),c([u({type:Number})],Ar.prototype,"figures",2);customElements.define("qti-round-to",Ar);var fi=class extends w{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})],fi.prototype,"toleranceMode",2);customElements.define("qti-equal",fi);var cs=class extends w{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",cs);var ds=class extends w{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",ds);var ps=class extends K{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",ps);var us=class extends w{getResult(){return null}};customElements.define("qti-null",us);var ms=class extends w{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",ms);var hs=class extends w{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",hs);var fs=class extends w{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",fs);var gs=class extends K{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",gs);var gi=class extends w{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})],gi.prototype,"identifier",2);customElements.define("qti-map-response",gi);var bi=class extends w{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})],bi.prototype,"identifier",2);customElements.define("qti-map-response-point",bi);var vi=class extends w{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})],vi.prototype,"name",2);customElements.define("qti-math-operator",vi);var bs=class o extends w{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",bs);var vs=class extends w{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",vs);var ys=class extends w{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",ys);var xs=class extends w{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",xs);var qs=class extends K{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",qs);var Cs=class extends w{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",Cs);var Es=class extends w{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",Es);var Sr=class extends v{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?k:h`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],Sr.prototype,"identifier",2),c([_({context:P,subscribe:!0}),E()],Sr.prototype,"context",2);customElements.define("qti-printed-variable",Sr);var ws=class extends w{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",ws);var yi=class extends ra(w){getResult(){return this.calculateChildren(Array.from(this.children))}};function ra(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",yi);var xi=class extends w{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"})],xi.prototype,"caseSensitive",2);customElements.define("qti-string-match",xi);var _s=class extends w{constructor(){super(),this._expression=new Ts(Array.from(this.children))}getResult(){return this._expression.calculate()}},Ts=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",_s);var As=class extends w{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",As);var $t=class extends w{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})],$t.prototype,"min",2),c([u({type:Number})],$t.prototype,"max",2),c([u({type:Number})],$t.prototype,"step",2);customElements.define("qti-random-integer",$t);var Ss=class extends w{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",Ss);var Rs=class extends w{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",Rs);var Rr=class extends w{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})],Rr.prototype,"n",2),Rr=c([g("qti-index")],Rr);export{co as Correctness,Ni as INITIAL_SESSION_CONTEXT,Hi as INITIAL_TEST_CONTEXT,R as Interaction,zi as IsNullOrUndefined,_e as ItemContainer,st as ItemCorrectResponseMode,wt as ItemPrintVariables,re as ItemShowCandidateCorrection,ie as ItemShowCorrectResponse,ui as QtiAnd,Y as QtiAssessmentItem,xe as QtiAssessmentItemRef,qe as QtiAssessmentSection,bt as QtiAssessmentStimulusRef,Bi as QtiAssessmentStimulusRefConnectedEvent,Qe as QtiAssessmentTest,Er as QtiAssociableHotspot,Tt as QtiAssociateInteraction,mi as QtiBaseValue,At as QtiChoiceInteraction,Gr as QtiCompanionMaterialsInfo,K as QtiConditionExpression,os as QtiContainerSize,ns as QtiContains,Jr as QtiContentBody,as as QtiCorrect,Te as QtiCustomInteraction,Yt as QtiCustomOperator,Lt as QtiDefault,Rs as QtiDelete,Fe as QtiEndAttemptInteraction,fi as QtiEqual,hi as QtiEqualRounded,w as QtiExpression,W as QtiExtendedTextInteraction,G as QtiFeedback,Jt as QtiFeedbackBlock,Kt as QtiFeedbackInline,hs as QtiFieldValue,It as QtiGap,kt as QtiGapImg,ur as QtiGapMatchInteraction,Mt as QtiGapText,cs as QtiGcd,he as QtiGraphicAssociateInteraction,mr as QtiGraphicGapMatchInteraction,hr as QtiGraphicOrderInteraction,ds as QtiGt,ps as QtiGte,ot as QtiHotspotChoice,fr as QtiHotspotInteraction,Cr as QtiHottext,gr as QtiHottextInteraction,Rr as QtiIndex,qr as QtiInlineChoice,Ae as QtiInlineChoiceInteraction,ms as QtiIsNull,_t as QtiItem,Zt as QtiItemBody,wr as QtiLookupOutcomeValue,fs as QtiLt,gs as QtiLte,gi as QtiMapResponse,bi as QtiMapResponsePoint,bs as QtiMatch,Se as QtiMatchInteraction,vi as QtiMathOperator,vr as QtiMediaInteraction,vs as QtiMember,et as QtiModalFeedback,ys as QtiMultiple,xs as QtiNot,us as QtiNull,qs as QtiOr,Re as QtiOrderInteraction,Cs as QtiOrdered,ce as QtiOutcomeDeclaration,F as QtiPortableCustomInteraction,Ki as QtiPositionObjectInteraction,yr as QtiPositionObjectStage,Es as QtiPower,Sr as QtiPrintedVariable,ws as QtiProduct,Yr as QtiPrompt,Ss as QtiRandom,$t as QtiRandomInteger,ts as QtiResponseCondition,Ee as QtiResponseDeclaration,_r as QtiResponseElse,ss as QtiResponseElseIf,Tr as QtiResponseIf,Qt as QtiResponseProcessing,ls as QtiRound,Ar as QtiRoundTo,le as QtiRubricBlock,po as QtiRuleElement,fe as QtiSelectPointInteraction,rs as QtiSetOutcomeValue,is as QtiSetOutcomeValueRule,Be as QtiSimpleAssociableChoice,Me as QtiSimpleChoice,ke as QtiSliderInteraction,xi as QtiStringMatch,Kr as QtiStylesheet,yi as QtiSubtract,_s as QtiSum,Ts as QtiSumExpression,Wr as QtiTest,er as QtiTestFeedback,Ce as QtiTestPart,Q as QtiTextEntryInteraction,xr as QtiUploadInteraction,As as QtiVariable,gt as QtiVariableDeclaration,z as ScoringHelper,pr as TestCheckItem,we as TestContainer,tr as TestEndAttempt,vt as TestItemLink,Z as TestNavigation,Oe as TestNext,nr as TestPagingButtonsStamp,De as TestPrev,cr as TestPrintContext,qt as TestPrintVariables,it as TestScoringButtons,Et as TestScoringFeedback,lr as TestSectionButtonsStamp,Ct as TestSectionLink,ee as TestShowCorrectResponse,rt as TestStamp,j as TestView,dr as TestViewToggle,$ as computedContext,Pe as computedItemContext,J as configContext,Gt as convertNumberToUniversalFormat,Sn as decimalSeparator,XC as getItemByUri,WC as getManifestInfo,P as itemContext,lo as itemContextVariables,ta as qtiAndMixin,jr as qtiContext,ra as qtiSubtractMixin,oe as qtiTransformItem,oo as qtiTransformManifest,mt as qtiTransformTest,Ze as removeDoubleSlashes,Ve as sessionContext,ne as testContext};
|
|
5808
|
+
`,Cr=c([g("qti-associable-hotspot")],Cr);var XC=async o=>{let r=o.substring(0,o.lastIndexOf("/")),e=await ao().load(`${o}`).then(a=>a.assessmentTest()),t=await ut().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await ut().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}},GC=async o=>oe().load(o).then(r=>r.htmlDoc().firstElementChild);var be=class extends v{render(){return f`<slot></slot>`}process(){throw new Error("Not implemented")}};be=c([g("qti-rule")],be);var Er=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:Xt(t)}})),t)}};c([u({type:String})],Er.prototype,"identifier",2),c([_({context:P,subscribe:!0}),E()],Er.prototype,"context",2);customElements.define("qti-lookup-outcome-value",Er);var rs=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",rs);var is=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 ss(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(Xt):r!==null?Xt(r):null}},ss=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",is);var wr=class extends v{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",wr);var _r=class extends wr{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",_r);var os=class extends _r{render(){return f`${super.render()}`}};customElements.define("qti-response-else-if",os);var ui=class extends ra(K){calculate(){return this.calculateChildren(Array.from(this.children))}};ui=c([g("qti-and")],ui);function ra(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 mi=class extends w{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],mi.prototype,"baseType",2);customElements.define("qti-base-value",mi);var ns=class extends w{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",ns);var as=class extends K{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",as);var ls=class extends w{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",ls);var It=class extends w{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})],It.prototype,"identifier",2),c([_({context:P,subscribe:!0}),E()],It.prototype,"context",2),c([E(),_({context:ne,subscribe:!0})],It.prototype,"_testContext",2);customElements.define("qti-default",It);var hi=class extends w{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})],hi.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",hi);var cs=class extends w{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",cs);var Tr=class extends w{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"})],Tr.prototype,"roundingMode",2),c([u({type:Number})],Tr.prototype,"figures",2);customElements.define("qti-round-to",Tr);var fi=class extends w{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})],fi.prototype,"toleranceMode",2);customElements.define("qti-equal",fi);var ds=class extends w{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",ds);var ps=class extends w{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",ps);var us=class extends K{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",us);var ms=class extends w{getResult(){return null}};customElements.define("qti-null",ms);var hs=class extends w{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",hs);var fs=class extends w{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",fs);var gs=class extends w{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",gs);var bs=class extends K{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",bs);var gi=class extends w{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})],gi.prototype,"identifier",2);customElements.define("qti-map-response",gi);var bi=class extends w{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})],bi.prototype,"identifier",2);customElements.define("qti-map-response-point",bi);var vi=class extends w{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})],vi.prototype,"name",2);customElements.define("qti-math-operator",vi);var vs=class o extends w{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",vs);var ys=class extends w{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",ys);var xs=class extends w{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",xs);var qs=class extends w{render(){return f`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",qs);var Cs=class extends K{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",Cs);var Es=class extends w{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",Es);var ws=class extends w{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",ws);var Ar=class extends v{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?R:f`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],Ar.prototype,"identifier",2),c([_({context:P,subscribe:!0}),E()],Ar.prototype,"context",2);customElements.define("qti-printed-variable",Ar);var _s=class extends w{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",_s);var yi=class extends ia(w){getResult(){return this.calculateChildren(Array.from(this.children))}};function ia(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",yi);var xi=class extends w{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"})],xi.prototype,"caseSensitive",2);customElements.define("qti-string-match",xi);var Ts=class extends w{constructor(){super(),this._expression=new As(Array.from(this.children))}getResult(){return this._expression.calculate()}},As=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",Ts);var Ss=class extends w{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",Ss);var Lt=class extends w{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})],Lt.prototype,"min",2),c([u({type:Number})],Lt.prototype,"max",2),c([u({type:Number})],Lt.prototype,"step",2);customElements.define("qti-random-integer",Lt);var ks=class extends w{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",ks);var Rs=class extends w{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",Rs);var Sr=class extends w{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})],Sr.prototype,"n",2),Sr=c([g("qti-index")],Sr);export{uo as Correctness,Di as INITIAL_SESSION_CONTEXT,Hi as INITIAL_TEST_CONTEXT,k as Interaction,zi as IsNullOrUndefined,_e as ItemContainer,it as ItemCorrectResponseMode,Et as ItemPrintVariables,re as ItemShowCandidateCorrection,ie as ItemShowCorrectResponse,ui as QtiAnd,Y as QtiAssessmentItem,xe as QtiAssessmentItemRef,qe as QtiAssessmentSection,gt as QtiAssessmentStimulusRef,Bi as QtiAssessmentStimulusRefConnectedEvent,Ze as QtiAssessmentTest,Cr as QtiAssociableHotspot,_t as QtiAssociateInteraction,mi as QtiBaseValue,Tt as QtiChoiceInteraction,Gr as QtiCompanionMaterialsInfo,K as QtiConditionExpression,ns as QtiContainerSize,as as QtiContains,Jr as QtiContentBody,ls as QtiCorrect,Te as QtiCustomInteraction,Gt as QtiCustomOperator,It as QtiDefault,Rs as QtiDelete,Ue as QtiEndAttemptInteraction,fi as QtiEqual,hi as QtiEqualRounded,w as QtiExpression,W as QtiExtendedTextInteraction,G as QtiFeedback,Yt as QtiFeedbackBlock,Jt as QtiFeedbackInline,fs as QtiFieldValue,Mt as QtiGap,kt as QtiGapImg,pr as QtiGapMatchInteraction,Rt as QtiGapText,ds as QtiGcd,he as QtiGraphicAssociateInteraction,ur as QtiGraphicGapMatchInteraction,mr as QtiGraphicOrderInteraction,ps as QtiGt,us as QtiGte,st as QtiHotspotChoice,hr as QtiHotspotInteraction,qr as QtiHottext,fr as QtiHottextInteraction,Sr as QtiIndex,xr as QtiInlineChoice,Ae as QtiInlineChoiceInteraction,hs as QtiIsNull,wt as QtiItem,Kt as QtiItemBody,Er as QtiLookupOutcomeValue,gs as QtiLt,bs as QtiLte,gi as QtiMapResponse,bi as QtiMapResponsePoint,vs as QtiMatch,Se as QtiMatchInteraction,vi as QtiMathOperator,br as QtiMediaInteraction,ys as QtiMember,Qe as QtiModalFeedback,xs as QtiMultiple,qs as QtiNot,ms as QtiNull,Cs as QtiOr,ke as QtiOrderInteraction,Es as QtiOrdered,ce as QtiOutcomeDeclaration,U as QtiPortableCustomInteraction,Zi as QtiPositionObjectInteraction,vr as QtiPositionObjectStage,ws as QtiPower,Ar as QtiPrintedVariable,_s as QtiProduct,Yr as QtiPrompt,ks as QtiRandom,Lt as QtiRandomInteger,rs as QtiResponseCondition,Ee as QtiResponseDeclaration,wr as QtiResponseElse,os as QtiResponseElseIf,_r as QtiResponseIf,Zt as QtiResponseProcessing,cs as QtiRound,Tr as QtiRoundTo,le as QtiRubricBlock,mo as QtiRuleElement,fe as QtiSelectPointInteraction,is as QtiSetOutcomeValue,ss as QtiSetOutcomeValueRule,Be as QtiSimpleAssociableChoice,Me as QtiSimpleChoice,Re as QtiSliderInteraction,xi as QtiStringMatch,Kr as QtiStylesheet,yi as QtiSubtract,Ts as QtiSum,As as QtiSumExpression,Wr as QtiTest,Qt as QtiTestFeedback,Ce as QtiTestPart,Q as QtiTextEntryInteraction,yr as QtiUploadInteraction,Ss as QtiVariable,ft as QtiVariableDeclaration,z as ScoringHelper,dr as TestCheckItem,we as TestContainer,er as TestEndAttempt,bt as TestItemLink,Z as TestNavigation,Oe as TestNext,or as TestPagingButtonsStamp,Ne as TestPrev,lr as TestPrintContext,xt as TestPrintVariables,rt as TestScoringButtons,Ct as TestScoringFeedback,ar as TestSectionButtonsStamp,qt as TestSectionLink,ee as TestShowCorrectResponse,tt as TestStamp,j as TestView,cr as TestViewToggle,$ as computedContext,Pe as computedItemContext,J as configContext,Xt as convertNumberToUniversalFormat,Sn as decimalSeparator,GC as getItemByUri,XC as getManifestInfo,P as itemContext,po as itemContextVariables,ra as qtiAndMixin,Br as qtiContext,ia as qtiSubtractMixin,oe as qtiTransformItem,ao as qtiTransformManifest,ut as qtiTransformTest,jr as removeDoubleSlashes,Ve as sessionContext,ne as testContext};
|
|
5458
5809
|
/*! Bundled license information:
|
|
5459
5810
|
|
|
5460
5811
|
@lit-labs/ssr-dom-shim/lib/element-internals.js:
|