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