@citolab/qti-components 6.0.2 → 6.0.3-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ExpressionResult-b1ac7b27.d.ts +23 -0
- package/dist/chunk-DLLHO3W2.js +1 -0
- package/dist/chunk-M3YT56HW.js +1437 -0
- package/dist/custom-elements.json +4123 -17029
- package/dist/index.js +2237 -0
- package/dist/qti-assessment-item-219cef9e.d.ts +102 -0
- package/dist/qti-components/index.d.ts +184 -335
- package/dist/qti-components/index.js +146 -104
- package/dist/qti-components.js +13502 -0
- package/dist/qti-item/index.d.ts +13 -6
- package/dist/qti-item/index.js +1 -17
- package/dist/qti-item-react/index.d.ts +19 -0
- package/dist/qti-item-react/index.js +1 -0
- package/dist/qti-rule-5fe4f91e.d.ts +303 -0
- package/dist/qti-test/index.d.ts +2 -2
- package/dist/qti-test/index.js +13 -11
- package/dist/themes/qti.css +142 -112
- package/dist/vite.svg +1 -0
- package/package.json +1 -1
- package/dist/ExpressionResult-2192c3d8.d.ts +0 -33
- package/dist/chunk-2TX3IEPD.cjs +0 -1
- package/dist/chunk-HOQW4KDA.cjs +0 -1
- package/dist/chunk-JLKCCEGG.cjs +0 -1
- package/dist/chunk-JQY6IKDF.js +0 -1
- package/dist/chunk-L6436D6O.js +0 -1
- package/dist/qti-assessment-item-e9f437d6.d.ts +0 -117
- package/dist/qti-components/index.cjs +0 -403
- package/dist/qti-item/index.cjs +0 -17
- package/dist/qti-test/index.cjs +0 -12
- package/dist/qti-transform/index.cjs +0 -102
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}from"../chunk-NMCIOGD2.js";var at={};var lt={};var ct={};var pt={};var dt={};var ut={};var mt={};var ht={};var ft={};var gt={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 $=class{constructor(){this.value=0}};import{customElement as Nt,property as oe}from"lit/decorators.js";import{html as Ot,LitElement as Ht}from"lit";var q=class extends Ht{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 Ot`<slot></slot>`}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(a=>a.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 $?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",{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",{composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))}};s([oe({type:Boolean})],q.prototype,"disabled",2),s([oe({type:Boolean})],q.prototype,"readonly",2),s([oe({type:String})],q.prototype,"title",2),s([oe({type:String})],q.prototype,"identifier",2),s([g("disabled",{waitUntilFirstUpdate:!0})],q.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],q.prototype,"_handleReadonlyChange",2),q=s([Nt("qti-assessment-item")],q);import{LitElement as Dt}from"lit";var Re=class extends Dt{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",Re);import{customElement as Pt}from"lit/decorators.js";import{html as It,LitElement as $t}from"lit";import{css as Vt}from"lit";var bt=Vt`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
|
5
|
-
`;var
|
|
6
|
-
<slot></slot>`}};
|
|
5
|
+
`;var F=class extends $t{render(){return It` <slot name="qti-rubric-block"></slot>
|
|
6
|
+
<slot></slot>`}};F.styles=bt,F=s([Pt("qti-item-body")],F);import{html as Ft,LitElement as Ut}from"lit";var Te=class extends Ut{render(){return Ft` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",Te);import{html as Bt}from"lit/static-html.js";import{property as G}from"lit/decorators.js";import{LitElement as Xt}from"lit";var Yt={SPACE:32},y=class extends Xt{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 Yt.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"),Bt` <slot></slot> `}};s([G({type:String})],y.prototype,"identifier",2),s([G({type:Number,reflect:!0})],y.prototype,"tabindex",2),s([G({type:Boolean,reflect:!0})],y.prototype,"disabled",2),s([G({type:Boolean,reflect:!0})],y.prototype,"readonly",2),s([G({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:c=>c}})],y.prototype,"checked",2),s([g("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"handleDisabledChange",1);import{html as Kt,LitElement as zt}from"lit";var H=class extends zt{render(){return Kt``}};customElements.define("qti-variabledeclaration",H);import{property as Se}from"lit/decorators.js";var U=class extends H{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([Se({type:String,attribute:"base-type"})],U.prototype,"baseType",2),s([Se({type:String,attribute:"identifier"})],U.prototype,"identifier",2),s([Se({type:String,attribute:"cardinality"})],U.prototype,"cardinality",2);customElements.define("qti-response-declaration",U);var Le=class extends H{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 $;e.identifier=i,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};customElements.define("qti-outcome-declaration",Le);import{LitElement as jt}from"lit";import{customElement as Gt}from"lit/decorators.js";var ne=class extends jt{};ne=s([Gt("qti-companion-materials-info")],ne);import{LitElement as Wt,css as Qt,html as Jt}from"lit";import{customElement as Zt,property as ae}from"lit/decorators.js";import{ContextConsumer as er}from"@lit-labs/context";var _=class extends Wt{constructor(){super(...arguments);this.logger=new er(this,se,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 Jt`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};_.styles=Qt`
|
|
7
7
|
:host {
|
|
8
8
|
display: block;
|
|
9
9
|
}
|
|
10
|
-
`,s([
|
|
10
|
+
`,s([ae({type:String})],_.prototype,"id",2),s([ae({type:String})],_.prototype,"use",2),s([ae({type:String})],_.prototype,"view",2),s([ae({type:String,attribute:"class"})],_.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],_.prototype,"handleclassNamesChange",1),_=s([Zt("qti-rubric-block")],_);import{LitElement as tr,html as rr}from"lit";import{customElement as ir}from"lit/decorators.js";var le=class extends tr{render(){return rr`<slot></slot>`}};le=s([ir("qti-content-body")],le);import{css as or,html as nr}from"lit";import{LitElement as sr}from"lit";import{property as ce}from"lit/decorators.js";var k=class extends sr{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([ce({type:String,attribute:"show-hide"})],k.prototype,"showHide",2),s([ce({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),s([ce({type:String})],k.prototype,"identifier",2),s([ce({type:String,attribute:!1})],k.prototype,"showStatus",2);var pe=class extends k{constructor(){super(...arguments);this.render=()=>nr` <slot class="${this.showStatus}"></slot> `}};pe.styles=or`
|
|
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",
|
|
17
|
+
`;customElements.define("qti-feedback-inline",pe);import{html as ar}from"lit";var Me=class extends k{render(){return ar`
|
|
18
18
|
<style>
|
|
19
19
|
.on {
|
|
20
20
|
display: inline-block;
|
|
@@ -26,7 +26,7 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
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",Me);import{css as pr,html as dr}from"lit";import{ifDefined as Oe}from"lit/directives/if-defined.js";import{property as Ne}from"lit/decorators.js";import{LitElement as lr}from"lit";var b=class extends lr{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([Ne({attribute:"response-identifier"})],b.prototype,"responseIdentifier",2),s([Ne({reflect:!0,type:Boolean})],b.prototype,"disabled",2),s([Ne({reflect:!0,type:Boolean})],b.prototype,"readonly",2);import{css as cr}from"lit";var B=cr`
|
|
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 Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
106
106
|
:where([draggable='true']) {
|
|
107
107
|
-webkit-user-drag: element;
|
|
108
108
|
}
|
|
109
|
-
`;var
|
|
109
|
+
`;import{property as W}from"lit/decorators.js";var L=class extends b{constructor(){super(...arguments);this.value=""}set response(e){this.value=e!==void 0?e:""}validate(){return this.value!==""}static get styles(){return[B,pr`
|
|
110
110
|
/* PK: display host as block, else design will be collapsed */
|
|
111
111
|
:host {
|
|
112
112
|
display: inline-block;
|
|
@@ -114,21 +114,20 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
114
114
|
input {
|
|
115
115
|
padding: var(--qti-padding, 0.5rem);
|
|
116
116
|
}
|
|
117
|
-
`]}render(){return
|
|
118
|
-
<input
|
|
117
|
+
`]}render(){return dr` <input
|
|
119
118
|
spellcheck="false"
|
|
120
119
|
autocomplete="off"
|
|
121
120
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
122
121
|
@keyup="${this.textChanged}"
|
|
123
122
|
@change="${this.textChanged}"
|
|
124
123
|
type="text"
|
|
125
|
-
placeholder="${
|
|
124
|
+
placeholder="${Oe(this.placeholderText?this.placeholderText:void 0)}"
|
|
126
125
|
.value="${this.value}"
|
|
127
|
-
size="${
|
|
128
|
-
pattern="${
|
|
126
|
+
size="${Oe(this.expectedLength?this.expectedLength:void 0)}"
|
|
127
|
+
pattern="${Oe(this.patternMask?this.patternMask:void 0)}"
|
|
129
128
|
?disabled="${this.disabled}"
|
|
130
129
|
?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.saveResponse(
|
|
130
|
+
/>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse(t.value)}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([W({type:Number,attribute:"expected-length"})],L.prototype,"expectedLength",2),s([W({type:String,attribute:"pattern-mask"})],L.prototype,"patternMask",2),s([W({type:String,attribute:"placeholder-text"})],L.prototype,"placeholderText",2),s([W({type:String})],L.prototype,"value",2),s([W({type:String,attribute:"class"})],L.prototype,"classNames",2);customElements.define("qti-text-entry-interaction",L);import{css as ur,html as mr}from"lit";import{ifDefined as He}from"lit/directives/if-defined.js";import{ref as hr,createRef as fr}from"lit/directives/ref.js";import{property as de}from"lit/decorators.js";var M=class extends b{constructor(){super(...arguments);this.textareaRef=fr();this.value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let a=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(a))}})}set response(e){this.value=e!==void 0?e:""}validate(){return this.value!==""}static get styles(){return[B,ur`
|
|
132
131
|
/* PK: display host as block, else design will be collapsed */
|
|
133
132
|
:host {
|
|
134
133
|
display: block;
|
|
@@ -138,64 +137,104 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
138
137
|
width: 100%;
|
|
139
138
|
height: 100%;
|
|
140
139
|
}
|
|
141
|
-
`]}render(){return
|
|
142
|
-
${
|
|
140
|
+
`]}render(){return mr`<textarea
|
|
141
|
+
${hr(this.textareaRef)}
|
|
143
142
|
spellcheck="false"
|
|
144
143
|
autocomplete="off"
|
|
145
144
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
146
145
|
@keyup="${this.textChanged}"
|
|
147
146
|
@change="${this.textChanged}"
|
|
148
|
-
placeholder="${
|
|
149
|
-
maxlength="${
|
|
150
|
-
pattern="${
|
|
147
|
+
placeholder="${He(this.placeholderText?this.placeholderText:void 0)}"
|
|
148
|
+
maxlength="${He(this.expectedLength?this.expectedLength:void 0)}"
|
|
149
|
+
pattern="${He(this.patternMask?this.patternMask:void 0)}"
|
|
151
150
|
?disabled="${this.disabled}"
|
|
152
151
|
?readonly="${this.readonly}"
|
|
153
152
|
.value=${this.value}
|
|
154
|
-
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
<
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
:host {
|
|
174
|
-
box-sizing: border-box;
|
|
153
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(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"})],M.prototype,"expectedLength",2),s([de({type:String,attribute:"pattern-mask"})],M.prototype,"patternMask",2),s([de({type:String,attribute:"placeholder-text"})],M.prototype,"placeholderText",2),s([de({type:String,attribute:"class"})],M.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],M.prototype,"handleclassNamesChange",1);customElements.define("qti-extended-text-interaction",M);import{customElement as gr}from"lit/decorators.js";var ue=class extends y{};ue=s([gr("qti-hottext")],ue);import{html as br}from"lit";import{property as vt}from"lit/decorators.js";var v=class extends b{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([vt({type:Number,attribute:"min-choices"})],v.prototype,"minChoices",2),s([vt({type:Number,attribute:"max-choices"})],v.prototype,"maxChoices",2),s([g("disabled",{waitUntilFirstUpdate:!0})],v.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],v.prototype,"_handleReadonlyChange",2),s([g("maxChoices",{waitUntilFirstUpdate:!0})],v.prototype,"_handleMaxChoicesChange",2);var De=class extends v{constructor(){super(...arguments);this.render=()=>br`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",De);import{css as vr,html as yt}from"lit";var me=class extends b{constructor(){super();this.options=[];this.addEventListener(gt.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 P(C({},b.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[B,vr`
|
|
154
|
+
:host {
|
|
155
|
+
display: inline-block;
|
|
156
|
+
}
|
|
157
|
+
select {
|
|
158
|
+
width: 100%;
|
|
159
|
+
padding: var(--qti-padding-y) var(--qti-padding-x);
|
|
160
|
+
padding-right: calc(var(--qti-padding-x) + 1ch);
|
|
161
|
+
}
|
|
162
|
+
`]}render(){return yt` <select @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
|
|
163
|
+
${this.options.map(e=>yt` <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option> `)}
|
|
164
|
+
</select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>P(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=>P(C({},r),{selected:r.value===t})),this.saveResponse(t)}};me.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",me);import{customElement as xr,property as Er}from"lit/decorators.js";import{html as Cr}from"lit";import{css as yr}from"lit";var xt=yr`
|
|
165
|
+
::slotted(qti-simple-choice) {
|
|
166
|
+
--width: 22px;
|
|
167
|
+
--height: 22px;
|
|
168
|
+
display: inline-flex;
|
|
169
|
+
width: fit-content;
|
|
170
|
+
align-items: center;
|
|
171
|
+
gap: 0.2rem;
|
|
175
172
|
}
|
|
176
173
|
|
|
177
|
-
:
|
|
178
|
-
|
|
179
|
-
:host *::after {
|
|
180
|
-
box-sizing: inherit;
|
|
174
|
+
::slotted(qti-simple-choice:not([disabled])) {
|
|
175
|
+
cursor: pointer;
|
|
181
176
|
}
|
|
182
177
|
|
|
183
|
-
[
|
|
184
|
-
|
|
178
|
+
::slotted(qti-simple-choice[disabled]) {
|
|
179
|
+
opacity: 0.2;
|
|
185
180
|
}
|
|
186
|
-
`;var Be=Vt`
|
|
187
|
-
${ae}
|
|
188
181
|
|
|
189
|
-
:
|
|
190
|
-
|
|
182
|
+
::slotted(qti-simple-choice[role='checkbox']):before {
|
|
183
|
+
content: '';
|
|
184
|
+
min-height: var(--width);
|
|
185
|
+
min-width: var(--width);
|
|
186
|
+
box-shadow: inset 0 0 0 var(--qti-border-width) var(--qti-border-color);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
::slotted(qti-simple-choice[role='checkbox'])::after {
|
|
190
|
+
/* border-bottom: 3px solid var(--qti-primary-color);
|
|
191
|
+
border-left: 3px solid var(--qti-primary-color); */
|
|
192
|
+
content: '';
|
|
193
|
+
display: inline-block;
|
|
194
|
+
height: 5px;
|
|
195
|
+
opacity: 0;
|
|
196
|
+
position: absolute;
|
|
197
|
+
transform: translate(5px, -2px) rotate(-45deg);
|
|
198
|
+
width: 10px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
::slotted(qti-simple-choice[role='checkbox'][aria-checked='true']):after {
|
|
202
|
+
border-bottom: 3px solid var(--qti-primary-color);
|
|
203
|
+
border-left: 3px solid var(--qti-primary-color);
|
|
204
|
+
opacity: 1;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
::slotted(qti-simple-choice[role='radio']):before {
|
|
208
|
+
border-radius: 100%;
|
|
209
|
+
content: '';
|
|
210
|
+
min-height: 22px;
|
|
211
|
+
min-width: 22px;
|
|
212
|
+
box-shadow: inset 0 0 0 var(--qti-border-width) var(--qti-border-color);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
::slotted(qti-simple-choice[role='radio']):after {
|
|
216
|
+
background: var(--qti-primary-color);
|
|
217
|
+
border-radius: 100%;
|
|
218
|
+
content: '';
|
|
219
|
+
display: inline-block;
|
|
220
|
+
height: 14px;
|
|
221
|
+
margin-left: 4px;
|
|
222
|
+
opacity: 0;
|
|
223
|
+
position: absolute;
|
|
224
|
+
transform: scale(0.8);
|
|
225
|
+
width: 14px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
::slotted(qti-simple-choice[role='radio'][aria-checked='true']):after {
|
|
229
|
+
opacity: 1;
|
|
230
|
+
transform: scale(1);
|
|
191
231
|
}
|
|
192
|
-
`;var N=class extends y{constructor(){super(...arguments);this.render=()=>Ft`<slot name="prompt"></slot><slot></slot>`}};N.styles=Be,s([Gt({attribute:"orientation",type:String})],N.prototype,"orientation",2),N=s([$t("qti-choice-interaction")],N);import{customElement as Bt}from"lit/decorators.js";import{css as Ut}from"lit";var Xe=Ut`
|
|
193
|
-
${ae}
|
|
194
232
|
|
|
195
233
|
:host {
|
|
196
234
|
display: block;
|
|
235
|
+
position: relative;
|
|
197
236
|
}
|
|
198
|
-
`;var
|
|
237
|
+
`;var D=class extends v{constructor(){super(...arguments);this.render=()=>Cr`<slot name="prompt"></slot><slot></slot>`}};D.styles=xt,s([Er({type:String})],D.prototype,"orientation",2),D=s([xr("qti-choice-interaction")],D);import{customElement as qr}from"lit/decorators.js";var Q=class extends y{};Q=s([qr("qti-simple-choice")],Q);import{customElement as _r}from"lit/decorators.js";import{html as kr,LitElement as wr}from"lit";var Et=`<qti-response-processing>
|
|
199
238
|
<qti-response-condition>
|
|
200
239
|
<qti-response-if>
|
|
201
240
|
<qti-match>
|
|
@@ -212,7 +251,7 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
212
251
|
</qti-set-outcome-value>
|
|
213
252
|
</qti-response-else>
|
|
214
253
|
</qti-response-condition>
|
|
215
|
-
</qti-response-processing>`,
|
|
254
|
+
</qti-response-processing>`,Ct=`<qti-response-processing>
|
|
216
255
|
<qti-response-condition>
|
|
217
256
|
<qti-response-if>
|
|
218
257
|
<qti-is-null>
|
|
@@ -228,7 +267,7 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
228
267
|
</qti-set-outcome-value>
|
|
229
268
|
</qti-response-else>
|
|
230
269
|
</qti-response-condition>
|
|
231
|
-
</qti-response-processing>`,
|
|
270
|
+
</qti-response-processing>`,qt=`<qti-response-processing>
|
|
232
271
|
<qti-response-condition>
|
|
233
272
|
<qti-response-if>
|
|
234
273
|
<qti-is-null>
|
|
@@ -244,12 +283,15 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
244
283
|
</qti-set-outcome-value>
|
|
245
284
|
</qti-response-else>
|
|
246
285
|
</qti-response-condition>
|
|
247
|
-
</qti-response-processing>`;var F=class extends Kt{render(){return Yt`<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(Ke));break}case"map_response_point":{this.appendChild(this.fragmentFromString(Je));break}case"match_correct":this.appendChild(this.fragmentFromString(Ye));break}}let r=[...this.children];for(let e of r)e.process()}fragmentFromString(r){return document.createRange().createContextualFragment(r)}};F=s([Xt("qti-response-processing")],F);import{customElement as Jt}from"lit/decorators.js";import{html as zt,LitElement as Wt}from"lit";var J=class extends Wt{render(){return zt``}process(){throw new Error("Not implemented")}};J=s([Jt("qti-rule")],J);import{html as ze}from"lit";var Te=class extends m{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"),i={},l=o=>{let a={},d=o.getAttribute("key");if(d){let p=Array.from(o.children),h=p.map(f=>f.getAttribute("key"));h.length>0&&!h.find(f=>!Number.isInteger(+f))?a[d]=p.map(f=>n(f)):a[d]=o.textContent}return a},n=o=>{if(o){let a={};for(let d of o.children)a=E(E({},a),l(d));return a}};for(let o of t)return o.getAttribute("key")||(i=E(E({},i),n(o))),i;this.err("Can not find qti-custom-interaction config")}register(e){let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",i=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let l=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(i,l,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,l),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(o=>o.getAttribute("href")).forEach(o=>{let a=document.createElement("link");a.rel="stylesheet",a.type="text/css",a.media="screen",a.href=o,i.appendChild(a)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),requirejs.config(e)(["require"],i=>{define("qtiCustomInteractionContext",()=>({register:l=>{this.register(l)},notifyReady:()=>{}})),i([this.module],()=>{},l=>{this._errorMessage=l})},i=>{this._errorMessage=i})}render(){return ze`<slot></slot>${this._errorMessage&&ze`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}};customElements.define("qti-portable-custom-interaction",Te);import{css as jt,html as Ze}from"lit";var A=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(r,e){this.data[r]=e},getData:function(r){return this.data[r]},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=(r,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let i=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let l of i)this._dragCopy.style[l]=i.getPropertyValue(l);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="absolute",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 i=this;requestAnimationFrame(function(){i._touchEndCalled||i._dragCopy===null||(i._dragCopy.style.top=e.clientY-i._copyOffset.y+"px",i._dragCopy.style.left=e.clientX-i._copyOffset.x+"px")});var t=this._findDroppable(r);t!=this._lastTarget&&(this._dispatchEvent(t,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=t),this._currentDropContainer=t,this._currentDropContainer&&this._dispatchEvent(t,"dragover")}};return A._instance?A._instance:(A._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(r){r.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(r){this._touchBegin=Date.now();let{x:e,y:t}=this.getPositionFromEvent(r);if(this._touchDown={x:e,y:t},this._dragSrc=r.currentTarget,this._canDrag=!0,this.dragOnClick){let i={clientX:e,clientY:t};this._dragRunning=!0,this.createDragCopy(r,i)}r.preventDefault()}_touchMove(r){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this.getPositionFromEvent(r),i={clientX:e,clientY:t};this._getDelta(i)>=this._DRAGDELTA&&(this._dragRunning=!0),this.createDragCopy(r,i),r.preventDefault()}}_touchEnd(r){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(r){this._reset()}_findDroppable(r){let e,t=r.composedPath().find(i=>{if(i.nodeType===1&&i.nodeName!=="SLOT"&&i.hasAttribute("dropzone"))return i});if(t){let i=t.getRootNode(),l=this._getPoint(r);e=i.elementFromPoint(l.x,l.y)}return e}_getPoint(r,e){return r&&r.touches&&(r=r.touches[0]),{x:e?r.pageX:r.clientX,y:e?r.pageY:r.clientY}}_calculateDragCopyPosition(r){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=r.clientX-e.left,this._copyOffset.y=r.clientY-e.top}_getDelta(r){let e=Math.abs(r.clientX-this._touchDown.x),t=Math.abs(r.clientY-this._touchDown.y);return e+t}_dispatchEvent(r,e,t=!0){if(!r)return!1;let i=new CustomEvent(e,{bubbles:t,cancelable:!0});return i.dataTransfer=this._dataTransfer,r.dispatchEvent(i),i.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(r,e){this.data[r]=e},getData:function(r){return this.data[r]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}getPositionFromEvent(r){let e;if(r.type=="touchstart"||r.type=="touchmove"||r.type=="touchend"||r.type=="touchcancel"){let t=typeof r.originalEvent=="undefined"?r:r.originalEvent,i=t.touches[0]||t.changedTouches[0];e={x:i.pageX,y:i.pageY}}else(r.type=="mousedown"||r.type=="mouseup"||r.type=="mousemove"||r.type=="mouseover"||r.type=="mouseout"||r.type=="mouseenter"||r.type=="mouseleave")&&(e={x:r.clientX,y:r.clientY});return e}};import{property as Qt}from"lit/decorators.js";var We=(c,r,e)=>{class t extends c{constructor(){super(...arguments);this.disabled=!1}firstUpdated(n){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(n);let o=Array.from(r?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),o.forEach(a=>{a.setAttribute("dropzone","move"),a.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(a)});for(let a of o)this.observer=new MutationObserver(d=>{d.forEach(p=>{if(p.type==="attributes")switch(p.attributeName){case"disabled":{a.hasAttribute("disabled")?this.removeHandler(a):this.attachHandler(a);break}}})}),this.observer.observe(a,{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 o=n.currentTarget,a=this.querySelector(`[identifier=${n.dataTransfer.getData("text")}`),d=a||this.shadowRoot.querySelector(`[identifier=${n.dataTransfer.getData("text")}`);return o?d.parentElement.getAttribute("identifier")!==o.getAttribute("identifier")&&o.appendChild(d):console.error(`cannot find droppable, target: ${n.target?JSON.stringify(n.target):"null"}`),o.removeAttribute("active"),!1}dragleaveHandler(n){return n.preventDefault(),n.currentTarget.removeAttribute("active"),!1}}return s([Qt({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var Qe=(c,r,e)=>{class t extends c{}return t};import{property as U}from"lit/decorators.js";function je(c,r){let e,t=E({},r);return(i,l)=>{let{connectedCallback:n,disconnectedCallback:o}=i;i.connectedCallback=function(){var p;n.call(this);let a=h=>{let x=Array.from(this.querySelectorAll(c));for(let f of h){let D=Array.from(f.addedNodes).map(S=>S),u=Array.from(f.addedNodes).map(S=>S);f.type==="childList"&&D.find(S=>x.includes(S))&&this[l](D,u)}};e=new MutationObserver(a),e.observe(this,{childList:!0,subtree:!0});let d=(p=this.querySelectorAll(c))!=null?p:[];this[l](Array.from(d),[])},i.disconnectedCallback=function(){o.call(this),e.disconnect()}}}var w=(c,r,e,t)=>{class i extends Qe(We(c,e,t),t,r){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(o,a){if(this.classList.contains("qti-match-tabular"))return;o.filter(p=>!this.draggables||!this.draggables.get(p)).length>0&&(this.dragDropApi.addDraggables(o),o.forEach(p=>{this.draggables.set(p,{parent:p.parentElement,index:Array.from(p.parentNode.children).indexOf(p)}),p.setAttribute("qti-draggable","true"),p.addEventListener("dragstart",h=>{h.dataTransfer.setData("text",h.currentTarget.getAttribute("identifier")),p.setAttribute("dragging","")}),p.addEventListener("dragend",h=>{if(h.preventDefault(),p.removeAttribute("over"),p.removeAttribute("dragging"),h.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let x=h.currentTarget,f=this.draggables.get(x),D=f.index<f.parent.children.length?f.index:f.parent.children.length-1,u=f.parent,S=f.parent.children[D];u.insertBefore(x,S),this.saveResponse(),this.checkMaxMatchAssociations()}h.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(o,a){this.dragDropApi.copyStylesDragClone=a.copyStylesDragClone,this.dragDropApi.dragOnClick=a.dragOnClick}handleDisabledChange(o,a){this.draggables.forEach((d,p)=>{a?p.setAttribute("disabled",""):p.removeAttribute("disabled"),a?p.removeAttribute("qti-draggable"):p.setAttribute("qti-draggable","true")})}handleReadonlyChange(o,a){this.draggables.forEach((d,p)=>{a?p.setAttribute("readonly",""):p.removeAttribute("readonly"),a?p.removeAttribute("qti-draggable"):p.setAttribute("qti-draggable","true")})}firstUpdated(o){super.firstUpdated(o),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new A,this.dispatchEvent(new CustomEvent(g.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}reset(o=!0){this.draggables.forEach((a,d)=>{let p=a.parent.children,h=a.index<p.length?a.index:p.length;a.parent.insertBefore(d,p[h])}),o&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(o=>{let d=+(o.getAttribute("match-max")||1)<=(o.children.length||0);d?o.setAttribute("disabled",""):o.removeAttribute("disabled"),d?o.removeAttribute("dropzone"):o.setAttribute("dropzone","move")})}set response(o){this.classList.contains("qti-match-tabular")||(this.reset(!1),o!==null&&Array.isArray(o)&&o.forEach(a=>{let[d,...p]=a.split(" ").reverse();if(d){let h=this.droppables.find(x=>x.getAttribute("identifier")===d);p.forEach(x=>{let f=this.querySelector(`[identifier=${x}]`);h?f?(h.appendChild(f),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${x}`):console.error(`cannot find droppable with identifier: ${d}`)})}}))}validate(){let a=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(d=>d.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=a}saveResponse(){let a={list:{pair:this.droppables.map(d=>{var h;let p="";return((h=d.children)==null?void 0:h.length)>0&&(p+=Array.from(d.children).map(x=>x.getAttribute("identifier")).join(" ")+" "),p+=d.getAttribute("identifier"),p})}};this.dispatchEvent(new CustomEvent(g.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:a}}))}}return s([je(r)],i.prototype,"reInitDragAndDrop",1),s([U({type:String,attribute:"response-identifier"})],i.prototype,"responseIdentifier",2),s([U({type:Object})],i.prototype,"configuration",2),s([b("configuration")],i.prototype,"handleDragOptionsChanged",1),s([U({type:Boolean,reflect:!0})],i.prototype,"disabled",2),s([b("disabled",{waitUntilFirstUpdate:!0})],i.prototype,"handleDisabledChange",1),s([U({type:Boolean,reflect:!0})],i.prototype,"readonly",2),s([b("readonly",{waitUntilFirstUpdate:!0})],i.prototype,"handleReadonlyChange",1),s([U({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),s([U({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),i};import{state as Zt}from"lit/decorators.js";var z=class extends w(m,"qti-simple-associable-choice",!0,"drop-list"){render(){return Ze` <slot name="prompt"></slot>
|
|
286
|
+
</qti-response-processing>`;var X=class extends wr{render(){return kr`<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(Ct));break}case"map_response_point":{this.appendChild(this.fragmentFromString(qt));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)}};X=s([_r("qti-response-processing")],X);import{customElement as Ar}from"lit/decorators.js";import{html as Rr,LitElement as Tr}from"lit";var S=class extends Tr{render(){return Rr``}process(){throw new Error("Not implemented")}};S=s([Ar("qti-rule")],S);import{html as Sr}from"lit";var Ve=class extends S{render(){return Sr`<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",Ve);var Pe=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",Pe);import{html as Nr}from"lit";import{html as Lr,LitElement as Mr}from"lit";var J=class extends Mr{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Lr` <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",J);var Z=class extends J{render(){return Nr`${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",Z);import{html as Or}from"lit";var Ie=class extends Z{render(){return Or`${super.render()}`}};customElements.define("qti-response-else-if",Ie);import{LitElement as Hr,html as Dr}from"lit";var u=class extends Hr{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 Dr``}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};customElements.define("qti-expression",u);var $e=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",$e);import{html as Vr}from"lit";var N=class extends u{render(){return Vr``}calculate(){throw new Error("Not implemented")}};var Fe=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",Fe);import{html as Pr}from"lit";var Ue=class extends N{render(){return Pr``}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",Ue);import{html as Ir}from"lit";var Be=class extends N{render(){return Ir``}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 $r}from"lit/decorators.js";var w=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 he=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):w.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([$r({type:String})],he.prototype,"toleranceMode",2);customElements.define("qti-equal",he);import{property as Fr}from"lit/decorators.js";var fe=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),a=parseFloat(r.value);if(!isNaN(o)&&!isNaN(a))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${a}`);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([Fr({type:String})],fe.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",fe);import{property as Ur}from"lit/decorators.js";var ge=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([Ur({type:String})],ge.prototype,"baseType",2);customElements.define("qti-base-value",ge);var Xe=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(l=>o.includes(l)).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",Xe);import{html as Br}from"lit";var Ye=class extends u{render(){return Br``}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",Ye);var Ke=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",Ke);import{property as Xr}from"lit/decorators.js";var be=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 a of r){let n=t.mapEntries.find(l=>w.compareSingleValues(l.mapKey,a,e.baseType));n==null||n.mappedValue==null?o+=t.defaultValue:o+=n.mappedValue}return t.lowerBound!=null&&(o=Math.max(t.lowerBound,o)),t.upperBound!=null&&(o=Math.min(t.upperBound,o)),o}};s([Xr({type:String})],be.prototype,"identifier",2);customElements.define("qti-map-response",be);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):w.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 a=e[r];if(!w.compareSingleValues(o,a,t.baseType))return!1}else{let a=null;for(let n of e.value)if(w.compareSingleValues(o,n,t.baseType)){a=n;break}if(a!==null)e.value.splice(e.value.indexOf(a),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 Yr}from"lit";var je=class extends u{render(){return Yr``}calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(i)}};customElements.define("qti-variable",je);var Ge=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",Ge);var We=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",We);import{property as Qe}from"lit/decorators.js";import{LitElement as Kr}from"lit";var Y=class extends Kr{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})],Y.prototype,"defaultValue",2),s([Qe({attribute:"lower-bound",type:Number})],Y.prototype,"lowerBound",2),s([Qe({attribute:"upper-bound",type:Number})],Y.prototype,"upperBound",2);customElements.define("qti-mapping",Y);import{LitElement as zr,html as _t}from"lit";var Je=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=n=>{let l={},p=n.getAttribute("key");if(p){let d=Array.from(n.children),m=d.map(f=>f.getAttribute("key"));m.length>0&&!m.find(f=>!Number.isInteger(+f))?l[p]=d.map(f=>a(f)):l[p]=n.textContent}return l},a=n=>{if(n){let l={};for(let p of n.children)l=C(C({},l),o(p));return l}};for(let n of t)return n.getAttribute("key")||(r=C(C({},r),a(n))),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(n=>n.getAttribute("href")).forEach(n=>{let l=document.createElement("link");l.rel="stylesheet",l.type="text/css",l.media="screen",l.href=n,r.appendChild(l)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),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 _t`<slot></slot>${this._errorMessage&&_t`<div style="color:red">
|
|
287
|
+
<h1>Error</h1>
|
|
288
|
+
${this._errorMessage}
|
|
289
|
+
</div>`}`}};customElements.define("qti-portable-custom-interaction",Je);import{LitElement as Gr,css as Wr,html as Rt}from"lit";var O=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="absolute",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 O._instance?O._instance:(O._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 jr}from"lit/decorators.js";var kt=(c,i,e)=>{class t extends c{constructor(){super(...arguments);this.disabled=!1}firstUpdated(a){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(a);let n=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),n.forEach(l=>{l.setAttribute("dropzone","move"),l.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(l)});for(let l of n)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{l.hasAttribute("disabled")?this.removeHandler(l):this.attachHandler(l);break}}})}),this.observer.observe(l,{attributes:!0})}attachHandler(a){a.addEventListener("dragover",this.dragoverHandler),a.addEventListener("drop",this.dropHandler)}removeHandler(a){a.removeEventListener("dragover",this.dragoverHandler),a.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var a;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(a=this.observer)==null||a.disconnect())}dragoverHandler(a){return a.preventDefault(),a.currentTarget.setAttribute("active",""),a.dataTransfer.dropEffect="move",!1}dropHandler(a){a.preventDefault();let n=a.currentTarget,l=this.querySelector(`[identifier=${a.dataTransfer.getData("text")}`),p=l||this.shadowRoot.querySelector(`[identifier=${a.dataTransfer.getData("text")}`);return n?p.parentElement.getAttribute("identifier")!==n.getAttribute("identifier")&&n.appendChild(p):console.error(`cannot find droppable, target: ${a.target?JSON.stringify(a.target):"null"}`),n.removeAttribute("active"),!1}dragleaveHandler(a){return a.preventDefault(),a.currentTarget.removeAttribute("active"),!1}}return s([jr({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var wt=(c,i,e)=>{class t extends c{}return t};import{property as K}from"lit/decorators.js";function At(c,i){let e,t=C({},i);return(r,o)=>{let{connectedCallback:a,disconnectedCallback:n}=r;r.connectedCallback=function(){var d;a.call(this);let l=m=>{let E=Array.from(this.querySelectorAll(c));for(let f of m){let V=Array.from(f.addedNodes).map(T=>T),h=Array.from(f.addedNodes).map(T=>T);f.type==="childList"&&V.find(T=>E.includes(T))&&this[o](V,h)}};e=new MutationObserver(l),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(c))!=null?d:[];this[o](Array.from(p),[])},r.disconnectedCallback=function(){n.call(this),e.disconnect()}}}var A=(c,i,e,t)=>{class r extends wt(kt(c,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(n,l){if(this.classList.contains("qti-match-tabular"))return;n.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(n),n.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,f=this.draggables.get(E),V=f.index<f.parent.children.length?f.index:f.parent.children.length-1,h=f.parent,T=f.parent.children[V];h.insertBefore(E,T),this.saveResponse(),this.checkMaxMatchAssociations()}m.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(n,l){this.dragDropApi.copyStylesDragClone=l.copyStylesDragClone,this.dragDropApi.dragOnClick=l.dragOnClick}handleDisabledChange(n,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("disabled",""):d.removeAttribute("disabled"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(n,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("readonly",""):d.removeAttribute("readonly"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(n){super.firstUpdated(n),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new O,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(n=!0){this.draggables.forEach((l,p)=>{let d=l.parent.children,m=l.index<d.length?l.index:d.length;l.parent.insertBefore(p,d[m])}),n&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(n=>{let p=+(n.getAttribute("match-max")||1)<=(n.children.length||0);p?n.setAttribute("disabled",""):n.removeAttribute("disabled"),p?n.removeAttribute("dropzone"):n.setAttribute("dropzone","move")})}set response(n){this.classList.contains("qti-match-tabular")||(this.reset(!1),n!==null&&Array.isArray(n)&&n.forEach(l=>{let[p,...d]=l.split(" ").reverse();if(p){let m=this.droppables.find(E=>E.getAttribute("identifier")===p);d.forEach(E=>{let f=this.querySelector(`[identifier=${E}]`);m?f?(m.appendChild(f),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${E}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let l=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=l}saveResponse(){let n=this.droppables.map(l=>{var d;let p="";return((d=l.children)==null?void 0:d.length)>0&&(p+=Array.from(l.children).map(m=>m.getAttribute("identifier")).join(" ")+" "),p+=l.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:n}}))}}return s([At(i)],r.prototype,"reInitDragAndDrop",1),s([K({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([K({attribute:!1,type:Object})],r.prototype,"configuration",2),s([g("configuration")],r.prototype,"handleDragOptionsChanged",1),s([K({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([g("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([K({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([g("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([K({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([K({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as Qr}from"lit/decorators.js";var ee=class extends A(Gr,"qti-simple-associable-choice",!0,"drop-list"){render(){return Rt` <slot name="prompt"></slot>
|
|
248
290
|
<slot name="qti-simple-associable-choice"></slot>
|
|
249
|
-
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>
|
|
291
|
+
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Rt`<div part="associables-container">
|
|
250
292
|
<drop-list part="drop-list" identifier="droplist${t}_left"></drop-list>
|
|
251
293
|
<drop-list part="drop-list" identifier="droplist${t}_right"></drop-list>
|
|
252
|
-
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};
|
|
294
|
+
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};ee.styles=Wr`
|
|
253
295
|
:host {
|
|
254
296
|
display: block; /* necessary to calculate scaling position */
|
|
255
297
|
}
|
|
@@ -258,11 +300,11 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
258
300
|
flex-wrap: wrap;
|
|
259
301
|
gap: 0.5rem;
|
|
260
302
|
}
|
|
261
|
-
`,s([
|
|
303
|
+
`,s([Qr()],ee.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ee);import{html as Jr,LitElement as Zr}from"lit";var Ze=class extends Zr{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return Jr`
|
|
262
304
|
<slot></slot>
|
|
263
305
|
<slot name="qti-simple-associable-choice"></slot>
|
|
264
|
-
`}};customElements.define("qti-simple-associable-choice",
|
|
265
|
-
<slot></slot>`}};
|
|
306
|
+
`}};customElements.define("qti-simple-associable-choice",Ze);import{css as ei,html as ti,LitElement as ri}from"lit";var ve=class extends A(ri,"qti-gap-text",!1,"qti-gap"){render(){return ti` <slot name="qti-gap-text"></slot>
|
|
307
|
+
<slot></slot>`}};ve.styles=ei`
|
|
266
308
|
:host {
|
|
267
309
|
display: block; /* necessary to calculate scaling position */
|
|
268
310
|
}
|
|
@@ -272,12 +314,12 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
272
314
|
gap: var(--qti-gap, 0.5rem);
|
|
273
315
|
padding: var(--qti-gap, 0.5rem) 0px;
|
|
274
316
|
}
|
|
275
|
-
`;customElements.define("qti-gap-match-interaction",
|
|
317
|
+
`;customElements.define("qti-gap-match-interaction",ve);import{html as ii,LitElement as si}from"lit";var et=class extends si{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return ii`<slot></slot>`}};customElements.define("qti-gap-text",et);import{html as oi,LitElement as ni}from"lit";var tt=class extends ni{render(){return oi` <slot name="qti-gap-text"></slot>`}};customElements.define("qti-gap",tt);import{LitElement as ai}from"lit";var rt=class extends ai{};customElements.define("qti-inline-choice",rt);import{css as li,html as ci}from"lit";function z(c,i,e,t){switch(c){case"circle":{let[r,o,a]=i,n=r/e.width*100,l=o/e.height*100,p=a/e.width*100;t.style.left=n-p+"%",t.style.top=l-p+"%",t.style.width=t.style.height=4*p+"px",t.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{let[r,o,a,n]=i,l=r/e.width*100,p=o/e.height*100,d=a/e.width*100,m=n/e.height*100;t.style.left=l+"%",t.style.top=p+"%",t.style.width=d-l+"%",t.style.height=m-p+"%"}break;case"poly":{let r=i.reduce((h,T,nt,Lt)=>{if(nt%2===1){let Mt=h.pop();h[h.length]={x:Mt,y:Lt[nt]}}else h.push(T);return h},[]),o=Math.min(...r.map(h=>h.x)),a=Math.max(...r.map(h=>h.x)),n=Math.min(...r.map(h=>h.y)),l=Math.max(...r.map(h=>h.y)),p=o/e.width*100,d=n/e.height*100,m=a/e.width*100,E=l/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=n/e.height*100+"%",t.style.width=m-p+"%",t.style.height=E-d+"%";let V=r.map(h=>({x:(h.x-o)/(a-o)*100,y:(h.y-n)/(l-n)*100})).map(h=>Math.round(h.x)+"% "+Math.round(h.y)+"%").join(",");t.style.clipPath=`polygon(${V})`}break;default:break}}var ye=class extends v{render(){return ci`
|
|
276
318
|
<slot name="prompt"></slot>
|
|
277
319
|
<!-- slot for the prompt -->
|
|
278
320
|
<slot></slot>
|
|
279
321
|
<!-- slot for the image and hotspots -->
|
|
280
|
-
`}positionHotspotOnRegister(e){let t=this.querySelector("img"),
|
|
322
|
+
`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),n=o.split(",").map(l=>parseInt(l));z(a,n,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ye.styles=[li`
|
|
281
323
|
slot:not([name='prompt']) {
|
|
282
324
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
283
325
|
display: block;
|
|
@@ -288,18 +330,18 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
288
330
|
pointer-events: none;
|
|
289
331
|
user-select: none;
|
|
290
332
|
}
|
|
291
|
-
`];customElements.define("qti-graphic-associate-interaction",
|
|
292
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(
|
|
293
|
-
slot[name=
|
|
333
|
+
`];customElements.define("qti-graphic-associate-interaction",ye);import{css as pi,html as di,LitElement as ui}from"lit";var xe=class extends A(ui,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return di` <slot></slot>
|
|
334
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=i.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),o=t.split(",").map(a=>parseInt(a));switch(r){case"circle":{let[a,n,l]=o;e.style.left=a-l+"px",e.style.top=n-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[a,n,l,p]=o;e.style.left=a+"px",e.style.top=n+"px",e.style.width=l-a+"px",e.style.height=p-n+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};xe.styles=pi`
|
|
335
|
+
slot[name='qti-gap-img'] {
|
|
294
336
|
display: flex;
|
|
295
337
|
gap: 1rem;
|
|
296
338
|
}
|
|
297
|
-
`;customElements.define("qti-graphic-gap-match-interaction",
|
|
339
|
+
`;customElements.define("qti-graphic-gap-match-interaction",xe);import{css as mi,html as hi}from"lit";var Ee=class extends v{render(){return hi`
|
|
298
340
|
<slot name="prompt"></slot>
|
|
299
341
|
<!-- slot for the prompt -->
|
|
300
342
|
<slot></slot>
|
|
301
343
|
<!-- slot for the image and hotspots -->
|
|
302
|
-
`}setHotspotOrder(e){let{identifier:t}=e.detail,
|
|
344
|
+
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),n=o.split(",").map(l=>parseInt(l));z(a,n,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)}};Ee.styles=[mi`
|
|
303
345
|
slot:not([name='prompt']) {
|
|
304
346
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
305
347
|
display: block;
|
|
@@ -310,12 +352,12 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
310
352
|
pointer-events: none;
|
|
311
353
|
user-select: none;
|
|
312
354
|
}
|
|
313
|
-
`];customElements.define("qti-graphic-order-interaction",
|
|
355
|
+
`];customElements.define("qti-graphic-order-interaction",Ee);import{css as fi,html as gi}from"lit";var Ce=class extends v{render(){return gi`
|
|
314
356
|
<slot name="prompt"></slot>
|
|
315
357
|
<!-- slot for the prompt -->
|
|
316
358
|
<slot></slot>
|
|
317
359
|
<!-- slot for the image and hotspots -->
|
|
318
|
-
`}positionHotspotOnRegister(
|
|
360
|
+
`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(n=>parseInt(n));z(o,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};Ce.styles=[fi`
|
|
319
361
|
slot:not([name='prompt']) {
|
|
320
362
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
321
363
|
display: block;
|
|
@@ -325,44 +367,21 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
325
367
|
/* image not selectable anymore */
|
|
326
368
|
pointer-events: none;
|
|
327
369
|
user-select: none;
|
|
370
|
+
/* width:100%; */
|
|
328
371
|
}
|
|
329
|
-
`];customElements.define("qti-hotspot-interaction",
|
|
372
|
+
`];customElements.define("qti-hotspot-interaction",Ce);import{css as bi}from"lit";import{property as vi}from"lit/decorators.js";var te=class extends y{};te.styles=bi`
|
|
330
373
|
:host {
|
|
331
374
|
position: absolute;
|
|
332
375
|
}
|
|
333
|
-
`,s([vi({attribute:"aria-ordervalue",type:Number,reflect:!0})],
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
z-index: 100000;
|
|
337
|
-
top: 0;
|
|
338
|
-
bottom: 0;
|
|
339
|
-
right: 0;
|
|
340
|
-
left: 0;
|
|
341
|
-
/* background: repeating-linear-gradient(45deg, #606cbc00, #606cbc00 10px, #4652980f 10px, #4652980f 20px); */
|
|
342
|
-
}
|
|
343
|
-
.notification:after {
|
|
344
|
-
position: absolute;
|
|
345
|
-
right: 1rem;
|
|
346
|
-
top: 1rem;
|
|
347
|
-
background-color: #222222;
|
|
348
|
-
color: #dddddd;
|
|
349
|
-
font-size: 14px;
|
|
350
|
-
width: fit-content;
|
|
351
|
-
padding: 0.4rem 0.6rem;
|
|
352
|
-
border-radius: 99999px;
|
|
353
|
-
content: 'preview not interactive';
|
|
354
|
-
}
|
|
355
|
-
`;var he=class extends w(xi,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){render(){return Ei`
|
|
356
|
-
<slot name="prompt"></slot>
|
|
357
|
-
<slot></slot>`}};he.styles=[M];customElements.define("qti-match-interaction",he);import{css as Ci,html as _i}from"lit";var ue=class extends v{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return L(E({},v.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return _i`
|
|
358
|
-
<slot name="prompt"></slot>
|
|
359
|
-
<slot></slot>`}connectedCallback(){super.connectedCallback()}};ue.styles=[M,Ci``];customElements.define("qti-media-interaction",ue);import{css as qi,html as et}from"lit";var Q=class extends w(m,"qti-simple-choice",!0,"drop-list"){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return et` <slot name="prompt"> </slot>
|
|
376
|
+
`,s([vi({attribute:"aria-ordervalue",type:Number,reflect:!0})],te.prototype,"order",2);customElements.define("qti-hotspot-choice",te);import{html as yi,LitElement as xi}from"lit";var qe=class extends A(xi,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){render(){return yi` <slot name="prompt"></slot>
|
|
377
|
+
<slot></slot>`}};qe.styles=[];customElements.define("qti-match-interaction",qe);import{css as Ei,html as Ci}from"lit";var _e=class extends b{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return P(C({},b.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return Ci` <slot name="prompt"></slot>
|
|
378
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback()}};_e.styles=[Ei``];customElements.define("qti-media-interaction",_e);import{css as qi,html as Tt,LitElement as _i}from"lit";var re=class extends A(_i,"qti-simple-choice",!0,"drop-list"){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return Tt` <slot name="prompt"> </slot>
|
|
360
379
|
<div class=${`container ${this._classNames}`}>
|
|
361
380
|
<slot class=${this._orientation==="vertical"?"ver":"hor"}> </slot>
|
|
362
381
|
<div class=${this._orientation==="vertical"?"ver":"hor"}>
|
|
363
|
-
${this.childrenMap.map((e,t)=>
|
|
382
|
+
${this.childrenMap.map((e,t)=>Tt`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
|
|
364
383
|
</div>
|
|
365
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};
|
|
384
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};re.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],re.styles=[qi`
|
|
366
385
|
.hor {
|
|
367
386
|
display: grid;
|
|
368
387
|
gap: var(--qti-gap, 2px);
|
|
@@ -370,7 +389,7 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
370
389
|
grid-auto-columns: 1fr;
|
|
371
390
|
}
|
|
372
391
|
.ver {
|
|
373
|
-
width:50%;
|
|
392
|
+
width: 50%;
|
|
374
393
|
display: grid;
|
|
375
394
|
gap: var(--qti-gap, 2px);
|
|
376
395
|
grid-auto-flow: row;
|
|
@@ -396,8 +415,31 @@ import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.j
|
|
|
396
415
|
content: 'drop here';
|
|
397
416
|
color: var(--qti-placeholder-text);
|
|
398
417
|
}
|
|
399
|
-
`];customElements.define("qti-order-interaction",
|
|
400
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}};
|
|
401
|
-
<div
|
|
418
|
+
`];customElements.define("qti-order-interaction",re);import{html as ki}from"lit";var ke=class extends v{constructor(){super()}render(){return ki`<slot></slot>
|
|
419
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}};ke.styles=[];customElements.define("qti-select-point-interaction",ke);import{css as wi,html as Ai}from"lit";import{property as j,query as St}from"lit/decorators.js";var x=class extends b{constructor(){super(...arguments);this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=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 Ai`<slot name="prompt"></slot>
|
|
420
|
+
<div
|
|
421
|
+
id="rail"
|
|
422
|
+
@mousedown=${this._onMouseDown}
|
|
423
|
+
@touchstart=${this._onTouchMove}
|
|
424
|
+
part="rail"
|
|
425
|
+
>
|
|
402
426
|
<div id="knob" part="knob" style="left:${e}%"></div>
|
|
403
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=
|
|
427
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=n=>{let{x:l}=this.getPositionFromEvent(n),p=l-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),n.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),a=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(a),e.stopPropagation()}_onMouseDown(e){let t=a=>{let n=a.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),a.preventDefault(),a.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.offsetWidth,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=[wi``],s([St("#knob")],x.prototype,"_knob",2),s([St("#rail")],x.prototype,"_rail",2),s([j({type:Number})],x.prototype,"value",2),s([j({type:Boolean,attribute:"step-label"})],x.prototype,"stepLabel",2),s([j({type:Boolean})],x.prototype,"reverse",2),s([j({type:Number,attribute:"lower-bound"})],x.prototype,"min",1),s([j({type:Number,attribute:"upper-bound"})],x.prototype,"max",1),s([j({type:Number,attribute:"step"})],x.prototype,"step",1),s([g("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],x.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",x);import{html as Ri}from"lit";var we=class extends u{constructor(){super(...arguments);this.value=0;this.render=()=>Ri`${this.value}`}levenshtein(e,t){let r;if(e.length===0)return t.length;if(t.length===0)return e.length;e.length>t.length&&(r=e,e=t,t=r);let o=e.length,a=t.length,n=Array(o),l,p,d;for(l=0;l<=o;l++)n[l]=l;for(l=1;l<=a;l++){for(d=l,p=1;p<=o;p++)r=n[p-1].toString(),n[p-1]=d,d=Math.min(Number(r)+(t.charAt(l-1)!==e.charAt(p-1)?1:0),d+1,n[p]+1);n[p-1]=d}return d}calculate(){let e=this.firstElementChild,t=this.lastElementChild,r=e.calculate(),o=t.calculate();return this.value=100-this.levenshtein(r.toString().trim(),o.toString().trim())/o.toString().length*100,this.value}};we.properties={value:{}};customElements.define("qti-custom-operator-levenshtein",we);import{html as Ti,LitElement as Si}from"lit";var it=class extends Si{render(){return Ti``}calculate(){var t;let e=(t=this.firstElementChild.calculate())==null?void 0:t.toString();return e?e.replace(/[^0-9$.,]/g,""):""}};customElements.define("qti-custom-operator-numeric",it);import{LitElement as Li,html as Mi}from"lit";var Ae=class extends Li{constructor(){super(...arguments);this.render=()=>Mi`${this.value}`}calculate(){var o;let e,r=(o=this.firstElementChild.calculate())==null?void 0:o.toString();return this.value=r?this.parseNumber(r,e):"",this.value}parseNumber(e,t=navigator.languages){let r=Intl.NumberFormat(t).format(1.1),o=new RegExp(`[^-+0-9${r.charAt(1)}]`,"g"),n=e.replace(o,"").replace(r.charAt(1),".");return parseFloat(n)}};Ae.properties={value:{}};customElements.define("qti-custom-operator-parse-numeric-nl",Ae);import{LitElement as Ni,html as Oi}from"lit";var st=class extends Ni{render(){return Oi``}calculate(){var t;let e=(t=this.firstElementChild.calculate())==null?void 0:t.toString();return e?e.replace(/ /g,""):""}};customElements.define("qti-custom-operator-remove-spaces",st);import{LitElement as Hi,html as Di}from"lit";var ot=class extends Hi{render(){return Di``}calculate(){return this.firstElementChild.calculate().toString().trim()}};customElements.define("qti-custom-operator-trim",ot);import{ContextConsumer as Vi}from"@lit-labs/context";import{LitElement as Pi,css as Ii,html as $i}from"lit";import{customElement as Fi,property as ie}from"lit/decorators.js";var R=class extends Pi{constructor(){super(...arguments);this.disabled=!1;this.readonly=!1;this.logger=new Vi(this,se,e=>{this.style.display=e.view==="scorer"?"block":"none"},!0)}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.value=t.value,this.closest("qti-test").manualOutcomeValue=this.value}render(){return $i`<input
|
|
428
|
+
part="input"
|
|
429
|
+
type="number"
|
|
430
|
+
spellcheck="false"
|
|
431
|
+
autocomplete="off"
|
|
432
|
+
@keyup=${this.textChanged}
|
|
433
|
+
@change=${this.textChanged}
|
|
434
|
+
placeholder="score"
|
|
435
|
+
min=${this.min}
|
|
436
|
+
max=${this.max}
|
|
437
|
+
.value=${this.value}
|
|
438
|
+
size="10"
|
|
439
|
+
?disabled=${this.disabled}
|
|
440
|
+
?readonly=${this.readonly}
|
|
441
|
+
/>`}};R.styles=Ii`
|
|
442
|
+
:host {
|
|
443
|
+
display: none;
|
|
444
|
+
}
|
|
445
|
+
`,s([ie({type:Boolean})],R.prototype,"disabled",2),s([ie({type:Boolean})],R.prototype,"readonly",2),s([ie({type:Number})],R.prototype,"value",2),s([ie({type:Number})],R.prototype,"min",2),s([ie({type:Number})],R.prototype,"max",2),R=s([Fi("qti-manual-scoring")],R);export{v as Choices,A as DragDropInteractionMixin,kt as DroppablesMixin,gt as Events,wt as FlippablesMixin,$ as OutcomeVariable,Ue as QtiAnd,q as QtiAssessmentItem,ee as QtiAssociateInteraction,ge as QtiBaseValue,y as QtiChoice,ft as QtiChoiceElementSelected,ne as QtiCompanionMaterialsInfo,Xe as QtiContains,Ye as QtiCorrect,we as QtiCustomOperatorLevenshtein,it as QtiCustomOperatorNumericOnly,Ae as QtiCustomOperatorParseNumberLocalNl,st as QtiCustomOperatorRemoveAllSpaces,ot as QtiCustomOperatorTrim,he as QtiEqual,fe as QtiEqualRounded,u as QtiExpression,M as QtiExtendedTextInteraction,pe as QtiFeedbackInline,tt as QtiGap,ve as QtiGapMatchInteraction,et as QtiGapText,ye as QtiGraphicAssociateInteraction,xe as QtiGraphicGapMatchInteraction,Ee as QtiGraphicOrderInteraction,$e as QtiGt,Fe as QtiGte,te as QtiHotspotChoice,Ce as QtiHotspotInteraction,ue as QtiHottext,De as QtiHottextInteraction,rt as QtiInlineChoice,me as QtiInlineChoiceInteraction,lt as QtiInteractionChanged,ht as QtiInteractionResponse,Ke as QtiIsNull,mt as QtiLooseChoice,R as QtiManualScoring,be as QtiMapResponse,Y as QtiMapping,ze as QtiMatch,qe as QtiMatchInteraction,_e as QtiMediaInteraction,Me as QtiModalFeedback,Ge as QtiMultiple,Be as QtiOr,re as QtiOrderInteraction,We as QtiOrdered,at as QtiOutcomeChanged,Le as QtiOutcomeDeclaration,Je as QtiPortableCustomInteraction,Te as QtiPrompt,dt as QtiRegisterChoice,ut as QtiRegisterHotspot,pt as QtiRegisterInteraction,ct as QtiRegisterVariable,Ve as QtiResponseCondition,U as QtiResponseDeclaration,J as QtiResponseElse,Ie as QtiResponseElseIf,Z as QtiResponseIf,X as QtiResponseProcessing,S as QtiRule,ke as QtiSelectPointInteraction,Pe as QtiSetOutcomeValue,Ze as QtiSimpleAssociableChoice,x as QtiSliderInteraction,Re as QtiStylesheet,L as QtiTextEntryInteraction,je as QtiVariable,I as ResponseVariable,O as TouchDragAndDrop,le as qtiContentBody,_ as qtiRubricBlock};
|