@citolab/qti-components 6.0.4-2 → 6.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/dist/chunk-67UY4OJW.js +2121 -0
- package/dist/chunk-7RTSAPMF.js +2135 -0
- package/dist/chunk-E7DMNXUW.js +2127 -0
- package/dist/chunk-MGEP4U4L.js +2139 -0
- package/dist/chunk-OIQME3LC.js +2212 -0
- package/dist/chunk-QH4IMEWP.js +2175 -0
- package/dist/chunk-TI6G3PT6.js +2172 -0
- package/dist/custom-elements.json +575 -434
- package/dist/index.css +263 -262
- package/dist/index.d.ts +35 -2
- package/dist/index.js +329 -319
- package/dist/qti-components/index.d.ts +36 -3
- package/dist/qti-components/index.js +71 -62
- package/dist/qti-item/index.js +1 -1
- package/dist/qti-item-react/index.d.ts +1 -1
- package/dist/qti-item-react/index.js +1 -1
- package/dist/qti-simple-choice-e1c352e0.d.ts +352 -0
- package/package.json +8 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{a as b,b as
|
|
1
|
+
import{a as b,b as ct}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}from"../chunk-NMCIOGD2.js";var pt={};var dt={};var ut={};var mt={};var ht={};var ft={};var gt={};var bt={};var vt={};var yt={ON_OUTCOME_CHANGED:"qti-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_VARIABLE:"on-register-variable",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"};var I=class{constructor({mapping:i,correctResponse:e,cardinality:t,baseType:r,identifier:o}){this._basetype="string";this._mapping=i,this._correctResponse=e,this._cardinality=t,this._basetype=r,this._identifier=o}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(i){this._candidateResponse=i}};var F=class{constructor(){this.value=0}};import{customElement as It,property as se}from"lit/decorators.js";import{html as Ft,LitElement as Ut}from"lit";var q=class extends Ut{constructor(){super();this.variables=[];this.feedbackElements=[];this.interactionElements=[];this._handleDisabledChange=(e,t)=>{this.interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this.interactionElements.forEach(r=>r.readonly=t);this.addEventListener("qti-register-variable",this._registerVariable),this.addEventListener("qti-register-feedback",this.registerFeedbackElement),this.addEventListener("qti-register-interaction",this.registerInteractionElement),this.addEventListener("qti-outcome-changed",this.outcomeChanged),this.addEventListener("qti-interaction-response",this.interactionResponse)}render(){return Ft`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-item-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}disconnectedCallback(){this.removeEventListener("qti-register-variable",this._registerVariable),this.removeEventListener("qti-register-feedback",this.registerFeedbackElement),this.removeEventListener("qti-register-interaction",this.registerInteractionElement),this.removeEventListener("qti-outcome-changed",this.outcomeChanged),this.removeEventListener("qti-interaction-response",this.interactionResponse)}_registerVariable(e){this.variables.push(e.detail.variable)}showCorrectResponse(){let e=this.variables.filter(t=>"correctResponse"in t);this.responses=e.map(t=>({responseIdentifier:t.identifier,response:t.correctResponse}))}processResponse(){if(!this.validateResponses())return console.info("Item is not valid, call validateResponses first"),!1;let e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}set responses(e){if(e)for(let t of e){let r=this.interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier),o=this.getResponse(t.responseIdentifier);o&&(o.value=t.response),r&&(r.response=t.response)}}resetInteractions(){this.interactionElements.forEach(e=>e.reset())}validateResponses(){let e=!0;return this.interactionElements.forEach(t=>{t.validate()||(e=!1)}),e}getVariableValue(e){let t=this.variables.find(r=>r.identifier===e);return t?t.value:(console.warn(`Variable with identifier ${e} was not found`),null)}getResponse(e){let t=this.variables.find(o=>o.identifier===e);return t instanceof I?t:null}getOutcome(e){let t=this.variables.find(r=>r.identifier===e);return t instanceof F?t:null}registerFeedbackElement(e){e.stopPropagation(),this.feedbackElements.push(e.detail)}registerInteractionElement(e){e.stopPropagation(),this.interactionElements.push(e.target)}interactionResponse(e){let t=e.detail,r=this.getResponse(t.responseIdentifier);r&&(r.value=t.response),e.stopImmediatePropagation();let o=this.getAttribute("identifier");o||console.warn("qti-assessment-item has no identifier specified"),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:o,responseIdentifier:t.responseIdentifier,response:t.response}}))}outcomeChanged(e){this.feedbackElements.forEach(t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)})}setOutcomeValue(e,t){let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}r.value=t,this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))}};s([se({type:Boolean})],q.prototype,"disabled",2),s([se({type:Boolean})],q.prototype,"readonly",2),s([se({type:String})],q.prototype,"title",2),s([se({type:String})],q.prototype,"identifier",2),s([b("disabled",{waitUntilFirstUpdate:!0})],q.prototype,"_handleDisabledChange",2),s([b("readonly",{waitUntilFirstUpdate:!0})],q.prototype,"_handleReadonlyChange",2),q=s([It("qti-assessment-item")],q);import{LitElement as Xt}from"lit";var Se=class extends Xt{constructor(){super()}connectedCallback(){super.connectedCallback();let e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.media="screen",r.href=t,e.appendChild(r),this.styleLink=r}disconnectedCallback(){let e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(t){console.log("could not remove stylesheet")}}};customElements.define("qti-stylesheet",Se);import{customElement as Bt}from"lit/decorators.js";import{html as Kt,LitElement as zt}from"lit";import{css as Yt}from"lit";var xt=Yt`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
|
5
|
-
`;var U=class extends
|
|
6
|
-
<slot></slot>`}};U.styles=
|
|
5
|
+
`;var U=class extends zt{render(){return Kt` <slot name="qti-rubric-block"></slot>
|
|
6
|
+
<slot></slot>`}};U.styles=xt,U=s([Bt("qti-item-body")],U);import{html as jt,LitElement as Gt}from"lit";var Me=class extends Gt{render(){return jt` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",Me);import{html as Wt}from"lit/static-html.js";import{property as J}from"lit/decorators.js";import{LitElement as Jt}from"lit";var Zt={SPACE:32},y=class extends Jt{constructor(){super(...arguments);this.tabindex=0;this.disabled=!1;this.readonly=!1;this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-register-choice",{bubbles:!0,cancelable:!1,composed:!0}))}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-loose-choice",{bubbles:!0,cancelable:!1,composed:!0}))}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){if(!e.altKey)switch(e.keyCode){case Zt.SPACE:e.preventDefault(),this._toggleChecked();break;default:}}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("qti-choice-element-selected",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier,checked:this.checked}})))}validateAllProps(){return!!this.getAttribute("identifier")}render(){return this.validateAllProps()||console.warn(`Invalid props for ${this.outerHTML}`,"missing identifier"),Wt` <slot></slot> `}};s([J({type:String})],y.prototype,"identifier",2),s([J({type:Number,reflect:!0})],y.prototype,"tabindex",2),s([J({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:a=>a}})],y.prototype,"disabled",2),s([J({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:a=>a}})],y.prototype,"readonly",2),s([J({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:a=>a}})],y.prototype,"checked",2),s([b("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"handleDisabledChange",1);import{html as Qt,LitElement as er}from"lit";var O=class extends er{render(){return Qt``}};customElements.define("qti-variabledeclaration",O);import{property as Ne}from"lit/decorators.js";var X=class extends O{connectedCallback(){super.connectedCallback();let e=new I({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping});this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let e,t=this.querySelector("qti-correct-response");if(t){let r=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)e=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){e=[];for(let o=0;o<r.length;o++)e.push(r[o].textContent),r[o].remove()}}return e}get mapping(){return this.querySelector("qti-mapping")}};s([Ne({type:String,attribute:"base-type"})],X.prototype,"baseType",2),s([Ne({type:String,attribute:"identifier"})],X.prototype,"identifier",2),s([Ne({type:String,attribute:"cardinality"})],X.prototype,"cardinality",2);customElements.define("qti-response-declaration",X);var He=class extends O{static get observedAttributes(){return["identifier","cardinality","base-type"]}get interpolationTable(){let i=this.querySelector("qti-interpolation-table");if(i){let e=new Map;for(let t of i.querySelectorAll("qti-interpolation-table-entry")){!t.getAttribute("source-value")&&t.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let r=parseInt(t.getAttribute("source-value")),o=parseInt(t.getAttribute("target-value"));(isNaN(r)||isNaN(o))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),e.set(r,o)}}return null}connectedCallback(){super.connectedCallback();let i=this.getAttribute("identifier"),e=new F;e.identifier=i,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};customElements.define("qti-outcome-declaration",He);import{LitElement as tr}from"lit";import{customElement as rr}from"lit/decorators.js";var oe=class extends tr{};oe=s([rr("qti-companion-materials-info")],oe);import{LitElement as ir,css as sr,html as or}from"lit";import{customElement as nr,property as ne}from"lit/decorators.js";import{ContextConsumer as ar}from"@lit-labs/context";var _=class extends ir{constructor(){super(...arguments);this.logger=new ar(this,ct,e=>this.style.display=this.view===e.view?"block":"none",!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{switch(o){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return or`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};_.styles=sr`
|
|
7
7
|
:host {
|
|
8
8
|
display: block;
|
|
9
9
|
}
|
|
10
|
-
`,s([ne({type:String})],_.prototype,"id",2),s([ne({type:String})],_.prototype,"use",2),s([ne({type:String})],_.prototype,"view",2),s([ne({type:String,attribute:"class"})],_.prototype,"classNames",2),s([b("classNames",{waitUntilFirstUpdate:!0})],_.prototype,"handleclassNamesChange",1),_=s([
|
|
10
|
+
`,s([ne({type:String})],_.prototype,"id",2),s([ne({type:String})],_.prototype,"use",2),s([ne({type:String})],_.prototype,"view",2),s([ne({type:String,attribute:"class"})],_.prototype,"classNames",2),s([b("classNames",{waitUntilFirstUpdate:!0})],_.prototype,"handleclassNamesChange",1),_=s([nr("qti-rubric-block")],_);import{LitElement as lr,html as cr}from"lit";import{customElement as pr}from"lit/decorators.js";var ae=class extends lr{render(){return cr`<slot></slot>`}};ae=s([pr("qti-content-body")],ae);import{css as ur,html as mr}from"lit";import{LitElement as dr}from"lit";import{property as le}from"lit/decorators.js";var k=class extends dr{constructor(){super();this.showHide="show",this.showFeedback(this.showHide==="hide")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){if(this.outcomeIdentifier!==e||!t)return;let r=Array.isArray(t)?t.includes(this.identifier):this.identifier===t.toString();this.showFeedback(r)}showFeedback(e){this.showStatus=e?"on":"off"}};s([le({type:String,attribute:"show-hide"})],k.prototype,"showHide",2),s([le({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),s([le({type:String})],k.prototype,"identifier",2),s([le({type:String,attribute:!1})],k.prototype,"showStatus",2);var ce=class extends k{constructor(){super(...arguments);this.render=()=>mr` <slot class="${this.showStatus}"></slot> `}};ce.styles=ur`
|
|
11
11
|
.on {
|
|
12
12
|
display: inline-block;
|
|
13
13
|
}
|
|
14
14
|
.off {
|
|
15
15
|
display: none;
|
|
16
16
|
}
|
|
17
|
-
`;customElements.define("qti-feedback-inline",ce);import{html as
|
|
17
|
+
`;customElements.define("qti-feedback-inline",ce);import{html as hr}from"lit";var Oe=class extends k{render(){return hr`
|
|
18
18
|
<style>
|
|
19
19
|
.on {
|
|
20
20
|
display: inline-block;
|
|
@@ -26,7 +26,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
26
26
|
<div class="feedback ${this.showStatus}">
|
|
27
27
|
<slot></slot>
|
|
28
28
|
</div>
|
|
29
|
-
`}};customElements.define("qti-modal-feedback",
|
|
29
|
+
`}};customElements.define("qti-modal-feedback",Oe);import{css as br,html as vr}from"lit";import{ifDefined as Ve}from"lit/directives/if-defined.js";import{property as De}from"lit/decorators.js";import{LitElement as fr}from"lit";var f=class extends fr{constructor(){super(...arguments);this.responseIdentifier="";this.disabled=!1;this.readonly=!1}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,cancelable:!1,composed:!0}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,cancelable:!1,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:e}}))}};s([De({attribute:"response-identifier"})],f.prototype,"responseIdentifier",2),s([De({reflect:!0,type:Boolean})],f.prototype,"disabled",2),s([De({reflect:!0,type:Boolean})],f.prototype,"readonly",2);import{css as gr}from"lit";var Y=gr`
|
|
30
30
|
/***
|
|
31
31
|
The new CSS reset - version 1.4.9 (last updated 11.2.2022)
|
|
32
32
|
GitHub page: https://github.com/elad2412/the-new-css-reset
|
|
@@ -106,7 +106,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
106
106
|
:where([draggable='true']) {
|
|
107
107
|
-webkit-user-drag: element;
|
|
108
108
|
}
|
|
109
|
-
`;import{customElement as
|
|
109
|
+
`;import{customElement as yr,property as pe,state as xr}from"lit/decorators.js";var S=class extends f{constructor(){super(...arguments);this._value=""}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Y,br`
|
|
110
110
|
/* PK: display host as block, else design will be collapsed */
|
|
111
111
|
:host {
|
|
112
112
|
display: inline-block;
|
|
@@ -114,7 +114,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
114
114
|
input {
|
|
115
115
|
padding: var(--qti-padding, 0.5rem);
|
|
116
116
|
}
|
|
117
|
-
`]}render(){return
|
|
117
|
+
`]}render(){return vr` <input
|
|
118
118
|
part="input"
|
|
119
119
|
spellcheck="false"
|
|
120
120
|
autocomplete="off"
|
|
@@ -122,13 +122,13 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
122
122
|
@keyup="${this.textChanged}"
|
|
123
123
|
@change="${this.textChanged}"
|
|
124
124
|
type="text"
|
|
125
|
-
placeholder="${
|
|
125
|
+
placeholder="${Ve(this.placeholderText?this.placeholderText:void 0)}"
|
|
126
126
|
.value="${this._value}"
|
|
127
|
-
size="${
|
|
128
|
-
pattern="${
|
|
127
|
+
size="${Ve(this.expectedLength?this.expectedLength:void 0)}"
|
|
128
|
+
pattern="${Ve(this.patternMask?this.patternMask:void 0)}"
|
|
129
129
|
?disabled="${this.disabled}"
|
|
130
130
|
?readonly="${this.readonly}"
|
|
131
|
-
/>`}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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([pe({type:Number,attribute:"expected-length"})],
|
|
131
|
+
/>`}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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([pe({type:Number,attribute:"expected-length"})],S.prototype,"expectedLength",2),s([pe({type:String,attribute:"pattern-mask"})],S.prototype,"patternMask",2),s([pe({type:String,attribute:"placeholder-text"})],S.prototype,"placeholderText",2),s([xr()],S.prototype,"_value",2),s([pe({type:String,attribute:"class"})],S.prototype,"classNames",2),S=s([yr("qti-text-entry-interaction")],S);import{css as Er,html as Cr}from"lit";import{ifDefined as Pe}from"lit/directives/if-defined.js";import{ref as qr,createRef as _r}from"lit/directives/ref.js";import{customElement as kr,property as de,state as wr}from"lit/decorators.js";var w=class extends f{constructor(){super(...arguments);this.textareaRef=_r();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let n=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(n))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Y,Er`
|
|
132
132
|
/* PK: display host as block, else design will be collapsed */
|
|
133
133
|
:host {
|
|
134
134
|
display: block;
|
|
@@ -138,38 +138,38 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
138
138
|
width: 100%;
|
|
139
139
|
height: 100%;
|
|
140
140
|
}
|
|
141
|
-
`]}render(){return
|
|
141
|
+
`]}render(){return Cr`<textarea
|
|
142
142
|
part="textarea"
|
|
143
|
-
${
|
|
143
|
+
${qr(this.textareaRef)}
|
|
144
144
|
spellcheck="false"
|
|
145
145
|
autocomplete="off"
|
|
146
146
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
147
147
|
@keyup="${this.textChanged}"
|
|
148
148
|
@change="${this.textChanged}"
|
|
149
|
-
placeholder="${
|
|
150
|
-
maxlength="${
|
|
151
|
-
pattern="${
|
|
149
|
+
placeholder="${Pe(this.placeholderText?this.placeholderText:void 0)}"
|
|
150
|
+
maxlength="${Pe(this.expectedLength?this.expectedLength:void 0)}"
|
|
151
|
+
pattern="${Pe(this.patternMask?this.patternMask:void 0)}"
|
|
152
152
|
?disabled="${this.disabled}"
|
|
153
153
|
?readonly="${this.readonly}"
|
|
154
154
|
.value=${this._value}
|
|
155
|
-
></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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([de({type:Number,attribute:"expected-length"})],w.prototype,"expectedLength",2),s([de({type:String,attribute:"pattern-mask"})],w.prototype,"patternMask",2),s([de({type:String,attribute:"placeholder-text"})],w.prototype,"placeholderText",2),s([
|
|
155
|
+
></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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([de({type:Number,attribute:"expected-length"})],w.prototype,"expectedLength",2),s([de({type:String,attribute:"pattern-mask"})],w.prototype,"patternMask",2),s([de({type:String,attribute:"placeholder-text"})],w.prototype,"placeholderText",2),s([wr()],w.prototype,"_value",2),s([de({type:String,attribute:"class"})],w.prototype,"classNames",2),s([b("classNames",{waitUntilFirstUpdate:!0})],w.prototype,"handleclassNamesChange",1),w=s([kr("qti-extended-text-interaction")],w);import{html as Ar}from"lit";import{property as Et}from"lit/decorators.js";var v=class extends f{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(r=>r.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(r=>r.readonly=t);this._handleMaxChoicesChange=()=>this._determineInputType();this.addEventListener("qti-register-choice",this._registerChoiceElement),this.addEventListener("qti-loose-choice",this._looseChoiceElement)}reset(){this._choiceElements.forEach(e=>{e.reset()})}validate(){return this._choiceElements.reduce((t,r)=>t+(r.checked?1:0),0)>=this.minChoices}set response(e){this._choiceElements.forEach(r=>{r.checked=!1}),(Array.isArray(e)?e:[e]).forEach(r=>{let o=this.querySelector(`[identifier='${r}']`);o&&(o.checked=!0)})}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler),this.removeEventListener("qti-register-choice",this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter(r=>r!==t)}_determineInputType(){this._choiceElements.forEach(e=>{this._setInputType(e)})}_setInputType(e){this.maxChoices===1?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){this.maxChoices===1&&this._choiceElements.filter(t=>t.identifier!==e.detail.identifier).forEach(t=>{t.checked=!1}),this._choiceElementSelected()}_choiceElementSelected(){let e=this._choiceElements.filter(r=>r.checked).map(r=>r.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(r=>r.disabled=!r.checked):this._choiceElements.forEach(r=>r.disabled=!1));let t;this.maxChoices===1?t=e.length>0?e[0]:void 0:t=e,this.saveResponse(t)}};s([Et({type:Number,attribute:"min-choices"})],v.prototype,"minChoices",2),s([Et({type:Number,attribute:"max-choices"})],v.prototype,"maxChoices",2),s([b("disabled",{waitUntilFirstUpdate:!0})],v.prototype,"_handleDisabledChange",2),s([b("readonly",{waitUntilFirstUpdate:!0})],v.prototype,"_handleReadonlyChange",2),s([b("maxChoices",{waitUntilFirstUpdate:!0})],v.prototype,"_handleMaxChoicesChange",2);var $e=class extends v{constructor(){super(...arguments);this.render=()=>Ar`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",$e);import{css as Tr,html as Ct}from"lit";var ue=class extends f{constructor(){super();this.options=[];this.addEventListener(yt.ON_DROPDOWN_SELECTED,this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}static get properties(){return $(C({},f.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[Y,Tr`
|
|
156
156
|
:host {
|
|
157
157
|
display: inline-block;
|
|
158
158
|
}
|
|
159
|
-
`]}render(){return
|
|
159
|
+
`]}render(){return Ct` <select
|
|
160
160
|
part="select"
|
|
161
161
|
@change="${this.choiceSelected}"
|
|
162
162
|
?disabled="${this.disabled}"
|
|
163
163
|
?readonly="${this.readonly}"
|
|
164
164
|
>
|
|
165
|
-
${this.options.map(e=>
|
|
166
|
-
</select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>$(C({},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>$(C({},r),{selected:r.value===t})),this.saveResponse(t)}};ue.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"];customElements.define("qti-inline-choice-interaction",ue);import{customElement as
|
|
165
|
+
${this.options.map(e=>Ct` <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option> `)}
|
|
166
|
+
</select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>$(C({},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>$(C({},r),{selected:r.value===t})),this.saveResponse(t)}};ue.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"];customElements.define("qti-inline-choice-interaction",ue);import{customElement as Rr,property as Sr}from"lit/decorators.js";import{html as Mr}from"lit";import{css as Lr}from"lit";var qt=Lr`
|
|
167
167
|
:host {
|
|
168
168
|
display: flex;
|
|
169
169
|
flex-direction: column;
|
|
170
170
|
align-items: flex-start;
|
|
171
171
|
}
|
|
172
|
-
`;var D=class extends v{constructor(){super(...arguments);this.render=()=>
|
|
172
|
+
`;var D=class extends v{constructor(){super(...arguments);this.render=()=>Mr` <slot name="prompt"></slot><slot></slot>`}};D.styles=qt,s([Sr({type:String})],D.prototype,"orientation",2),D=s([Rr("qti-choice-interaction")],D);import{customElement as Nr}from"lit/decorators.js";import{html as Hr,LitElement as Or}from"lit";var _t=`<qti-response-processing>
|
|
173
173
|
<qti-response-condition>
|
|
174
174
|
<qti-response-if>
|
|
175
175
|
<qti-match>
|
|
@@ -186,7 +186,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
186
186
|
</qti-set-outcome-value>
|
|
187
187
|
</qti-response-else>
|
|
188
188
|
</qti-response-condition>
|
|
189
|
-
</qti-response-processing>`,
|
|
189
|
+
</qti-response-processing>`,kt=`<qti-response-processing>
|
|
190
190
|
<qti-response-condition>
|
|
191
191
|
<qti-response-if>
|
|
192
192
|
<qti-is-null>
|
|
@@ -202,7 +202,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
202
202
|
</qti-set-outcome-value>
|
|
203
203
|
</qti-response-else>
|
|
204
204
|
</qti-response-condition>
|
|
205
|
-
</qti-response-processing>`,
|
|
205
|
+
</qti-response-processing>`,wt=`<qti-response-processing>
|
|
206
206
|
<qti-response-condition>
|
|
207
207
|
<qti-response-if>
|
|
208
208
|
<qti-is-null>
|
|
@@ -218,15 +218,15 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
218
218
|
</qti-set-outcome-value>
|
|
219
219
|
</qti-response-else>
|
|
220
220
|
</qti-response-condition>
|
|
221
|
-
</qti-response-processing>`;var B=class extends Sr{render(){return Tr`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){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(xt));break}case"map_response_point":{this.appendChild(this.fragmentFromString(Ct));break}case"match_correct":this.appendChild(this.fragmentFromString(Et));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};B=s([Lr("qti-response-processing")],B);import{customElement as Mr}from"lit/decorators.js";import{html as Nr,LitElement as Hr}from"lit";var S=class extends Hr{render(){return Nr``}process(){throw new Error("Not implemented")}};S=s([Mr("qti-rule")],S);import{html as Or}from"lit";var $e=class extends S{render(){return Or`<slot></slot>`}process(){let i=[...this.children];for(let e=0;e<i.length;e++){let t=i[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",$e);var Ie=class extends S{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,t=e?e.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}this.closest("qti-assessment-item").setOutcomeValue(i,t)}};customElements.define("qti-set-outcome-value",Ie);import{html as Pr}from"lit";import{html as Dr,LitElement as Vr}from"lit";var Z=class extends Vr{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Dr` <slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let i=this.getSubRules();for(let e=0;e<i.length;e++)i[e].process()}};customElements.define("qti-response-else",Z);var Q=class extends Z{render(){return Pr`${super.render()}`}calculate(){return this.firstElementChild.calculate()}getSubRules(){let i=[];for(let e=1;e<this.children.length;e++)i.push(this.children[e]);return i}};customElements.define("qti-response-if",Q);import{html as $r}from"lit";var Fe=class extends Q{render(){return $r`${super.render()}`}};customElements.define("qti-response-else-if",Fe);import{LitElement as Ir,html as Fr}from"lit";var u=class extends Ir{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,cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.assessmentItem.getResponse(t)}case"qti-multiple":{let r=e.calculate();return r.length>0?{baseType:r[0].baseType,value:r.map(o=>o.value),cardinality:"multiple"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.assessmentItem.getResponse(t);return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:return null}}).filter(e=>e!==null)}render(){return Fr``}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};customElements.define("qti-expression",u);var Ue=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Ue);import{html as Ur}from"lit";var N=class extends u{render(){return Ur``}calculate(){throw new Error("Not implemented")}};var Xe=class extends N{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Xe);import{html as Xr}from"lit";var Ye=class extends N{render(){return Xr``}calculate(){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();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).every(e=>typeof e=="boolean"&&e)}};customElements.define("qti-and",Ye);import{html as Yr}from"lit";var Be=class extends N{render(){return Yr``}calculate(){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();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Be);import{property as Br}from"lit/decorators.js";var A=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),o=parseInt(e,10);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),o=parseFloat(e);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),o=e.split(" ").sort();if(r.length===2&&o.length===2)return t==="pair"&&(r.sort(),o.sort()),r.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var me=class extends u{constructor(){super(...arguments);this.toleranceMode="exact"}calculate(){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):A.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([Br({type:String})],me.prototype,"toleranceMode",2);customElements.define("qti-equal",me);import{property as Kr}from"lit/decorators.js";var he=class extends u{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}calculate(){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 o=parseFloat(t.value),n=parseFloat(r.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};s([Kr({type:String})],he.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",he);import{property as zr}from"lit/decorators.js";var fe=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([zr({type:String})],fe.prototype,"baseType",2);customElements.define("qti-base-value",fe);var Ke=class extends u{calculate(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,o=t.value;return r.filter(c=>o.includes(c)).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",Ke);import{html as jr}from"lit";var ze=class extends u{render(){return jr``}get interpretation(){return this.getAttribute("interpretation")||""}calculate(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",ze);var je=class extends u{calculate(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",je);import{property as Gr}from"lit/decorators.js";var ge=class extends u{calculate(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],o=0;for(let n of r){let l=t.mapEntries.find(c=>A.compareSingleValues(c.mapKey,n,e.baseType));l==null||l.mappedValue==null?o+=t.defaultValue:o+=l.mappedValue}return t.lowerBound!=null&&(o=Math.max(t.lowerBound,o)),t.upperBound!=null&&(o=Math.min(t.upperBound,o)),o}};s([Gr({type:String})],ge.prototype,"identifier",2);customElements.define("qti-map-response",ge);var Ge=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(t.cardinality==="single")return Array.isArray(e.value)||Array.isArray(t.value)?(console.error("unexpected cardinality in qti match"),!1):A.compareSingleValues(e.value.toString(),t.value.toString(),t.baseType);{if(!Array.isArray(e.value)||!Array.isArray(t.value))return console.error("unexpected cardinality in qti match"),!1;if(e.value.length!==t.value.length)return!1;let r=0;for(let o of t.value){if(t.cardinality==="ordered"){let n=e[r];if(!A.compareSingleValues(o,n,t.baseType))return!1}else{let n=null;for(let l of e.value)if(A.compareSingleValues(o,l,t.baseType)){n=l;break}if(n!==null)e.value.splice(e.value.indexOf(n),1);else return!1}r++}return!0}}return console.error("unexpected number of children in match"),null}};customElements.define("qti-match",Ge);import{html as Wr}from"lit";var We=class extends u{render(){return Wr``}calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(i)}};customElements.define("qti-variable",We);var Je=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",Je);var Ze=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",Ze);import{property as Qe}from"lit/decorators.js";import{LitElement as Jr}from"lit";var K=class extends Jr{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")}))}};s([Qe({attribute:"default-value",type:Number})],K.prototype,"defaultValue",2),s([Qe({attribute:"lower-bound",type:Number})],K.prototype,"lowerBound",2),s([Qe({attribute:"upper-bound",type:Number})],K.prototype,"upperBound",2);customElements.define("qti-mapping",K);import{LitElement as Zr,html as qt}from"lit";var et=class extends Zr{constructor(){super(...arguments);this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},o=l=>{let c={},p=l.getAttribute("key");if(p){let d=Array.from(l.children),m=d.map(g=>g.getAttribute("key"));m.length>0&&!m.find(g=>!Number.isInteger(+g))?c[p]=d.map(g=>n(g)):c[p]=l.textContent}return c},n=l=>{if(l){let c={};for(let p of l.children)c=C(C({},c),o(p));return c}};for(let l of t)return l.getAttribute("key")||(r=C(C({},r),n(l))),r;console.log("Can not find qti-custom-interaction config")}register(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 o=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,o,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,o),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(l=>l.getAttribute("href")).forEach(l=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=l,r.appendChild(c)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}requirejs.config(e)(["require"],r=>{define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}})),r([this.module],()=>{},o=>{this._errorMessage=o})},r=>{this._errorMessage=r})}render(){return qt`<slot></slot>${this._errorMessage&&qt`<div style="color:red">
|
|
221
|
+
</qti-response-processing>`;var B=class extends Or{render(){return Hr`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){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(kt));break}case"map_response_point":{this.appendChild(this.fragmentFromString(wt));break}case"match_correct":this.appendChild(this.fragmentFromString(_t));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};B=s([Nr("qti-response-processing")],B);import{customElement as Dr}from"lit/decorators.js";import{html as Vr,LitElement as Pr}from"lit";var M=class extends Pr{render(){return Vr``}process(){throw new Error("Not implemented")}};M=s([Dr("qti-rule")],M);import{html as $r}from"lit";var Ie=class extends M{render(){return $r`<slot></slot>`}process(){let i=[...this.children];for(let e=0;e<i.length;e++){let t=i[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",Ie);var Fe=class extends M{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,t=e?e.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}this.closest("qti-assessment-item").setOutcomeValue(i,t)}};customElements.define("qti-set-outcome-value",Fe);import{html as Ur}from"lit";import{html as Ir,LitElement as Fr}from"lit";var Z=class extends Fr{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Ir` <slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let i=this.getSubRules();for(let e=0;e<i.length;e++)i[e].process()}};customElements.define("qti-response-else",Z);var Q=class extends Z{render(){return Ur`${super.render()}`}calculate(){return this.firstElementChild.calculate()}getSubRules(){let i=[];for(let e=1;e<this.children.length;e++)i.push(this.children[e]);return i}};customElements.define("qti-response-if",Q);import{html as Xr}from"lit";var Ue=class extends Q{render(){return Xr`${super.render()}`}};customElements.define("qti-response-else-if",Ue);import{LitElement as Yr,html as Br}from"lit";var u=class extends Yr{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,cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.assessmentItem.getResponse(t)}case"qti-multiple":{let r=e.calculate();return r.length>0?{baseType:r[0].baseType,value:r.map(o=>o.value),cardinality:"multiple"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.assessmentItem.getResponse(t);return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:return null}}).filter(e=>e!==null)}render(){return Br``}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};customElements.define("qti-expression",u);var Xe=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Xe);import{html as Kr}from"lit";var A=class extends u{render(){return Kr``}calculate(){throw new Error("Not implemented")}};var Ye=class extends A{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Ye);var Be=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Be);var Ke=class extends A{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Ke);import{html as zr}from"lit";var ze=class extends A{render(){return zr``}calculate(){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();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).every(e=>typeof e=="boolean"&&e)}};customElements.define("qti-and",ze);import{html as jr}from"lit";var je=class extends A{render(){return jr``}calculate(){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();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",je);import{property as Gr}from"lit/decorators.js";var T=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),o=parseInt(e,10);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),o=parseFloat(e);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),o=e.split(" ").sort();if(r.length===2&&o.length===2)return t==="pair"&&(r.sort(),o.sort()),r.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var me=class extends u{constructor(){super(...arguments);this.toleranceMode="exact"}calculate(){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):T.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([Gr({type:String})],me.prototype,"toleranceMode",2);customElements.define("qti-equal",me);import{property as Wr}from"lit/decorators.js";var he=class extends u{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}calculate(){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 o=parseFloat(t.value),n=parseFloat(r.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};s([Wr({type:String})],he.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",he);import{property as Jr}from"lit/decorators.js";var fe=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([Jr({type:String})],fe.prototype,"baseType",2);customElements.define("qti-base-value",fe);var Ge=class extends u{calculate(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,o=t.value;return r.filter(c=>o.includes(c)).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",Ge);import{html as Zr}from"lit";var We=class extends u{render(){return Zr``}get interpretation(){return this.getAttribute("interpretation")||""}calculate(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",We);var Je=class extends u{calculate(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Je);import{property as Qr}from"lit/decorators.js";var ge=class extends u{calculate(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],o=0;for(let n of r){let l=t.mapEntries.find(c=>T.compareSingleValues(c.mapKey,n,e.baseType));l==null||l.mappedValue==null?o+=t.defaultValue:o+=l.mappedValue}return t.lowerBound!=null&&(o=Math.max(t.lowerBound,o)),t.upperBound!=null&&(o=Math.min(t.upperBound,o)),o}};s([Qr({type:String})],ge.prototype,"identifier",2);customElements.define("qti-map-response",ge);var Ze=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(t.cardinality==="single")return Array.isArray(e.value)||Array.isArray(t.value)?(console.error("unexpected cardinality in qti match"),!1):T.compareSingleValues(e.value.toString(),t.value.toString(),t.baseType);{if(!Array.isArray(e.value)||!Array.isArray(t.value))return console.error("unexpected cardinality in qti match"),!1;if(e.value.length!==t.value.length)return!1;let r=0;for(let o of t.value){if(t.cardinality==="ordered"){let n=e[r];if(!T.compareSingleValues(o,n,t.baseType))return!1}else{let n=null;for(let l of e.value)if(T.compareSingleValues(o,l,t.baseType)){n=l;break}if(n!==null)e.value.splice(e.value.indexOf(n),1);else return!1}r++}return!0}}return console.error("unexpected number of children in match"),null}};customElements.define("qti-match",Ze);import{html as ei}from"lit";var Qe=class extends u{render(){return ei``}calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(i)}};customElements.define("qti-variable",Qe);var et=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",et);var tt=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",tt);import{property as rt}from"lit/decorators.js";import{LitElement as ti}from"lit";var K=class extends ti{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")}))}};s([rt({attribute:"default-value",type:Number})],K.prototype,"defaultValue",2),s([rt({attribute:"lower-bound",type:Number})],K.prototype,"lowerBound",2),s([rt({attribute:"upper-bound",type:Number})],K.prototype,"upperBound",2);customElements.define("qti-mapping",K);import{LitElement as ri,html as At}from"lit";var it=class extends ri{constructor(){super(...arguments);this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},o=l=>{let c={},p=l.getAttribute("key");if(p){let d=Array.from(l.children),m=d.map(g=>g.getAttribute("key"));m.length>0&&!m.find(g=>!Number.isInteger(+g))?c[p]=d.map(g=>n(g)):c[p]=l.textContent}return c},n=l=>{if(l){let c={};for(let p of l.children)c=C(C({},c),o(p));return c}};for(let l of t)return l.getAttribute("key")||(r=C(C({},r),n(l))),r;console.log("Can not find qti-custom-interaction config")}register(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 o=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,o,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,o),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(l=>l.getAttribute("href")).forEach(l=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=l,r.appendChild(c)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}requirejs.config(e)(["require"],r=>{define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}})),r([this.module],()=>{},o=>{this._errorMessage=o})},r=>{this._errorMessage=r})}render(){return At`<slot></slot>${this._errorMessage&&At`<div style="color:red">
|
|
222
222
|
<h1>Error</h1>
|
|
223
223
|
${this._errorMessage}
|
|
224
|
-
</div>`}`}};customElements.define("qti-portable-custom-interaction",et);import{LitElement as ei,css as ti,html as At}from"lit";var H=class{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return H._instance?H._instance:(H._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPositionFromEvent(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPositionFromEvent(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e,t=i.composedPath().find(r=>{if(r.nodeType===1&&r.nodeName!=="SLOT"&&r.hasAttribute("dropzone"))return r});if(t){let r=t.getRootNode(),o=this._getPoint(i);e=r.elementFromPoint(o.x,o.y)}return e}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}_getPositionFromEvent(i){let e;if(i.type=="touchstart"||i.type=="touchmove"||i.type=="touchend"||i.type=="touchcancel"){let t=typeof i.originalEvent=="undefined"?i:i.originalEvent,r=t.touches[0]||t.changedTouches[0];e={x:r.pageX,y:r.pageY}}else(i.type=="mousedown"||i.type=="mouseup"||i.type=="mousemove"||i.type=="mouseover"||i.type=="mouseout"||i.type=="mouseenter"||i.type=="mouseleave")&&(e={x:i.clientX,y:i.clientY});return e}};import{property as Qr}from"lit/decorators.js";var _t=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(n){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(n);let l=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),l.forEach(c=>{c.setAttribute("dropzone","move"),c.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(c)});for(let c of l)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{c.hasAttribute("disabled")?this.removeHandler(c):this.attachHandler(c);break}}})}),this.observer.observe(c,{attributes:!0})}attachHandler(n){n.addEventListener("dragover",this.dragoverHandler),n.addEventListener("drop",this.dropHandler)}removeHandler(n){n.removeEventListener("dragover",this.dragoverHandler),n.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var n;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(n=this.observer)==null||n.disconnect())}dragoverHandler(n){return n.preventDefault(),n.currentTarget.setAttribute("active",""),n.dataTransfer.dropEffect="move",!1}dropHandler(n){n.preventDefault();let l=n.currentTarget,c=this.querySelector(`[identifier=${n.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${n.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${n.target?JSON.stringify(n.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(n){return n.preventDefault(),n.currentTarget.removeAttribute("active"),!1}}return s([Qr({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var kt=(a,i,e)=>{class t extends a{}return t};import{property as z}from"lit/decorators.js";function wt(a,i){let e,t=C({},i);return(r,o)=>{let{connectedCallback:n,disconnectedCallback:l}=r;r.connectedCallback=function(){var d;n.call(this);let c=m=>{let x=Array.from(this.querySelectorAll(a));for(let g of m){let P=Array.from(g.addedNodes).map(L=>L),h=Array.from(g.addedNodes).map(L=>L);g.type==="childList"&&P.find(L=>x.includes(L))&&this[o](P,h)}};e=new MutationObserver(c),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(a))!=null?d:[];this[o](Array.from(p),[])},r.disconnectedCallback=function(){l.call(this),e.disconnect()}}}var R=(a,i,e,t)=>{class r extends kt(_t(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(l,c){if(this.classList.contains("qti-match-tabular"))return;l.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(l),l.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",m=>{m.dataTransfer.setData("text",m.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",m=>{if(m.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),m.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let x=m.currentTarget,g=this.draggables.get(x),P=g.index<g.parent.children.length?g.index:g.parent.children.length-1,h=g.parent,L=g.parent.children[P];h.insertBefore(x,L),this.saveResponse(),this.checkMaxMatchAssociations()}m.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(l,c){this.dragDropApi.copyStylesDragClone=c.copyStylesDragClone,this.dragDropApi.dragOnClick=c.dragOnClick}handleDisabledChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("disabled",""):d.removeAttribute("disabled"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("readonly",""):d.removeAttribute("readonly"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(l){super.firstUpdated(l),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new H,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(l=!0){this.draggables.forEach((c,p)=>{let d=c.parent.children,m=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[m])}),l&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(l=>{let p=+(l.getAttribute("match-max")||1)<=(l.children.length||0);p?l.setAttribute("disabled",""):l.removeAttribute("disabled"),p?l.removeAttribute("dropzone"):l.setAttribute("dropzone","move")})}set response(l){this.classList.contains("qti-match-tabular")||(this.reset(!1),l!==null&&Array.isArray(l)&&l.forEach(c=>{let[p,...d]=c.split(" ").reverse();if(p){let m=this.droppables.find(x=>x.getAttribute("identifier")===p);d.forEach(x=>{let g=this.querySelector(`[identifier=${x}]`);m?g?(m.appendChild(g),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${x}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let c=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=c}saveResponse(){let l=this.droppables.map(c=>{var d;let p="";return((d=c.children)==null?void 0:d.length)>0&&(p+=Array.from(c.children).map(m=>m.getAttribute("identifier")).join(" ")+" "),p+=c.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:l}}))}}return s([wt(i)],r.prototype,"reInitDragAndDrop",1),s([z({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([z({attribute:!1,type:Object})],r.prototype,"configuration",2),s([b("configuration")],r.prototype,"handleDragOptionsChanged",1),s([z({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([b("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([z({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([b("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([z({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([z({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as ri}from"lit/decorators.js";var ee=class extends R(ei,"qti-simple-associable-choice",!0,".dl"){render(){return At` <slot name="prompt"></slot>
|
|
224
|
+
</div>`}`}};customElements.define("qti-portable-custom-interaction",it);import{LitElement as si,css as oi,html as St}from"lit";var H=class{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return H._instance?H._instance:(H._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPositionFromEvent(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPositionFromEvent(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e,t=i.composedPath().find(r=>{if(r.nodeType===1&&r.nodeName!=="SLOT"&&r.hasAttribute("dropzone"))return r});if(t){let r=t.getRootNode(),o=this._getPoint(i);e=r.elementFromPoint(o.x,o.y)}return e}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}_getPositionFromEvent(i){let e;if(i.type=="touchstart"||i.type=="touchmove"||i.type=="touchend"||i.type=="touchcancel"){let t=typeof i.originalEvent=="undefined"?i:i.originalEvent,r=t.touches[0]||t.changedTouches[0];e={x:r.pageX,y:r.pageY}}else(i.type=="mousedown"||i.type=="mouseup"||i.type=="mousemove"||i.type=="mouseover"||i.type=="mouseout"||i.type=="mouseenter"||i.type=="mouseleave")&&(e={x:i.clientX,y:i.clientY});return e}};import{property as ii}from"lit/decorators.js";var Tt=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(n){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(n);let l=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),l.forEach(c=>{c.setAttribute("dropzone","move"),c.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(c)});for(let c of l)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{c.hasAttribute("disabled")?this.removeHandler(c):this.attachHandler(c);break}}})}),this.observer.observe(c,{attributes:!0})}attachHandler(n){n.addEventListener("dragover",this.dragoverHandler),n.addEventListener("drop",this.dropHandler)}removeHandler(n){n.removeEventListener("dragover",this.dragoverHandler),n.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var n;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(n=this.observer)==null||n.disconnect())}dragoverHandler(n){return n.preventDefault(),n.currentTarget.setAttribute("active",""),n.dataTransfer.dropEffect="move",!1}dropHandler(n){n.preventDefault();let l=n.currentTarget,c=this.querySelector(`[identifier=${n.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${n.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${n.target?JSON.stringify(n.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(n){return n.preventDefault(),n.currentTarget.removeAttribute("active"),!1}}return s([ii({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var Lt=(a,i,e)=>{class t extends a{}return t};import{property as z}from"lit/decorators.js";function Rt(a,i){let e,t=C({},i);return(r,o)=>{let{connectedCallback:n,disconnectedCallback:l}=r;r.connectedCallback=function(){var d;n.call(this);let c=m=>{let E=Array.from(this.querySelectorAll(a));for(let g of m){let P=Array.from(g.addedNodes).map(R=>R),h=Array.from(g.addedNodes).map(R=>R);g.type==="childList"&&P.find(R=>E.includes(R))&&this[o](P,h)}};e=new MutationObserver(c),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(a))!=null?d:[];this[o](Array.from(p),[])},r.disconnectedCallback=function(){l.call(this),e.disconnect()}}}var L=(a,i,e,t)=>{class r extends Lt(Tt(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(l,c){if(this.classList.contains("qti-match-tabular"))return;l.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(l),l.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",m=>{m.dataTransfer.setData("text",m.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",m=>{if(m.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),m.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let E=m.currentTarget,g=this.draggables.get(E),P=g.index<g.parent.children.length?g.index:g.parent.children.length-1,h=g.parent,R=g.parent.children[P];h.insertBefore(E,R),this.saveResponse(),this.checkMaxMatchAssociations()}m.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(l,c){this.dragDropApi.copyStylesDragClone=c.copyStylesDragClone,this.dragDropApi.dragOnClick=c.dragOnClick}handleDisabledChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("disabled",""):d.removeAttribute("disabled"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("readonly",""):d.removeAttribute("readonly"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(l){super.firstUpdated(l),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new H,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(l=!0){this.draggables.forEach((c,p)=>{let d=c.parent.children,m=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[m])}),l&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(l=>{let p=+(l.getAttribute("match-max")||1)<=(l.children.length||0);p?l.setAttribute("disabled",""):l.removeAttribute("disabled"),p?l.removeAttribute("dropzone"):l.setAttribute("dropzone","move")})}set response(l){this.classList.contains("qti-match-tabular")||(this.reset(!1),l!==null&&Array.isArray(l)&&l.forEach(c=>{let[p,...d]=c.split(" ").reverse();if(p){let m=this.droppables.find(E=>E.getAttribute("identifier")===p);d.forEach(E=>{let g=this.querySelector(`[identifier=${E}]`);m?g?(m.appendChild(g),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${E}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let c=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=c}saveResponse(){let l=this.droppables.map(c=>{var d;let p="";return((d=c.children)==null?void 0:d.length)>0&&(p+=Array.from(c.children).map(m=>m.getAttribute("identifier")).join(" ")+" "),p+=c.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:l}}))}}return s([Rt(i)],r.prototype,"reInitDragAndDrop",1),s([z({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([z({attribute:!1,type:Object})],r.prototype,"configuration",2),s([b("configuration")],r.prototype,"handleDragOptionsChanged",1),s([z({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([b("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([z({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([b("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([z({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([z({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as ni}from"lit/decorators.js";var ee=class extends L(si,"qti-simple-associable-choice",!0,".dl"){render(){return St` <slot name="prompt"></slot>
|
|
225
225
|
<slot name="qti-simple-associable-choice"></slot>
|
|
226
|
-
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>
|
|
226
|
+
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>St`<div part="associables-container">
|
|
227
227
|
<div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
|
|
228
228
|
<div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
|
|
229
|
-
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};ee.styles=
|
|
229
|
+
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};ee.styles=oi`
|
|
230
230
|
:host {
|
|
231
231
|
display: block; /* necessary to calculate scaling position */
|
|
232
232
|
}
|
|
@@ -235,8 +235,8 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
235
235
|
flex-wrap: wrap;
|
|
236
236
|
gap: 0.5rem;
|
|
237
237
|
}
|
|
238
|
-
`,s([
|
|
239
|
-
<slot part="drops"></slot>`}};be.styles=[
|
|
238
|
+
`,s([ni()],ee.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ee);import{css as ai,html as li,LitElement as ci}from"lit";var be=class extends L(ci,"qti-gap-text",!1,"qti-gap"){render(){return li` <slot part="drags" name="qti-gap-text"></slot>
|
|
239
|
+
<slot part="drops"></slot>`}};be.styles=[ai`
|
|
240
240
|
:host {
|
|
241
241
|
display: flex;
|
|
242
242
|
align-items: flex-start;
|
|
@@ -259,14 +259,14 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
259
259
|
align-items: flex-start;
|
|
260
260
|
flex: 1;
|
|
261
261
|
}
|
|
262
|
-
`];customElements.define("qti-gap-match-interaction",be);import{css as
|
|
262
|
+
`];customElements.define("qti-gap-match-interaction",be);import{css as pi,svg as Mt,html as di}from"lit";function j(a,i,e,t){switch(a){case"circle":{let[r,o,n]=i,l=r/e.width*100,c=o/e.height*100,p=n/e.width*100;t.style.left=l-p+"%",t.style.top=c-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,o,n,l]=i,c=r/e.width*100,p=o/e.height*100,d=n/e.width*100,m=l/e.height*100;t.style.left=c+"%",t.style.top=p+"%",t.style.width=d-c+"%",t.style.height=m-p+"%"}break;case"poly":{let r=i.reduce((h,R,lt,Pt)=>{if(lt%2===1){let $t=h.pop();h[h.length]={x:$t,y:Pt[lt]}}else h.push(R);return h},[]),o=Math.min(...r.map(h=>h.x)),n=Math.max(...r.map(h=>h.x)),l=Math.min(...r.map(h=>h.y)),c=Math.max(...r.map(h=>h.y)),p=o/e.width*100,d=l/e.height*100,m=n/e.width*100,E=c/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=l/e.height*100+"%",t.style.width=m-p+"%",t.style.height=E-d+"%";let P=r.map(h=>({x:(h.x-o)/(n-o)*100,y:(h.y-l)/(c-l)*100})).map(h=>Math.round(h.x)+"% "+Math.round(h.y)+"%").join(",");t.style.clipPath=`polygon(${P})`}break;default:break}}import{query as ui,queryAssignedElements as mi,state as st}from"lit/decorators.js";import{repeat as hi}from"lit/directives/repeat.js";import{ifDefined as Nt}from"lit/directives/if-defined.js";var N=class extends f{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 response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,o;return di`<slot name="prompt"></slot>
|
|
263
263
|
<line-container>
|
|
264
264
|
<svg
|
|
265
|
-
width=${
|
|
266
|
-
height=${
|
|
265
|
+
width=${Nt((e=this.grImage[0])==null?void 0:e.width)}
|
|
266
|
+
height=${Nt((t=this.grImage[0])==null?void 0:t.height)}
|
|
267
267
|
viewbox="0 0 ${(r=this.grImage[0])==null?void 0:r.width} ${(o=this.grImage[0])==null?void 0:o.height}"
|
|
268
268
|
>
|
|
269
|
-
${
|
|
269
|
+
${hi(this._lines,n=>n,(n,l)=>Mt`
|
|
270
270
|
<line
|
|
271
271
|
part="line"
|
|
272
272
|
x1=${parseInt(this.querySelector("[identifier="+n.split(" ")[0]+"]").style.left)}
|
|
@@ -278,7 +278,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
278
278
|
@click=${c=>{c.stopPropagation(),this._lines=this._lines.filter((p,d)=>d!==l),this.saveResponse(this._lines)}}
|
|
279
279
|
/>
|
|
280
280
|
`)}
|
|
281
|
-
${this.startPoint&&
|
|
281
|
+
${this.startPoint&&Mt`<line
|
|
282
282
|
part="point"
|
|
283
283
|
x1=${this.startCoord.x}
|
|
284
284
|
y1=${this.startCoord.y}
|
|
@@ -289,7 +289,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
289
289
|
/>`}
|
|
290
290
|
</svg>
|
|
291
291
|
<slot></slot>
|
|
292
|
-
</line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));j(n,l,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=document.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)}};
|
|
292
|
+
</line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));j(n,l,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=document.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)}};N.styles=[pi`
|
|
293
293
|
slot:not([name='prompt']) {
|
|
294
294
|
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
295
295
|
display: block;
|
|
@@ -312,8 +312,8 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
312
312
|
top: 0px;
|
|
313
313
|
left: 0px;
|
|
314
314
|
}
|
|
315
|
-
`],s([
|
|
316
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=n;t.style.left=l-p+"px",t.style.top=c-p+"px",t.style.width=t.style.height=2*p+"px"}break;case"rect":{let[l,c,p,d]=n;t.style.left=l+"px",t.style.top=c+"px",t.style.width=p-l+"px",t.style.height=d-c+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ve.styles=
|
|
315
|
+
`],s([st()],N.prototype,"_lines",2),s([st()],N.prototype,"startCoord",2),s([st()],N.prototype,"mouseCoord",2),s([ui("svg")],N.prototype,"svgContainer",2),s([mi({selector:"img"})],N.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",N);import{css as fi,html as gi,LitElement as bi}from"lit";var ve=class extends L(bi,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return gi` <slot></slot>
|
|
316
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=n;t.style.left=l-p+"px",t.style.top=c-p+"px",t.style.width=t.style.height=2*p+"px"}break;case"rect":{let[l,c,p,d]=n;t.style.left=l+"px",t.style.top=c+"px",t.style.width=p-l+"px",t.style.height=d-c+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ve.styles=fi`
|
|
317
317
|
:host {
|
|
318
318
|
display: inline-block;
|
|
319
319
|
position: relative;
|
|
@@ -322,12 +322,12 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
322
322
|
display: flex;
|
|
323
323
|
gap: 1rem;
|
|
324
324
|
}
|
|
325
|
-
`;customElements.define("qti-graphic-gap-match-interaction",ve);import{css as
|
|
325
|
+
`;customElements.define("qti-graphic-gap-match-interaction",ve);import{css as vi,html as yi}from"lit";var ye=class extends v{render(){return yi`
|
|
326
326
|
<slot name="prompt"></slot>
|
|
327
327
|
<!-- slot for the prompt -->
|
|
328
328
|
<slot></slot>
|
|
329
329
|
<!-- slot for the image and hotspots -->
|
|
330
|
-
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(n=>n.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(n=>n.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(n=>!!n.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(n=>(n.order>n.order&&n.order--,n)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));j(n,l,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};ye.styles=[
|
|
330
|
+
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(n=>n.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(n=>n.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(n=>!!n.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(n=>(n.order>n.order&&n.order--,n)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));j(n,l,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};ye.styles=[vi`
|
|
331
331
|
slot:not([name='prompt']) {
|
|
332
332
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
333
333
|
display: block;
|
|
@@ -338,12 +338,12 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
338
338
|
pointer-events: none;
|
|
339
339
|
user-select: none;
|
|
340
340
|
}
|
|
341
|
-
`];customElements.define("qti-graphic-order-interaction",ye);import{css as
|
|
341
|
+
`];customElements.define("qti-graphic-order-interaction",ye);import{css as xi,html as Ei}from"lit";var xe=class extends v{render(){return Ei`
|
|
342
342
|
<slot name="prompt"></slot>
|
|
343
343
|
<!-- slot for the prompt -->
|
|
344
344
|
<slot></slot>
|
|
345
345
|
<!-- slot for the image and hotspots -->
|
|
346
|
-
`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));j(o,n,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};
|
|
346
|
+
`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));j(o,n,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};xe.styles=[xi`
|
|
347
347
|
slot:not([name='prompt']) {
|
|
348
348
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
349
349
|
display: block;
|
|
@@ -355,10 +355,10 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
355
355
|
user-select: none;
|
|
356
356
|
/* width:100%; */
|
|
357
357
|
}
|
|
358
|
-
`];customElements.define("qti-hotspot-interaction",
|
|
358
|
+
`];customElements.define("qti-hotspot-interaction",xe);import{html as te,LitElement as _i}from"lit";import{html as Ci,LitElement as qi}from"lit";var ot=class extends qi{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return Ci`
|
|
359
359
|
<slot></slot>
|
|
360
360
|
<slot name="qti-simple-associable-choice"></slot>
|
|
361
|
-
`}};customElements.define("qti-simple-associable-choice",
|
|
361
|
+
`}};customElements.define("qti-simple-associable-choice",ot);var Ee=class extends L(_i,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){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"))}render(){return this.classList.contains("qti-match-tabular")?te`<table>
|
|
362
362
|
<tr>
|
|
363
363
|
<td><slot name="prompt"></slot></td>
|
|
364
364
|
${this.cols.map((e,t)=>te`<th>${e.innerHTML}</th>`)}
|
|
@@ -367,14 +367,14 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
367
367
|
<td>${e.innerHTML}</td>
|
|
368
368
|
${this.cols.map((t,r)=>te`<td><input type="checkbox" /></td>`)}
|
|
369
369
|
</tr>`)}
|
|
370
|
-
</table>`:te`<slot name="prompt"></slot> <slot></slot>`}};
|
|
371
|
-
<slot></slot>`}connectedCallback(){super.connectedCallback()}};Ce.styles=[
|
|
370
|
+
</table>`:te`<slot name="prompt"></slot> <slot></slot>`}};Ee.styles=[];customElements.define("qti-match-interaction",Ee);import{css as ki,html as wi}from"lit";var Ce=class extends f{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return $(C({},f.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return wi` <slot name="prompt"></slot>
|
|
371
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback()}};Ce.styles=[ki``];customElements.define("qti-media-interaction",Ce);import{css as Ai,html as Ht,LitElement as Ti}from"lit";import{property as Li}from"lit/decorators.js";var G=class extends L(Ti,"qti-simple-choice",!0,"drop-list"){render(){return Ht` <slot name="prompt"> </slot>
|
|
372
372
|
<div part="container">
|
|
373
373
|
<slot part="drags"> </slot>
|
|
374
374
|
<div part="drops">
|
|
375
|
-
${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>
|
|
375
|
+
${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>Ht`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
|
|
376
376
|
</div>
|
|
377
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};G.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],G.styles=[
|
|
377
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};G.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],G.styles=[Ai`
|
|
378
378
|
[part='drags'] {
|
|
379
379
|
display: flex;
|
|
380
380
|
align-items: flex-start;
|
|
@@ -422,7 +422,7 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
422
422
|
:host(.qti-choices-right) [part='container'] {
|
|
423
423
|
flex-direction: row-reverse;
|
|
424
424
|
}
|
|
425
|
-
`],s([
|
|
425
|
+
`],s([Li({type:String})],G.prototype,"orientation",2);customElements.define("qti-order-interaction",G);import{LitElement as Ri,css as Si,html as Mi}from"lit";var qe=class extends Ri{render(){return Mi`<slot></slot>`}};qe.styles=[Si`
|
|
426
426
|
:host {
|
|
427
427
|
display: block;
|
|
428
428
|
}
|
|
@@ -433,22 +433,22 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
433
433
|
left: 50%;
|
|
434
434
|
transform: translateX(-50%);
|
|
435
435
|
}
|
|
436
|
-
`];customElements.define("qti-position-object-interaction",qe);import{LitElement as
|
|
436
|
+
`];customElements.define("qti-position-object-interaction",qe);import{LitElement as Ni,css as Hi,html as Oi}from"lit";var _e=class extends Ni{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return Oi`<slot></slot>`}dragElementHandler(e){e.preventDefault();let t=e.clientX-this.startX,r=e.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+t+"px",this.dragElement.style.top=this.dragElement.offsetTop+r+"px",this.startX=e.clientX,this.startY=e.clientY}connectedCallback(){super.connectedCallback(),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(e){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};_e.styles=[Hi`
|
|
437
437
|
:host {
|
|
438
438
|
display: inline-block;
|
|
439
439
|
position: relative;
|
|
440
440
|
}
|
|
441
|
-
`];customElements.define("qti-position-object-stage",_e);import{css as
|
|
441
|
+
`];customElements.define("qti-position-object-stage",_e);import{css as Di,html as Ot}from"lit";import{property as Dt,state as Vi}from"lit/decorators.js";import{repeat as Pi}from"lit/directives/repeat.js";import{styleMap as $i}from"lit/directives/style-map.js";var V=class extends f{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return Ot` <slot name="prompt"></slot>
|
|
442
442
|
<point-container>
|
|
443
|
-
${
|
|
443
|
+
${Pi(this._points,e=>e,(e,t)=>Ot`
|
|
444
444
|
<button
|
|
445
445
|
part="point"
|
|
446
|
-
style=${
|
|
446
|
+
style=${$i({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
|
|
447
447
|
@click=${r=>{r.stopPropagation(),this._points=this._points.filter((o,n)=>n!==t),this.saveResponse(this._points)}}
|
|
448
448
|
></button>
|
|
449
449
|
`)}
|
|
450
450
|
<slot></slot>
|
|
451
|
-
</point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set response(e){this._points=Array.isArray(e)?e:[e]}connectedCallback(){super.connectedCallback(),this.querySelector("img").addEventListener("click",t=>{let r=t.offsetX,o=t.offsetY;this._points=[...this._points,r+" "+o],this.saveResponse(this._points)})}disconnectedCallback(){super.disconnectedCallback()}};V.styles=[
|
|
451
|
+
</point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set response(e){this._points=Array.isArray(e)?e:[e]}connectedCallback(){super.connectedCallback(),this.querySelector("img").addEventListener("click",t=>{let r=t.offsetX,o=t.offsetY;this._points=[...this._points,r+" "+o],this.saveResponse(this._points)})}disconnectedCallback(){super.disconnectedCallback()}};V.styles=[Di`
|
|
452
452
|
host() {
|
|
453
453
|
display: block;
|
|
454
454
|
}
|
|
@@ -456,17 +456,26 @@ import{a as b,b as ot}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}fro
|
|
|
456
456
|
display: block;
|
|
457
457
|
position: relative;
|
|
458
458
|
}
|
|
459
|
-
`],s([
|
|
460
|
-
<div id="
|
|
461
|
-
|
|
462
|
-
|
|
459
|
+
`],s([Dt({type:Number,attribute:"max-choices"})],V.prototype,"maxChoices",2),s([Dt({type:Number,attribute:"min-choices"})],V.prototype,"minChoices",2),s([Vi()],V.prototype,"_points",2);customElements.define("qti-select-point-interaction",V);import{css as Ii,html as ke,nothing as nt}from"lit";import{property as W,query as Vt}from"lit/decorators.js";var x=class extends f{constructor(){super();this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{};this.csLive=getComputedStyle(this)}set min(e){this._min=e,this.value=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let t=parseInt(e);if(Number.isNaN(t)){console.error("QtiSliderInteraction: response is not a number");return}this.value=t}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);let e=(this.value-this.min)/(this.max-this.min)*100;return this.style.setProperty("--value-percentage",`${e}%`),this.setAttribute("aria-valuenow",this.value.toString()),ke`<slot name="prompt"></slot>
|
|
460
|
+
<div id="slider" part="slider">
|
|
461
|
+
${this.csLive.getPropertyValue("--show-bounds")=="true"?ke`<div id="bounds" part="bounds">
|
|
462
|
+
<div>${this._min}</div>
|
|
463
|
+
<div>${this._max}</div>
|
|
464
|
+
</div>`:nt}
|
|
465
|
+
${this.csLive.getPropertyValue("--show-ticks")=="true"?ke`<div id="ticks" part="ticks"></div>`:nt}
|
|
466
|
+
<div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove}>
|
|
467
|
+
<div id="knob" part="knob">
|
|
468
|
+
${this.csLive.getPropertyValue("--show-value")=="true"?ke`<div id="value" part="value">${this.value}</div>`:nt}
|
|
469
|
+
</div>
|
|
470
|
+
</div>
|
|
471
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=l=>{let{x:c}=this.getPositionFromEvent(l),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),l.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:o}=this.getPositionFromEvent(e),n=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),e.stopPropagation()}_onMouseDown(e){let t=n=>{let l=n.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),n.preventDefault(),n.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=r.touches[0]||r.changedTouches[0];t={x:o.pageX,y:o.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};x.styles=[Ii``],s([Vt("#knob")],x.prototype,"_knob",2),s([Vt("#rail")],x.prototype,"_rail",2),s([W({type:Number})],x.prototype,"value",2),s([W({type:Boolean,attribute:"step-label"})],x.prototype,"stepLabel",2),s([W({type:Boolean})],x.prototype,"reverse",2),s([W({type:Number,attribute:"lower-bound"})],x.prototype,"min",1),s([W({type:Number,attribute:"upper-bound"})],x.prototype,"max",1),s([W({type:Number,attribute:"step"})],x.prototype,"step",1),s([b("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"_handleDisabledChange",2),s([b("readonly",{waitUntilFirstUpdate:!0})],x.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",x);import{LitElement as Fi,css as Ui,html as Xi}from"lit";var we=class extends Fi{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return Xi` <slot name="qti-gap-img"></slot> `}};we.styles=Ui`
|
|
463
472
|
:host {
|
|
464
473
|
position: absolute;
|
|
465
474
|
}
|
|
466
|
-
`;customElements.define("qti-associable-hotspot",
|
|
475
|
+
`;customElements.define("qti-associable-hotspot",we);import{LitElement as Yi}from"lit";import{property as Bi}from"lit/decorators.js";var Ae=class extends Yi{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};s([Bi({type:Number,reflect:!0})],Ae.prototype,"tabindex",2);customElements.define("qti-gap-img",Ae);import{html as Ki,LitElement as zi}from"lit";import{property as ji}from"lit/decorators.js";var Te=class extends zi{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return Ki`<slot></slot>`}};s([ji({type:Number,reflect:!0})],Te.prototype,"tabindex",2);customElements.define("qti-gap-text",Te);import{html as Gi,LitElement as Wi}from"lit";import{property as Ji}from"lit/decorators.js";var Le=class extends Wi{constructor(){super(...arguments);this.tabindex=0}render(){return Gi` <slot name="qti-gap-text"></slot>`}};s([Ji({type:Number,reflect:!0})],Le.prototype,"tabindex",2);customElements.define("qti-gap",Le);import{css as Zi}from"lit";import{property as Qi}from"lit/decorators.js";var re=class extends y{};re.styles=Zi`
|
|
467
476
|
:host {
|
|
468
477
|
position: absolute;
|
|
469
478
|
}
|
|
470
|
-
`,s([
|
|
471
|
-
<slot></slot> `}};
|
|
472
|
-
<slot></slot> `}};ie=s([
|
|
479
|
+
`,s([Qi({attribute:"aria-ordervalue",type:Number,reflect:!0})],re.prototype,"order",2);customElements.define("qti-hotspot-choice",re);import{customElement as es}from"lit/decorators.js";import{html as ts}from"lit";var Re=class extends y{render(){return ts`<div part="ch"><div part="cha"></div></div>
|
|
480
|
+
<slot></slot> `}};Re=s([es("qti-hottext")],Re);import{LitElement as rs}from"lit";var at=class extends rs{};customElements.define("qti-inline-choice",at);import{customElement as is}from"lit/decorators.js";import{html as ss}from"lit";var ie=class extends y{render(){return ss`<div part="ch"><div part="cha"></div></div>
|
|
481
|
+
<slot></slot> `}};ie=s([is("qti-simple-choice")],ie);export{yt as Events,F as OutcomeVariable,ze as QtiAnd,q as QtiAssessmentItem,we as QtiAssociableHotspot,ee as QtiAssociateInteraction,fe as QtiBaseValue,y as QtiChoice,vt as QtiChoiceElementSelected,oe as QtiCompanionMaterialsInfo,Ge as QtiContains,We as QtiCorrect,me as QtiEqual,he as QtiEqualRounded,u as QtiExpression,w as QtiExtendedTextInteraction,ce as QtiFeedbackInline,Le as QtiGap,Ae as QtiGapImg,be as QtiGapMatchInteraction,Te as QtiGapText,N as QtiGraphicAssociateInteraction,ve as QtiGraphicGapMatchInteraction,ye as QtiGraphicOrderInteraction,Xe as QtiGt,Ye as QtiGte,re as QtiHotspotChoice,xe as QtiHotspotInteraction,Re as QtiHottext,$e as QtiHottextInteraction,at as QtiInlineChoice,ue as QtiInlineChoiceInteraction,dt as QtiInteractionChanged,bt as QtiInteractionResponse,Je as QtiIsNull,gt as QtiLooseChoice,Be as QtiLt,Ke as QtiLte,ge as QtiMapResponse,K as QtiMapping,Ze as QtiMatch,Ee as QtiMatchInteraction,Ce as QtiMediaInteraction,Oe as QtiModalFeedback,et as QtiMultiple,je as QtiOr,G as QtiOrderInteraction,tt as QtiOrdered,pt as QtiOutcomeChanged,He as QtiOutcomeDeclaration,it as QtiPortableCustomInteraction,_e as QtiPositionObjectStage,Me as QtiPrompt,ht as QtiRegisterChoice,ft as QtiRegisterHotspot,mt as QtiRegisterInteraction,ut as QtiRegisterVariable,Ie as QtiResponseCondition,X as QtiResponseDeclaration,Z as QtiResponseElse,Ue as QtiResponseElseIf,Q as QtiResponseIf,B as QtiResponseProcessing,M as QtiRule,qe as QtiSPositionObjectInteraction,V as QtiSelectPointInteraction,Fe as QtiSetOutcomeValue,ot as QtiSimpleAssociableChoice,x as QtiSliderInteraction,Se as QtiStylesheet,S as QtiTextEntryInteraction,Qe as QtiVariable,I as ResponseVariable,ae as qtiContentBody,_ as qtiRubricBlock};
|