@citolab/qti-components 6.0.25 → 6.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VBLA6PHI.cjs → chunk-EGPC25SK.cjs} +23 -43
- package/dist/{chunk-YFSV2M2E.js → chunk-OKBEUQM2.js} +23 -43
- package/dist/custom-elements.json +319 -310
- package/dist/index.cjs +89 -101
- package/dist/index.css +23 -43
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +90 -102
- package/dist/qti-components/index.cjs +44 -36
- package/dist/qti-components/index.d.cts +2 -2
- package/dist/qti-components/index.d.ts +2 -2
- package/dist/qti-components/index.js +62 -54
- package/dist/qti-item/index.cjs +1 -1
- package/dist/qti-item/index.js +1 -1
- package/dist/qti-item-react/index.cjs +1 -1
- package/dist/qti-item-react/index.d.cts +1 -1
- package/dist/qti-item-react/index.d.ts +1 -1
- package/dist/qti-item-react/index.js +1 -1
- package/dist/{qti-simple-choice-f19f8469.d.ts → qti-simple-choice-86f433b6.d.ts} +1 -0
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5GG2XAUT.js";import{a as _,b as D,c as s}from"../chunk-NMCIOGD2.js";var vt={};var yt={};var xt={};var Et={};var qt={};var Ct={};var _t={};var kt={};var At={};var Tt={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 H=class{constructor(){this.value=null}},$=class{constructor(){this.value=null;this.candidateResponse=null;this.correctResponse=null}};import{customElement as Jt,property as
|
|
1
|
+
import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5GG2XAUT.js";import{a as _,b as D,c as s}from"../chunk-NMCIOGD2.js";var vt={};var yt={};var xt={};var Et={};var qt={};var Ct={};var _t={};var kt={};var At={};var Tt={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 H=class{constructor(){this.value=null}},$=class{constructor(){this.value=null;this.candidateResponse=null;this.correctResponse=null}};import{customElement as Jt,property as ie}from"lit/decorators.js";import{html as Zt,LitElement as Qt}from"lit";var A=class extends Qt{constructor(){super();this.variables=[];this.feedbackElements=[];this.interactionElements=[];this._numAttempts=0;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 Zt`<slot></slot>`}firstUpdated(e){super.firstUpdated(e),this.dispatchEvent(new CustomEvent("qti-item-connected",{bubbles:!0,composed:!0,detail:this}))}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&&t.correctResponse);this.responses=e.map(t=>({responseIdentifier:t.identifier,response:t.correctResponse}))}processResponse(){let e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),this._numAttempts++,this.dispatchEvent(new CustomEvent("qti-response-processing")),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}set responses(e){if(e)for(let t of e){let r=this.interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier),o=this.getResponse(t.responseIdentifier);o&&(o.value=t.response),r&&(r.response=t.response)}}resetInteractions(){this.interactionElements.forEach(e=>e.reset())}validateResponses(){let e=!0;return this.interactionElements.forEach(t=>{t.validate()||(e=!1)}),e}getVariable(e){switch(e){case"numAttempts":return{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:this._numAttempts.toString()};default:{let t=this.variables.find(r=>r.identifier===e);return t||(console.warn(`Variable with identifier ${e} was not found`),null)}break}}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 H?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.showFeedback(e)}showFeedback(e){this.feedbackElements.forEach(t=>{t.checkShowFeedback(e.detail.outcomeIdentifier)})}setOutcomeValue(e,t){let r;switch(e){case"completionStatus":r={identifier:"completionStatus",cardinality:"single",baseType:"string",value:t};break;default:{if(r=this.getOutcome(e),!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}r.cardinality==="single"?r.value=t:r.value.push(t)}break}this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:r.value}}))}};s([ie({type:Boolean})],A.prototype,"disabled",2),s([ie({type:Boolean})],A.prototype,"readonly",2),s([ie({type:String})],A.prototype,"title",2),s([ie({type:String})],A.prototype,"identifier",2),s([f("disabled",{waitUntilFirstUpdate:!0})],A.prototype,"_handleDisabledChange",2),s([f("readonly",{waitUntilFirstUpdate:!0})],A.prototype,"_handleReadonlyChange",2),A=s([Jt("qti-assessment-item")],A);import{LitElement as er}from"lit";var Ne=class extends er{constructor(){super()}connectedCallback(){super.connectedCallback();let e=this.closest("qti-assessment-item"),t=this.getAttribute("href");if(t!==null){let r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.media="screen",r.href=t,e.appendChild(r),this.styleLink=r}if(this.textContent!==null){let r=document.createElement("style");r.media="screen",r.textContent=this.textContent,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",Ne);import{customElement as rr}from"lit/decorators.js";import{html as ir,LitElement as sr}from"lit";import{css as tr}from"lit";var wt=tr`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
|
5
|
-
`;var
|
|
5
|
+
`;var O=class extends sr{render(){return ir`<slot></slot>`}};O.styles=wt,O=s([rr("qti-item-body")],O);import{html as or,LitElement as nr}from"lit";var De=class extends nr{render(){return or`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",De);import{html as ar}from"lit/static-html.js";import{property as K}from"lit/decorators.js";import{LitElement as lr}from"lit";var cr={SPACE:32},y=class extends lr{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 cr.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"),ar` <slot></slot> `}};s([K({type:String})],y.prototype,"identifier",2),s([K({type:Number,reflect:!0})],y.prototype,"tabindex",2),s([K({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:n=>n}})],y.prototype,"disabled",2),s([K({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:n=>n}})],y.prototype,"readonly",2),s([K({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:n=>n}})],y.prototype,"checked",2),s([f("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"handleDisabledChange",1);import{html as pr,LitElement as dr}from"lit";var V=class extends dr{render(){return pr``}defaultValues(i){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(r=>r.innerHTML);return t.length>1||i.cardinality==="multiple"||i.cardinality==="ordered"?t:t[0]}};customElements.define("qti-variabledeclaration",V);import{property as He}from"lit/decorators.js";var P=class extends V{connectedCallback(){super.connectedCallback();let e=new $;e.baseType=this.baseType,e.identifier=this.identifier,e.correctResponse=this.correctResponse,e.cardinality=this.cardinality||"single",e.mapping=this.mapping,e.value=this.defaultValues(e),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([He({type:String,attribute:"base-type"})],P.prototype,"baseType",2),s([He({type:String})],P.prototype,"identifier",2),s([He({type:String})],P.prototype,"cardinality",2);customElements.define("qti-response-declaration",P);import{property as $e}from"lit/decorators.js";var I=class extends V{get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let r of e.querySelectorAll("qti-interpolation-table-entry")){!r.getAttribute("source-value")&&r.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let o=parseInt(r.getAttribute("source-value")),a=parseInt(r.getAttribute("target-value"));(isNaN(o)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(o,a)}}return null}connectedCallback(){super.connectedCallback();let e=new H;e.identifier=this.identifier,e.cardinality=this.cardinality,e.baseType=this.baseType,e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};s([$e({type:String,attribute:"base-type"})],I.prototype,"baseType",2),s([$e({type:String})],I.prototype,"identifier",2),s([$e({type:String})],I.prototype,"cardinality",2);customElements.define("qti-outcome-declaration",I);import{LitElement as ur}from"lit";import{customElement as mr}from"lit/decorators.js";var se=class extends ur{};se=s([mr("qti-companion-materials-info")],se);import{LitElement as hr,css as fr,html as br}from"lit";import{customElement as gr,property as oe}from"lit/decorators.js";import{ContextConsumer as vr}from"@lit-labs/context";var T=class extends hr{constructor(){super(...arguments);this.logger=new vr(this,bt,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 br`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};T.styles=fr`
|
|
6
6
|
:host {
|
|
7
7
|
display: block;
|
|
8
8
|
}
|
|
9
|
-
`,s([
|
|
9
|
+
`,s([oe({type:String})],T.prototype,"id",2),s([oe({type:String})],T.prototype,"use",2),s([oe({type:String})],T.prototype,"view",2),s([oe({type:String,attribute:"class"})],T.prototype,"classNames",2),s([f("classNames",{waitUntilFirstUpdate:!0})],T.prototype,"handleclassNamesChange",1),T=s([gr("qti-rubric-block")],T);import{LitElement as yr,html as xr}from"lit";import{customElement as Er}from"lit/decorators.js";var ne=class extends yr{render(){return xr`<slot></slot>`}};ne=s([Er("qti-content-body")],ne);import{css as Cr,html as _r}from"lit";import{LitElement as qr}from"lit";import{property as ae}from"lit/decorators.js";var E=class extends qr{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){let t=this.closest("qti-assessment-item").getOutcome(e);if(this.outcomeIdentifier!==e||!t)return;let r=!1;Array.isArray(t.value)?r=t.baseType=="float"||t.baseType=="integer"?t.value.includes(this.identifier):t.value.includes(this.identifier):r=t.baseType=="float"||t.baseType=="integer"?this.identifier===t.value:this.identifier===t.value,this.showFeedback(r)}showFeedback(e){this.showStatus=e?"on":"off"}};s([ae({type:String,attribute:"show-hide"})],E.prototype,"showHide",2),s([ae({type:String,attribute:"outcome-identifier"})],E.prototype,"outcomeIdentifier",2),s([ae({type:String})],E.prototype,"identifier",2),s([ae({type:String,attribute:!1})],E.prototype,"showStatus",2);var le=class extends E{constructor(){super(...arguments);this.render=()=>_r` <slot class="${this.showStatus}"></slot> `}};le.styles=Cr`
|
|
10
10
|
.on {
|
|
11
11
|
display: inline-block;
|
|
12
12
|
}
|
|
13
13
|
.off {
|
|
14
14
|
display: none;
|
|
15
15
|
}
|
|
16
|
-
`;customElements.define("qti-feedback-inline",
|
|
16
|
+
`;customElements.define("qti-feedback-inline",le);import{html as kr}from"lit";var Oe=class extends E{render(){return kr`
|
|
17
17
|
<style>
|
|
18
18
|
.on {
|
|
19
19
|
display: inline-block;
|
|
@@ -25,7 +25,7 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
25
25
|
<div class="feedback ${this.showStatus}">
|
|
26
26
|
<slot></slot>
|
|
27
27
|
</div>
|
|
28
|
-
`}};customElements.define("qti-modal-feedback",Oe);import{html as
|
|
28
|
+
`}};customElements.define("qti-modal-feedback",Oe);import{html as Ar}from"lit";var Pe=class extends E{render(){return Ar`
|
|
29
29
|
<style>
|
|
30
30
|
.on {
|
|
31
31
|
display: block;
|
|
@@ -37,7 +37,7 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
37
37
|
<div class="feedback ${this.showStatus}">
|
|
38
38
|
<slot></slot>
|
|
39
39
|
</div>
|
|
40
|
-
`}firstUpdated(i){this.checkShowFeedback(this.outcomeIdentifier)}};customElements.define("qti-feedback-block",Pe);import{css as
|
|
40
|
+
`}firstUpdated(i){this.checkShowFeedback(this.outcomeIdentifier)}};customElements.define("qti-feedback-block",Pe);import{css as wr,html as Rr}from"lit";import{ifDefined as Rt}from"lit/directives/if-defined.js";import{property as Ie}from"lit/decorators.js";import{LitElement as Tr}from"lit";var m=class extends Tr{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([Ie({attribute:"response-identifier"})],m.prototype,"responseIdentifier",2),s([Ie({reflect:!0,type:Boolean})],m.prototype,"disabled",2),s([Ie({reflect:!0,type:Boolean})],m.prototype,"readonly",2);import{customElement as Lr,property as ce,state as Lt}from"lit/decorators.js";import{createRef as Sr}from"lit/directives/ref.js";var k=class extends m{constructor(){super(...arguments);this._value="";this._size=5;this.inputRef=Sr()}handleclassNamesChange(e,t){t.split(" ").forEach(o=>{if(o.startsWith("qti-input-width")){let a=o.replace("qti-input-width-","");this._size=parseInt(a)}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[wr`
|
|
41
41
|
:host {
|
|
42
42
|
display: inline-flex;
|
|
43
43
|
}
|
|
@@ -49,13 +49,13 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
49
49
|
@keyup="${this.textChanged}"
|
|
50
50
|
@change="${this.textChanged}"
|
|
51
51
|
type="text"
|
|
52
|
-
placeholder="${
|
|
52
|
+
placeholder="${Rt(this.placeholderText?this.placeholderText:void 0)}"
|
|
53
53
|
.value="${this._value}"
|
|
54
54
|
size="${this._size}"
|
|
55
|
-
pattern="${
|
|
55
|
+
pattern="${Rt(this.patternMask?this.patternMask:void 0)}"
|
|
56
56
|
?disabled="${this.disabled}"
|
|
57
57
|
?readonly="${this.readonly}"
|
|
58
|
-
/>`}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([
|
|
58
|
+
/>`}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([ce({type:Number,attribute:"expected-length"})],k.prototype,"expectedLength",2),s([ce({type:String,attribute:"pattern-mask"})],k.prototype,"patternMask",2),s([ce({type:String,attribute:"placeholder-text"})],k.prototype,"placeholderText",2),s([Lt()],k.prototype,"_value",2),s([Lt()],k.prototype,"_size",2),s([ce({type:String,attribute:"class"})],k.prototype,"classNames",2),s([f("classNames")],k.prototype,"handleclassNamesChange",1),k=s([Lr("qti-text-entry-interaction")],k);import{css as Mr,html as Vr}from"lit";import{ifDefined as Fe}from"lit/directives/if-defined.js";import{ref as Nr,createRef as Dr}from"lit/directives/ref.js";import{customElement as Hr,property as pe,state as $r}from"lit/decorators.js";var w=class extends m{constructor(){super(...arguments);this.textareaRef=Dr();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let a=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(a))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Mr`
|
|
59
59
|
/* PK: display host as block, else design will be collapsed */
|
|
60
60
|
:host {
|
|
61
61
|
display: block;
|
|
@@ -66,9 +66,9 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
66
66
|
height: 100%;
|
|
67
67
|
border: 0;
|
|
68
68
|
}
|
|
69
|
-
`]}render(){return
|
|
69
|
+
`]}render(){return Vr`<textarea
|
|
70
70
|
part="textarea"
|
|
71
|
-
${
|
|
71
|
+
${Nr(this.textareaRef)}
|
|
72
72
|
spellcheck="false"
|
|
73
73
|
autocomplete="off"
|
|
74
74
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
@@ -80,7 +80,7 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
80
80
|
?disabled="${this.disabled}"
|
|
81
81
|
?readonly="${this.readonly}"
|
|
82
82
|
.value=${this._value}
|
|
83
|
-
></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([
|
|
83
|
+
></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([pe({type:Number,attribute:"expected-length"})],w.prototype,"expectedLength",2),s([pe({type:String,attribute:"pattern-mask"})],w.prototype,"patternMask",2),s([pe({type:String,attribute:"placeholder-text"})],w.prototype,"placeholderText",2),s([$r()],w.prototype,"_value",2),s([pe({type:String,attribute:"class"})],w.prototype,"classNames",2),s([f("classNames",{waitUntilFirstUpdate:!0})],w.prototype,"handleclassNamesChange",1),w=s([Hr("qti-extended-text-interaction")],w);import{html as Or}from"lit";import{property as St}from"lit/decorators.js";var v=class extends m{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([St({type:Number,attribute:"min-choices"})],v.prototype,"minChoices",2),s([St({type:Number,attribute:"max-choices"})],v.prototype,"maxChoices",2),s([f("disabled",{waitUntilFirstUpdate:!0})],v.prototype,"_handleDisabledChange",2),s([f("readonly",{waitUntilFirstUpdate:!0})],v.prototype,"_handleReadonlyChange",2),s([f("maxChoices",{waitUntilFirstUpdate:!0})],v.prototype,"_handleMaxChoicesChange",2);var Ue=class extends v{constructor(){super(...arguments);this.render=()=>Or`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",Ue);import{css as Pr,html as Mt}from"lit";var de=class extends m{constructor(){super();this.options=[];this.addEventListener(Tt.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 D(_({},m.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[Pr`
|
|
84
84
|
:host {
|
|
85
85
|
display: inline-block;
|
|
86
86
|
}
|
|
@@ -91,13 +91,13 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
91
91
|
?readonly="${this.readonly}"
|
|
92
92
|
>
|
|
93
93
|
${this.options.map(e=>Mt` <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option> `)}
|
|
94
|
-
</select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>D(_({},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=>D(_({},r),{selected:r.value===t})),this.saveResponse(t)}};
|
|
94
|
+
</select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>D(_({},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=>D(_({},r),{selected:r.value===t})),this.saveResponse(t)}};de.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",de);import{customElement as Fr,property as Ur}from"lit/decorators.js";import{html as Xr}from"lit";import{css as Ir}from"lit";var Vt=Ir`
|
|
95
95
|
:host {
|
|
96
96
|
display: flex;
|
|
97
97
|
flex-direction: column;
|
|
98
|
-
align-items: flex-start;
|
|
98
|
+
// align-items: flex-start;
|
|
99
99
|
}
|
|
100
|
-
`;var
|
|
100
|
+
`;var F=class extends v{constructor(){super(...arguments);this.render=()=>Xr` <slot name="prompt"></slot><slot></slot>`}};F.styles=Vt,s([Ur({type:String})],F.prototype,"orientation",2),F=s([Fr("qti-choice-interaction")],F);import{customElement as Yr}from"lit/decorators.js";import{html as Br,LitElement as zr}from"lit";var Nt=`<qti-response-processing>
|
|
101
101
|
<qti-response-condition>
|
|
102
102
|
<qti-response-if>
|
|
103
103
|
<qti-match>
|
|
@@ -146,8 +146,8 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
146
146
|
</qti-set-outcome-value>
|
|
147
147
|
</qti-response-else>
|
|
148
148
|
</qti-response-condition>
|
|
149
|
-
</qti-response-processing>`;var
|
|
150
|
-
${this._debug?
|
|
149
|
+
</qti-response-processing>`;var U=class extends zr{render(){return Br`<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(Dt));break}case"map_response_point":{this.appendChild(this.fragmentFromString(Ht));break}case"match_correct":this.appendChild(this.fragmentFromString(Nt));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};U=s([Yr("qti-response-processing")],U);import{customElement as jr}from"lit/decorators.js";import{html as Kr,LitElement as Wr}from"lit";var S=class extends Wr{render(){return Kr`<slot></slot>`}process(){throw new Error("Not implemented")}};S=s([jr("qti-rule")],S);import{html as Gr}from"lit";var Xe=class extends S{render(){return Gr`<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",Xe);var Ye=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",Ye);import{html as Qr}from"lit";import{html as Jr,LitElement as Zr}from"lit";var W=class extends Zr{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Jr` <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",W);var G=class extends W{render(){return Qr`${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",G);import{html as ei}from"lit";var Be=class extends G{render(){return ei`${super.render()}`}};customElements.define("qti-response-else-if",Be);import{LitElement as ti,css as ri,html as J,nothing as ze}from"lit";import{state as $t}from"lit/decorators.js";var u=class extends ti{constructor(){super(...arguments);this._error=[];this._debug=!1;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.getVariable(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:{try{return{baseType:"integer",value:e.calculate().toString(),cardinality:"single"}}catch(t){console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}set error(e){let t=this._error;this._error.push(e),this.requestUpdate("error",t)}render(){return J`${this._debug?J`${this._error.map(e=>J`<div role="alert">${e}</div>`)}`:ze}
|
|
150
|
+
${this._debug?J`${JSON.stringify(this._result)}`:ze} ${this._debug?J`<slot></slot>`:ze}`}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};u.styles=ri`
|
|
151
151
|
:host {
|
|
152
152
|
display: inline;
|
|
153
153
|
}
|
|
@@ -160,15 +160,15 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
160
160
|
border-radius: 5px;
|
|
161
161
|
margin-bottom: 3px;
|
|
162
162
|
}
|
|
163
|
-
`,s([$t()],u.prototype,"_result",2),s([$t()],u.prototype,"error",1);var q=class extends u{calculate(){throw new Error("Not implemented")}};var je=class extends q{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",je);import{property as ri}from"lit/decorators.js";var de=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([ri({type:String,attribute:"base-type"})],de.prototype,"baseType",2);customElements.define("qti-base-value",de);var Ke=class extends q{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);var We=class extends u{get interpretation(){return this.getAttribute("interpretation")||""}calculate(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",We);import{property as ii}from"lit/decorators.js";var w=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),o=parseInt(e,10);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),o=parseFloat(e);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),o=e.split(" ").sort();if(r.length===2&&o.length===2)return t==="pair"&&(r.sort(),o.sort()),r.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var ue=class extends u{constructor(){super(...arguments);this.toleranceMode="exact"}calculate(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):w.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([ii({type:String})],ue.prototype,"toleranceMode",2);customElements.define("qti-equal",ue);import{property as si}from"lit/decorators.js";var me=class extends u{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}calculate(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(t.value),a=parseFloat(r.value);if(!isNaN(o)&&!isNaN(a))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};s([si({type:String})],me.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",me);var Ge=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",Ge);var Je=class extends q{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",Je);var Ze=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",Ze);var Qe=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Qe);var et=class extends q{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",et);import{property as tt}from"lit/decorators.js";import{LitElement as oi}from"lit";var U=class extends oi{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([tt({attribute:"default-value",type:Number})],U.prototype,"defaultValue",2),s([tt({attribute:"lower-bound",type:Number})],U.prototype,"lowerBound",2),s([tt({attribute:"upper-bound",type:Number})],U.prototype,"upperBound",2);customElements.define("qti-mapping",U);import{property as ni}from"lit/decorators.js";var he=class extends u{calculate(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],o=0;for(let a of r){let l=t.mapEntries.find(c=>w.compareSingleValues(c.mapKey,a,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([ni({type:String})],he.prototype,"identifier",2);customElements.define("qti-map-response",he);var rt=class n extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return this._result=n.match(e,t),this._result}return console.error("unexpected number of children in match"),null}static match(i,e){if(e.cardinality==="single")return Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):w.compareSingleValues(i.value.toString(),e.value.toString(),e.baseType);{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;let t=0;for(let r of e.value){if(e.cardinality==="ordered"){let o=i[t];if(!w.compareSingleValues(r,o,e.baseType))return!1}else{let o=null;for(let a of i.value)if(w.compareSingleValues(r,a,e.baseType)){o=a;break}if(o!==null)i.value.splice(i.value.indexOf(o),1);else return!1}t++}return!0}}};customElements.define("qti-match",rt);var it=class extends u{calculate(){let i=this.getVariables();this.children.length!==2&&(this.error="The member operator takes two sub-expressions");let[e,t]=i;if(e.baseType!==t.baseType&&(this.error="Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||(this.error="and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&(this.error="The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&(this.error="It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let r=e.value;return t.value.includes(r)}};customElements.define("qti-member",it);var st=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",st);import{html as ai}from"lit";var ot=class extends u{render(){return ai`${super.render()}`}calculate(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",ot);import{html as li}from"lit";var nt=class extends q{render(){return li``}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",nt);var at=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",at);import{LitElement as ci,html as Ot}from"lit";import{property as pi,state as di}from"lit/decorators.js";var J=class extends ci{constructor(){super();this.value="";this.closest("qti-assessment-item").addEventListener("qti-response-processing",()=>{this.value=this.calculate()})}render(){return Ot`${Array.isArray(this.value)?this.value.map(e=>Ot`${e}`):this.value}`}calculate(){let e=this.closest("qti-assessment-item"),t=this.identifier;return e.getVariable(t).value}};s([pi({type:String})],J.prototype,"identifier",2),s([di()],J.prototype,"value",2);customElements.define("qti-printed-variable",J);var lt=class extends u{calculate(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch(o){console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",lt);var ct=class extends u{calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariable(i).value}};customElements.define("qti-variable",ct);import{LitElement as ui,html as Pt}from"lit";var pt=class extends ui{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),h=d.map(g=>g.getAttribute("key"));h.length>0&&!h.find(g=>!Number.isInteger(+g))?c[p]=d.map(g=>a(g)):c[p]=l.textContent}return c},a=l=>{if(l){let c={};for(let p of l.children)c=_(_({},c),o(p));return c}};for(let l of t)return l.getAttribute("key")||(r=_(_({},r),a(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 Pt`<slot></slot>${this._errorMessage&&Pt`<div style="color:red">
|
|
163
|
+
`,s([$t()],u.prototype,"_result",2),s([$t()],u.prototype,"error",1);var q=class extends u{calculate(){throw new Error("Not implemented")}};var je=class extends q{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",je);import{property as ii}from"lit/decorators.js";var ue=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([ii({type:String,attribute:"base-type"})],ue.prototype,"baseType",2);customElements.define("qti-base-value",ue);var Ke=class extends q{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);var We=class extends u{get interpretation(){return this.getAttribute("interpretation")||""}calculate(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",We);import{property as si}from"lit/decorators.js";var R=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):R.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([si({type:String})],me.prototype,"toleranceMode",2);customElements.define("qti-equal",me);import{property as oi}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),a=parseFloat(r.value);if(!isNaN(o)&&!isNaN(a))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};s([oi({type:String})],he.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",he);var Ge=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",Ge);var Je=class extends q{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",Je);var Ze=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",Ze);var Qe=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Qe);var et=class extends q{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",et);import{property as tt}from"lit/decorators.js";import{LitElement as ni}from"lit";var X=class extends ni{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([tt({attribute:"default-value",type:Number})],X.prototype,"defaultValue",2),s([tt({attribute:"lower-bound",type:Number})],X.prototype,"lowerBound",2),s([tt({attribute:"upper-bound",type:Number})],X.prototype,"upperBound",2);customElements.define("qti-mapping",X);import{property as ai}from"lit/decorators.js";var fe=class extends u{calculate(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],o=0;for(let a of r){let l=t.mapEntries.find(c=>R.compareSingleValues(c.mapKey,a,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([ai({type:String})],fe.prototype,"identifier",2);customElements.define("qti-map-response",fe);var rt=class n extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return this._result=n.match(e,t),this._result}return console.error("unexpected number of children in match"),null}static match(i,e){if(e.cardinality==="single")return Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):R.compareSingleValues(i.value.toString(),e.value.toString(),e.baseType);{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;let t=0;for(let r of e.value){if(e.cardinality==="ordered"){let o=i[t];if(!R.compareSingleValues(r,o,e.baseType))return!1}else{let o=null;for(let a of i.value)if(R.compareSingleValues(r,a,e.baseType)){o=a;break}if(o!==null)i.value.splice(i.value.indexOf(o),1);else return!1}t++}return!0}}};customElements.define("qti-match",rt);var it=class extends u{calculate(){let i=this.getVariables();this.children.length!==2&&(this.error="The member operator takes two sub-expressions");let[e,t]=i;if(e.baseType!==t.baseType&&(this.error="Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||(this.error="and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&(this.error="The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&(this.error="It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let r=e.value;return t.value.includes(r)}};customElements.define("qti-member",it);var st=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",st);import{html as li}from"lit";var ot=class extends u{render(){return li`${super.render()}`}calculate(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",ot);import{html as ci}from"lit";var nt=class extends q{render(){return ci``}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",nt);var at=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",at);import{LitElement as pi,html as Ot}from"lit";import{property as di,state as ui}from"lit/decorators.js";var Z=class extends pi{constructor(){super();this.value="";this.closest("qti-assessment-item").addEventListener("qti-response-processing",()=>{this.value=this.calculate()})}render(){return Ot`${Array.isArray(this.value)?this.value.map(e=>Ot`${e}`):this.value}`}calculate(){let e=this.closest("qti-assessment-item"),t=this.identifier;return e.getVariable(t).value}};s([di({type:String})],Z.prototype,"identifier",2),s([ui()],Z.prototype,"value",2);customElements.define("qti-printed-variable",Z);var lt=class extends u{calculate(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch(o){console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",lt);var ct=class extends u{calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariable(i).value}};customElements.define("qti-variable",ct);import{LitElement as mi,html as Pt}from"lit";var pt=class extends mi{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),h=d.map(g=>g.getAttribute("key"));h.length>0&&!h.find(g=>!Number.isInteger(+g))?c[p]=d.map(g=>a(g)):c[p]=l.textContent}return c},a=l=>{if(l){let c={};for(let p of l.children)c=_(_({},c),o(p));return c}};for(let l of t)return l.getAttribute("key")||(r=_(_({},r),a(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 Pt`<slot></slot>${this._errorMessage&&Pt`<div style="color:red">
|
|
164
164
|
<h1>Error</h1>
|
|
165
165
|
${this._errorMessage}
|
|
166
|
-
</div>`}`}};customElements.define("qti-portable-custom-interaction",pt);import{LitElement as hi,css as fi,html as Ut}from"lit";var fe=class n{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 n._instance?n._instance:(n._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 mi}from"lit/decorators.js";var It=(n,i,e)=>{class t extends n{constructor(){super(...arguments);this.disabled=!1}firstUpdated(a){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(a);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(a){a.addEventListener("dragover",this.dragoverHandler),a.addEventListener("drop",this.dropHandler)}removeHandler(a){a.removeEventListener("dragover",this.dragoverHandler),a.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var a;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(a=this.observer)==null||a.disconnect())}dragoverHandler(a){return a.preventDefault(),a.currentTarget.setAttribute("active",""),a.dataTransfer.dropEffect="move",!1}dropHandler(a){a.preventDefault();let l=a.currentTarget,c=this.querySelector(`[identifier=${a.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${a.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${a.target?JSON.stringify(a.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(a){return a.preventDefault(),a.currentTarget.removeAttribute("active"),!1}}return s([mi({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var Ft=(n,i,e)=>{class t extends n{}return t};import{property as X}from"lit/decorators.js";var L=(n,i,e,t)=>{class r extends Ft(It(n,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",h=>{h.dataTransfer.setData("text",h.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",h=>{if(h.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),h.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let C=h.currentTarget,g=this.draggables.get(C),Me=g.index<g.parent.children.length?g.index:g.parent.children.length-1,b=g.parent,Ve=g.parent.children[Me];b.insertBefore(C,Ve),this.saveResponse(),this.checkMaxMatchAssociations()}h.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 fe,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,h=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[h])}),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 h=this.droppables.find(C=>C.getAttribute("identifier")===p);d.forEach(C=>{let g=this.querySelector(`[identifier=${C}]`);h?g?(h.appendChild(g),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${C}`):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(h=>h.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([gt(i)],r.prototype,"reInitDragAndDrop",1),s([X({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([X({attribute:!1,type:Object})],r.prototype,"configuration",2),s([f("configuration")],r.prototype,"handleDragOptionsChanged",1),s([X({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([f("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([X({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([f("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([X({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([X({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as bi}from"lit/decorators.js";var Z=class extends L(hi,"qti-simple-associable-choice",!0,".dl"){render(){return Ut` <slot name="prompt"></slot>
|
|
166
|
+
</div>`}`}};customElements.define("qti-portable-custom-interaction",pt);import{LitElement as fi,css as bi,html as Ut}from"lit";var be=class n{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 n._instance?n._instance:(n._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 hi}from"lit/decorators.js";var It=(n,i,e)=>{class t extends n{constructor(){super(...arguments);this.disabled=!1}firstUpdated(a){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(a);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(a){a.addEventListener("dragover",this.dragoverHandler),a.addEventListener("drop",this.dropHandler)}removeHandler(a){a.removeEventListener("dragover",this.dragoverHandler),a.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var a;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(a=this.observer)==null||a.disconnect())}dragoverHandler(a){return a.preventDefault(),a.currentTarget.setAttribute("active",""),a.dataTransfer.dropEffect="move",!1}dropHandler(a){a.preventDefault();let l=a.currentTarget,c=this.querySelector(`[identifier=${a.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${a.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${a.target?JSON.stringify(a.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(a){return a.preventDefault(),a.currentTarget.removeAttribute("active"),!1}}return s([hi({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var Ft=(n,i,e)=>{class t extends n{}return t};import{property as Y}from"lit/decorators.js";var L=(n,i,e,t)=>{class r extends Ft(It(n,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",h=>{h.dataTransfer.setData("text",h.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",h=>{if(h.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),h.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let C=h.currentTarget,g=this.draggables.get(C),Me=g.index<g.parent.children.length?g.index:g.parent.children.length-1,b=g.parent,Ve=g.parent.children[Me];b.insertBefore(C,Ve),this.saveResponse(),this.checkMaxMatchAssociations()}h.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 be,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,h=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[h])}),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 h=this.droppables.find(C=>C.getAttribute("identifier")===p);d.forEach(C=>{let g=this.querySelector(`[identifier=${C}]`);h?g?(h.appendChild(g),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${C}`):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(h=>h.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([gt(i)],r.prototype,"reInitDragAndDrop",1),s([Y({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([Y({attribute:!1,type:Object})],r.prototype,"configuration",2),s([f("configuration")],r.prototype,"handleDragOptionsChanged",1),s([Y({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([f("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([Y({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([f("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([Y({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([Y({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as gi}from"lit/decorators.js";var Q=class extends L(fi,"qti-simple-associable-choice",!0,".dl"){render(){return Ut` <slot name="prompt"></slot>
|
|
167
167
|
<slot name="qti-simple-associable-choice"></slot>
|
|
168
168
|
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Ut`<div part="associables-container">
|
|
169
169
|
<div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
|
|
170
170
|
<div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
|
|
171
|
-
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};
|
|
171
|
+
</div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};Q.styles=bi`
|
|
172
172
|
:host {
|
|
173
173
|
display: block; /* necessary to calculate scaling position */
|
|
174
174
|
}
|
|
@@ -177,8 +177,8 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
177
177
|
flex-wrap: wrap;
|
|
178
178
|
gap: 0.5rem;
|
|
179
179
|
}
|
|
180
|
-
`,s([
|
|
181
|
-
<slot part="drops"></slot>`}};
|
|
180
|
+
`,s([gi()],Q.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",Q);import{css as vi,html as yi,LitElement as xi}from"lit";var ge=class extends L(xi,"qti-gap-text",!1,"qti-gap"){render(){return yi` <slot part="drags" name="qti-gap-text"></slot>
|
|
181
|
+
<slot part="drops"></slot>`}};ge.styles=[vi`
|
|
182
182
|
:host {
|
|
183
183
|
display: flex;
|
|
184
184
|
align-items: flex-start;
|
|
@@ -201,14 +201,14 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
201
201
|
align-items: flex-start;
|
|
202
202
|
flex: 1;
|
|
203
203
|
}
|
|
204
|
-
`];customElements.define("qti-gap-match-interaction",
|
|
204
|
+
`];customElements.define("qti-gap-match-interaction",ge);import{css as Ei,svg as Xt,html as qi}from"lit";function B(n,i,e,t){switch(n){case"circle":{let[r,o,a]=i,l=r/e.width*100,c=o/e.height*100,p=a/e.width*100;t.style.left=l-p+"%",t.style.top=c-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,o,a,l]=i,c=r/e.width*100,p=o/e.height*100,d=a/e.width*100,h=l/e.height*100;t.style.left=c+"%",t.style.top=p+"%",t.style.width=d-c+"%",t.style.height=h-p+"%"}break;case"poly":{let r=i.reduce((b,Ve,ft,Wt)=>{if(ft%2===1){let Gt=b.pop();b[b.length]={x:Gt,y:Wt[ft]}}else b.push(Ve);return b},[]),o=Math.min(...r.map(b=>b.x)),a=Math.max(...r.map(b=>b.x)),l=Math.min(...r.map(b=>b.y)),c=Math.max(...r.map(b=>b.y)),p=o/e.width*100,d=l/e.height*100,h=a/e.width*100,C=c/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=l/e.height*100+"%",t.style.width=h-p+"%",t.style.height=C-d+"%";let Me=r.map(b=>({x:(b.x-o)/(a-o)*100,y:(b.y-l)/(c-l)*100})).map(b=>Math.round(b.x)+"% "+Math.round(b.y)+"%").join(",");t.style.clipPath=`polygon(${Me})`}break;default:break}}import{query as Ci,queryAssignedElements as _i,state as dt}from"lit/decorators.js";import{repeat as ki}from"lit/directives/repeat.js";import{ifDefined as Yt}from"lit/directives/if-defined.js";var M=class extends m{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,o;return qi`<slot name="prompt"></slot>
|
|
205
205
|
<line-container>
|
|
206
206
|
<svg
|
|
207
207
|
width=${Yt((e=this.grImage[0])==null?void 0:e.width)}
|
|
208
208
|
height=${Yt((t=this.grImage[0])==null?void 0:t.height)}
|
|
209
209
|
viewbox="0 0 ${(r=this.grImage[0])==null?void 0:r.width} ${(o=this.grImage[0])==null?void 0:o.height}"
|
|
210
210
|
>
|
|
211
|
-
${
|
|
211
|
+
${ki(this._lines,a=>a,(a,l)=>Xt`
|
|
212
212
|
<line
|
|
213
213
|
part="line"
|
|
214
214
|
x1=${parseInt(this.querySelector("[identifier="+a.split(" ")[0]+"]").style.left)}
|
|
@@ -231,7 +231,7 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
231
231
|
/>`}
|
|
232
232
|
</svg>
|
|
233
233
|
<slot></slot>
|
|
234
|
-
</line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));
|
|
234
|
+
</line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));B(a,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=[Ei`
|
|
235
235
|
slot:not([name='prompt']) {
|
|
236
236
|
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
237
237
|
display: block;
|
|
@@ -254,8 +254,8 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
254
254
|
top: 0px;
|
|
255
255
|
left: 0px;
|
|
256
256
|
}
|
|
257
|
-
`],s([dt()],M.prototype,"_lines",2),s([dt()],M.prototype,"startCoord",2),s([dt()],M.prototype,"mouseCoord",2),s([
|
|
258
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=a;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]=a;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)}};
|
|
257
|
+
`],s([dt()],M.prototype,"_lines",2),s([dt()],M.prototype,"startCoord",2),s([dt()],M.prototype,"mouseCoord",2),s([Ci("svg")],M.prototype,"svgContainer",2),s([_i({selector:"img"})],M.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",M);import{css as Ai,html as Ti,LitElement as wi}from"lit";var ve=class extends L(wi,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return Ti` <slot></slot>
|
|
258
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=a;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]=a;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=Ai`
|
|
259
259
|
:host {
|
|
260
260
|
display: inline-block;
|
|
261
261
|
position: relative;
|
|
@@ -264,12 +264,12 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
264
264
|
display: flex;
|
|
265
265
|
gap: 1rem;
|
|
266
266
|
}
|
|
267
|
-
`;customElements.define("qti-graphic-gap-match-interaction",
|
|
267
|
+
`;customElements.define("qti-graphic-gap-match-interaction",ve);import{css as Ri,html as Li}from"lit";var ye=class extends v{render(){return Li`
|
|
268
268
|
<slot name="prompt"></slot>
|
|
269
269
|
<!-- slot for the prompt -->
|
|
270
270
|
<slot></slot>
|
|
271
271
|
<!-- slot for the image and hotspots -->
|
|
272
|
-
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));
|
|
272
|
+
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));B(a,l,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};ye.styles=[Ri`
|
|
273
273
|
slot:not([name='prompt']) {
|
|
274
274
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
275
275
|
display: block;
|
|
@@ -280,12 +280,12 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
280
280
|
pointer-events: none;
|
|
281
281
|
user-select: none;
|
|
282
282
|
}
|
|
283
|
-
`];customElements.define("qti-graphic-order-interaction",
|
|
283
|
+
`];customElements.define("qti-graphic-order-interaction",ye);import{css as Si,html as Mi}from"lit";var xe=class extends v{render(){return Mi`
|
|
284
284
|
<slot name="prompt"></slot>
|
|
285
285
|
<!-- slot for the prompt -->
|
|
286
286
|
<slot></slot>
|
|
287
287
|
<!-- slot for the image and hotspots -->
|
|
288
|
-
`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));
|
|
288
|
+
`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));B(o,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};xe.styles=[Si`
|
|
289
289
|
slot:not([name='prompt']) {
|
|
290
290
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
291
291
|
display: block;
|
|
@@ -297,26 +297,26 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
297
297
|
user-select: none;
|
|
298
298
|
/* width:100%; */
|
|
299
299
|
}
|
|
300
|
-
`];customElements.define("qti-hotspot-interaction",
|
|
300
|
+
`];customElements.define("qti-hotspot-interaction",xe);import{html as ee,LitElement as Di}from"lit";import{html as Vi,LitElement as Ni}from"lit";var ut=class extends Ni{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return Vi`
|
|
301
301
|
<slot></slot>
|
|
302
302
|
<slot name="qti-simple-associable-choice"></slot>
|
|
303
|
-
`}};customElements.define("qti-simple-associable-choice",ut);var
|
|
303
|
+
`}};customElements.define("qti-simple-associable-choice",ut);var Ee=class extends L(Di,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice"))}render(){return this.classList.contains("qti-match-tabular")?ee`<table>
|
|
304
304
|
<tr>
|
|
305
305
|
<td><slot name="prompt"></slot></td>
|
|
306
|
-
${this.cols.map((e,t)=>
|
|
306
|
+
${this.cols.map((e,t)=>ee`<th>${e.innerHTML}</th>`)}
|
|
307
307
|
</tr>
|
|
308
|
-
${this.rows.map(e=>
|
|
308
|
+
${this.rows.map(e=>ee`<tr>
|
|
309
309
|
<td>${e.innerHTML}</td>
|
|
310
|
-
${this.cols.map((t,r)=>
|
|
310
|
+
${this.cols.map((t,r)=>ee`<td><input type="checkbox" /></td>`)}
|
|
311
311
|
</tr>`)}
|
|
312
|
-
</table>`:
|
|
313
|
-
<slot></slot>`}connectedCallback(){super.connectedCallback()}};
|
|
312
|
+
</table>`:ee`<slot name="prompt"></slot> <slot></slot>`}};Ee.styles=[];customElements.define("qti-match-interaction",Ee);import{css as Hi,html as $i}from"lit";var qe=class extends m{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return D(_({},m.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return $i` <slot name="prompt"></slot>
|
|
313
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback()}};qe.styles=[Hi``];customElements.define("qti-media-interaction",qe);import{css as Oi,html as Bt,LitElement as Pi}from"lit";import{property as Ii}from"lit/decorators.js";var z=class extends L(Pi,"qti-simple-choice",!0,"drop-list"){render(){return Bt` <slot name="prompt"> </slot>
|
|
314
314
|
<div part="container">
|
|
315
315
|
<slot part="drags"> </slot>
|
|
316
316
|
<div part="drops">
|
|
317
317
|
${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>Bt`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
|
|
318
318
|
</div>
|
|
319
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};
|
|
319
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};z.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],z.styles=[Oi`
|
|
320
320
|
[part='drags'] {
|
|
321
321
|
display: flex;
|
|
322
322
|
align-items: flex-start;
|
|
@@ -364,7 +364,7 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
364
364
|
:host(.qti-choices-right) [part='container'] {
|
|
365
365
|
flex-direction: row-reverse;
|
|
366
366
|
}
|
|
367
|
-
`],s([
|
|
367
|
+
`],s([Ii({type:String})],z.prototype,"orientation",2);customElements.define("qti-order-interaction",z);import{LitElement as Fi,css as Ui,html as Xi}from"lit";var Ce=class extends Fi{render(){return Xi`<slot></slot>`}};Ce.styles=[Ui`
|
|
368
368
|
:host {
|
|
369
369
|
display: block;
|
|
370
370
|
}
|
|
@@ -375,22 +375,22 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
375
375
|
left: 50%;
|
|
376
376
|
transform: translateX(-50%);
|
|
377
377
|
}
|
|
378
|
-
`];customElements.define("qti-position-object-interaction",
|
|
378
|
+
`];customElements.define("qti-position-object-interaction",Ce);import{LitElement as Yi,css as Bi,html as zi}from"lit";var _e=class extends Yi{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return zi`<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=[Bi`
|
|
379
379
|
:host {
|
|
380
380
|
display: inline-block;
|
|
381
381
|
position: relative;
|
|
382
382
|
}
|
|
383
|
-
`];customElements.define("qti-position-object-stage",
|
|
383
|
+
`];customElements.define("qti-position-object-stage",_e);import{css as ji,html as zt}from"lit";import{property as jt,state as Ki}from"lit/decorators.js";import{repeat as Wi}from"lit/directives/repeat.js";import{styleMap as Gi}from"lit/directives/style-map.js";var N=class extends m{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return zt` <slot name="prompt"></slot>
|
|
384
384
|
<point-container>
|
|
385
|
-
${
|
|
385
|
+
${Wi(this._points,e=>e,(e,t)=>zt`
|
|
386
386
|
<button
|
|
387
387
|
part="point"
|
|
388
|
-
style=${
|
|
388
|
+
style=${Gi({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
|
|
389
389
|
@click=${r=>{r.stopPropagation(),this._points=this._points.filter((o,a)=>a!==t),this.saveResponse(this._points)}}
|
|
390
390
|
></button>
|
|
391
391
|
`)}
|
|
392
392
|
<slot></slot>
|
|
393
|
-
</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()}};N.styles=[
|
|
393
|
+
</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()}};N.styles=[ji`
|
|
394
394
|
host() {
|
|
395
395
|
display: block;
|
|
396
396
|
}
|
|
@@ -398,26 +398,34 @@ import{a as gt,b as f}from"../chunk-BVYXUE3V.js";import{a as bt}from"../chunk-5G
|
|
|
398
398
|
display: block;
|
|
399
399
|
position: relative;
|
|
400
400
|
}
|
|
401
|
-
`],s([jt({type:Number,attribute:"max-choices"})],N.prototype,"maxChoices",2),s([jt({type:Number,attribute:"min-choices"})],N.prototype,"minChoices",2),s([
|
|
401
|
+
`],s([jt({type:Number,attribute:"max-choices"})],N.prototype,"maxChoices",2),s([jt({type:Number,attribute:"min-choices"})],N.prototype,"minChoices",2),s([Ki()],N.prototype,"_points",2);customElements.define("qti-select-point-interaction",N);import{css as Ji,html as ke,nothing as mt}from"lit";import{property as j,query as Kt}from"lit/decorators.js";var x=class extends m{constructor(){super();this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{};this.csLive=getComputedStyle(this)}set min(e){this._min=e,this.value=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let t=parseInt(e);if(Number.isNaN(t)){console.error("QtiSliderInteraction: response is not a number");return}this.value=t}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);let e=(this.value-this.min)/(this.max-this.min)*100;return this.style.setProperty("--value-percentage",`${e}%`),this.setAttribute("aria-valuenow",this.value.toString()),ke`<slot name="prompt"></slot>
|
|
402
402
|
<div id="slider" part="slider">
|
|
403
|
-
${this.csLive.getPropertyValue("--show-bounds")=="true"?
|
|
403
|
+
${this.csLive.getPropertyValue("--show-bounds")=="true"?ke`<div id="bounds" part="bounds">
|
|
404
404
|
<div>${this._min}</div>
|
|
405
405
|
<div>${this._max}</div>
|
|
406
406
|
</div>`:mt}
|
|
407
|
-
${this.csLive.getPropertyValue("--show-ticks")=="true"?
|
|
407
|
+
${this.csLive.getPropertyValue("--show-ticks")=="true"?ke`<div id="ticks" part="ticks"></div>`:mt}
|
|
408
408
|
<div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove}>
|
|
409
409
|
<div id="knob" part="knob">
|
|
410
|
-
${this.csLive.getPropertyValue("--show-value")=="true"?
|
|
410
|
+
${this.csLive.getPropertyValue("--show-value")=="true"?ke`<div id="value" part="value">${this.value}</div>`:mt}
|
|
411
411
|
</div>
|
|
412
412
|
</div>
|
|
413
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=l=>{let{x:c}=this.getPositionFromEvent(l),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),l.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:o}=this.getPositionFromEvent(e),a=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(a),e.stopPropagation()}_onMouseDown(e){let t=a=>{let l=a.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),a.preventDefault(),a.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=r.touches[0]||r.changedTouches[0];t={x:o.pageX,y:o.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};x.styles=[
|
|
413
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=l=>{let{x:c}=this.getPositionFromEvent(l),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),l.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:o}=this.getPositionFromEvent(e),a=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(a),e.stopPropagation()}_onMouseDown(e){let t=a=>{let l=a.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),a.preventDefault(),a.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=r.touches[0]||r.changedTouches[0];t={x:o.pageX,y:o.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};x.styles=[Ji``],s([Kt("#knob")],x.prototype,"_knob",2),s([Kt("#rail")],x.prototype,"_rail",2),s([j({type:Number})],x.prototype,"value",2),s([j({type:Boolean,attribute:"step-label"})],x.prototype,"stepLabel",2),s([j({type:Boolean})],x.prototype,"reverse",2),s([j({type:Number,attribute:"lower-bound"})],x.prototype,"min",1),s([j({type:Number,attribute:"upper-bound"})],x.prototype,"max",1),s([j({type:Number,attribute:"step"})],x.prototype,"step",1),s([f("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"_handleDisabledChange",2),s([f("readonly",{waitUntilFirstUpdate:!0})],x.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",x);import{LitElement as Zi,html as Qi}from"lit";import{property as es}from"lit/decorators.js";var Ae=class extends Zi{render(){return Qi`<button @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.closest("qti-assessment-item").processResponse()}};s([es({type:String})],Ae.prototype,"title",2);customElements.define("qti-end-attempt-interaction",Ae);import{LitElement as ts,css as rs,html as is}from"lit";var Te=class extends ts{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return is` <slot name="qti-gap-img"></slot> `}};Te.styles=rs`
|
|
414
414
|
:host {
|
|
415
415
|
position: absolute;
|
|
416
416
|
}
|
|
417
|
-
`;customElements.define("qti-associable-hotspot",
|
|
417
|
+
`;customElements.define("qti-associable-hotspot",Te);import{LitElement as ss}from"lit";import{property as os}from"lit/decorators.js";var we=class extends ss{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};s([os({type:Number,reflect:!0})],we.prototype,"tabindex",2);customElements.define("qti-gap-img",we);import{html as ns,LitElement as as}from"lit";import{property as ls}from"lit/decorators.js";var Re=class extends as{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return ns`<slot></slot>`}};s([ls({type:Number,reflect:!0})],Re.prototype,"tabindex",2);customElements.define("qti-gap-text",Re);import{html as cs,LitElement as ps}from"lit";import{property as ds}from"lit/decorators.js";var Le=class extends ps{constructor(){super(...arguments);this.tabindex=0}render(){return cs` <slot name="qti-gap-text"></slot>`}};s([ds({type:Number,reflect:!0})],Le.prototype,"tabindex",2);customElements.define("qti-gap",Le);import{css as us}from"lit";import{property as ms}from"lit/decorators.js";var te=class extends y{};te.styles=us`
|
|
418
418
|
:host {
|
|
419
419
|
position: absolute;
|
|
420
420
|
}
|
|
421
|
-
`,s([
|
|
422
|
-
<slot></slot> `}};
|
|
423
|
-
<slot></slot> `}};
|
|
421
|
+
`,s([ms({attribute:"aria-ordervalue",type:Number,reflect:!0})],te.prototype,"order",2);customElements.define("qti-hotspot-choice",te);import{customElement as hs}from"lit/decorators.js";import{html as fs}from"lit";var Se=class extends y{render(){return fs`<div part="ch"><div part="cha"></div></div>
|
|
422
|
+
<slot></slot> `}};Se=s([hs("qti-hottext")],Se);import{LitElement as bs}from"lit";var ht=class extends bs{};customElements.define("qti-inline-choice",ht);import{customElement as gs}from"lit/decorators.js";import{css as vs,html as ys}from"lit";var re=class extends y{render(){return ys`<div part="ch"><div part="cha"></div></div>
|
|
423
|
+
<slot></slot> `}};re.styles=vs`
|
|
424
|
+
:host {
|
|
425
|
+
display: flex;
|
|
426
|
+
}
|
|
427
|
+
slot {
|
|
428
|
+
width: 100%;
|
|
429
|
+
display: block;
|
|
430
|
+
}
|
|
431
|
+
`,re=s([gs("qti-simple-choice")],re);export{Tt as Events,H as OutcomeVariable,Z as QtPrintedVariable,je as QtiAnd,A as QtiAssessmentItem,Te as QtiAssociableHotspot,Q as QtiAssociateInteraction,ue as QtiBaseValue,y as QtiChoice,At as QtiChoiceElementSelected,F as QtiChoiceInteraction,se as QtiCompanionMaterialsInfo,q as QtiConditionExpression,Ke as QtiContains,We as QtiCorrect,Ae as QtiEndAttemptInteraction,me as QtiEqual,he as QtiEqualRounded,u as QtiExpression,w as QtiExtendedTextInteraction,Pe as QtiFeedbackBlock,le as QtiFeedbackInline,Le as QtiGap,we as QtiGapImg,ge as QtiGapMatchInteraction,Re as QtiGapText,M as QtiGraphicAssociateInteraction,ve as QtiGraphicGapMatchInteraction,ye as QtiGraphicOrderInteraction,Ge as QtiGt,Je as QtiGte,te as QtiHotspotChoice,xe as QtiHotspotInteraction,Se as QtiHottext,Ue as QtiHottextInteraction,ht as QtiInlineChoice,de as QtiInlineChoiceInteraction,yt as QtiInteractionChanged,kt as QtiInteractionResponse,Ze as QtiIsNull,_t as QtiLooseChoice,Qe as QtiLt,et as QtiLte,fe as QtiMapResponse,X as QtiMapping,rt as QtiMatch,Ee as QtiMatchInteraction,qe as QtiMediaInteraction,it as QtiMember,Oe as QtiModalFeedback,st as QtiMultiple,ot as QtiNot,nt as QtiOr,z as QtiOrderInteraction,at as QtiOrdered,vt as QtiOutcomeChanged,I as QtiOutcomeDeclaration,pt as QtiPortableCustomInteraction,_e as QtiPositionObjectStage,lt as QtiProduct,De as QtiPrompt,qt as QtiRegisterChoice,Ct as QtiRegisterHotspot,Et as QtiRegisterInteraction,xt as QtiRegisterVariable,Xe as QtiResponseCondition,P as QtiResponseDeclaration,W as QtiResponseElse,Be as QtiResponseElseIf,G as QtiResponseIf,U as QtiResponseProcessing,S as QtiRule,Ce as QtiSPositionObjectInteraction,N as QtiSelectPointInteraction,Ye as QtiSetOutcomeValue,ut as QtiSimpleAssociableChoice,re as QtiSimpleChoice,x as QtiSliderInteraction,Ne as QtiStylesheet,k as QtiTextEntryInteraction,ct as QtiVariable,$ as ResponseVariable,ne as qtiContentBody,T as qtiRubricBlock};
|