@citolab/qti-components 6.0.2-2 → 6.0.2
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-2192c3d8.d.ts +33 -0
- package/dist/chunk-2TX3IEPD.cjs +1 -0
- package/dist/chunk-HOQW4KDA.cjs +1 -0
- package/dist/chunk-JLKCCEGG.cjs +1 -0
- package/dist/chunk-JQY6IKDF.js +1 -0
- package/dist/chunk-L6436D6O.js +1 -0
- package/dist/custom-elements.json +16868 -3962
- package/dist/qti-assessment-item-e9f437d6.d.ts +117 -0
- package/dist/qti-components/index.cjs +403 -0
- package/dist/qti-components/index.d.ts +335 -184
- package/dist/qti-components/index.js +104 -146
- package/dist/qti-item/index.cjs +17 -0
- package/dist/qti-item/index.d.ts +6 -13
- package/dist/qti-item/index.js +17 -1
- package/dist/qti-test/index.cjs +12 -0
- package/dist/qti-test/index.d.ts +2 -2
- package/dist/qti-test/index.js +11 -13
- package/dist/qti-transform/index.cjs +102 -0
- package/dist/themes/qti.css +112 -142
- package/package.json +1 -1
- package/dist/ExpressionResult-b1ac7b27.d.ts +0 -23
- package/dist/chunk-DLLHO3W2.js +0 -1
- package/dist/chunk-M3YT56HW.js +0 -1437
- package/dist/index.js +0 -2237
- package/dist/qti-assessment-item-219cef9e.d.ts +0 -102
- package/dist/qti-item-react/index.d.ts +0 -22
- package/dist/qti-item-react/index.js +0 -1
- package/dist/qti-rule-5c200a1b.d.ts +0 -304
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as Oe}from"../chunk-L6436D6O.js";import{a as b}from"../chunk-JQY6IKDF.js";import{a as E,b as L,c as s}from"../chunk-NMCIOGD2.js";var Le={};var Ae={};var Me={};var He={};var Ne={};var De={};var Pe={};var Ie={};var Ve={};var g={ON_OUTCOME_CHANGED:"on-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 O=class{constructor({mapping:r,correctResponse:e,cardinality:t,baseType:i,identifier:l}){this._basetype="string";this._mapping=r,this._correctResponse=e,this._cardinality=t,this._basetype=i,this._identifier=l}static getCandidateResponse(r){let e=Object.keys(r)[0],t=Object.keys(r[e])[0];return r[e][t]}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(r){this._candidateResponse=r}set qtiVariable(r){this._qtiVariable=r,this._candidateResponse=O.getCandidateResponse(r)}get qtiVariable(){return this._qtiVariable}};var P=class{};import{customElement as ot,property as j}from"lit/decorators.js";import{html as nt}from"lit";import{LitElement as st}from"lit";import{property as $e}from"lit/decorators.js";var m=class extends st{emit(e,t){let i=new CustomEvent(e,E({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(i),i}err(e){throw e}};s([$e()],m.prototype,"dir",2),s([$e()],m.prototype,"lang",2);var q=class extends m{constructor(){super();this.variables=[];this.feedbackElements=[];this.interactionElements=[];this._handleDisabledChange=(e,t)=>this.interactionElements.forEach(i=>i.disabled=t);this._handleReadonlyChange=(e,t)=>this.interactionElements.forEach(i=>i.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 nt`<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={item:this.identifier,interactions:e.map(t=>({responseIdentifier:t.identifier,responses:{base:{identifier:t.correctResponse}}}))}}processResponse(){if(!this.validateResponses())return console.info("Item is not valid, call validateResponses first"),!1;let e=this.querySelector("qti-responseprocessing");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){e&&e.interactions.forEach(i=>{let l=this.interactionElements.find(a=>a.getAttribute("response-identifier")===i.responseIdentifier),n=this.getResponse(i.responseIdentifier);n&&(n.qtiVariable=i.responses);let o=O.getCandidateResponse(i.responses);l&&(l.response=o)})}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(i=>i.identifier===e);return t?t.value:(console.warn(`Variable with identifier ${e} was not found`),null)}getResponse(e){let t=this.variables.find(l=>l.identifier===e);return t instanceof O?t:null}getOutcome(e){let t=this.variables.find(i=>i.identifier===e);return t instanceof P?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,i=this.getResponse(t.responseIdentifier);i&&(i.qtiVariable=t.responses),e.stopImmediatePropagation();let l=this.getAttribute("identifier");l||console.warn("qti-assessment-item has no identifier specified"),this.emit("qti-interaction-changed",{detail:{item:l,interaction:{responseIdentifier:t.responseIdentifier,responses:t.responses}}})}outcomeChanged(e){this.feedbackElements.forEach(t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)})}setOutcomeValue(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}i.value=t,this.dispatchEvent(new CustomEvent(g.ON_OUTCOME_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))}};s([j({type:Boolean})],q.prototype,"disabled",2),s([j({type:Boolean})],q.prototype,"readonly",2),s([j({type:String})],q.prototype,"title",2),s([j({type:String})],q.prototype,"identifier",2),s([b("disabled",{waitUntilFirstUpdate:!0})],q.prototype,"_handleDisabledChange",2),s([b("readonly",{waitUntilFirstUpdate:!0})],q.prototype,"_handleReadonlyChange",2),q=s([ot("qti-assessment-item")],q);import{LitElement as at}from"lit";var be=class extends at{constructor(){super()}connectedCallback(){super.connectedCallback();let e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),i=document.createElement("link");i.rel="stylesheet",i.type="text/css",i.media="screen",i.href=t,e.appendChild(i),this.styleLink=i}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",be);import{customElement as ct}from"lit/decorators.js";import{html as pt,LitElement as dt}from"lit";import{css as lt}from"lit";var Ge=lt`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
|
5
|
-
`;var
|
|
6
|
-
<slot></slot>`}};
|
|
5
|
+
`;var I=class extends dt{render(){return pt` <slot name="qti-rubric-block"></slot>
|
|
6
|
+
<slot></slot>`}};I.styles=Ge,I=s([ct("qti-item-body")],I);import{html as mt,LitElement as ht}from"lit";var ge=class extends ht{render(){return mt` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",ge);import{html as ut}from"lit/static-html.js";import{property as Y}from"lit/decorators.js";var ft={SPACE:32},C=class extends m{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.emit("qti-register-choice")}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit("qti-loose-choice")}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){if(!e.altKey)switch(e.keyCode){case ft.SPACE:e.preventDefault(),this._toggleChecked();break;default:}}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit("qti-choice-element-selected",{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"),ut` <slot></slot> `}};s([Y({type:String})],C.prototype,"identifier",2),s([Y({type:Number,reflect:!0})],C.prototype,"tabindex",2),s([Y({type:Boolean,reflect:!0})],C.prototype,"disabled",2),s([Y({type:Boolean,reflect:!0})],C.prototype,"readonly",2),s([Y({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:c=>c}})],C.prototype,"checked",2),s([b("disabled",{waitUntilFirstUpdate:!0})],C.prototype,"handleDisabledChange",1);import{html as bt}from"lit";var H=class extends m{render(){return bt``}};customElements.define("qti-variabledeclaration",H);import{property as ve}from"lit/decorators.js";var V=class extends H{connectedCallback(){super.connectedCallback();let e=new O({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping});this.emit("qti-register-variable",{detail:{variable:e}})}get correctResponse(){let e,t=this.querySelector("qti-correct-response");if(t){let i=t.querySelectorAll("qti-value");if(i.length===1)e=i[0].textContent,i[0].remove();else{e=[];for(let l=0;l<i.length;l++)e.push(i[l].textContent),i[l].remove()}}return e}get mapping(){let e=this.querySelector("qti-mapping");if(e){let t=new Map,i=e.querySelectorAll("qti-map-entry");for(let l=0;l<i.length;l++){let n=i[l],o=n.getAttribute("map-key"),a=n.getAttribute("mapped-value");t.set(o,a?parseFloat(a):null)}return t}else return null}};s([ve({type:String,attribute:"base-type"})],V.prototype,"baseType",2),s([ve({type:String,attribute:"identifier"})],V.prototype,"identifier",2),s([ve({type:String,attribute:"cardinality"})],V.prototype,"cardinality",2);customElements.define("qti-response-declaration",V);var ye=class extends H{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();let r=this.getAttribute("identifier"),e=new P;e.identifier=r,this.emit("qti-register-variable",{detail:{variable:e}})}};customElements.define("qti-outcome-declaration",ye);import{customElement as gt}from"lit/decorators.js";var Z=class extends m{};Z=s([gt("qti-companion-materials-info")],Z);import{css as vt,html as yt}from"lit";import{customElement as Et,property as ee}from"lit/decorators.js";import{ContextConsumer as xt}from"@lit-labs/context";var T=class extends m{constructor(){super(...arguments);this.logger=new xt(this,Oe,e=>this.style.display=this.view===e.view?"block":"none",!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(l=>{switch(l){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return yt`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};T.styles=vt`
|
|
7
7
|
:host {
|
|
8
8
|
display: block;
|
|
9
9
|
}
|
|
10
|
-
`,s([
|
|
10
|
+
`,s([ee({type:String})],T.prototype,"id",2),s([ee({type:String})],T.prototype,"use",2),s([ee({type:String})],T.prototype,"view",2),s([ee({type:String,attribute:"class"})],T.prototype,"classNames",2),s([b("classNames",{waitUntilFirstUpdate:!0})],T.prototype,"handleclassNamesChange",1),T=s([Et("qti-rubric-block")],T);import{html as Ct}from"lit";import{customElement as _t}from"lit/decorators.js";var te=class extends m{render(){return Ct`<slot></slot>`}};te=s([_t("qti-content-body")],te);import{css as Tt,html as kt}from"lit";import{LitElement as qt}from"lit";import{property as ie}from"lit/decorators.js";var k=class extends qt{constructor(){super();this.showHide="show",this.showFeedback(this.showHide==="hide")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(g.ON_REGISTER_FEEDBACK,{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){if(this.outcomeIdentifier!==e||!t)return;let i=Array.isArray(t)?t.includes(this.identifier):this.identifier===t;this.showFeedback(i)}showFeedback(e){this.showStatus=e?"on":"off"}};s([ie({type:String})],k.prototype,"showHide",2),s([ie({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),s([ie({type:String})],k.prototype,"identifier",2),s([ie({type:String,attribute:"show-hide"})],k.prototype,"showStatus",2);var re=class extends k{constructor(){super(...arguments);this.render=()=>kt` <slot class="${this.showStatus}"></slot> `}};re.styles=Tt`
|
|
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",re);import{html as Rt}from"lit";var Ee=class extends k{render(){return Rt`
|
|
18
18
|
<style>
|
|
19
19
|
.on {
|
|
20
20
|
display: inline-block;
|
|
@@ -26,7 +26,7 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
26
26
|
<div class="feedback ${this.showStatus}">
|
|
27
27
|
<slot></slot>
|
|
28
28
|
</div>
|
|
29
|
-
`}};customElements.define("qti-modal-feedback",
|
|
29
|
+
`}};customElements.define("qti-modal-feedback",Ee);import{css as St,html as Ot}from"lit";import{ifDefined as Ce}from"lit/directives/if-defined.js";import{property as xe}from"lit/decorators.js";var v=class extends m{constructor(){super(...arguments);this.responseIdentifier="";this.disabled=!1;this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit("qti-register-interaction")}saveResponse(e){this.emit("qti-interaction-response",{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}};s([xe({attribute:"response-identifier"})],v.prototype,"responseIdentifier",2),s([xe({reflect:!0,type:Boolean})],v.prototype,"disabled",2),s([xe({reflect:!0,type:Boolean})],v.prototype,"readonly",2);import{css as wt}from"lit";var $=wt`
|
|
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 g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
106
106
|
:where([draggable='true']) {
|
|
107
107
|
-webkit-user-drag: element;
|
|
108
108
|
}
|
|
109
|
-
`;
|
|
109
|
+
`;var se=class extends v{constructor(){super();this.value=""}static get properties(){return L(E({},v.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String}})}set response(e){this.value=e!==void 0?e:""}validate(){return this.value!==""}static get styles(){return[$,St`
|
|
110
110
|
/* PK: display host as block, else design will be collapsed */
|
|
111
111
|
:host {
|
|
112
112
|
display: inline-block;
|
|
@@ -114,20 +114,21 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
114
114
|
input {
|
|
115
115
|
padding: var(--qti-padding, 0.5rem);
|
|
116
116
|
}
|
|
117
|
-
`]}render(){return
|
|
117
|
+
`]}render(){return Ot`
|
|
118
|
+
<input
|
|
118
119
|
spellcheck="false"
|
|
119
120
|
autocomplete="off"
|
|
120
121
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
121
122
|
@keyup="${this.textChanged}"
|
|
122
123
|
@change="${this.textChanged}"
|
|
123
124
|
type="text"
|
|
124
|
-
placeholder="${
|
|
125
|
+
placeholder="${Ce(this.placeholderText?this.placeholderText:void 0)}"
|
|
125
126
|
.value="${this.value}"
|
|
126
|
-
size="${
|
|
127
|
-
pattern="${
|
|
127
|
+
size="${Ce(this.expectedLength?this.expectedLength:void 0)}"
|
|
128
|
+
pattern="${Ce(this.patternMask?this.patternMask:void 0)}"
|
|
128
129
|
?disabled="${this.disabled}"
|
|
129
130
|
?readonly="${this.readonly}"
|
|
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")}};
|
|
131
|
+
/>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};se.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-text-entry-interaction",se);import{css as Lt,html as At}from"lit";import{ifDefined as _e}from"lit/directives/if-defined.js";import{ref as Mt,createRef as Ht}from"lit/directives/ref.js";import{property as K}from"lit/decorators.js";var R=class extends v{constructor(){super(...arguments);this.textareaRef=Ht();this.value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(l=>{if(l.startsWith("qti-height-lines")){let n=l.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(n))}})}set response(e){this.value=e!==void 0?e:""}validate(){return this.value!==""}static get styles(){return[$,Lt`
|
|
131
132
|
/* PK: display host as block, else design will be collapsed */
|
|
132
133
|
:host {
|
|
133
134
|
display: block;
|
|
@@ -137,104 +138,64 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
137
138
|
width: 100%;
|
|
138
139
|
height: 100%;
|
|
139
140
|
}
|
|
140
|
-
`]}render(){return
|
|
141
|
-
${
|
|
141
|
+
`]}render(){return At`<textarea
|
|
142
|
+
${Mt(this.textareaRef)}
|
|
142
143
|
spellcheck="false"
|
|
143
144
|
autocomplete="off"
|
|
144
145
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
145
146
|
@keyup="${this.textChanged}"
|
|
146
147
|
@change="${this.textChanged}"
|
|
147
|
-
placeholder="${
|
|
148
|
-
maxlength="${
|
|
149
|
-
pattern="${
|
|
148
|
+
placeholder="${_e(this.placeholderText?this.placeholderText:void 0)}"
|
|
149
|
+
maxlength="${_e(this.expectedLength?this.expectedLength:void 0)}"
|
|
150
|
+
pattern="${_e(this.patternMask?this.patternMask:void 0)}"
|
|
150
151
|
?disabled="${this.disabled}"
|
|
151
152
|
?readonly="${this.readonly}"
|
|
152
153
|
.value=${this.value}
|
|
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([
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
::slotted(qti-simple-choice:not([disabled])) {
|
|
175
|
-
cursor: pointer;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
::slotted(qti-simple-choice[disabled]) {
|
|
179
|
-
opacity: 0.2;
|
|
180
|
-
}
|
|
181
|
-
|
|
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;
|
|
154
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};R.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],s([K({type:Number,attribute:"expected-length"})],R.prototype,"expectedLength",2),s([K({type:String,attribute:"pattern-mask"})],R.prototype,"patternMask",2),s([K({type:String,attribute:"placeholder-text"})],R.prototype,"placeholderText",2),s([K({type:String})],R.prototype,"value",2),s([K({type:String,attribute:"class"})],R.prototype,"classNames",2),s([b("classNames",{waitUntilFirstUpdate:!0})],R.prototype,"handleclassNamesChange",1);customElements.define("qti-extended-text-interaction",R);import{customElement as Nt}from"lit/decorators.js";var oe=class extends C{};oe=s([Nt("qti-hottext")],oe);import{html as Dt}from"lit";import{property as Fe}from"lit/decorators.js";var y=class extends v{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(i=>i.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(i=>i.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,i)=>t+(i.checked?1:0),0)>=this.minChoices}set response(e){this._choiceElements.forEach(i=>{i.checked=!1}),(Array.isArray(e)?e:[e]).forEach(i=>{let l=this.querySelector(`[identifier='${i}']`);l&&(l.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(i=>i!==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(i=>i.checked).map(i=>i.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(i=>i.disabled=!i.checked):this._choiceElements.forEach(i=>i.disabled=!1));let t;this.maxChoices===1?t={base:{identifier:e.length>0?e[0]:""}}:t={list:{identifier:e}},this.saveResponse(t)}};s([Fe({type:Number,attribute:"min-choices"})],y.prototype,"minChoices",2),s([Fe({type:Number,attribute:"max-choices"})],y.prototype,"maxChoices",2),s([b("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"_handleDisabledChange",2),s([b("readonly",{waitUntilFirstUpdate:!0})],y.prototype,"_handleReadonlyChange",2),s([b("_maxChoices",{waitUntilFirstUpdate:!0})],y.prototype,"_handleMaxChoicesChange",2);var qe=class extends y{constructor(){super(...arguments);this.render=()=>Dt`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",qe);import{css as Pt,html as Ue}from"lit";var ne=class extends v{constructor(){super();this.options=[];this.addEventListener(g.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 L(E({},v.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[$,Pt`
|
|
155
|
+
:host {
|
|
156
|
+
display: inline-block;
|
|
157
|
+
}
|
|
158
|
+
select {
|
|
159
|
+
width:100%;
|
|
160
|
+
padding: var(--qti-padding-y) var(--qti-padding-x);
|
|
161
|
+
padding-right: calc(var(--qti-padding-x) + 1ch)
|
|
162
|
+
}
|
|
163
|
+
`]}render(){return Ue`
|
|
164
|
+
<select
|
|
165
|
+
@change="${this.choiceSelected}"
|
|
166
|
+
?disabled="${this.disabled}"
|
|
167
|
+
?readonly="${this.readonly}"
|
|
168
|
+
>
|
|
169
|
+
${this.options.map(e=>Ue`
|
|
170
|
+
<option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
|
|
171
|
+
`)}
|
|
172
|
+
</select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>L(E({},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(i=>L(E({},i),{selected:i.value===t})),this.saveResponse({base:{string:t}})}};ne.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",ne);import{customElement as $t,property as Gt}from"lit/decorators.js";import{html as Ft}from"lit";import{css as Vt}from"lit";import{css as It}from"lit";var ae=It`
|
|
173
|
+
:host {
|
|
174
|
+
box-sizing: border-box;
|
|
205
175
|
}
|
|
206
176
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
min-width: 22px;
|
|
212
|
-
box-shadow: inset 0 0 0 var(--qti-border-width) var(--qti-border-color);
|
|
177
|
+
:host *,
|
|
178
|
+
:host *::before,
|
|
179
|
+
:host *::after {
|
|
180
|
+
box-sizing: inherit;
|
|
213
181
|
}
|
|
214
182
|
|
|
215
|
-
|
|
216
|
-
|
|
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;
|
|
183
|
+
[hidden] {
|
|
184
|
+
display: none !important;
|
|
226
185
|
}
|
|
186
|
+
`;var Be=Vt`
|
|
187
|
+
${ae}
|
|
227
188
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
transform: scale(1);
|
|
189
|
+
:host {
|
|
190
|
+
display: block;
|
|
231
191
|
}
|
|
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}
|
|
232
194
|
|
|
233
195
|
:host {
|
|
234
196
|
display: block;
|
|
235
|
-
position: relative;
|
|
236
197
|
}
|
|
237
|
-
`;var
|
|
198
|
+
`;var G=class extends C{};G.styles=Xe,G=s([Bt("qti-simple-choice")],G);import{customElement as Xt}from"lit/decorators.js";import{html as Yt,LitElement as Kt}from"lit";var Ye=`<qti-response-processing>
|
|
238
199
|
<qti-response-condition>
|
|
239
200
|
<qti-response-if>
|
|
240
201
|
<qti-match>
|
|
@@ -251,7 +212,7 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
251
212
|
</qti-set-outcome-value>
|
|
252
213
|
</qti-response-else>
|
|
253
214
|
</qti-response-condition>
|
|
254
|
-
</qti-response-processing>`,
|
|
215
|
+
</qti-response-processing>`,Ke=`<qti-response-processing>
|
|
255
216
|
<qti-response-condition>
|
|
256
217
|
<qti-response-if>
|
|
257
218
|
<qti-is-null>
|
|
@@ -267,7 +228,7 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
267
228
|
</qti-set-outcome-value>
|
|
268
229
|
</qti-response-else>
|
|
269
230
|
</qti-response-condition>
|
|
270
|
-
</qti-response-processing>`,
|
|
231
|
+
</qti-response-processing>`,Je=`<qti-response-processing>
|
|
271
232
|
<qti-response-condition>
|
|
272
233
|
<qti-response-if>
|
|
273
234
|
<qti-is-null>
|
|
@@ -283,15 +244,12 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
283
244
|
</qti-set-outcome-value>
|
|
284
245
|
</qti-response-else>
|
|
285
246
|
</qti-response-condition>
|
|
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 Hr}from"lit";var $e=class extends Z{render(){return Hr`${super.render()}`}};customElements.define("qti-response-else-if",$e);import{LitElement as Or,html as Dr}from"lit";var u=class extends Or{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 Ie=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",Ie);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 $r}from"lit";var Be=class extends N{render(){return $r``}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 Ir}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([Ir({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 H=class{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this.createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="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 H._instance?H._instance:(H._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this.getPositionFromEvent(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this.createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this.getPositionFromEvent(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this.createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e,t=i.composedPath().find(r=>{if(r.nodeType===1&&r.nodeName!=="SLOT"&&r.hasAttribute("dropzone"))return r});if(t){let r=t.getRootNode(),o=this._getPoint(i);e=r.elementFromPoint(o.x,o.y)}return e}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}getPositionFromEvent(i){let e;if(i.type=="touchstart"||i.type=="touchmove"||i.type=="touchend"||i.type=="touchcancel"){let t=typeof i.originalEvent=="undefined"?i:i.originalEvent,r=t.touches[0]||t.changedTouches[0];e={x:r.pageX,y:r.pageY}}else(i.type=="mousedown"||i.type=="mouseup"||i.type=="mousemove"||i.type=="mouseover"||i.type=="mouseout"||i.type=="mouseenter"||i.type=="mouseleave")&&(e={x:i.clientX,y:i.clientY});return e}};import{property as 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 H,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>
|
|
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>
|
|
290
248
|
<slot name="qti-simple-associable-choice"></slot>
|
|
291
|
-
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>
|
|
249
|
+
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Ze`<div part="associables-container">
|
|
292
250
|
<drop-list part="drop-list" identifier="droplist${t}_left"></drop-list>
|
|
293
251
|
<drop-list part="drop-list" identifier="droplist${t}_right"></drop-list>
|
|
294
|
-
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};
|
|
252
|
+
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};z.styles=jt`
|
|
295
253
|
:host {
|
|
296
254
|
display: block; /* necessary to calculate scaling position */
|
|
297
255
|
}
|
|
@@ -300,11 +258,11 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
300
258
|
flex-wrap: wrap;
|
|
301
259
|
gap: 0.5rem;
|
|
302
260
|
}
|
|
303
|
-
`,s([
|
|
261
|
+
`,s([Zt()],z.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",z);import{html as ei,LitElement as ti}from"lit";var ke=class extends ti{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return ei`
|
|
304
262
|
<slot></slot>
|
|
305
263
|
<slot name="qti-simple-associable-choice"></slot>
|
|
306
|
-
`}};customElements.define("qti-simple-associable-choice",
|
|
307
|
-
<slot></slot>`}};
|
|
264
|
+
`}};customElements.define("qti-simple-associable-choice",ke);import{css as ii,html as ri,LitElement as si}from"lit";var le=class extends w(si,"qti-gap-text",!1,"qti-gap"){render(){return ri` <slot name="qti-gap-text"></slot>
|
|
265
|
+
<slot></slot>`}};le.styles=ii`
|
|
308
266
|
:host {
|
|
309
267
|
display: block; /* necessary to calculate scaling position */
|
|
310
268
|
}
|
|
@@ -314,12 +272,12 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
314
272
|
gap: var(--qti-gap, 0.5rem);
|
|
315
273
|
padding: var(--qti-gap, 0.5rem) 0px;
|
|
316
274
|
}
|
|
317
|
-
`;customElements.define("qti-gap-match-interaction",
|
|
275
|
+
`;customElements.define("qti-gap-match-interaction",le);import{html as oi,LitElement as ni}from"lit";var Re=class extends ni{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return oi`<slot></slot>`}};customElements.define("qti-gap-text",Re);import{html as ai,LitElement as li}from"lit";var we=class extends li{render(){return ai` <slot name="qti-gap-text"></slot>`}};customElements.define("qti-gap",we);import{css as ci,html as pi}from"lit";function B(c,r,e,t){switch(c){case"circle":{let[i,l,n]=r,o=i/e.width*100,a=l/e.height*100,d=n/e.width*100;t.style.left=o-d+"%",t.style.top=a-d+"%",t.style.width=t.style.height=4*d+"px",t.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{let[i,l,n,o]=r,a=i/e.width*100,d=l/e.height*100,p=n/e.width*100,h=o/e.height*100;t.style.left=a+"%",t.style.top=d+"%",t.style.width=p-a+"%",t.style.height=h-d+"%"}break;case"poly":{let i=r.reduce((u,S,Se,it)=>{if(Se%2===1){let rt=u.pop();u[u.length]={x:rt,y:it[Se]}}else u.push(S);return u},[]),l=Math.min(...i.map(u=>u.x)),n=Math.max(...i.map(u=>u.x)),o=Math.min(...i.map(u=>u.y)),a=Math.max(...i.map(u=>u.y)),d=l/e.width*100,p=o/e.height*100,h=n/e.width*100,x=a/e.height*100;t.style.left=l/e.width*100+"%",t.style.top=o/e.height*100+"%",t.style.width=h-d+"%",t.style.height=x-p+"%";let D=i.map(u=>({x:(u.x-l)/(n-l)*100,y:(u.y-o)/(a-o)*100})).map(u=>Math.round(u.x)+"% "+Math.round(u.y)+"%").join(",");t.style.clipPath=`polygon(${D})`}break;default:break}}var ce=class extends y{render(){return pi`
|
|
318
276
|
<slot name="prompt"></slot>
|
|
319
277
|
<!-- slot for the prompt -->
|
|
320
278
|
<slot></slot>
|
|
321
279
|
<!-- slot for the image and hotspots -->
|
|
322
|
-
`}positionHotspotOnRegister(e){let t=this.querySelector("img"),
|
|
280
|
+
`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,l=i.getAttribute("coords"),n=i.getAttribute("shape"),o=l.split(",").map(a=>parseInt(a));B(n,o,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener(g.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(g.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}};ce.styles=[ci`
|
|
323
281
|
slot:not([name='prompt']) {
|
|
324
282
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
325
283
|
display: block;
|
|
@@ -330,18 +288,18 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
330
288
|
pointer-events: none;
|
|
331
289
|
user-select: none;
|
|
332
290
|
}
|
|
333
|
-
`];customElements.define("qti-graphic-associate-interaction",
|
|
334
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(
|
|
335
|
-
slot[name=
|
|
291
|
+
`];customElements.define("qti-graphic-associate-interaction",ce);import{css as di,html as mi}from"lit";var pe=class extends w(m,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return mi` <slot></slot>
|
|
292
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),l=t.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,o,a]=l;e.style.left=n-a+"px",e.style.top=o-a+"px",e.style.width=e.style.height=2*a+"px"}break;case"rect":{let[n,o,a,d]=l;e.style.left=n+"px",e.style.top=o+"px",e.style.width=a-n+"px",e.style.height=d-o+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener(g.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(g.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}};pe.styles=di`
|
|
293
|
+
slot[name="qti-gap-img"] {
|
|
336
294
|
display: flex;
|
|
337
295
|
gap: 1rem;
|
|
338
296
|
}
|
|
339
|
-
`;customElements.define("qti-graphic-gap-match-interaction",
|
|
297
|
+
`;customElements.define("qti-graphic-gap-match-interaction",pe);import{css as hi,html as ui}from"lit";var de=class extends y{render(){return ui`
|
|
340
298
|
<slot name="prompt"></slot>
|
|
341
299
|
<!-- slot for the prompt -->
|
|
342
300
|
<slot></slot>
|
|
343
301
|
<!-- slot for the image and hotspots -->
|
|
344
|
-
`}setHotspotOrder(e){let{identifier:t}=e.detail,
|
|
302
|
+
`}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t),l=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){if(this._choiceElements.filter(n=>n.order>0).length>=l){this.choiceOrdering=!1;return}i.order=this._choiceElements.filter(n=>!!n.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(n=>(n.order>n.order&&n.order--,n)),i.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,l=i.getAttribute("coords"),n=i.getAttribute("shape"),o=l.split(",").map(a=>parseInt(a));B(n,o,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener(g.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(g.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(g.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(g.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}};de.styles=[hi`
|
|
345
303
|
slot:not([name='prompt']) {
|
|
346
304
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
347
305
|
display: block;
|
|
@@ -352,12 +310,12 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
352
310
|
pointer-events: none;
|
|
353
311
|
user-select: none;
|
|
354
312
|
}
|
|
355
|
-
`];customElements.define("qti-graphic-order-interaction",
|
|
313
|
+
`];customElements.define("qti-graphic-order-interaction",de);import{css as fi,html as bi}from"lit";var me=class extends y{render(){return bi`
|
|
356
314
|
<slot name="prompt"></slot>
|
|
357
315
|
<!-- slot for the prompt -->
|
|
358
316
|
<slot></slot>
|
|
359
317
|
<!-- slot for the image and hotspots -->
|
|
360
|
-
`}positionHotspotOnRegister(
|
|
318
|
+
`}positionHotspotOnRegister(r){let e=this.querySelector("img"),t=r.target,i=t.getAttribute("coords"),l=t.getAttribute("shape"),n=i.split(",").map(o=>parseInt(o));B(l,n,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};me.styles=[fi`
|
|
361
319
|
slot:not([name='prompt']) {
|
|
362
320
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
363
321
|
display: block;
|
|
@@ -367,21 +325,44 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
367
325
|
/* image not selectable anymore */
|
|
368
326
|
pointer-events: none;
|
|
369
327
|
user-select: none;
|
|
370
|
-
/* width:100%; */
|
|
371
328
|
}
|
|
372
|
-
`];customElements.define("qti-hotspot-interaction",
|
|
329
|
+
`];customElements.define("qti-hotspot-interaction",me);import{css as gi}from"lit";import{property as vi}from"lit/decorators.js";var W=class extends C{};W.styles=gi`
|
|
373
330
|
:host {
|
|
374
331
|
position: absolute;
|
|
375
332
|
}
|
|
376
|
-
`,s([vi({attribute:"aria-ordervalue",type:Number,reflect:!0})],
|
|
377
|
-
|
|
378
|
-
|
|
333
|
+
`,s([vi({attribute:"aria-ordervalue",type:Number,reflect:!0})],W.prototype,"order",2);customElements.define("qti-hotspot-choice",W);import{html as Ei,LitElement as xi}from"lit";import{css as yi}from"lit";var M=yi`
|
|
334
|
+
.notification {
|
|
335
|
+
position: absolute;
|
|
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>
|
|
379
360
|
<div class=${`container ${this._classNames}`}>
|
|
380
361
|
<slot class=${this._orientation==="vertical"?"ver":"hor"}> </slot>
|
|
381
362
|
<div class=${this._orientation==="vertical"?"ver":"hor"}>
|
|
382
|
-
${this.childrenMap.map((e,t)=>
|
|
363
|
+
${this.childrenMap.map((e,t)=>et`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
|
|
383
364
|
</div>
|
|
384
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};
|
|
365
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};Q.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Q.styles=[M,qi`
|
|
385
366
|
.hor {
|
|
386
367
|
display: grid;
|
|
387
368
|
gap: var(--qti-gap, 2px);
|
|
@@ -389,7 +370,7 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
389
370
|
grid-auto-columns: 1fr;
|
|
390
371
|
}
|
|
391
372
|
.ver {
|
|
392
|
-
width:
|
|
373
|
+
width:50%;
|
|
393
374
|
display: grid;
|
|
394
375
|
gap: var(--qti-gap, 2px);
|
|
395
376
|
grid-auto-flow: row;
|
|
@@ -415,31 +396,8 @@ import{a as g,b as se}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
|
|
|
415
396
|
content: 'drop here';
|
|
416
397
|
color: var(--qti-placeholder-text);
|
|
417
398
|
}
|
|
418
|
-
`];customElements.define("qti-order-interaction",
|
|
419
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}};
|
|
420
|
-
<div
|
|
421
|
-
id="rail"
|
|
422
|
-
@mousedown=${this._onMouseDown}
|
|
423
|
-
@touchstart=${this._onTouchMove}
|
|
424
|
-
part="rail"
|
|
425
|
-
>
|
|
399
|
+
`];customElements.define("qti-order-interaction",Q);import{html as Ti}from"lit";var fe=class extends y{constructor(){super()}render(){return Ti`<slot></slot>
|
|
400
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}};fe.styles=[M];customElements.define("qti-select-point-interaction",fe);import{css as ki,html as Ri}from"lit";import{property as X,query as tt}from"lit/decorators.js";var _=class extends v{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){this.value=e}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 Ri`<slot name="prompt"></slot>
|
|
401
|
+
<div id="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove} part="rail">
|
|
426
402
|
<div id="knob" part="knob" style="left:${e}%"></div>
|
|
427
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=
|
|
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=$i`
|
|
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,I 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,Ie 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,$e 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,$ as ResponseVariable,H as TouchDragAndDrop,le as qtiContentBody,_ as qtiRubricBlock};
|
|
403
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=o=>{let{x:a}=this.getPositionFromEvent(o),d=a-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(d),o.stopPropagation()},i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this.saveResponse({base:{float:this.value}})};document.addEventListener("touchmove",t),document.addEventListener("touchend",i);let{x:l}=this.getPositionFromEvent(e),n=l-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),e.stopPropagation()}_onMouseDown(e){let t=n=>{let o=n.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),n.preventDefault(),n.stopPropagation()},i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i);let l=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this.offsetWidth,i=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=i}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let i=typeof e.originalEvent=="undefined"?e:e.originalEvent,l=i.touches[0]||i.changedTouches[0];t={x:l.pageX,y:l.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}};_.styles=[ki``],s([tt("#knob")],_.prototype,"_knob",2),s([tt("#rail")],_.prototype,"_rail",2),s([X({type:Number})],_.prototype,"value",2),s([X({type:Boolean,attribute:"step-label"})],_.prototype,"stepLabel",2),s([X({type:Boolean})],_.prototype,"reverse",2),s([X({type:Number,attribute:"lower-bound"})],_.prototype,"min",1),s([X({type:Number,attribute:"upper-bound"})],_.prototype,"max",1),s([X({type:Number,attribute:"step"})],_.prototype,"step",1),s([b("disabled",{waitUntilFirstUpdate:!0})],_.prototype,"_handleDisabledChange",2),s([b("readonly",{waitUntilFirstUpdate:!0})],_.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",_);export{y as Choices,w as DragDropInteractionMixin,We as DroppablesMixin,g as Events,Qe as FlippablesMixin,P as OutcomeVariable,q as QtiAssessmentItem,z as QtiAssociateInteraction,C as QtiChoice,Ve as QtiChoiceElementSelected,Z as QtiCompanionMaterialsInfo,R as QtiExtendedTextInteraction,re as QtiFeedbackInline,we as QtiGap,le as QtiGapMatchInteraction,Re as QtiGapText,ce as QtiGraphicAssociateInteraction,pe as QtiGraphicGapMatchInteraction,de as QtiGraphicOrderInteraction,W as QtiHotspotChoice,me as QtiHotspotInteraction,oe as QtiHottext,qe as QtiHottextInteraction,ne as QtiInlineChoiceInteraction,Ae as QtiInteractionChanged,Ie as QtiInteractionResponse,Pe as QtiLooseChoice,he as QtiMatchInteraction,ue as QtiMediaInteraction,Ee as QtiModalFeedback,Q as QtiOrderInteraction,Le as QtiOutcomeChanged,ye as QtiOutcomeDeclaration,Te as QtiPortableCustomInteraction,ge as QtiPrompt,Ne as QtiRegisterChoice,De as QtiRegisterHotspot,He as QtiRegisterInteraction,Me as QtiRegisterVariable,V as QtiResponseDeclaration,F as QtiResponseProcessing,J as QtiRule,fe as QtiSelectPointInteraction,_ as QtiSliderInteraction,be as QtiStylesheet,se as QtiTextEntryInteraction,O as ResponseVariable,A as TouchDragAndDrop,te as qtiContentBody,T as qtiRubricBlock,ke as qtiSimpleAssociableChoice};
|