@citolab/qti-components 7.0.3 → 7.0.5
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/chunks/chunk-4UJBK6JO.js +1 -0
- package/cdn/chunks/chunk-5FCXUJAG.js +23 -0
- package/cdn/chunks/chunk-5O3Z7TDV.js +1 -0
- package/cdn/chunks/chunk-65LFT33L.js +8 -0
- package/cdn/chunks/chunk-6D25UFJR.js +8 -0
- package/cdn/chunks/chunk-6DMSHH5X.js +0 -0
- package/cdn/chunks/chunk-6UGPNL7M.js +1 -0
- package/cdn/chunks/chunk-CFXQCNG6.js +3523 -0
- package/cdn/chunks/chunk-CSUKVUZF.js +3 -0
- package/cdn/chunks/chunk-CSY3WI5A.js +1 -0
- package/cdn/chunks/chunk-DAZR7RUI.js +0 -0
- package/cdn/chunks/chunk-EHK76KRT.js +1 -0
- package/cdn/chunks/chunk-EOPEMJS3.js +0 -0
- package/cdn/chunks/chunk-G5O7EN45.js +5 -0
- package/cdn/chunks/chunk-GEFUIFM7.js +0 -0
- package/cdn/chunks/chunk-JLNHEMQG.js +1 -0
- package/cdn/chunks/chunk-LPWIM7QJ.js +902 -0
- package/cdn/chunks/chunk-M3YRM3AV.js +1 -0
- package/cdn/chunks/chunk-M6BOWL2U.js +1 -0
- package/cdn/chunks/chunk-P5IE36FO.js +8 -0
- package/cdn/chunks/chunk-PXH5KN5O.js +1 -0
- package/cdn/chunks/chunk-RBEI6NIF.js +1 -0
- package/cdn/chunks/chunk-SMKIYFFI.js +1 -0
- package/cdn/chunks/chunk-SRLMW23F.js +0 -0
- package/cdn/chunks/chunk-T3YDLD2H.js +11 -0
- package/cdn/chunks/chunk-T4HD2C4F.js +1 -0
- package/cdn/chunks/chunk-T6IXJ4W4.js +1 -0
- package/cdn/chunks/chunk-TFAUBGP2.js +0 -0
- package/cdn/chunks/chunk-UIEC4LXR.js +17 -0
- package/cdn/chunks/chunk-V44O3GTW.js +0 -0
- package/cdn/chunks/chunk-V6B54FQW.js +5 -0
- package/cdn/chunks/chunk-V6KX6BQN.js +1 -0
- package/cdn/chunks/chunk-VYANBI35.js +1 -0
- package/cdn/chunks/chunk-XUJ7TXHW.js +1 -0
- package/cdn/chunks/chunk-ZIZLFFSG.js +0 -0
- package/cdn/index.css +1 -0
- package/cdn/index.global.js +45 -45
- package/cdn/index.js +354 -4148
- package/cdn/qti-components/index.global.js +226 -0
- package/cdn/qti-components/index.js +924 -0
- package/cdn/qti-item/components/index.css +1 -0
- package/cdn/qti-item/components/index.global.js +149 -0
- package/cdn/qti-item/components/index.js +3549 -0
- package/cdn/qti-item/components/item-container.css +1 -0
- package/cdn/qti-item/components/item-container.global.js +149 -0
- package/cdn/qti-item/components/item-container.js +3549 -0
- package/cdn/qti-item/index.css +1 -0
- package/cdn/qti-item/index.global.js +149 -0
- package/cdn/qti-item/index.js +3549 -0
- package/cdn/qti-item/qti-item.global.js +114 -0
- package/cdn/qti-item/qti-item.js +1 -0
- package/cdn/qti-loader/index.global.js +1 -0
- package/cdn/qti-loader/index.js +23 -0
- package/cdn/qti-test/components/index.css +1 -0
- package/cdn/qti-test/components/index.global.js +242 -0
- package/cdn/qti-test/components/index.js +3598 -0
- package/cdn/qti-test/components/styles.global.js +44 -0
- package/cdn/qti-test/components/styles.js +17 -0
- package/cdn/qti-test/components/test-component.abstract.global.js +170 -0
- package/cdn/qti-test/components/test-component.abstract.js +1 -0
- package/cdn/qti-test/components/test-container.css +1 -0
- package/cdn/qti-test/components/test-container.global.js +149 -0
- package/cdn/qti-test/components/test-container.js +3549 -0
- package/cdn/qti-test/components/test-item-link.global.js +170 -0
- package/cdn/qti-test/components/test-item-link.js +24 -0
- package/cdn/qti-test/components/test-next.global.js +170 -0
- package/cdn/qti-test/components/test-next.js +24 -0
- package/cdn/qti-test/components/test-next.spec.css +1 -0
- package/cdn/qti-test/components/test-next.spec.global.js +297 -0
- package/cdn/qti-test/components/test-next.spec.js +5215 -0
- package/cdn/qti-test/components/test-paging-buttons-stamp.global.js +207 -0
- package/cdn/qti-test/components/test-paging-buttons-stamp.js +3 -0
- package/cdn/qti-test/components/test-prev.global.js +170 -0
- package/cdn/qti-test/components/test-prev.js +24 -0
- package/cdn/qti-test/components/test-view.global.js +170 -0
- package/cdn/qti-test/components/test-view.js +11 -0
- package/cdn/qti-test/context/index.global.js +58 -0
- package/cdn/qti-test/context/index.js +1 -0
- package/cdn/qti-test/context/test.context.global.js +58 -0
- package/cdn/qti-test/context/test.context.js +1 -0
- package/cdn/qti-test/index.css +1 -0
- package/cdn/qti-test/index.global.js +242 -0
- package/cdn/qti-test/index.js +3598 -0
- package/cdn/qti-test/mixins/index.global.js +1 -0
- package/cdn/qti-test/mixins/index.js +23 -0
- package/cdn/qti-test/mixins/test-loader.mixin.global.js +1 -0
- package/cdn/qti-test/mixins/test-loader.mixin.js +23 -0
- package/cdn/qti-test/mixins/test-navigation.mixin.global.js +1 -0
- package/cdn/qti-test/mixins/test-navigation.mixin.js +1 -0
- package/cdn/qti-test/mixins/test-view.mixin.global.js +1 -0
- package/cdn/qti-test/mixins/test-view.mixin.js +1 -0
- package/cdn/qti-test/qti-assessment-test/index.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/index.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-item-ref.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-item-ref.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-section.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-section.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-test.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-test.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-test-part.global.js +114 -0
- package/cdn/qti-test/qti-assessment-test/qti-test-part.js +1 -0
- package/cdn/qti-test/qti-test.global.js +170 -0
- package/cdn/qti-test/qti-test.js +23 -0
- package/cdn/qti-test/test-base.global.js +170 -0
- package/cdn/qti-test/test-base.js +1 -0
- package/cdn/qti-transformers/index.global.js +1 -0
- package/cdn/qti-transformers/index.js +23 -0
- package/dist/chunks/chunk-3G2DDBJW.js +44 -0
- package/dist/chunks/chunk-3G2DDBJW.js.map +1 -0
- package/dist/chunks/chunk-3NLCJYSX.js +1 -0
- package/dist/chunks/chunk-3NLCJYSX.js.map +1 -0
- package/dist/chunks/chunk-3OXGDCSU.js +6253 -0
- package/dist/chunks/chunk-3OXGDCSU.js.map +1 -0
- package/dist/chunks/chunk-3ROZMGAN.js +43 -0
- package/dist/chunks/chunk-3ROZMGAN.js.map +1 -0
- package/dist/chunks/chunk-4O5F7WV7.js +30 -0
- package/dist/chunks/chunk-4O5F7WV7.js.map +1 -0
- package/dist/chunks/chunk-6YE2KJ4C.js +55 -0
- package/dist/chunks/chunk-6YE2KJ4C.js.map +1 -0
- package/dist/chunks/chunk-AAQCM2FP.js +56 -0
- package/dist/chunks/chunk-AAQCM2FP.js.map +1 -0
- package/dist/chunks/chunk-D3RGDWKP.js +37 -0
- package/dist/chunks/chunk-D3RGDWKP.js.map +1 -0
- package/dist/chunks/chunk-DJLE6EV2.js +36 -0
- package/dist/chunks/chunk-DJLE6EV2.js.map +1 -0
- package/dist/chunks/chunk-ELDMXTUQ.js +31 -0
- package/dist/chunks/chunk-ELDMXTUQ.js.map +1 -0
- package/dist/chunks/chunk-EW5CTHAD.js +1 -0
- package/dist/chunks/chunk-EW5CTHAD.js.map +1 -0
- package/dist/chunks/chunk-HWA4A3SR.js +50 -0
- package/dist/chunks/chunk-HWA4A3SR.js.map +1 -0
- package/dist/chunks/chunk-IKZWK2C5.js +1 -0
- package/dist/chunks/chunk-IKZWK2C5.js.map +1 -0
- package/dist/chunks/chunk-IP7JSYO6.js +1 -0
- package/dist/chunks/chunk-IP7JSYO6.js.map +1 -0
- package/dist/chunks/chunk-JE6BMXZU.js +94 -0
- package/dist/chunks/chunk-JE6BMXZU.js.map +1 -0
- package/dist/chunks/chunk-JSPJGWGT.js +20 -0
- package/dist/chunks/chunk-JSPJGWGT.js.map +1 -0
- package/dist/chunks/chunk-LKINC6JO.js +118 -0
- package/dist/chunks/chunk-LKINC6JO.js.map +1 -0
- package/dist/chunks/chunk-LROTNPC2.js +94 -0
- package/dist/chunks/chunk-LROTNPC2.js.map +1 -0
- package/dist/chunks/chunk-MTMT2RMF.js +63 -0
- package/dist/chunks/chunk-MTMT2RMF.js.map +1 -0
- package/dist/chunks/chunk-NDJZGJUR.js +65 -0
- package/dist/chunks/chunk-NDJZGJUR.js.map +1 -0
- package/dist/chunks/chunk-OE2LFIH2.js +1 -0
- package/dist/chunks/chunk-OE2LFIH2.js.map +1 -0
- package/dist/chunks/chunk-OJ2XGDWK.js +1 -0
- package/dist/chunks/chunk-OJ2XGDWK.js.map +1 -0
- package/dist/chunks/chunk-PUBGXXTM.js +50 -0
- package/dist/chunks/chunk-PUBGXXTM.js.map +1 -0
- package/dist/chunks/chunk-QRCUNRP5.js +75 -0
- package/dist/chunks/chunk-QRCUNRP5.js.map +1 -0
- package/dist/chunks/chunk-S6JJYCO7.js +51 -0
- package/dist/chunks/chunk-S6JJYCO7.js.map +1 -0
- package/dist/chunks/chunk-U3AALKEP.js +1 -0
- package/dist/chunks/chunk-U3AALKEP.js.map +1 -0
- package/dist/chunks/chunk-UCQFSRYF.js +34 -0
- package/dist/chunks/chunk-UCQFSRYF.js.map +1 -0
- package/dist/chunks/chunk-URGVQ64M.js +1 -0
- package/dist/chunks/chunk-URGVQ64M.js.map +1 -0
- package/dist/chunks/chunk-V4FXK4TP.js +128 -0
- package/dist/chunks/chunk-V4FXK4TP.js.map +1 -0
- package/dist/chunks/chunk-W4B23OIP.js +72 -0
- package/dist/chunks/chunk-W4B23OIP.js.map +1 -0
- package/dist/chunks/chunk-XDFXD3BI.js +10 -0
- package/dist/chunks/chunk-XDFXD3BI.js.map +1 -0
- package/dist/chunks/chunk-XDMSEAYC.js +294 -0
- package/dist/chunks/chunk-XDMSEAYC.js.map +1 -0
- package/dist/chunks/chunk-XPDS72XY.js +29 -0
- package/dist/chunks/chunk-XPDS72XY.js.map +1 -0
- package/dist/chunks/chunk-Y6UWSECL.js +3529 -0
- package/dist/chunks/chunk-Y6UWSECL.js.map +1 -0
- package/dist/chunks/chunk-ZEFOMZNY.js +78 -0
- package/dist/chunks/chunk-ZEFOMZNY.js.map +1 -0
- package/dist/index-Cvrd4KQA.d.ts +109 -0
- package/dist/index.d.ts +18 -469
- package/dist/index.js +2717 -8728
- package/dist/index.js.map +1 -1
- package/dist/item.css +10 -78
- package/dist/qti-components/index.d.ts +150 -0
- package/dist/qti-components/index.js +6525 -0
- package/dist/qti-components/index.js.map +1 -0
- package/dist/qti-components-jsx.d.ts +159 -184
- package/dist/qti-item/components/index.d.ts +3 -0
- package/dist/qti-item/components/index.js +3856 -0
- package/dist/qti-item/components/index.js.map +1 -0
- package/dist/qti-item/components/item-container.d.ts +40 -0
- package/dist/qti-item/components/item-container.js +3856 -0
- package/dist/qti-item/components/item-container.js.map +1 -0
- package/dist/qti-item/index.d.ts +4 -0
- package/dist/qti-item/index.js +3869 -0
- package/dist/qti-item/index.js.map +1 -0
- package/dist/qti-item/qti-item.d.ts +25 -0
- package/dist/qti-item/qti-item.js +26 -0
- package/dist/qti-item/qti-item.js.map +1 -0
- package/dist/{loader → qti-loader}/index.d.ts +1 -1
- package/dist/{loader → qti-loader}/index.js +5 -0
- package/dist/{loader → qti-loader}/index.js.map +1 -1
- package/dist/{qti-simple-choice-UTrFa_RQ.d.ts → qti-simple-choice-DxWcdKHi.d.ts} +71 -90
- package/dist/qti-test/components/index.d.ts +13 -0
- package/dist/qti-test/components/index.js +4144 -0
- package/dist/qti-test/components/index.js.map +1 -0
- package/dist/qti-test/components/styles.d.ts +8 -0
- package/dist/qti-test/components/styles.js +29 -0
- package/dist/qti-test/components/styles.js.map +1 -0
- package/dist/qti-test/components/test-component.abstract.d.ts +23 -0
- package/dist/qti-test/components/test-component.abstract.js +149 -0
- package/dist/qti-test/components/test-component.abstract.js.map +1 -0
- package/dist/qti-test/components/test-container.d.ts +37 -0
- package/dist/qti-test/components/test-container.js +3782 -0
- package/dist/qti-test/components/test-container.js.map +1 -0
- package/dist/qti-test/components/test-item-link.d.ts +21 -0
- package/dist/qti-test/components/test-item-link.js +202 -0
- package/dist/qti-test/components/test-item-link.js.map +1 -0
- package/dist/qti-test/components/test-next.d.ts +32 -0
- package/dist/qti-test/components/test-next.js +209 -0
- package/dist/qti-test/components/test-next.js.map +1 -0
- package/dist/qti-test/components/test-next.spec.d.ts +16 -0
- package/dist/qti-test/components/test-next.spec.js +56915 -0
- package/dist/qti-test/components/test-next.spec.js.map +1 -0
- package/dist/qti-test/components/test-paging-buttons-stamp.d.ts +22 -0
- package/dist/qti-test/components/test-paging-buttons-stamp.js +218 -0
- package/dist/qti-test/components/test-paging-buttons-stamp.js.map +1 -0
- package/dist/qti-test/components/test-prev.d.ts +32 -0
- package/dist/qti-test/components/test-prev.js +209 -0
- package/dist/qti-test/components/test-prev.js.map +1 -0
- package/dist/qti-test/components/test-view.d.ts +27 -0
- package/dist/qti-test/components/test-view.js +209 -0
- package/dist/qti-test/components/test-view.js.map +1 -0
- package/dist/qti-test/context/index.d.ts +6 -0
- package/dist/qti-test/context/index.js +9 -0
- package/dist/qti-test/context/index.js.map +1 -0
- package/dist/qti-test/context/test.context.d.ts +6 -0
- package/dist/qti-test/context/test.context.js +9 -0
- package/dist/qti-test/context/test.context.js.map +1 -0
- package/dist/qti-test/index.d.ts +14 -0
- package/dist/qti-test/index.js +4746 -0
- package/dist/qti-test/index.js.map +1 -0
- package/dist/qti-test/mixins/index.d.ts +8 -0
- package/dist/qti-test/mixins/index.js +350 -0
- package/dist/qti-test/mixins/index.js.map +1 -0
- package/dist/qti-test/mixins/test-loader.mixin.d.ts +8 -0
- package/dist/qti-test/mixins/test-loader.mixin.js +240 -0
- package/dist/qti-test/mixins/test-loader.mixin.js.map +1 -0
- package/dist/qti-test/mixins/test-navigation.mixin.d.ts +22 -0
- package/dist/qti-test/mixins/test-navigation.mixin.js +64 -0
- package/dist/qti-test/mixins/test-navigation.mixin.js.map +1 -0
- package/dist/qti-test/mixins/test-view.mixin.d.ts +6 -0
- package/dist/qti-test/mixins/test-view.mixin.js +50 -0
- package/dist/qti-test/mixins/test-view.mixin.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/index.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/index.js +221 -0
- package/dist/qti-test/qti-assessment-test/index.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.js +85 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-section.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-section.js +73 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-section.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-test.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-test.js +54 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-test.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-test-part.d.ts +19 -0
- package/dist/qti-test/qti-assessment-test/qti-test-part.js +62 -0
- package/dist/qti-test/qti-assessment-test/qti-test-part.js.map +1 -0
- package/dist/qti-test/qti-test.d.ts +68 -0
- package/dist/qti-test/qti-test.js +500 -0
- package/dist/qti-test/qti-test.js.map +1 -0
- package/dist/qti-test/test-base.d.ts +6 -0
- package/dist/qti-test/test-base.js +137 -0
- package/dist/qti-test/test-base.js.map +1 -0
- package/dist/{transformers → qti-transformers}/index.d.ts +1 -0
- package/dist/{transformers → qti-transformers}/index.js +5 -0
- package/dist/{transformers → qti-transformers}/index.js.map +1 -1
- package/dist/test-base-BJwG9Ie8.d.ts +109 -0
- package/dist/vscode.css-custom-data.json +1 -37
- package/dist/vscode.html-custom-data.json +70 -45
- package/package.json +29 -51
- package/dist/custom-element-eslint-rules.js +0 -337
- package/dist/custom-elements.json +0 -27271
|
@@ -0,0 +1,924 @@
|
|
|
1
|
+
var Rr=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var n=(c,o,e,t)=>{for(var r=t>1?void 0:t?Ar(o,e):o,i=c.length-1,l;i>=0;i--)(l=c[i])&&(r=(t?l(o,e,r):l(r))||r);return t&&r&&Rr(o,e,r),r};import{provide as Lr}from"@lit/context";import{LitElement as _r,html as Dr}from"lit";import{customElement as Vr,property as Y}from"lit/decorators.js";function x(c,o){let e={waitUntilFirstUpdate:!1,...o};return(t,r)=>{let{update:i}=t,l=Array.isArray(c)?c:[c];t.update=function(s){l.forEach(a=>{let p=a;if(s.has(p)){let d=s.get(p),u=this[p];d!==u&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[r](d,u)}}),i.call(this,s)}}}import{createContext as kr}from"@lit/context";var Dt=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}],y=kr(Symbol("item"));var E=class extends _r{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(r=>r.readonly=t);this._context={identifier:this.getAttribute("identifier"),variables:Dt};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(i=>i.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:r}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(r)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:r}=e.detail;this.updateOutcomeVariable(t,r),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}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 r=e.find(i=>i.identifier===t.identifier);return r?{...t,...r}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(i=>i.responseIdentifier===t.identifier);r&&(r.value=t.value)}})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let i=this._interactionElements.find(l=>l.getAttribute("response-identifier")===t.responseIdentifier);i&&(i.value=t.response)}}render(){return Dr`<slot></slot>`}showCorrectResponse(e){let r=this._context.variables.filter(i=>"correctResponse"in i&&i.correctResponse).map(i=>({responseIdentifier:i.identifier,response:i.correctResponse}));for(let i of r){let l=this._interactionElements.find(s=>s.getAttribute("response-identifier")===i.responseIdentifier);l&&(l.correctResponse=e?i.response:"")}}processResponse(e=!0){this.validate();let t=this.querySelector("qti-response-processing");return!t||!t.process?!1:(t.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(r=>r.identifier==="numAttempts")?.value+1).toString()),this._emit("qti-response-processed"),!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}handleUpdateResponseVariable(e){let{responseIdentifier:t,response:r}=e.detail;this.updateResponseVariable(t,r)}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,value:t})},this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}updateOutcomeVariable(e,t){let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:r.cardinality==="single"?t:[...i.value,t]})},this._feedbackElements.forEach(i=>i.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(i=>i.identifier===e)?.value})}validate(){return this._interactionElements.every(e=>e.validate())?!0:this._interactionElements.some(e=>e.validate())?!1:null}_getCompletionStatus(){let e=this.validate();return e===!0?"completed":e===!1?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};n([Y({type:String})],E.prototype,"title",2),n([Y({type:String})],E.prototype,"identifier",2),n([Y({type:String})],E.prototype,"adaptive",2),n([Y({type:String})],E.prototype,"timeDependent",2),n([Y({type:Boolean})],E.prototype,"disabled",2),n([x("disabled",{waitUntilFirstUpdate:!0})],E.prototype,"_handleDisabledChange",2),n([Y({type:Boolean})],E.prototype,"readonly",2),n([x("readonly",{waitUntilFirstUpdate:!0})],E.prototype,"_handleReadonlyChange",2),n([Lr({context:y})],E.prototype,"_context",2),E=n([Vr("qti-assessment-item")],E);import{LitElement as $r}from"lit";import{customElement as Ir,property as Pt}from"lit/decorators.js";var Hr=String.raw,Nr=Hr`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
2
|
+
<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes" />
|
|
3
|
+
<xsl:template match="@*|node()">
|
|
4
|
+
<xsl:copy>
|
|
5
|
+
<xsl:apply-templates select="@*|node()"/>
|
|
6
|
+
</xsl:copy>
|
|
7
|
+
</xsl:template>
|
|
8
|
+
|
|
9
|
+
<!-- remove existing namespaces -->
|
|
10
|
+
<xsl:template match="*">
|
|
11
|
+
<!-- remove element prefix -->
|
|
12
|
+
<xsl:element name="{local-name()}">
|
|
13
|
+
<!-- process attributes -->
|
|
14
|
+
<xsl:for-each select="@*">
|
|
15
|
+
<!-- remove attribute prefix -->
|
|
16
|
+
<xsl:attribute name="{local-name()}">
|
|
17
|
+
<xsl:value-of select="."/>
|
|
18
|
+
</xsl:attribute>
|
|
19
|
+
</xsl:for-each>
|
|
20
|
+
<xsl:apply-templates/>
|
|
21
|
+
</xsl:element>
|
|
22
|
+
</xsl:template>
|
|
23
|
+
</xsl:stylesheet>`;function Vt(c,o,e){c.querySelectorAll(o).forEach(t=>{let r=`${o}-${e}`,i=Nt(t,r);t.replaceWith(i)})}function Ht(c,o){c.querySelectorAll("*").forEach(e=>{let t=e.classList;t&&t.forEach(r=>{if(r.startsWith(`${o}:`)){let i=r.slice(`${o}:`.length),l=`${e.nodeName}-${i}`,s=Nt(e,l);e.replaceWith(s)}})})}function Nt(c,o){let e=document.createElement(o);for(let t of c.attributes)e.setAttribute(t.name,t.value);for(;c.firstChild;)e.appendChild(c.firstChild);return e}var Qe=null;function Me(c,o=!1){return o&&Qe!==null&&Qe.abort(),new Promise((e,t)=>{let r=new XMLHttpRequest;Qe=r,r.open("GET",c,!0),r.responseType="document",r.onload=()=>{r.status>=200&&r.status<300?e(r.responseXML):t(r.statusText)},r.onerror=()=>{t(r.statusText)},r.send()})}function Se(c){return new DOMParser().parseFromString(c,"text/xml")}function Re(c){let o=new XSLTProcessor,e=new DOMParser().parseFromString(Nr,"text/xml");return o.importStylesheet(e),o.transformToFragment(c,document)}function et(c,o){o.endsWith("/")||(o+="/"),c.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 r=e.getAttribute(t)?.trim();if(!r.startsWith("data:")&&!r.startsWith("http")){let i=o+encodeURI(r);e.setAttribute(t,i)}})}function $t(c){c.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let t=document.createComment(e.textContent);e.replaceChild(t,e.firstChild)})}function It(c){c.querySelectorAll("qti-stylesheet").forEach(o=>o.remove())}var Ot=()=>{let c,o={async load(e,t=!1){return new Promise(r=>{Me(e,t).then(i=>(c=i,o.path(e.substring(0,e.lastIndexOf("/"))),r(o)))})},parse(e){return c=Se(e),o},path:e=>(et(c,e),o),fn(e){return e(c),o},pciHooks(e){let t=["hook","module"],r=e.substring(0,e.lastIndexOf("/"));for(let i of t)c.querySelectorAll("["+i+"]").forEach(s=>{let a=s.getAttribute(i);!a.startsWith("data:")&&!a.startsWith("http")&&(s.setAttribute("base-url",e),s.setAttribute("module",r+"/"+encodeURI(a+(a.endsWith(".js")?"":".js"))))});return o},extendElementName:(e,t)=>(Vt(c,e,t),o),extendElementsWithClass:(e="extend")=>(Ht(c,e),o),customInteraction(e,t){let r=c.querySelector("qti-custom-interaction"),i=r.querySelector("object");return r.setAttribute("data-base-ref",e),r.setAttribute("data-base-item",e+t),r.setAttribute("data",i.getAttribute("data")),r.setAttribute("width",i.getAttribute("width")),r.setAttribute("height",i.getAttribute("height")),r.removeChild(i),o},convertCDATAtoComment(){return $t(c),o},stripStyleSheets(){return It(c),o},html(){return new XMLSerializer().serializeToString(Re(c))},xml(){return new XMLSerializer().serializeToString(c)},htmlDoc(){return Re(c)},xmlDoc(){return c}};return o};var W=class extends $r{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0,composed:!0});if(this.dispatchEvent(e)){let i=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);i?await this.updateStimulusRef(i):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Ot().load(this.href).then(r=>r.htmlDoc());if(t){let r=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...r)}}};n([Pt({type:String})],W.prototype,"identifier",2),n([Pt({type:String})],W.prototype,"href",2),W=n([Ir("qti-assessment-stimulus-ref")],W);import{html as Or}from"lit";import{property as Ae}from"lit/decorators.js";var Ft={toAttribute:c=>c?"true":"false",fromAttribute:c=>c==="true"};function M(c,o){class e extends c{constructor(...i){super(...i);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(i,l){this.tabIndex=l?-1:0,l&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${o}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${o}`,{bubbles:!0,composed:!0}))}_onKeyUp(i){i.altKey||i.code==="Space"&&(i.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${o}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return Or`<slot></slot>`}}return n([Ae({type:String})],e.prototype,"identifier",2),n([Ae({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),n([Ae({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Ft})],e.prototype,"disabled",2),n([Ae({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Ft})],e.prototype,"readonly",2),n([x("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}import{customElement as Fr}from"lit/decorators.js";import{html as zr,LitElement as Ur}from"lit";import{css as Pr}from"lit";var zt=Pr`
|
|
24
|
+
:host {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
`;var ie=class extends Ur{render(){return zr`<slot name="qti-rubric-block"></slot><slot></slot>`}};ie.styles=zt,ie=n([Fr("qti-item-body")],ie);import{html as Xr,LitElement as Br}from"lit";import{customElement as Yr}from"lit/decorators.js";var ke=class extends Br{render(){return Xr`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};ke=n([Yr("qti-prompt")],ke);import{LitElement as Wr}from"lit";import{customElement as jr}from"lit/decorators.js";var Le=class extends Wr{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(r=>r.text()).then(r=>{let i=this.minifyCss(r);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.")}).catch(r=>{console.error("Failed to load stylesheet:",r)}),this.textContent!==null&&this.textContent.trim()!==""){let r=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${r}}`,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()}};Le=n([jr("qti-stylesheet")],Le);import{consume as Zr}from"@lit/context";import{css as Qr,html as ei}from"lit";import{customElement as ti,property as _e,state as ri}from"lit/decorators.js";import{html as Kr,LitElement as Jr}from"lit";import{customElement as Gr}from"lit/decorators.js";var I=class extends Jr{render(){return Kr`<slot></slot>`}defaultValues(o){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(r=>r.innerHTML.trim());return t.length>1||o.cardinality==="multiple"||o.cardinality==="ordered"?t:t[0]}};I=n([Gr("qti-variabledeclaration")],I);var S=class extends I{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return ei`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let r of e.querySelectorAll("qti-interpolation-table-entry")){!r.getAttribute("source-value")&&r.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let i=parseInt(r.getAttribute("source-value")),l=parseInt(r.getAttribute("target-value"));(isNaN(i)||isNaN(l))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(i,l)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};S.styles=[Qr`
|
|
28
|
+
:host {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
`],n([_e({type:String,attribute:"base-type"})],S.prototype,"baseType",2),n([_e({type:String,attribute:"external-scored"})],S.prototype,"externalScored",2),n([_e({type:String})],S.prototype,"identifier",2),n([_e({type:String})],S.prototype,"cardinality",2),n([Zr({context:y,subscribe:!0}),ri()],S.prototype,"itemContext",2),S=n([ti("qti-outcome-declaration")],S);import{consume as ii}from"@lit/context";import{css as si,html as oi}from"lit";import{customElement as ni,property as tt,state as ai}from"lit/decorators.js";var D=class extends I{render(){let o=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return oi`${JSON.stringify(o,null,2)}`}connectedCallback(){super.connectedCallback();let o={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};o.value=this.defaultValues(o),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:o}}))}get correctResponse(){let o,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)o=t[0].textContent,t[0].remove();else if(this.cardinality!=="single"){o=[];for(let r=0;r<t.length;r++)o.push(t[r].textContent),t[r].remove()}}return o}get mapping(){return this.querySelector("qti-mapping")}};D.styles=[si`
|
|
32
|
+
:host {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
`],n([tt({type:String,attribute:"base-type"})],D.prototype,"baseType",2),n([tt({type:String})],D.prototype,"identifier",2),n([tt({type:String})],D.prototype,"cardinality",2),n([ii({context:y,subscribe:!0}),ai()],D.prototype,"itemContext",2),D=n([ni("qti-response-declaration")],D);import{LitElement as li}from"lit";import{customElement as ci}from"lit/decorators.js";var De=class extends li{};De=n([ci("qti-companion-materials-info")],De);import{LitElement as pi,html as di}from"lit";import{customElement as ui}from"lit/decorators.js";var Ve=class extends pi{render(){return di`<slot></slot>`}};Ve=n([ui("qti-content-body")],Ve);import{LitElement as mi,css as hi,html as fi}from"lit";import{customElement as gi,property as He}from"lit/decorators.js";var R=class extends mi{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return fi`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};R.styles=hi`
|
|
36
|
+
:host {
|
|
37
|
+
display: block;
|
|
38
|
+
}
|
|
39
|
+
`,n([He({type:String})],R.prototype,"id",2),n([He({type:String})],R.prototype,"use",2),n([He({type:String})],R.prototype,"view",2),n([He({type:String,attribute:"class"})],R.prototype,"classNames",2),n([x("classNames",{waitUntilFirstUpdate:!0})],R.prototype,"handleclassNamesChange",1),R=n([gi("qti-rubric-block")],R);import{css as Ei,html as Ci}from"lit";import{customElement as qi}from"lit/decorators.js";import{consume as vi}from"@lit/context";import{LitElement as yi}from"lit";import{property as Ne,state as xi}from"lit/decorators.js";var bi=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),se=c=>{if(typeof c=="string")return c;let o=bi();return o==="."?c.toLocaleString():c.toString().replace(".","").replace(o,".")};function rt(c){return c==null}function oe(c){return c.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var C=class extends yi{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(o){let e=this._context.variables.find(r=>r.identifier===o)||null;if(this.outcomeIdentifier!==o||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!rt(this.identifier)&&!rt(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(o){this.showStatus=o&&this.showHide==="show"||!o&&this.showHide==="hide"?"on":"off"}};n([Ne({type:String,attribute:"show-hide"})],C.prototype,"showHide",2),n([Ne({type:String,attribute:"outcome-identifier"})],C.prototype,"outcomeIdentifier",2),n([Ne({type:String})],C.prototype,"identifier",2),n([Ne({type:String,attribute:!1})],C.prototype,"showStatus",2),n([vi({context:y,subscribe:!0}),xi()],C.prototype,"_context",2);var ne=class extends C{render(){return Ci` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(o){this.checkShowFeedback(this.outcomeIdentifier)}};ne.styles=Ei`
|
|
40
|
+
:host {
|
|
41
|
+
display: block;
|
|
42
|
+
}
|
|
43
|
+
.on {
|
|
44
|
+
display: block;
|
|
45
|
+
}
|
|
46
|
+
.off {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
`,ne=n([qi("qti-feedback-block")],ne);import{css as Ti,html as wi}from"lit";import{customElement as Mi}from"lit/decorators.js";var ae=class extends C{constructor(){super(...arguments);this.render=()=>wi` <slot part="feedback" class="${this.showStatus}"></slot> `}};ae.styles=Ti`
|
|
50
|
+
.on {
|
|
51
|
+
display: inline-block;
|
|
52
|
+
}
|
|
53
|
+
.off {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
`,ae=n([Mi("qti-feedback-inline")],ae);import{css as Si,html as Ri}from"lit";import{customElement as Ai}from"lit/decorators.js";var le=class extends C{render(){return Ri`
|
|
57
|
+
<dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
|
|
58
|
+
<slot></slot>
|
|
59
|
+
<div style="margin-top: var(--qti-gap-size); text-align: center;">
|
|
60
|
+
<button class="button close-button" @click="${this.closeFeedback}"></button>
|
|
61
|
+
</div>
|
|
62
|
+
</dialog>
|
|
63
|
+
`}openFeedback(){let o=this.shadowRoot?.querySelector("dialog");o&&!o.open&&o.showModal()}closeFeedback(){let o=this.shadowRoot?.querySelector("dialog");o&&o.open&&(o.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(o){o.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};le.styles=Si`
|
|
64
|
+
.qti-dialog {
|
|
65
|
+
background: var(--qti-bg);
|
|
66
|
+
border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
|
|
67
|
+
border-radius: var(--qti-border-radius);
|
|
68
|
+
padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
|
|
69
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
70
|
+
position: fixed;
|
|
71
|
+
top: 50%;
|
|
72
|
+
left: 50%;
|
|
73
|
+
transform: translate(-50%, -50%);
|
|
74
|
+
z-index: 1000;
|
|
75
|
+
width: auto;
|
|
76
|
+
max-width: 90%;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.button {
|
|
80
|
+
border-radius: var(--qti-border-radius);
|
|
81
|
+
padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
|
|
82
|
+
background-color: var(--qti-bg-active);
|
|
83
|
+
border: var(--qti-border-active);
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
position: relative;
|
|
86
|
+
display: inline-block;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.button:hover {
|
|
90
|
+
background-color: var(--qti-hover-bg);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.button:disabled {
|
|
94
|
+
background-color: var(--qti-disabled-bg);
|
|
95
|
+
color: var(--qti-disabled-color);
|
|
96
|
+
cursor: not-allowed;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.button:focus {
|
|
100
|
+
outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Text content of the button */
|
|
104
|
+
.button::after {
|
|
105
|
+
content: var(--qti-close-text, 'Close');
|
|
106
|
+
color: inherit;
|
|
107
|
+
font-size: inherit;
|
|
108
|
+
text-align: center;
|
|
109
|
+
display: inline-block;
|
|
110
|
+
line-height: 1.5;
|
|
111
|
+
}
|
|
112
|
+
`,le=n([Ai("qti-modal-feedback")],le);import{html as Di}from"lit";import{ifDefined as Vi}from"lit/directives/if-defined.js";import{property as it,state as ki}from"lit/decorators.js";import{LitElement as Li}from"lit";var h=class extends Li{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}reportValidity(){return this._internals.reportValidity()}reset(){this.value=""}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{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}}))}};h.formAssociated=!0,n([it({type:String,attribute:"response-identifier"})],h.prototype,"responseIdentifier",2),n([it({reflect:!0,type:Boolean})],h.prototype,"disabled",2),n([it({reflect:!0,type:Boolean})],h.prototype,"readonly",2),n([ki()],h.prototype,"_correctResponse",2);import{customElement as Hi,property as ce,state as Xt}from"lit/decorators.js";import{css as _i}from"lit";var Ut=_i`
|
|
113
|
+
/* PK: display host as block, else design will be collapsed */
|
|
114
|
+
:host {
|
|
115
|
+
display: block;
|
|
116
|
+
}
|
|
117
|
+
textarea {
|
|
118
|
+
box-sizing: border-box;
|
|
119
|
+
width: 100%;
|
|
120
|
+
height: 100%;
|
|
121
|
+
border: 0;
|
|
122
|
+
}
|
|
123
|
+
`;var q=class extends h{constructor(){super(...arguments);this._rows=5;this._value=""}handleclassNamesChange(e,t){let r=t.split(" "),i=!1;if(r.forEach(l=>{if(l.startsWith("qti-height-lines-")){let s=l.replace("qti-height-lines-","");this._rows=parseInt(s),i=!0}}),!i&&this.expectedLength){let l=Math.ceil(this.expectedLength/50);this._rows=l}}get value(){return this._value}set value(e){if(typeof e=="string"){this._value=e;let t=new FormData;t.append(this.responseIdentifier,e),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}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}$`,r=new RegExp(t);e.checkValidity()&&r.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._value!==""&&e.checkValidity()}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return Di`<slot name="prompt"></slot
|
|
124
|
+
><textarea
|
|
125
|
+
part="textarea"
|
|
126
|
+
name="${this.responseIdentifier}"
|
|
127
|
+
spellcheck="false"
|
|
128
|
+
autocomplete="off"
|
|
129
|
+
maxlength="${5e3}"
|
|
130
|
+
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
131
|
+
@keyup="${this.textChanged}"
|
|
132
|
+
@change="${this.textChanged}"
|
|
133
|
+
@blur="${e=>{this.reportValidity()}}"
|
|
134
|
+
placeholder="${Vi(this.placeholderText?this.placeholderText:void 0)}"
|
|
135
|
+
rows="${this._rows}"
|
|
136
|
+
?disabled="${this.disabled}"
|
|
137
|
+
?readonly="${this.readonly}"
|
|
138
|
+
.value=${this._value}
|
|
139
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};q.styles=Ut,n([Xt()],q.prototype,"_rows",2),n([ce({type:Number,attribute:"expected-length"})],q.prototype,"expectedLength",2),n([ce({type:String,attribute:"pattern-mask"})],q.prototype,"patternMask",2),n([ce({type:String,attribute:"placeholder-text"})],q.prototype,"placeholderText",2),n([ce({type:String,attribute:"data-patternmask-message"})],q.prototype,"dataPatternmaskMessage",2),n([Xt()],q.prototype,"_value",2),n([ce({type:String,attribute:"class"})],q.prototype,"classNames",2),n([x("classNames")],q.prototype,"handleclassNamesChange",1),q=n([Hi("qti-extended-text-interaction")],q);import{html as $i}from"lit";import{customElement as Ii,property as $e,state as Oi}from"lit/decorators.js";import{ifDefined as Yt}from"lit/directives/if-defined.js";import{createRef as Pi}from"lit/directives/ref.js";import{css as Ni}from"lit";var Bt=Ni`
|
|
140
|
+
:host {
|
|
141
|
+
display: inline-block;
|
|
142
|
+
}
|
|
143
|
+
[part='correct'] {
|
|
144
|
+
position: absolute;
|
|
145
|
+
width: 100%;
|
|
146
|
+
}
|
|
147
|
+
:host(.qti-input-width-1) [part='input'] {
|
|
148
|
+
width: 1.1rem;
|
|
149
|
+
min-width: 1.1rem;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
:host(.qti-input-width-2) [part='input'] {
|
|
153
|
+
width: 2.3rem;
|
|
154
|
+
min-width: 2.3rem;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:host(.qti-input-width-3) [part='input'] {
|
|
158
|
+
width: 3.3rem;
|
|
159
|
+
min-width: 3.3rem;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
:host(.qti-input-width-4) [part='input'] {
|
|
163
|
+
width: 4.2rem;
|
|
164
|
+
min-width: 4.2rem;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
:host(.qti-input-width-6) [part='input'] {
|
|
168
|
+
width: 6.6rem;
|
|
169
|
+
min-width: 6.6rem;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
:host(.qti-input-width-10) [part='input'] {
|
|
173
|
+
width: 8rem;
|
|
174
|
+
min-width: 8rem;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
:host(.qti-input-width-15) [part='input'] {
|
|
178
|
+
width: 12rem;
|
|
179
|
+
min-width: 12rem;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
:host(.qti-input-width-20) [part='input'] {
|
|
183
|
+
width: 17rem;
|
|
184
|
+
min-width: 17rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
:host(.qti-input-width-25) [part='input'] {
|
|
188
|
+
width: 20rem;
|
|
189
|
+
min-width: 20rem;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:host(.qti-input-width-30) [part='input'] {
|
|
193
|
+
width: 24rem;
|
|
194
|
+
min-width: 24rem;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
:host(.qti-input-width-35) [part='input'] {
|
|
198
|
+
width: 28rem;
|
|
199
|
+
min-width: 28rem;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
:host(.qti-input-width-40) [part='input'] {
|
|
203
|
+
width: 32rem;
|
|
204
|
+
min-width: 32rem;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
:host(.qti-input-width-45) [part='input'] {
|
|
208
|
+
width: 36rem;
|
|
209
|
+
min-width: 36rem;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
:host(.qti-input-width-50) [part='input'] {
|
|
213
|
+
width: 40rem;
|
|
214
|
+
min-width: 40rem;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
:host(.qti-input-width-72) [part='input'] {
|
|
218
|
+
width: 57rem;
|
|
219
|
+
min-width: 57rem;
|
|
220
|
+
}
|
|
221
|
+
`;var A=class extends h{constructor(){super(...arguments);this._value="";this.inputRef=Pi()}get value(){return this._value}set value(e){if(typeof e=="string"){this._value=e;let t=new FormData;t.append(this.responseIdentifier,e),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),e.setCustomValidity(""),e.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage));else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}render(){return $i`
|
|
222
|
+
<input
|
|
223
|
+
part="input"
|
|
224
|
+
name="${this.responseIdentifier}"
|
|
225
|
+
spellcheck="false"
|
|
226
|
+
autocomplete="off"
|
|
227
|
+
@blur="${e=>{this.reportValidity()}}"
|
|
228
|
+
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
229
|
+
@keyup="${this.textChanged}"
|
|
230
|
+
@change="${this.textChanged}"
|
|
231
|
+
type="${this.patternMask=="[0-9]*"?"number":"text"}"
|
|
232
|
+
placeholder="${Yt(this.placeholderText?this.placeholderText:void 0)}"
|
|
233
|
+
.value="${this._value}"
|
|
234
|
+
pattern="${Yt(this.patternMask?this.patternMask:void 0)}"
|
|
235
|
+
maxlength=${1e3}
|
|
236
|
+
?disabled="${this.disabled}"
|
|
237
|
+
?readonly="${this.readonly}"
|
|
238
|
+
/>
|
|
239
|
+
<div part="correct">${this._correctResponse}</div>
|
|
240
|
+
`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==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._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};A.styles=Bt,n([$e({type:Number,attribute:"expected-length"})],A.prototype,"expectedLength",2),n([$e({type:String,attribute:"pattern-mask"})],A.prototype,"patternMask",2),n([$e({type:String,attribute:"placeholder-text"})],A.prototype,"placeholderText",2),n([$e({type:String,attribute:"data-patternmask-message"})],A.prototype,"dataPatternmaskMessage",2),n([Oi()],A.prototype,"_value",2),A=n([Ii("qti-text-entry-interaction")],A);import{html as zi}from"lit";import{customElement as Ui}from"lit/decorators.js";import{property as Wt,query as Fi}from"lit/decorators.js";var O=(c,o)=>{class e extends c{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(i,l)=>{this._choiceElements.forEach(s=>s.disabled=l)};this._handleReadonlyChange=(i,l)=>{this._choiceElements.forEach(s=>s.readonly=l)};this._value=""}_handleMaxChoicesChange(i,l){this._determineInputType()}get value(){return Array.isArray(this._value)?this._value.join(","):this._value}set value(i){if(this.maxChoices>1&&typeof i=="string"?this._value=i.split(","):this._value=i,Array.isArray(this._value)){let l=new FormData;this._value.forEach(s=>{l.append(this.responseIdentifier,s)}),this._internals.setFormValue(l)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(i){this._correctResponse=i;let l=Array.isArray(i)?i:[i];this._choiceElements.forEach(s=>{s.internals.states.delete("correct-response"),s.internals.states.delete("incorrect-response"),l.length>0&&(l.includes(s.identifier)?s.internals.states.add("correct-response"):s.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${o}`,this._registerChoiceElement),this.addEventListener(`unregister-${o}`,this._unregisterChoiceElement),this.addEventListener(`activate-${o}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${o}`,this._registerChoiceElement),this.removeEventListener(`unregister-${o}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${o}`,this._choiceElementSelectedHandler)}validate(){let i=this._choiceElements.filter(p=>this._getChoiceChecked(p)),l=i.length,s=!0,a="";return this.maxChoices!==0&&l>this.maxChoices?(s=!1,a=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):l<this.minChoices&&(s=!1,a=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),i.length>0&&this._internals.setValidity(s?{}:{customError:!0},a,i[l-1]||this._choiceElements[0]||this),this.reportValidity(),s}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.display="block")),this._internals.validity.valid}_registerChoiceElement(i){i.stopPropagation();let l=i.target;l.disabled=this.disabled,this._choiceElements.push(l),this._setInputType(l)}_unregisterChoiceElement(i){i.stopPropagation();let l=i.target;this._choiceElements=this._choiceElements.filter(s=>s!==l)}_determineInputType(){this._choiceElements.forEach(i=>{this._setInputType(i)})}_setInputType(i){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let l=this.maxChoices===1?"radio":"checkbox";i.internals.role=l,i.internals.states.delete(l==="radio"?"checkbox":"radio"),i.internals.states.add(l)}_choiceElementSelectedHandler(i){this._toggleChoiceChecked(i.target),this.maxChoices===1&&this._choiceElements.forEach(l=>{l.identifier!==i.detail.identifier&&this._setChoiceChecked(l,!1)}),this._handleChoiceSelection()}_setChoiceChecked(i,l){i.internals?.states&&(l?(i.internals.states.add("--checked"),i.internals.ariaChecked="true"):(i.internals.states.delete("--checked"),i.internals.ariaChecked="false"))}_getChoiceChecked(i){return i.internals.states.has("--checked")}_toggleChoiceChecked(i){let l=this._getChoiceChecked(i);this._setChoiceChecked(i,!l)}_handleChoiceSelection(){let l=this._choiceElements.filter(s=>this._getChoiceChecked(s)).map(s=>s.identifier);this.value=this.maxChoices===1?l[0]||"":l,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let i=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(l=>{let s=i.includes(l.identifier);this._setChoiceChecked(l,s)})}}return n([Fi("#validationMessage")],e.prototype,"_validationMessageElement",2),n([Wt({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),n([Wt({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),n([x("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),n([x("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),n([x("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var Ie=class extends O(h,"qti-hottext"){constructor(){super(...arguments);this.render=()=>zi`<slot></slot>`}};Ie=n([Ui("qti-hottext-interaction")],Ie);import{css as Xi,html as jt}from"lit";import{customElement as Bi,property as Yi,state as Kt}from"lit/decorators.js";import{unsafeHTML as Jt}from"lit/directives/unsafe-html.js";var P=class extends h{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[Xi`
|
|
241
|
+
:host {
|
|
242
|
+
display: inline-block;
|
|
243
|
+
}
|
|
244
|
+
slot {
|
|
245
|
+
display: flex;
|
|
246
|
+
flex-direction: column;
|
|
247
|
+
}
|
|
248
|
+
[role='menu'] {
|
|
249
|
+
position: absolute;
|
|
250
|
+
z-index: 1000;
|
|
251
|
+
}
|
|
252
|
+
.anchor {
|
|
253
|
+
/* anchor-name: --infobox; */
|
|
254
|
+
width: fit-content;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.positionedElement {
|
|
258
|
+
position: absolute;
|
|
259
|
+
/* position-anchor: --infobox; */
|
|
260
|
+
/* top: anchor(bottom); */
|
|
261
|
+
}
|
|
262
|
+
`]}render(){return jt`
|
|
263
|
+
<select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
|
|
264
|
+
${this.options.map(e=>jt`
|
|
265
|
+
<option value="${e.value}" ?selected="${e.selected}">${Jt(e.textContent)}</option>
|
|
266
|
+
`)}
|
|
267
|
+
</select>
|
|
268
|
+
|
|
269
|
+
${Jt(this.correctOption)}
|
|
270
|
+
`}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}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 value(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}get value(){return this.options.find(e=>e.selected).value}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(t=>e===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>({...r,selected:r.value===t})),this.saveResponse(t)}};P.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"],n([Kt()],P.prototype,"options",2),n([Kt()],P.prototype,"correctOption",2),n([Yi({attribute:"data-prompt",type:String})],P.prototype,"dataPrompt",2),P=n([Bi("qti-inline-choice-interaction")],P);import{html as Ji}from"lit";import{customElement as Gi,property as Zi}from"lit/decorators.js";import{property as Wi}from"lit/decorators.js";var Oe=(c,o)=>{class e extends c{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(i){i.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let i=Array.from(this.querySelectorAll(o)),l=i.filter(m=>m.hasAttribute("fixed")),s=i.filter(m=>!m.hasAttribute("fixed"));if(s.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let a=[...s],p=!1,d=0;for(;!p&&d<10;){d++;for(let m=s.length-1;m>0;m--){let g=Math.floor(Math.random()*(m+1));[s[m],s[g]]=[s[g],s[m]]}p=!s.every((m,g)=>m===a[g])}p||console.warn("Failed to shuffle the choices after multiple attempts.");let u=1;[...l,...s].forEach(m=>{m.style.setProperty("order",String(u++))})}_resetShuffleChoices(){this.querySelectorAll(o).forEach(i=>{i.style.setProperty("order","initial")})}}return n([Wi({type:String,reflect:!0})],e.prototype,"shuffle",2),e};import{property as ji}from"lit/decorators.js";var Gt=(c,o)=>{class e extends c{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(i){i&&(this._classes=i.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(i){super.updated(i),i.has("shuffle")&&this._addLabels()}_addLabels(){let i=this._classes.some(s=>this._allLabels.includes(s)||this._allLabelSuffixes.includes(s)),l=s=>!isNaN(+s);if(i){let a=Array.from(this.querySelectorAll("qti-simple-choice")).map(p=>p).map((p,d)=>({el:p,order:l(p.style.order)?+p.style.order:d+1})).sort((p,d)=>p.order-d.order).map(p=>p.el);for(let p=0;p<a.length;p++)a[p].marker=this._getLabel(p+1)}}_getLabel(i){let l=this._classes.filter(p=>this._allLabels.includes(p)).pop(),s=this._classes.filter(p=>this._allLabelSuffixes.includes(p)).pop();!l&&s&&(l="qti-labels-upper-alpha");let a="";switch(l){case"qti-labels-decimal":a=`${i}`;break;case"qti-labels-lower-alpha":a=`${String.fromCharCode(97+i-1)}`;break;case"qti-labels-upper-alpha":a=`${String.fromCharCode(65+i-1)}`;break}return s==="qti-labels-suffix-period"?a+=".":s==="qti-labels-suffix-parenthesis"&&(a+=")"),a}}return n([ji({type:String,reflect:!0})],e.prototype,"class",1),e};import{css as Ki}from"lit";var Zt=Ki`
|
|
271
|
+
[part='slot'] {
|
|
272
|
+
display: flex;
|
|
273
|
+
flex-direction: column;
|
|
274
|
+
gap: var(--qti-gap-size);
|
|
275
|
+
flex-wrap: wrap;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
::slotted(qti-simple-choice) {
|
|
279
|
+
flex: 0 0
|
|
280
|
+
calc((100% - (var(--qti-gap-size) * var(--choice-interactions-stacking))) / var(--choice-interactions-stacking)) !important;
|
|
281
|
+
box-sizing: border-box !important;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
:host(.qti-choices-stacking-1) [part='slot'] {
|
|
285
|
+
flex-direction: row;
|
|
286
|
+
--choice-interactions-stacking: 1;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
:host(.qti-choices-stacking-2) [part='slot'] {
|
|
290
|
+
flex-direction: row;
|
|
291
|
+
--choice-interactions-stacking: 2;
|
|
292
|
+
}
|
|
293
|
+
:host(.qti-choices-stacking-3) [part='slot'] {
|
|
294
|
+
flex-direction: row;
|
|
295
|
+
--choice-interactions-stacking: 3;
|
|
296
|
+
}
|
|
297
|
+
:host(.qti-choices-stacking-4) [part='slot'] {
|
|
298
|
+
flex-direction: row;
|
|
299
|
+
--choice-interactions-stacking: 4;
|
|
300
|
+
}
|
|
301
|
+
:host(.qti-choices-stacking-5) [part='slot'] {
|
|
302
|
+
flex-direction: row;
|
|
303
|
+
--choice-interactions-stacking: 5;
|
|
304
|
+
}
|
|
305
|
+
:host([orientation='horizontal']) [part='slot'] {
|
|
306
|
+
flex-direction: row;
|
|
307
|
+
}
|
|
308
|
+
`;var j=class extends Gt(Oe(O(h,"qti-simple-choice"),"qti-simple-choice"),"qti-simple-choice"){constructor(){super(),this._internals.role="group"}render(){return Ji`
|
|
309
|
+
<slot part="prompt" name="prompt"></slot><slot part="slot"></slot>
|
|
310
|
+
<div part="message" role="alert" id="validationMessage"></div>
|
|
311
|
+
`}};j.styles=Zt,n([Zi({type:String})],j.prototype,"orientation",2),j=n([Gi("qti-choice-interaction")],j);import{css as Qi,html as es}from"lit";import{customElement as ts}from"lit/decorators.js";var pe=class extends h{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 value(){return this._base64}set value(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{...h.properties}}render(){return es`
|
|
312
|
+
<div>
|
|
313
|
+
<slot name="prompt"></slot>
|
|
314
|
+
<input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
|
|
315
|
+
</div>
|
|
316
|
+
`}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,r)=>{let i=new FileReader;i.onload=()=>t(i.result),i.onerror=()=>r(i.error),i.readAsDataURL(e)})}};pe.styles=[Qi`
|
|
317
|
+
:host {
|
|
318
|
+
display: block;
|
|
319
|
+
margin: 1em 0;
|
|
320
|
+
}
|
|
321
|
+
input[type='file'] {
|
|
322
|
+
display: block;
|
|
323
|
+
margin-top: 0.5em;
|
|
324
|
+
}
|
|
325
|
+
`],pe=n([ts("qti-upload-interaction")],pe);import{css as rs,html as is,LitElement as ss}from"lit";import{customElement as os}from"lit/decorators.js";var de=class extends ss{render(){return is`<slot></slot>`}process(){let o=new st,e=[...this.children];o.process(e)}};de.styles=[rs`
|
|
326
|
+
:host {
|
|
327
|
+
display: none;
|
|
328
|
+
}
|
|
329
|
+
`],de=n([os("qti-outcome-processing")],de);var st=class{process(o){for(let e of o)e.process()}};import{css as ns,html as as,LitElement as ls}from"lit";import{customElement as cs}from"lit/decorators.js";var Qt=`<qti-response-processing>
|
|
330
|
+
<qti-response-condition>
|
|
331
|
+
<qti-response-if>
|
|
332
|
+
<qti-match>
|
|
333
|
+
<qti-variable identifier="RESPONSE"></qti-variable>
|
|
334
|
+
<qti-correct identifier="RESPONSE"></qti-correct>
|
|
335
|
+
</qti-match>
|
|
336
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
337
|
+
<qti-base-value base-type="float">1</qti-base-value>
|
|
338
|
+
</qti-set-outcome-value>
|
|
339
|
+
</qti-response-if>
|
|
340
|
+
<qti-response-else>
|
|
341
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
342
|
+
<qti-base-value base-type="float">0</qti-base-value>
|
|
343
|
+
</qti-set-outcome-value>
|
|
344
|
+
</qti-response-else>
|
|
345
|
+
</qti-response-condition>
|
|
346
|
+
</qti-response-processing>`,er=`<qti-response-processing>
|
|
347
|
+
<qti-response-condition>
|
|
348
|
+
<qti-response-if>
|
|
349
|
+
<qti-is-null>
|
|
350
|
+
<qti-variable identifier="RESPONSE"></qti-variable>
|
|
351
|
+
</qti-is-null>
|
|
352
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
353
|
+
<qti-base-value base-type="float">0.0</qti-base-value>
|
|
354
|
+
</qti-set-outcome-value>
|
|
355
|
+
</qti-response-if>
|
|
356
|
+
<qti-response-else>
|
|
357
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
358
|
+
<qti-map-response identifier="RESPONSE"> </qti-map-response>
|
|
359
|
+
</qti-set-outcome-value>
|
|
360
|
+
</qti-response-else>
|
|
361
|
+
</qti-response-condition>
|
|
362
|
+
</qti-response-processing>`,tr=`<qti-response-processing>
|
|
363
|
+
<qti-response-condition>
|
|
364
|
+
<qti-response-if>
|
|
365
|
+
<qti-is-null>
|
|
366
|
+
<qti-variable identifier="RESPONSE"></qti-variable>
|
|
367
|
+
</qti-is-null>
|
|
368
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
369
|
+
<qti-base-value base-type="float">0</qti-base-value>
|
|
370
|
+
</qti-set-outcome-value>
|
|
371
|
+
</qti-response-if>
|
|
372
|
+
<qti-response-else>
|
|
373
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
374
|
+
<qti-map-response-point identifier="RESPONSE"></qti-map-response-point>
|
|
375
|
+
</qti-set-outcome-value>
|
|
376
|
+
</qti-response-else>
|
|
377
|
+
</qti-response-condition>
|
|
378
|
+
</qti-response-processing>`;var X=class extends ls{render(){return as`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(o){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(er).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(tr).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(Qt).firstElementChild.firstElementChild);break}}}fragmentFromString(o){return document.createRange().createContextualFragment(o)}};X.styles=[ns`
|
|
379
|
+
:host {
|
|
380
|
+
display: none;
|
|
381
|
+
}
|
|
382
|
+
`],X=n([cs("qti-response-processing")],X);import{property as ms}from"lit/decorators.js";import{customElement as ps}from"lit/decorators.js";import{html as ds,LitElement as us}from"lit";var k=class extends us{render(){return ds`<slot></slot>`}process(){throw new Error("Not implemented")}};k=n([ps("qti-rule")],k);var Pe=class extends k{get childExpression(){return this.firstElementChild}process(){let o=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(o),t;return e.interpolationTable&&(t=e.interpolationTable.get(parseInt(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:se(t)}})),t)}};n([ms({type:String})],Pe.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Pe);import{html as hs}from"lit";var ot=class extends k{render(){return hs`<slot></slot>`}process(){let o=[...this.children];for(let e=0;e<o.length;e++){let t=o[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",ot);var nt=class extends k{process(){let o=this.getAttribute("identifier"),e=this.firstElementChild,r=new at(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:o,value:Array.isArray(r)?r.map(i=>se(i)):se(r)}}))}},at=class{constructor(o){this.expression=o}process(){let o=this.expression?this.expression.calculate():null;if(o==null){console.warn("setOutcomeValue: value is null or undefined");return}return o}};customElements.define("qti-set-outcome-value",nt);import{LitElement as fs,html as gs}from"lit";var ue=class extends fs{render(){return gs`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let o=this.getSubRules();for(let e=0;e<o.length;e++)o[e].process()}};customElements.define("qti-response-else",ue);import{html as bs}from"lit";var me=class extends ue{calculate(){return this.firstElementChild.calculate()}getSubRules(){let o=[];for(let e=1;e<this.children.length;e++)o.push(this.children[e]);return o}};customElements.define("qti-response-if",me);var lt=class extends me{render(){return bs`${super.render()}`}};customElements.define("qti-response-else-if",lt);import{consume as vs}from"@lit/context";import{css as ys,html as xs,LitElement as Es}from"lit";import{state as rr}from"lit/decorators.js";var f=class extends Es{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(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 this.context.variables.find(i=>i.identifier===t)||null}case"qti-multiple":{let r=e.getResult();return r.length>0?{identifier:"",baseType:r[0].baseType,value:r.map(i=>i.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.context.variables.find(i=>i.identifier===t)||null;return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return xs`<pre>${JSON.stringify(this.result,null,2)}</pre>
|
|
383
|
+
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};f.styles=ys`
|
|
384
|
+
slot {
|
|
385
|
+
display: none;
|
|
386
|
+
}
|
|
387
|
+
`,n([rr()],f.prototype,"result",2),n([vs({context:y,subscribe:!0}),rr()],f.prototype,"context",2);var T=class extends f{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Fe=class extends Cs(T){calculate(){return this.calculateChildren(Array.from(this.children))}};function Cs(c){return class extends c{calculateChildren(e){return e.map(r=>{let i=r;if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let l=i.calculate(),s=!1;if(typeof l=="string")if(l==="true")s=!0;else if(l==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof l=="boolean"&&(s=l);return s}).every(r=>typeof r=="boolean"&&r)}}}customElements.define("qti-and",Fe);import{property as qs}from"lit/decorators.js";var ze=class extends f{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};n([qs({type:String,attribute:"base-type"})],ze.prototype,"baseType",2);customElements.define("qti-base-value",ze);var ct=class extends T{getResult(){let o=this.getVariables();if(this.children.length===2){let e=o[0],t=o[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,i=t.value;return r.filter(a=>i.includes(a)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}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",ct);var pt=class extends f{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let o=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===o)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",pt);import{property as Ts}from"lit/decorators.js";var Ue=class extends f{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],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let i=parseFloat(t.value),l=parseFloat(r.value);if(!isNaN(i)&&!isNaN(l))return this.roundingMode==="significantFigures"?i.toPrecision(this.figures)===l.toPrecision(this.figures):Math.round(i*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(l*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${i}, ${l}`);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}};n([Ts({type:String})],Ue.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Ue);import{property as ws}from"lit/decorators.js";var w=class{static compareSingleValues(o,e,t){switch(t){case"identifier":case"string":return o===e;case"integer":{let r=parseInt(o,10),i=parseInt(e,10);if(!isNaN(r)&&!isNaN(i))return r===i;console.error(`Cannot convert ${o} and/or ${e} to int.`);break}case"float":{let r=parseFloat(o),i=parseFloat(e);if(!isNaN(r)&&!isNaN(i))return r===i;console.error(`couldn't convert ${o} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=o.split(" ").sort(),i=e.split(" ").sort();if(r.length===2&&i.length===2)return t==="pair"&&(r.sort(),i.sort()),r.join(" ")===i.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${o} 2: ${e}`);break}}return!1}};var Xe=class extends f{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):w.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};n([ws({type:String})],Xe.prototype,"toleranceMode",2);customElements.define("qti-equal",Xe);var dt=class extends f{getResult(){if(this.children.length===2){let o=this.getVariables(),e=o[0],t=o[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",dt);var ut=class extends T{getResult(){if(this.children.length===2){let o=this.getVariables(),e=o[0],t=o[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",ut);var mt=class extends f{getResult(){if(this.children.length===1){let o=this.getVariables();if(!o)return!0;let e=o[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",mt);var ht=class extends f{getResult(){if(this.children.length===2){let o=this.getVariables(),e=o[0],t=o[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",ht);var ft=class extends T{getResult(){if(this.children.length===2){let o=this.getVariables(),e=o[0],t=o[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",ft);import{property as Ms}from"lit/decorators.js";var Be=class extends f{getResult(){let o=this.context.variables.find(i=>i.identifier===this.identifier);if(!o)return console.warn(`Response ${this.identifier} can not be found`),null;let e=o.mapping,t=Array.isArray(o.value)?o.value:[o.value],r=0;for(let i of t){let l=e.mapEntries.find(s=>w.compareSingleValues(s.mapKey,i,o.baseType));l==null||l.mappedValue==null?r+=e.defaultValue:r+=l.mappedValue}return e.lowerBound!=null&&(r=Math.max(e.lowerBound,r)),e.upperBound!=null&&(r=Math.min(e.upperBound,r)),r}};n([Ms({type:String})],Be.prototype,"identifier",2);customElements.define("qti-map-response",Be);import{property as gt}from"lit/decorators.js";import{LitElement as Ss}from"lit";var K=class extends Ss{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};n([gt({attribute:"default-value",type:Number})],K.prototype,"defaultValue",2),n([gt({attribute:"lower-bound",type:Number})],K.prototype,"lowerBound",2),n([gt({attribute:"upper-bound",type:Number})],K.prototype,"upperBound",2);customElements.define("qti-mapping",K);var bt=class c extends f{getResult(){if(this.children.length===2){let o=this.getVariables(),e=o[0],t=o[1];return c.match(e,t)}return console.error("unexpected number of children in match"),null}static match(o,e){switch(e.cardinality){case"single":return o.value===null?!1:Array.isArray(o.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):w.compareSingleValues(o.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(o.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(o.value.length!==e.value.length)return!1;for(let t=0;t<o.value.length;t++)if(!w.compareSingleValues(e.value[t],o.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(o.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(o.value.length!==e.value.length)return!1;let t=0;for(let r of e.value){let i=null,l=[...o.value];for(let s of l)if(w.compareSingleValues(r,s,e.baseType)){i=s;break}if(i!==null)l.splice(l.indexOf(i),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",bt);var vt=class extends f{getResult(){let o=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=o;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 r=e.value;return t.value.includes(r)}};customElements.define("qti-member",vt);var yt=class extends f{getResult(){let o=this.getVariables();if(o.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of o)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return o}};customElements.define("qti-multiple",yt);import{html as Rs}from"lit";var xt=class extends f{render(){return Rs`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",xt);var Et=class extends T{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate(),i=!1;if(typeof r=="string")if(r==="true")i=!0;else if(r==="false")i=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof r=="boolean"&&(i=r);return i}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Et);var Ct=class extends f{getResult(){let o=this.getVariables();if(o.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of o)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return o}};customElements.define("qti-ordered",Ct);import{consume as As}from"@lit/context";import{LitElement as ks,html as Ls}from"lit";import{property as _s,state as Ds}from"lit/decorators.js";var he=class extends ks{render(){let o=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return Ls`${JSON.stringify(o,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};n([_s({type:String})],he.prototype,"identifier",2),n([As({context:y,subscribe:!0}),Ds()],he.prototype,"context",2);customElements.define("qti-printed-variable",he);var qt=class extends f{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",qt);var Ye=class extends Vs(f){getResult(){return this.calculateChildren(Array.from(this.children))}};function Vs(c){return class extends c{calculateChildren(e){let t=e.map(r=>{if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=r.calculate();return Number.isNaN(i)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(i)});return t.some(r=>r===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",Ye);import{property as Hs}from"lit/decorators.js";var We=class extends f{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti string-match"),!1;let i=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),l=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return w.compareSingleValues(i,l,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};n([Hs({type:String,attribute:"case-sensitive"})],We.prototype,"caseSensitive",2);customElements.define("qti-string-match",We);var Tt=class extends f{constructor(){super(),this._expression=new wt(Array.from(this.children))}getResult(){return this._expression.calculate()}},wt=class{constructor(o){this.expressions=o}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let t=e.calculate();return Number.isNaN(t)?(console.error("unexpected value in qti-sum, expected number"),null):Number(t)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Tt);var Mt=class extends f{getResult(){let o=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===o).value}};customElements.define("qti-variable",Mt);import{html as ir}from"lit";import{customElement as Ns,property as sr,state as $s}from"lit/decorators.js";var B=class extends h{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let r=await fetch(e);if(r.ok){let l=await r.json();for(let s in l.paths)t&&(l.paths[s]=this.getResolvablePath(l.paths[s],t));return l}}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(r=>this.getResolvablePathString(r,t)):this.getResolvablePathString(e,t)}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let r=e[t];if(r){for(let i in r)if(r.hasOwnProperty(i)){let l=r[i];if(Array.isArray(l))return l.map(String);if(l!=null)return String(l)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),t=this.pci.getResponse(),r=JSON.stringify(e);if(r!==this.rawResponse){this.rawResponse=r;let i=this.convertQtiVariableJSON(t);this.value=i,this.saveResponse(i)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},i=s=>{let a={},p=s.getAttribute("key");if(p){let d=Array.from(s.children),u=d.map(g=>g.getAttribute("key"));u.length>0&&!u.find(g=>!Number.isInteger(+g))?a[p]=d.map(g=>l(g)):a[p]=s.textContent}return a},l=s=>{if(s){let a={};for(let p of s.children)a={...a,...i(p)};return a}};for(let s of t)return s.getAttribute("key")||(r={...r,...l(s)}),r;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let i=t=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,i,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,i),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(s=>s.getAttribute("href")).forEach(s=>{let a=document.createElement("link");a.rel="stylesheet",a.type="text/css",a.media="screen",a.href=s,r.appendChild(a)}),this.startChecking()}connectedCallback(){super.connectedCallback(),define("qtiCustomInteractionContext",()=>({register:r=>{this.register(r)},notifyReady:()=>{}}));let e=this.buildRequireConfig();requirejs.config(e)(["require"],r=>{r([this.module])})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim: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"),r=this.querySelector("qti-interaction-modules");if(r){let i=r.querySelectorAll("qti-interaction-module");for(let l of i){let s=l.getAttribute("id"),a=l.getAttribute("primary-path"),p=l.getAttribute("fallback-path");if(s&&a){let d=p?this.combineRequireResolvePaths(this.getResolvablePath(a,t),this.getResolvablePath(p,t)):this.getResolvablePath(a,t),u=e.paths[s]||[];e.paths[s]=this.combineRequireResolvePaths(u,d)}}}return e}combineRequireResolvePaths(e,t){let r=Array.isArray(e)?e:[e],i=Array.isArray(t)?t:[t];return r.concat(i)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return ir`<slot></slot>${this._errorMessage&&ir`<div style="color:red">
|
|
388
|
+
<h1>Error</h1>
|
|
389
|
+
${this._errorMessage}
|
|
390
|
+
</div>`}`}};n([sr({type:String,attribute:"module"})],B.prototype,"module",2),n([sr({type:String,attribute:"custom-interaction-type-identifier"})],B.prototype,"customInteractionTypeIdentifier",2),n([$s()],B.prototype,"_errorMessage",2),B=n([Ns("qti-portable-custom-interaction")],B);import{html as ar}from"lit";import{customElement as Os,state as Ps}from"lit/decorators.js";var or=(c,o,e)=>{class t extends c{}return t};import{property as St}from"lit/decorators.js";function je(c,o){let e;return(t,r)=>{let{connectedCallback:i,disconnectedCallback:l}=t;t.connectedCallback=function(){i.call(this);let s=p=>{let d=Array.from(this.querySelectorAll(c)).concat(Array.from(this.shadowRoot?.querySelectorAll(c)||[]));for(let u of p){let m=Array.from(u.addedNodes).map(v=>v),g=Array.from(u.addedNodes).map(v=>v);u.type==="childList"&&m.find(v=>d.includes(v))&&this[r](m,g)}};e=new MutationObserver(s),e.observe(this,{childList:!0,subtree:!0});let a=Array.from(this.querySelectorAll(c)).concat(Array.from(this.shadowRoot?.querySelectorAll(c)||[]));this[r](Array.from(a),[])},t.disconnectedCallback=function(){l.call(this),e.disconnect()}}}var L=(c,o,e,t)=>{class r extends or(c,e,o){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.rootNode=null;this.allDropzones=[];this.lastTarget=null;this.dropzoneOriginalParent=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(s,a){this.data[s]=a},getData(s){return this.data[s]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(s,a)=>{for(let d of a)this.draggables.includes(d)&&(this.draggables=this.draggables.filter(u=>u!==d),d.removeAttribute("tabindex"),d.removeEventListener("touchstart",this.handleTouchStart.bind(this)),d.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let d of s)this.draggables.includes(d)||(this.draggables.push(d),d.setAttribute("tabindex","0"),d.hasTouchStartListener||(d.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),d.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),d.hasTouchStartListener=!0));let p=0;this.draggables.forEach(d=>{d.style.viewTransitionName=`drag-${p}-${this.getAttribute("identifier")||crypto.randomUUID()}`,d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",this.handleDragStart),d.addEventListener("dragend",this.handleDragEnd),p++})};this.droppablesModified=(s,a)=>{for(let p of a)this.droppables.includes(p)&&(this.droppables=this.droppables.filter(d=>d!==p),this.allDropzones=this.allDropzones.filter(d=>d!==p));for(let p of s)this.droppables.includes(p)||(this.droppables.push(p),this.allDropzones.push(p));for(let p of this.droppables)this.dataset.choicesContainerWidth&&(p.style.width=`${this.dataset.choicesContainerWidth}px`,p.style.boxSizing="border-box")};this.handleDragStart=s=>{let a=s.currentTarget;s.dataTransfer.setData("text",a.getAttribute("identifier")),this.responseIdentifier&&s.dataTransfer.setData("responseIdentifier",this.responseIdentifier),this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),a.setAttribute("dragging",""),this.activateDragLocation(),this.activateDroppables(a)};this.handleDragEnd=async s=>{s.preventDefault();let a=s.currentTarget;this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),a.removeAttribute("dragging")}}handleDraggableContainerChange(s,a){this.isMatchTabular()||(s.length>0||a.length>0)&&this.dragContainersModified(s||[],a||[])}dragContainersModified(s,a){for(let p of a)this.dragContainers.includes(p)&&(this.dragContainers=this.dragContainers.filter(d=>d!==p),this.allDropzones=this.allDropzones.filter(d=>d!==p));for(let p of s)this.dragContainers.includes(p)||(this.dragContainers.push(p),this.allDropzones.push(p))}handleDraggablesChange(s,a){this.isMatchTabular()||(s.length>0||a.length>0)&&this.draggablesModified(s||[],a||[])}handleDroppablesChange(s,a){this.isMatchTabular()||(s.length>0||a.length>0)&&this.droppablesModified(s||[],a||[])}firstUpdated(s){super.firstUpdated(s),this.hasAttribute("disabled")||(document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}));let p=Array.from(this.querySelectorAll(o)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(o)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),u=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(u,[]),this.droppablesModified(d,[]),this.draggablesModified(p,[]),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(g=>this.resizeObserver?.observe(g))}async moveDraggableToDroppable(s,a){(()=>{s.style.transform="translate(0, 0)",a.tagName==="SLOT"?s.setAttribute("slot",a.getAttribute("name")):a.appendChild(s),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(s){this.dragContainers.includes(s)?(this._internals.states.add("--dragzone-active"),s.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),s.setAttribute("active",""))}deactivateDroppable(s,a=!0){a&&this._internals.states.add("--dragzone-active"),s.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let s=this.querySelectorAll(o),a=Array.from(this.querySelectorAll(e)).map(m=>m),p=0,d=0;s.forEach(m=>{let g=m.getBoundingClientRect();p=Math.max(p,g.height),d=Math.max(d,g.width)});let u=this.querySelector(t)||this.shadowRoot?.querySelector(t);u&&(u.style.minHeight=`${p}px`,u.style.minWidth=`${d}px`);for(let m of a)m.style.minHeight=`${p}px`,m.style.minWidth=`${d}px`}activateDroppables(s){this.dragContainers.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(s)||p.shadowRoot&&p.shadowRoot.contains(s))&&p.removeAttribute("disabled")}),this.droppables.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(s)||p.shadowRoot&&p.shadowRoot.contains(s))&&p.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(a=>{a.removeAttribute("enabled")}),this.droppables.forEach(a=>a.removeAttribute("enabled"))}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("touchmove",this.handleTouchMove),document.removeEventListener("mousemove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("mouseup",this.handleTouchEnd),document.removeEventListener("touchcancel",this.handleTouchCancel)}handleTouchMove(s){if(this.isDraggable&&this.dragClone){let{x:a,y:p}=this.getEventCoordinates(s),d={clientX:a,clientY:p};this.calculateDragDistance(d)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(d));let u=this.findClosestDropzone();this.currentDropTarget=u,u!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),u&&(this.activateDroppable(u),this.dispatchCustomEvent(u,"dragenter")),this.lastTarget=u),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),s.preventDefault()}}handleTouchEnd(s){if(this.isDragging){if(this.currentDropTarget){let a=this.dragClone;this.moveDraggableToDroppable(a,this.currentDropTarget)}this.resetDragState()}this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),s.preventDefault()}handleTouchCancel(s){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let s=this.getValidAssociations(),a=!0,p="";this.maxAssociations>0&&s>this.maxAssociations?(a=!1,p=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&s<this.minAssociations&&(a=!1,p=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let d=this.lastElementChild;return this._internals.setValidity(a?{}:{customError:!0},p,d),this.reportValidity(),a}reportValidity(){let s=this.shadowRoot.querySelector("#validationMessage");return s&&(this._internals.validity.valid?(s.textContent="",s.style.display="none"):(s.textContent=this._internals.validationMessage,s.style.display="block")),this._internals.validity.valid}checkMaxAssociations(s){let a=this.getMatchMaxValue(s),p=s.querySelectorAll('[qti-draggable="true"]').length;return a===0||p>=a}resetDragState(){if(this.dragClone)if(!(this.currentDropTarget!==null)||this.dragContainers.includes(this.currentDropTarget))this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.pointerEvents="auto",this.dragClone.remove();else{let p=window.getComputedStyle(this.dragSource);for(let d=0;d<p.length;d++){let u=p[d];this.dragClone.style.setProperty(u,p.getPropertyValue(u))}this.dragClone.style.opacity="1.0",this.dragClone.style.display="block",this.dragClone.style.pointerEvents="auto"}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null}checkAllMaxAssociations(){this.droppables.forEach(s=>{this.checkMaxAssociations(s)?this.disableDroppable(s):this.enableDroppable(s)})}getMatchMaxValue(s){let a=s.getAttribute("match-max");return a?parseInt(a,10):1}disableDroppable(s){s.setAttribute("disabled","")}enableDroppable(s){s.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(s){if(!this.isMatchTabular())if(Array.isArray(s)){s?.forEach(p=>this.placeResponse(p));let a=new FormData;s.forEach(p=>{a.append(this.responseIdentifier,p)}),this._internals.setFormValue(a)}else this._internals.setFormValue(s)}placeResponse(s){let[a,...p]=s.split(" ").reverse(),d=this.findDroppableById(a);p.forEach(u=>this.placeDraggableInDroppable(u,d))}findDroppableById(s){return this.droppables.find(a=>a.getAttribute("identifier")===s)}async placeDraggableInDroppable(s,a){let p=this.querySelector(`[identifier=${s}]`);if(!a||!p){console.error(`Cannot find draggable or droppable with the given identifier: ${s}`);return}let d=()=>{p.style.transform="translate(0, 0)",console.log("droppable",a),a.appendChild(p),this.checkAllMaxAssociations()};document.startViewTransition?await document.startViewTransition(d).finished:d()}getValidAssociations(){return this.droppables.filter(s=>s.childElementCount>0).length}saveResponse(){this.validate();let s=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:s}}))}collectResponseData(){return this.droppables.map(a=>{let p=a.querySelectorAll('[qti-draggable="true"]'),d=Array.from(p).map(m=>m.getAttribute("identifier")),u=a.getAttribute("identifier");return d.map(m=>`${m} ${u}`)}).flat()}reset(s=!0){s&&this.saveResponse()}updateDragClonePosition(s){if(!this.isDragging||!this.dragClone)return;let a=s.clientX-this.cloneOffset.x,p=s.clientY-this.cloneOffset.y,{newLeft:d,newTop:u}=this.applyBoundaries(a,p,this.dragClone);this.dragClone.style.left=`${d}px`,this.dragClone.style.top=`${u}px`}getEventCoordinates(s,a=!1){let p=s.touches?s.touches[0]:s;return{x:a?p.pageX:p.clientX,y:a?p.pageY:p.clientY}}calculateDragDistance(s){let a=Math.abs(s.clientX-this.touchStartPoint.x),p=Math.abs(s.clientY-this.touchStartPoint.y);return a+p}applyBoundaries(s,a,p){let d=new DOMRect(0,0,window.innerWidth,window.innerHeight);this.rootNode instanceof ShadowRoot?d=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document&&(d=document.documentElement.getBoundingClientRect());let u=p.getBoundingClientRect(),m=u.width,g=u.height,v=Math.max(d.left,Math.min(s,d.right-m)),b=Math.max(d.top,Math.min(a,d.bottom-g));return{newLeft:v,newTop:b}}findClosestDropzone(){let s=this.allDropzones.filter(u=>!u.hasAttribute("disabled"));if(!this.dragClone||s.length===0)return null;let a=this.dragClone.getBoundingClientRect(),p=null,d=0;for(let u of s){let m=u.getBoundingClientRect(),g=this.calculateOverlapArea(a,m);g>d&&(d=g,p=u)}if(!p){let u=200;for(let m of s){let g=m.getBoundingClientRect(),v=Math.sqrt(Math.pow(a.left-g.left,2)+Math.pow(a.top-g.top,2));v<u&&(u=v,p=m)}}return p}calculateOverlapArea(s,a){let p=Math.max(0,Math.min(s.right,a.right)-Math.max(s.left,a.left)),d=Math.max(0,Math.min(s.bottom,a.bottom)-Math.max(s.top,a.top));return p*d}dispatchCustomEvent(s,a,p=!0){if(!s)return;let d=new CustomEvent(a,{bubbles:p,cancelable:!0});d.dataTransfer=this.dataTransfer,s.dispatchEvent(d)}handleTouchStart(s){let{x:a,y:p}=this.getEventCoordinates(s);this.dropzoneOriginalParent=s.currentTarget.parentElement,this.touchStartPoint={x:a,y:p},this.dragSource=s.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode();let d=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),u=this.dragSource.parentElement;if(this.droppables.includes(u)){this.enableDroppable(u),this.dragClone=this.dragSource,this.dragSource=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier"));let m=this.findParentInteractionElement(this.dragSource),g=this.dragClone.getBoundingClientRect();m?m.appendChild(this.dragClone):this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone),g&&this.setDragCloneStyles(g)}else{let m=d.getBoundingClientRect();this.cloneOffset.x=a-m.left,this.cloneOffset.y=p-m.top,this.dragClone=d.cloneNode(!0),m&&this.setDragCloneStyles(m);let g=this.findParentInteractionElement(this.dragSource);g?g.appendChild(this.dragClone):this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone);let v=this.getMatchMaxValue(this.dragSource),b=this.draggables.filter(Ze=>Ze.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));v!==0&&b.length>=v?(d.style.opacity="0.0",d.style.pointerEvents="none"):d.style.opacity="1.0",s.preventDefault()}}findParentInteractionElement(s){let a=s.parentElement;for(;a&&!a.tagName?.toLowerCase().endsWith("-interaction");)a=a.parentElement;return a}findDraggableInDraggableContainer(s){let a=this.dragContainers.flat();for(let p of a){if(p.getAttribute("identifier")===s)return p;let u=Array.from(p.assignedElements()||[]).find(m=>m.getAttribute("identifier")===s);if(u)return u}}setDragCloneStyles(s){this.dragClone.style.position="fixed",this.dragClone.style.top=`${s.top}px`,this.dragClone.style.left=`${s.left}px`,this.dragClone.style.width=`${s.width}px`,this.dragClone.style.height=`${s.height}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 n([St({attribute:!1,type:Object})],r.prototype,"configuration",2),n([St({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),n([St({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),n([je(t)],r.prototype,"handleDraggableContainerChange",1),n([je(o)],r.prototype,"handleDraggablesChange",1),n([je(e)],r.prototype,"handleDroppablesChange",1),r};import{css as Is}from"lit";var nr=Is`
|
|
391
|
+
:host {
|
|
392
|
+
display: block; /* necessary to calculate scaling position */
|
|
393
|
+
}
|
|
394
|
+
slot[name='qti-simple-associable-choice'] {
|
|
395
|
+
display: flex;
|
|
396
|
+
align-items: flex-start;
|
|
397
|
+
flex: 1;
|
|
398
|
+
border: 2px solid transparent;
|
|
399
|
+
padding: 0.3rem;
|
|
400
|
+
border-radius: 0.3rem;
|
|
401
|
+
gap: 0.5rem;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
:host::part(associables-container) {
|
|
405
|
+
display: flex;
|
|
406
|
+
padding: 0.5rem;
|
|
407
|
+
justify-content: space-between;
|
|
408
|
+
background: linear-gradient(
|
|
409
|
+
180deg,
|
|
410
|
+
rgb(0 0 0 / 0%) calc(50% - 1px),
|
|
411
|
+
var(--qti-border-color-gray) calc(50%),
|
|
412
|
+
rgb(0 0 0 / 0%) calc(50% + 1px)
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
`;var J=class extends L(h,"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 ar` <slot name="prompt"></slot>
|
|
416
|
+
<slot name="qti-simple-associable-choice"></slot>
|
|
417
|
+
<div part="drop-container">
|
|
418
|
+
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>ar`<div part="associables-container">
|
|
419
|
+
<div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
|
|
420
|
+
<div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
|
|
421
|
+
</div>`)}
|
|
422
|
+
|
|
423
|
+
<div role="alert" id="validationMessage"></div>
|
|
424
|
+
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};J.styles=nr,n([Ps()],J.prototype,"_childrenMap",2),J=n([Os("qti-associate-interaction")],J);import{html as lr}from"lit";import{customElement as Fs,property as Ke,state as zs}from"lit/decorators.js";var V=class extends h{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:oe(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let e=this.shadowRoot.querySelector("#pciContainer"),t=e.contentDocument;window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
|
|
425
|
+
<html>
|
|
426
|
+
<head>
|
|
427
|
+
<link href='${oe(`${this.baseRefUrl}/${this.manifest.style[0]}`)}' rel="stylesheet" />
|
|
428
|
+
<script src='${oe(`${this.baseRefUrl}/${this.manifest.script[0]}`)}'></script>
|
|
429
|
+
</head>
|
|
430
|
+
<body></body>
|
|
431
|
+
</html>
|
|
432
|
+
`),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),r=[...e,...t];for(let i of r){let l=i.src;if(new URL(l,window.location.href).origin===window.location.origin)try{let a=i.contentDocument||i.contentWindow.document;a&&this.getInnerIFrames(a,r)}catch(a){console.error("Error accessing nested iframe:",a)}}return r.forEach((i,l)=>{r.indexOf(i)!==l&&r.splice(l,1)}),r}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(i=>{t.push(i);let l=i.src;if(new URL(l,window.location.href).origin===window.location.origin)try{let a=i.contentDocument||i.contentWindow.document;this.getInnerIFrames(a,t)}catch(a){console.error("Error accessing nested iframe:",a)}else console.warn("Skipped cross-origin iframe:",l)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let r=this.getIFrames();for(let i of r)i.contentWindow&&i.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:r}=e.data;switch(t){case"setResponse":this.rawResponse=r,this.saveResponse(r);break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let i=this.manifest.media.map(l=>l.startsWith("http")?l:oe(this.baseRefUrl+"/"+l));this.postToWindowAndIframes("mediaData",i);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){return this.rawResponse!==""}get value(){return this.rawResponse}set value(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else throw new Error("Value must be a string")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return lr`<iframe
|
|
433
|
+
width=${this.getAttribute("width")}
|
|
434
|
+
height=${this.getAttribute("height")}
|
|
435
|
+
frameborder="0"
|
|
436
|
+
title="pciContainer"
|
|
437
|
+
id="pciContainer"
|
|
438
|
+
>
|
|
439
|
+
</iframe>
|
|
440
|
+
${this._errorMessage&&lr`<div style="color:red">
|
|
441
|
+
<h1>Error</h1>
|
|
442
|
+
${this._errorMessage}
|
|
443
|
+
</div>`}`}};n([Ke({type:String,attribute:"data"})],V.prototype,"data",2),n([Ke({type:String,attribute:"data-base-item"})],V.prototype,"baseItemUrl",2),n([Ke({type:String,attribute:"data-base-ref"})],V.prototype,"baseRefUrl",2),n([Ke({type:String,attribute:"id"})],V.prototype,"id",2),n([zs()],V.prototype,"_errorMessage",2),V=n([Fs("qti-custom-interaction")],V);import{html as Us,LitElement as Xs}from"lit";import{customElement as Bs,property as Je}from"lit/decorators.js";var F=class extends Xs{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return Us`<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"}}))}};n([Je({type:String,attribute:"response-identifier"})],F.prototype,"responseIdentifier",2),n([Je({reflect:!0,type:Boolean})],F.prototype,"disabled",2),n([Je({type:String,attribute:"count-attempt"})],F.prototype,"countAttempt",2),n([Je({type:String})],F.prototype,"title",2),F=n([Bs("qti-end-attempt-interaction")],F);import{html as Ws}from"lit";import{customElement as js}from"lit/decorators.js";import{css as Ys}from"lit";var cr=Ys`
|
|
444
|
+
:host {
|
|
445
|
+
display: flex;
|
|
446
|
+
align-items: flex-start;
|
|
447
|
+
flex-direction: column;
|
|
448
|
+
flex-wrap: wrap;
|
|
449
|
+
gap: 0.5rem;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
:host(.qti-choices-top) {
|
|
453
|
+
flex-direction: column;
|
|
454
|
+
}
|
|
455
|
+
:host(.qti-choices-bottom) {
|
|
456
|
+
flex-direction: column-reverse;
|
|
457
|
+
}
|
|
458
|
+
:host(.qti-choices-left) {
|
|
459
|
+
flex-direction: row;
|
|
460
|
+
}
|
|
461
|
+
:host(.qti-choices-right) {
|
|
462
|
+
flex-direction: row-reverse;
|
|
463
|
+
}
|
|
464
|
+
/* [part='drops'] , */
|
|
465
|
+
[name='prompt'] {
|
|
466
|
+
width: 100%;
|
|
467
|
+
}
|
|
468
|
+
[name='drags'] {
|
|
469
|
+
display: flex;
|
|
470
|
+
align-items: flex-start;
|
|
471
|
+
flex: 1;
|
|
472
|
+
border: 2px solid transparent;
|
|
473
|
+
padding: 0.3rem;
|
|
474
|
+
border-radius: 0.3rem;
|
|
475
|
+
gap: 0.5rem;
|
|
476
|
+
}
|
|
477
|
+
`;var fe=class extends L(h,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return Ws`<slot name="prompt"> </slot>
|
|
478
|
+
<slot part="drags" name="drags"></slot>
|
|
479
|
+
<slot part="drops"></slot>
|
|
480
|
+
<div role="alert" id="validationMessage"></div>`}set correctResponse(o){let e=[],t=Array.isArray(o)?o:[o];t&&(e=t.map(i=>{let l=i.split(" ");return{text:l[0],gap:l[1]}})),this.querySelectorAll("qti-gap").forEach(i=>{let l=i.getAttribute("identifier"),s=e.find(p=>p.gap===l)?.text,a=this.querySelector(`qti-gap-text[identifier="${s}"]`)?.textContent.trim();if(s&&a){if(!i.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=a,i.insertAdjacentElement("afterend",p)}}else i.nextElementSibling?.classList.contains("correct-option")&&i.nextElementSibling.remove()})}};fe.styles=cr,fe=n([js("qti-gap-match-interaction")],fe);import{html as Js,svg as dr}from"lit";import{customElement as Gs,queryAssignedElements as Zs,state as Rt}from"lit/decorators.js";import{ifDefined as ur}from"lit/directives/if-defined.js";import{repeat as Qs}from"lit/directives/repeat.js";function G(c,o,e,t){switch(c){case"circle":{let[r,i,l]=o,s=r/e.width*100,a=i/e.height*100,p=l/e.width*100;t.style.left=s-p+"%",t.style.top=a-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,i,l,s]=o,a=r/e.width*100,p=i/e.height*100,d=l/e.width*100,u=s/e.height*100;t.style.left=a+"%",t.style.top=p+"%",t.style.width=d-a+"%",t.style.height=u-p+"%"}break;case"poly":{let r=o.reduce((b,Ze,_t,Mr)=>{if(_t%2===1){let Sr=b.pop();b[b.length]={x:Sr,y:Mr[_t]}}else b.push(Ze);return b},[]),i=Math.min(...r.map(b=>b.x)),l=Math.max(...r.map(b=>b.x)),s=Math.min(...r.map(b=>b.y)),a=Math.max(...r.map(b=>b.y)),p=i/e.width*100,d=s/e.height*100,u=l/e.width*100,m=a/e.height*100;t.style.left=i/e.width*100+"%",t.style.top=s/e.height*100+"%",t.style.width=u-p+"%",t.style.height=m-d+"%";let v=r.map(b=>({x:(b.x-i)/(l-i)*100,y:(b.y-s)/(a-s)*100})).map(b=>Math.round(b.x)+"% "+Math.round(b.y)+"%").join(",");t.style.clipPath=`polygon(${v})`}break;default:break}}import{css as Ks}from"lit";var pr=Ks`
|
|
481
|
+
slot:not([name='prompt']) {
|
|
482
|
+
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
483
|
+
display: block;
|
|
484
|
+
width: fit-content; /* hotspots not stretching further if image is at max size */
|
|
485
|
+
}
|
|
486
|
+
::slotted(img) {
|
|
487
|
+
/* image not selectable anymore */
|
|
488
|
+
pointer-events: none;
|
|
489
|
+
user-select: none;
|
|
490
|
+
}
|
|
491
|
+
::slotted(qti-associable-hotspot) {
|
|
492
|
+
transform: translate(-50%, -50%);
|
|
493
|
+
}
|
|
494
|
+
line-container {
|
|
495
|
+
display: block;
|
|
496
|
+
position: relative;
|
|
497
|
+
}
|
|
498
|
+
svg {
|
|
499
|
+
position: absolute;
|
|
500
|
+
top: 0px;
|
|
501
|
+
left: 0px;
|
|
502
|
+
}
|
|
503
|
+
`;var H=class extends h{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set value(e){Array.isArray(e)&&(this._lines=e)}get value(){return this._lines}render(){return Js`<slot name="prompt"></slot>
|
|
504
|
+
<line-container>
|
|
505
|
+
<svg
|
|
506
|
+
width=${ur(this.grImage[0]?.width)}
|
|
507
|
+
height=${ur(this.grImage[0]?.height)}
|
|
508
|
+
viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
|
|
509
|
+
>
|
|
510
|
+
${Qs(this._lines,e=>e,(e,t)=>dr`
|
|
511
|
+
<line
|
|
512
|
+
part="line"
|
|
513
|
+
x1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.left)}
|
|
514
|
+
y1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.top)}
|
|
515
|
+
x2=${parseInt(this.querySelector("[identifier="+e.split(" ")[1]+"]").style.left)}
|
|
516
|
+
y2=${parseInt(this.querySelector("[identifier="+e.split(" ")[1]+"]").style.top)}
|
|
517
|
+
stroke="red"
|
|
518
|
+
stroke-width="3"
|
|
519
|
+
@click=${r=>{r.stopPropagation(),this._lines=this._lines.filter((i,l)=>l!==t),this.saveResponse(this._lines)}}
|
|
520
|
+
/>
|
|
521
|
+
`)}
|
|
522
|
+
${this.startPoint&&dr`<line
|
|
523
|
+
part="point"
|
|
524
|
+
x1=${this.startCoord.x}
|
|
525
|
+
y1=${this.startCoord.y}
|
|
526
|
+
x2=${this.mouseCoord.x}
|
|
527
|
+
y2=${this.mouseCoord.y}
|
|
528
|
+
stroke="red"
|
|
529
|
+
stroke-width="3"
|
|
530
|
+
/>`}
|
|
531
|
+
</svg>
|
|
532
|
+
<slot></slot>
|
|
533
|
+
</line-container>
|
|
534
|
+
<div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,i=r.getAttribute("coords"),l=r.getAttribute("shape"),s=i.split(",").map(a=>parseInt(a));G(l,s,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=this.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",t=>{this.mouseCoord={x:t.clientX-this.grImage[0].getBoundingClientRect().left,y:t.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",r=>{this.startPoint?this.endPoint||(this.endPoint=r.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=r.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};H.styles=pr,n([Rt()],H.prototype,"_lines",2),n([Rt()],H.prototype,"startCoord",2),n([Rt()],H.prototype,"mouseCoord",2),n([Zs({selector:"img"})],H.prototype,"grImage",2),H=n([Gs("qti-graphic-associate-interaction")],H);import{html as to}from"lit";import{customElement as ro}from"lit/decorators.js";import{css as eo}from"lit";var mr=eo`
|
|
535
|
+
:host {
|
|
536
|
+
display: flex;
|
|
537
|
+
align-items: flex-start;
|
|
538
|
+
flex-direction: column;
|
|
539
|
+
flex-wrap: wrap;
|
|
540
|
+
gap: 0.5rem;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
:host(.qti-choices-top) {
|
|
544
|
+
flex-direction: column-reverse;
|
|
545
|
+
}
|
|
546
|
+
:host(.qti-choices-bottom) {
|
|
547
|
+
flex-direction: column;
|
|
548
|
+
}
|
|
549
|
+
:host(.qti-choices-left) {
|
|
550
|
+
flex-direction: row-reverse;
|
|
551
|
+
& [name='drags'] {
|
|
552
|
+
width: 25%;
|
|
553
|
+
}
|
|
554
|
+
& [part='image'] {
|
|
555
|
+
width: 75%;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
:host(.qti-choices-right) {
|
|
559
|
+
flex-direction: row;
|
|
560
|
+
& [name='drags'] {
|
|
561
|
+
width: 25%;
|
|
562
|
+
}
|
|
563
|
+
& [part='image'] {
|
|
564
|
+
width: 75%;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
[part='image'] {
|
|
568
|
+
display: block;
|
|
569
|
+
position: relative;
|
|
570
|
+
}
|
|
571
|
+
/* [part='drops'] , */
|
|
572
|
+
|
|
573
|
+
[name='drags'] {
|
|
574
|
+
display: flex;
|
|
575
|
+
align-items: flex-start;
|
|
576
|
+
flex-wrap: wrap;
|
|
577
|
+
flex: 1;
|
|
578
|
+
border: 2px solid transparent;
|
|
579
|
+
padding: 0.3rem;
|
|
580
|
+
border-radius: 0.3rem;
|
|
581
|
+
gap: 0.5rem;
|
|
582
|
+
}
|
|
583
|
+
::slotted(img) {
|
|
584
|
+
display: inline-block;
|
|
585
|
+
user-select: none;
|
|
586
|
+
pointer-events: none;
|
|
587
|
+
}
|
|
588
|
+
`;var ge=class extends L(h,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return to` <slot name="prompt"></slot>
|
|
589
|
+
<slot part="image"></slot>
|
|
590
|
+
<slot part="drags" name="drags" class="hover-border"></slot>
|
|
591
|
+
<div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(o){let e=o.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),i=t.split(",").map(l=>parseInt(l));switch(r){case"circle":{let[l,s,a]=i;e.style.left=l-a+"px",e.style.top=s-a+"px",e.style.width=e.style.height=2*a+"px"}break;case"rect":{let[l,s,a,p]=i;e.style.left=l+"px",e.style.top=s+"px",e.style.width=a-l+"px",e.style.height=p-s+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ge.styles=mr,ge=n([ro("qti-graphic-gap-match-interaction")],ge);import{html as so}from"lit";import{customElement as oo}from"lit/decorators.js";import{css as io}from"lit";var hr=io`
|
|
592
|
+
slot:not([name='prompt']) {
|
|
593
|
+
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
594
|
+
display: block;
|
|
595
|
+
width: fit-content; /* hotspots not stretching further if image is at max size */
|
|
596
|
+
}
|
|
597
|
+
::slotted(img) {
|
|
598
|
+
/* image not selectable anymore */
|
|
599
|
+
pointer-events: none;
|
|
600
|
+
user-select: none;
|
|
601
|
+
}
|
|
602
|
+
`;var be=class extends O(h,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return so`
|
|
603
|
+
<slot name="prompt"></slot>
|
|
604
|
+
<slot></slot>
|
|
605
|
+
<div role="alert" id="validationMessage"></div>
|
|
606
|
+
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(l=>l.getAttribute("identifier")===t),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(l=>l.order>0).length>=i){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(l=>!!l.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(l=>(l.order>l.order&&l.order--,l)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,i=r.getAttribute("coords"),l=r.getAttribute("shape"),s=i.split(",").map(a=>parseInt(a));G(l,s,t,r)}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)}};be.styles=hr,be=n([oo("qti-graphic-order-interaction")],be);import{html as ao}from"lit";import{customElement as lo}from"lit/decorators.js";import{css as no}from"lit";var fr=no`
|
|
607
|
+
slot:not([name='prompt']) {
|
|
608
|
+
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
609
|
+
display: block;
|
|
610
|
+
width: fit-content; /* hotspots not stretching further if image is at max size */
|
|
611
|
+
}
|
|
612
|
+
::slotted(img) {
|
|
613
|
+
/* image not selectable anymore */
|
|
614
|
+
pointer-events: none;
|
|
615
|
+
user-select: none;
|
|
616
|
+
/* width:100%; */
|
|
617
|
+
}
|
|
618
|
+
`;var ve=class extends O(h,"qti-hotspot-choice"){render(){return ao`
|
|
619
|
+
<slot name="prompt"></slot>
|
|
620
|
+
<slot></slot>
|
|
621
|
+
`}positionHotspotOnRegister(o){let e=this.querySelector("img"),t=o.target,r=t.getAttribute("coords"),i=t.getAttribute("shape"),l=r.split(",").map(s=>parseInt(s));G(i,l,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};ve.styles=fr,ve=n([lo("qti-hotspot-interaction")],ve);import{html as ye,nothing as fo}from"lit";import{customElement as go,property as br,state as vr}from"lit/decorators.js";import{unsafeHTML as yr}from"lit/directives/unsafe-html.js";import{css as co,html as po,LitElement as uo}from"lit";import{customElement as mo,property as At}from"lit/decorators.js";var z=class extends M(uo,"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 po`
|
|
622
|
+
<slot part="slot"></slot>
|
|
623
|
+
<slot part="dropslot" name="qti-simple-associable-choice"></slot>
|
|
624
|
+
`}};z.styles=co`
|
|
625
|
+
:host {
|
|
626
|
+
display: flex;
|
|
627
|
+
user-select: none;
|
|
628
|
+
}
|
|
629
|
+
slot {
|
|
630
|
+
width: 100%;
|
|
631
|
+
display: block;
|
|
632
|
+
}
|
|
633
|
+
slot[name='qti-simple-associable-choice'] {
|
|
634
|
+
width: 100%;
|
|
635
|
+
}
|
|
636
|
+
`,n([At({type:Number,attribute:"match-min"})],z.prototype,"matchMin",2),n([At({type:Number,attribute:"match-max"})],z.prototype,"matchMax",2),n([At({type:Boolean,attribute:"fixed"})],z.prototype,"fixed",2),z=n([mo("qti-simple-associable-choice")],z);import{css as ho}from"lit";var gr=ho`
|
|
637
|
+
slot:not([hidden]) {
|
|
638
|
+
/* slot where the */
|
|
639
|
+
display: flex;
|
|
640
|
+
flex-direction: column;
|
|
641
|
+
gap: 0.5rem;
|
|
642
|
+
align-items: flex-start; /* prevents the drag and drop container slots having the same height */
|
|
643
|
+
}
|
|
644
|
+
:host(.qti-choices-top) slot {
|
|
645
|
+
flex-direction: column;
|
|
646
|
+
}
|
|
647
|
+
:host(.qti-choices-bottom) slot {
|
|
648
|
+
flex-direction: column-reverse;
|
|
649
|
+
}
|
|
650
|
+
:host(.qti-choices-left) slot {
|
|
651
|
+
flex-direction: row;
|
|
652
|
+
}
|
|
653
|
+
:host(.qti-choices-right) slot {
|
|
654
|
+
flex-direction: row-reverse;
|
|
655
|
+
}
|
|
656
|
+
slot[name='prompt'] {
|
|
657
|
+
display: block;
|
|
658
|
+
}
|
|
659
|
+
::slotted(qti-simple-match-set) {
|
|
660
|
+
/* Make sure the drag and drop container slots have the same width */
|
|
661
|
+
flex: 1;
|
|
662
|
+
}
|
|
663
|
+
`;var N=class extends L(h,"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=[];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,r=t.value,i=t.name,l=t.type;t.checked?(this.value?this.value.indexOf(r)===-1&&(l==="radio"&&(this.value=this.value.filter(s=>s.indexOf(i)===-1)),this.value=[...this.value,r]):this.value=[r],this.lastCheckedRadio=t):(this.value=this.value.filter(s=>s!==r),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e)}render(){let e=this.class.split(" ").includes("qti-match-tabular");return ye`
|
|
664
|
+
<slot name="prompt"></slot>
|
|
665
|
+
<slot ?hidden=${e}></slot>
|
|
666
|
+
|
|
667
|
+
${e?ye`
|
|
668
|
+
<table>
|
|
669
|
+
<tr>
|
|
670
|
+
<td></td>
|
|
671
|
+
${this.cols.map(t=>ye`<th part="r-header">${yr(t.innerHTML)}</th>`)}
|
|
672
|
+
</tr>
|
|
673
|
+
|
|
674
|
+
${this.rows.map(t=>ye`<tr>
|
|
675
|
+
<td part="c-header">${yr(t.innerHTML)}</td>
|
|
676
|
+
${this.cols.map(r=>{let i=t.getAttribute("identifier"),l=r.getAttribute("identifier"),s=`${i} ${l}`,a=this.value.filter(m=>m.split(" ")[0]===i).length||0,p=this.value.includes(s),d=`rb ${p?"rb-checked":""} ${this.correctOptions.includes(s)?"rb-correct":""}`,u=this.correctOptions.length>0?!0:t.matchMax===1?!1:a>=t.matchMax&&!p;return ye`<td>
|
|
677
|
+
<input
|
|
678
|
+
type=${t.matchMax===1?"radio":"checkbox"}
|
|
679
|
+
part=${d}
|
|
680
|
+
name=${i}
|
|
681
|
+
value=${s}
|
|
682
|
+
.disabled=${u}
|
|
683
|
+
@change=${m=>this.handleRadioChange(m)}
|
|
684
|
+
@click=${m=>t.matchMax===1?this.handleRadioClick(m):null}
|
|
685
|
+
/>
|
|
686
|
+
</td>`})}
|
|
687
|
+
</tr>`)}
|
|
688
|
+
</table>
|
|
689
|
+
`:fo}
|
|
690
|
+
|
|
691
|
+
<div role="alert" id="validationMessage"></div>
|
|
692
|
+
`}};N.styles=gr,n([br({type:String})],N.prototype,"class",2),n([vr()],N.prototype,"_response",2),n([br({type:String,attribute:"response-identifier"})],N.prototype,"responseIdentifier",2),n([vr()],N.prototype,"correctOptions",2),N=n([go("qti-match-interaction")],N);import{css as bo,html as vo}from"lit";import{customElement as yo}from"lit/decorators.js";var xe=class extends h{constructor(){super();this._value=0}reset(){}validate(){return!0}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}static get properties(){return{...h.properties,step:{type:Number,attribute:"step",default:10}}}render(){return vo` <slot name="prompt"></slot>
|
|
693
|
+
<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)})}};xe.styles=[bo``],xe=n([yo("qti-media-interaction")],xe);import{html as Er}from"lit";import{customElement as Eo,property as Co,state as kt}from"lit/decorators.js";import{unsafeHTML as qo}from"lit/directives/unsafe-html.js";import{css as xo}from"lit";var xr=xo`
|
|
694
|
+
[part='drags'] {
|
|
695
|
+
display: flex;
|
|
696
|
+
align-items: flex-start;
|
|
697
|
+
flex: 1;
|
|
698
|
+
border: 2px solid transparent;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
[part='drops'] {
|
|
702
|
+
flex: 1;
|
|
703
|
+
display: grid;
|
|
704
|
+
grid-auto-flow: column;
|
|
705
|
+
grid-auto-columns: 1fr;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
:host([orientation='horizontal']) [part='drags'] {
|
|
709
|
+
flex-direction: row;
|
|
710
|
+
}
|
|
711
|
+
:host([orientation='horizontal']) [part='drops'] {
|
|
712
|
+
grid-auto-flow: column;
|
|
713
|
+
}
|
|
714
|
+
:host([orientation='vertical']) [part='drags'] {
|
|
715
|
+
flex-direction: column;
|
|
716
|
+
}
|
|
717
|
+
:host([orientation='vertical']) [part='drops'] {
|
|
718
|
+
grid-auto-flow: row;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
[part='drop-list'] {
|
|
722
|
+
display: block;
|
|
723
|
+
flex: 1;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
[part='container'] {
|
|
727
|
+
display: flex;
|
|
728
|
+
gap: 0.5rem;
|
|
729
|
+
}
|
|
730
|
+
:host(.qti-choices-top) [part='container'] {
|
|
731
|
+
flex-direction: column;
|
|
732
|
+
}
|
|
733
|
+
:host(.qti-choices-bottom) [part='container'] {
|
|
734
|
+
flex-direction: column-reverse;
|
|
735
|
+
}
|
|
736
|
+
:host(.qti-choices-left) [part='container'] {
|
|
737
|
+
flex-direction: row;
|
|
738
|
+
}
|
|
739
|
+
:host(.qti-choices-right) [part='container'] {
|
|
740
|
+
flex-direction: row-reverse;
|
|
741
|
+
}
|
|
742
|
+
`;var $=class extends Oe(L(h,"qti-simple-choice","drop-list","slot[part='drags']"),"qti-simple-choice"){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),Er` <slot name="prompt"> </slot>
|
|
743
|
+
<div part="container">
|
|
744
|
+
<slot part="drags"> </slot>
|
|
745
|
+
<div part="drops">
|
|
746
|
+
${Array.from(Array(this.nrChoices)).map((t,r)=>Er`<drop-list part="drop-list" identifier="droplist${r}"></drop-list>${this.showCorrectResponses&&this.correctResponses.length>r?qo(`<span part='correct-response'>${this.correctResponses[r]}</span>`):""}`)}
|
|
747
|
+
</div>
|
|
748
|
+
</div>`}set correctResponse(e){if(e===""){this.showCorrectResponses=!1;return}this.correctResponses.length===0&&(Array.isArray(e)?e:[e]).forEach(r=>{let i=this.querySelector(`qti-simple-choice[identifier="${r}"]`);i||(i=this.shadowRoot.querySelector(`qti-simple-choice[identifier="${r}"]`));let l=i?.textContent.trim();this.correctResponses=[...this.correctResponses,l]}),this.showCorrectResponses=!0}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(r=>{let i=r.querySelectorAll('[qti-draggable="true"]');return[...Array.from(i).map(s=>s.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"))}};$.styles=xr,n([kt()],$.prototype,"nrChoices",2),n([kt()],$.prototype,"correctResponses",2),n([kt()],$.prototype,"showCorrectResponses",2),n([Co({type:String})],$.prototype,"orientation",2),$=n([Eo("qti-order-interaction")],$);import{LitElement as To,css as wo,html as Mo}from"lit";var Ge=class extends To{render(){return Mo`<slot></slot>`}};Ge.styles=[wo`
|
|
749
|
+
:host {
|
|
750
|
+
display: block;
|
|
751
|
+
}
|
|
752
|
+
::slotted(img) {
|
|
753
|
+
position: absolute;
|
|
754
|
+
cursor: move;
|
|
755
|
+
user-select: none;
|
|
756
|
+
left: 50%;
|
|
757
|
+
transform: translateX(-50%);
|
|
758
|
+
}
|
|
759
|
+
`];customElements.define("qti-position-object-interaction",Ge);import{LitElement as So,css as Ro,html as Ao}from"lit";import{customElement as ko}from"lit/decorators.js";var Ee=class extends So{render(){return Ao`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(o){o.preventDefault();let e=o.clientX-this.startX,t=o.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=o.clientX,this.startY=o.clientY}firstUpdated(o){super.firstUpdated(o),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)}};Ee.styles=[Ro`
|
|
760
|
+
:host {
|
|
761
|
+
display: inline-block;
|
|
762
|
+
position: relative;
|
|
763
|
+
}
|
|
764
|
+
`],Ee=n([ko("qti-position-object-stage")],Ee);import{css as Lo,html as Cr}from"lit";import{customElement as _o,property as qr,state as Do}from"lit/decorators.js";import{repeat as Vo}from"lit/directives/repeat.js";import{styleMap as Ho}from"lit/directives/style-map.js";var U=class extends h{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._imgElement=null;this._onImageClick=e=>{if(this._points.length<this.maxChoices){let t=e.offsetX,r=e.offsetY;this._points=[...this._points,`${t} ${r}`],this.saveResponse(this._points)}}}render(){return Cr` <slot name="prompt"></slot>
|
|
765
|
+
<point-container>
|
|
766
|
+
${Vo(this._points,e=>e,(e,t)=>Cr`
|
|
767
|
+
<button
|
|
768
|
+
part="point"
|
|
769
|
+
style=${Ho({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
|
|
770
|
+
aria-label="Remove point at ${e}"
|
|
771
|
+
@click=${r=>{r.stopPropagation(),this._points=this._points.filter((i,l)=>l!==t),this.saveResponse(this._points)}}
|
|
772
|
+
></button>
|
|
773
|
+
`)}
|
|
774
|
+
<slot></slot>
|
|
775
|
+
</point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set value(e){this._points=Array.isArray(e)?e:[e]}get value(){return this._points}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?this._imgElement.addEventListener("click",this._onImageClick):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};U.styles=[Lo`
|
|
776
|
+
:host {
|
|
777
|
+
display: block;
|
|
778
|
+
}
|
|
779
|
+
point-container {
|
|
780
|
+
display: block;
|
|
781
|
+
position: relative;
|
|
782
|
+
}
|
|
783
|
+
`],n([qr({type:Number,attribute:"max-choices"})],U.prototype,"maxChoices",2),n([qr({type:Number,attribute:"min-choices"})],U.prototype,"minChoices",2),n([Do()],U.prototype,"_points",2),U=n([_o("qti-select-point-interaction")],U);import{html as $o,LitElement as Io}from"lit";import{customElement as Oo,property as Lt,query as Po}from"lit/decorators.js";import{css as No}from"lit";var Tr=No`
|
|
784
|
+
:host {
|
|
785
|
+
display: block;
|
|
786
|
+
--show-bounds: true;
|
|
787
|
+
--show-ticks: true;
|
|
788
|
+
--show-value: true;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
[part='slider'] {
|
|
792
|
+
margin-left: 2rem; /* mx-8 */
|
|
793
|
+
margin-right: 2rem;
|
|
794
|
+
padding-bottom: 1rem; /* pb-4 */
|
|
795
|
+
padding-top: 1.25rem; /* pt-5 */
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
[part='bounds'] {
|
|
799
|
+
display: flex;
|
|
800
|
+
width: 100%;
|
|
801
|
+
justify-content: space-between;
|
|
802
|
+
margin-bottom: 0.5rem; /* mb-2 */
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
[part='ticks'] {
|
|
806
|
+
margin-left: 0.125rem; /* mx-0.5 */
|
|
807
|
+
margin-right: 0.125rem;
|
|
808
|
+
margin-bottom: 0.25rem; /* mb-1 */
|
|
809
|
+
height: 0.5rem; /* h-2 */
|
|
810
|
+
background: linear-gradient(to right, var(--qti-border-color) var(--qti-border-thickness), transparent 1px) repeat-x
|
|
811
|
+
0 center / calc(calc(100% - var(--qti-border-thickness)) / ((var(--max) - var(--min)) / var(--step))) 100%;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
[part='rail'] {
|
|
815
|
+
display: flex;
|
|
816
|
+
align-items: center;
|
|
817
|
+
box-sizing: border-box;
|
|
818
|
+
height: 0.375rem; /* h-1.5 */
|
|
819
|
+
width: 100%;
|
|
820
|
+
cursor: pointer;
|
|
821
|
+
border-radius: 9999px; /* rounded-full */
|
|
822
|
+
border: 1px solid #d1d5db; /* border-gray-300 */
|
|
823
|
+
background-color: #e5e7eb; /* bg-gray-200 */
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
[part='knob'] {
|
|
827
|
+
background-color: var(--qti-bg-active);
|
|
828
|
+
border: 2px solid var(--qti-border-active);
|
|
829
|
+
position: relative;
|
|
830
|
+
height: 1rem; /* h-4 */
|
|
831
|
+
width: 1rem; /* w-4 */
|
|
832
|
+
transform-origin: center;
|
|
833
|
+
transform: translateX(-50%);
|
|
834
|
+
cursor: pointer;
|
|
835
|
+
border-radius: 9999px; /* rounded-full */
|
|
836
|
+
left: var(--value-percentage);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
[part='value'] {
|
|
840
|
+
position: absolute;
|
|
841
|
+
bottom: 2rem; /* bottom-8 */
|
|
842
|
+
left: 0.5rem; /* left-2 */
|
|
843
|
+
transform: translateX(-50%);
|
|
844
|
+
cursor: pointer;
|
|
845
|
+
border-radius: 0.25rem; /* rounded */
|
|
846
|
+
background-color: #f3f4f6; /* bg-gray-100 */
|
|
847
|
+
padding: 0.25rem 0.5rem; /* px-2 py-1 */
|
|
848
|
+
text-align: center;
|
|
849
|
+
color: #6b7280; /* text-gray-500 */
|
|
850
|
+
}
|
|
851
|
+
`;var _=class extends Io{constructor(){super();this._value=0;this.min=0;this.max=100;this.step=1;this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get value(){return this._value.toString()}set value(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}_updateValue(e){this._value=Math.min(this.max,Math.max(this.min,e));let t=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${t}%`),this._internals.setFormValue(this.value),this.requestUpdate()}render(){return $o`
|
|
852
|
+
<slot name="prompt"></slot>
|
|
853
|
+
<div id="slider" part="slider">
|
|
854
|
+
<div id="bounds" part="bounds">
|
|
855
|
+
<div>${this.min}</div>
|
|
856
|
+
<div>${this.max}</div>
|
|
857
|
+
</div>
|
|
858
|
+
|
|
859
|
+
<div id="ticks" part="ticks"></div>
|
|
860
|
+
|
|
861
|
+
<div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchStart}>
|
|
862
|
+
<div id="knob" part="knob"><div id="value" part="value">${this.value}</div></div>
|
|
863
|
+
</div>
|
|
864
|
+
</div>
|
|
865
|
+
`}_onMouseDown(e){this._startDrag(e.pageX);let t=i=>this._onDrag(i.pageX),r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=i=>this._onDrag(i.touches[0].pageX),r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",r)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),r=e-t.left,i=Math.min(1,Math.max(0,r/t.width)),l=this.min+Math.round(i*(this.max-this.min)/this.step)*this.step;this._updateValue(l)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};_.formAssociated=!0,_.styles=Tr,n([Po("#rail")],_.prototype,"_rail",2),n([Lt({type:Number,attribute:"lower-bound"})],_.prototype,"min",2),n([Lt({type:Number,attribute:"upper-bound"})],_.prototype,"max",2),n([Lt({type:Number,attribute:"step"})],_.prototype,"step",2),_=n([Oo("qti-slider-interaction")],_);import{consume as Fo}from"@lit/context";import{LitElement as zo,html as Uo}from"lit";import{customElement as Xo,state as Bo}from"lit/decorators.js";var Ce=class extends zo{render(){return Uo`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let o=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",o?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let o={variable:t=>this._context?.variables.find(r=>r.identifier===t)?.value??"",correct:t=>this._context?.variables.find(r=>r.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(r=>r.identifier===t),updateOutcomeVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:r}}))},updateResponseVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:r}}))}};return this.operatorFunction(this._context,o,e)}};n([Fo({context:y,subscribe:!0}),Bo()],Ce.prototype,"_context",2),Ce=n([Xo("qti-custom-operator")],Ce);import{LitElement as Yo,css as Wo,html as jo}from"lit";import{customElement as Ko}from"lit/decorators.js";var qe=class extends Yo{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return jo` <slot name="drags"></slot> `}};qe.styles=Wo`
|
|
866
|
+
:host {
|
|
867
|
+
display: flex;
|
|
868
|
+
user-select: none;
|
|
869
|
+
position: absolute;
|
|
870
|
+
}
|
|
871
|
+
`,qe=n([Ko("qti-associable-hotspot")],qe);import{css as Jo,html as Go,LitElement as Zo}from"lit";import{customElement as Qo,property as en}from"lit/decorators.js";var Z=class extends Zo{constructor(){super(...arguments);this.tabindex=0}render(){return Go` <slot name="drags"></slot>`}};Z.styles=Jo`
|
|
872
|
+
:host {
|
|
873
|
+
display: flex;
|
|
874
|
+
user-select: none;
|
|
875
|
+
}
|
|
876
|
+
`,n([en({type:Number,reflect:!0})],Z.prototype,"tabindex",2),Z=n([Qo("qti-gap")],Z);import{css as tn,LitElement as rn}from"lit";import{customElement as sn,property as on}from"lit/decorators.js";var Q=class extends rn{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};Q.styles=tn`
|
|
877
|
+
:host {
|
|
878
|
+
display: flex;
|
|
879
|
+
user-select: none;
|
|
880
|
+
}
|
|
881
|
+
`,n([on({type:Number,reflect:!0})],Q.prototype,"tabindex",2),Q=n([sn("qti-gap-img")],Q);import{css as nn,html as an,LitElement as ln}from"lit";import{customElement as cn,property as pn}from"lit/decorators.js";var ee=class extends M(ln,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return an`<slot></slot>`}};ee.styles=nn`
|
|
882
|
+
:host {
|
|
883
|
+
display: inline-flex;
|
|
884
|
+
user-select: none;
|
|
885
|
+
}
|
|
886
|
+
`,n([pn({type:Number,reflect:!0})],ee.prototype,"tabindex",2),ee=n([cn("qti-gap-text")],ee);import{css as dn,LitElement as un}from"lit";import{customElement as mn,property as hn}from"lit/decorators.js";var te=class extends M(un,"qti-hotspot-choice"){};te.styles=dn`
|
|
887
|
+
:host {
|
|
888
|
+
display: flex;
|
|
889
|
+
user-select: none;
|
|
890
|
+
position: absolute;
|
|
891
|
+
}
|
|
892
|
+
`,n([hn({attribute:"aria-ordervalue",type:Number,reflect:!0})],te.prototype,"order",2),te=n([mn("qti-hotspot-choice")],te);import{css as fn,html as gn,LitElement as bn}from"lit";import{customElement as vn}from"lit/decorators.js";var Te=class extends M(bn,"qti-hottext"){render(){return gn`<div part="ch"><div part="cha"></div></div>
|
|
893
|
+
<slot></slot> `}};Te.styles=fn`
|
|
894
|
+
:host {
|
|
895
|
+
display: flex;
|
|
896
|
+
user-select: none;
|
|
897
|
+
}
|
|
898
|
+
`,Te=n([vn("qti-hottext")],Te);import{css as yn,html as xn,LitElement as En}from"lit";import{customElement as Cn,property as qn}from"lit/decorators.js";var we=class extends En{static get styles(){return[yn`
|
|
899
|
+
:host {
|
|
900
|
+
display: block;
|
|
901
|
+
cursor: pointer;
|
|
902
|
+
}
|
|
903
|
+
`]}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 xn` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};n([qn({type:String})],we.prototype,"identifier",2),we=n([Cn("qti-inline-choice")],we);import{css as Tn,html as wr,LitElement as wn,nothing as Mn}from"lit";import{customElement as Sn,property as Rn}from"lit/decorators.js";var re=class extends M(wn,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return wr`<div part="ch">
|
|
904
|
+
<div part="cha"></div>
|
|
905
|
+
</div>
|
|
906
|
+
${this.marker?wr`<div id="label">${this.marker}</div>`:Mn}
|
|
907
|
+
<slot part="slot"></slot> `}};re.styles=Tn`
|
|
908
|
+
:host {
|
|
909
|
+
display: flex;
|
|
910
|
+
align-items: center;
|
|
911
|
+
user-select: none;
|
|
912
|
+
}
|
|
913
|
+
slot {
|
|
914
|
+
width: 100%;
|
|
915
|
+
display: flex;
|
|
916
|
+
align-items: center;
|
|
917
|
+
}
|
|
918
|
+
[part='ch'] {
|
|
919
|
+
display: flex;
|
|
920
|
+
flex-shrink: 0;
|
|
921
|
+
align-items: center;
|
|
922
|
+
justify-content: center;
|
|
923
|
+
}
|
|
924
|
+
`,n([Rn({type:String,attribute:!1})],re.prototype,"marker",2),re=n([Sn("qti-simple-choice")],re);export{M as ActiveElementMixin,h as Interaction,Fe as QtiAnd,E as QtiAssessmentItem,W as QtiAssessmentStimulusRef,qe as QtiAssociableHotspot,J as QtiAssociateInteraction,ze as QtiBaseValue,j as QtiChoiceInteraction,De as QtiCompanionMaterialsInfo,T as QtiConditionExpression,ct as QtiContains,Ve as QtiContentBody,pt as QtiCorrect,V as QtiCustomInteraction,Ce as QtiCustomOperator,F as QtiEndAttemptInteraction,Xe as QtiEqual,Ue as QtiEqualRounded,f as QtiExpression,q as QtiExtendedTextInteraction,ne as QtiFeedbackBlock,ae as QtiFeedbackInline,Z as QtiGap,Q as QtiGapImg,fe as QtiGapMatchInteraction,ee as QtiGapText,H as QtiGraphicAssociateInteraction,ge as QtiGraphicGapMatchInteraction,be as QtiGraphicOrderInteraction,dt as QtiGt,ut as QtiGte,te as QtiHotspotChoice,ve as QtiHotspotInteraction,Te as QtiHottext,Ie as QtiHottextInteraction,we as QtiInlineChoice,P as QtiInlineChoiceInteraction,mt as QtiIsNull,ie as QtiItemBody,Pe as QtiLookupOutcomeValue,ht as QtiLt,ft as QtiLte,Be as QtiMapResponse,K as QtiMapping,bt as QtiMatch,N as QtiMatchInteraction,xe as QtiMediaInteraction,vt as QtiMember,le as QtiModalFeedback,yt as QtiMultiple,xt as QtiNot,Et as QtiOr,$ as QtiOrderInteraction,Ct as QtiOrdered,S as QtiOutcomeDeclaration,de as QtiOutcomeProcessing,st as QtiOutcomeProcessingProcessor,B as QtiPortableCustomInteraction,Ge as QtiPositionObjectInteraction,Ee as QtiPositionObjectStage,he as QtiPrintedVariable,qt as QtiProduct,ke as QtiPrompt,ot as QtiResponseCondition,D as QtiResponseDeclaration,ue as QtiResponseElse,lt as QtiResponseElseIf,me as QtiResponseIf,X as QtiResponseProcessing,R as QtiRubricBlock,k as QtiRule,U as QtiSelectPointInteraction,nt as QtiSetOutcomeValue,at as QtiSetOutcomeValueRule,z as QtiSimpleAssociableChoice,re as QtiSimpleChoice,_ as QtiSliderInteraction,We as QtiStringMatch,Le as QtiStylesheet,Ye as QtiSubtract,Tt as QtiSum,wt as QtiSumExpression,A as QtiTextEntryInteraction,pe as QtiUploadInteraction,Mt as QtiVariable,y as itemContext,Dt as itemContextVariables,Cs as qtiAndMixin,Vs as qtiSubtractMixin};
|