@citolab/qti-components 3.0.51 → 3.0.53
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/index.css +215 -1094
- package/index.js +97 -80
- package/index.umd.css +215 -1094
- package/index.umd.js +117 -99
- package/lab/qti-manual-scoring/qti-manual-scoring.d.ts +2 -0
- package/lab/qti-test/qti-test.d.ts +1 -0
- package/lib/qti-base/qti-preview/qti-associate-interaction/qti-associate-interaction.d.ts +2 -3
- package/lib/qti-base/qti-preview/qti-associate-interaction/qti-simple-associable-choice.d.ts +1 -0
- package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-match-interaction.d.ts +1 -1
- package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-text.d.ts +4 -1
- package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap.d.ts +3 -1
- package/lib/qti-base/qti-preview/qti-slider-interaction/qti-slider-interaction.d.ts +17 -10
- package/lib/utilities/{watch → decorators}/watch.d.ts +0 -0
- package/lib/utilities/drag-drop/drag-drop-api.d.ts +83 -0
- package/lib/utilities/drag-drop/drag-drop-interaction-mixin.d.ts +1 -1
- package/lib/utilities/drag-drop/droppables-mixin.d.ts +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{LitElement as e,html as t,css as s
|
|
1
|
+
import{LitElement as e,html as t,css as s}from"lit";import{customElement as i,property as n,state as r,query as o}from"lit/decorators.js";import{html as a}from"lit/static-html.js";import{createContext as l,ContextConsumer as c,ContextProvider as d}from"@lit-labs/context";import{ifDefined as h}from"lit/directives/if-defined.js";import{createRef as p,ref as u}from"lit/directives/ref.js";var m,g;!function(e){e.boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair"}(m||(m={})),function(e){e.multiple="multiple",e.ordered="ordered",e.single="single"}(g||(g={}));const b={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_VARIABLE:"on-register-variable",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"},y={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"};class f{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:n}){this._basetype=m.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=n}static getCandidateResponse(e){return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]]}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(e){this._candidateResponse=e}set qtiVariable(e){this._qtiVariable=e,this._candidateResponse=f.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class v{}class E extends e{emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}err(e){throw e}}class _ extends E{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(b.ON_REGISTER_VARIABLE,this._registerVariable),this.addEventListener(b.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(b.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(b.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(b.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return t`<slot></slot>`}updated(e){e.forEach(((e,t)=>{switch(t){case"disabled":this.interactionElements.forEach((e=>e.disabled=this.disabled));break;case"readonly":this.interactionElements.forEach((e=>e.readonly=this.readonly))}}))}disconnectedCallback(){this.removeEventListener(b.ON_REGISTER_VARIABLE,this._registerVariable),this.removeEventListener(b.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(b.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(b.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(b.ON_INTERACTION_RESPONSE,this.interactionResponse)}_registerVariable(e){this.variables.push(e.detail)}showCorrectResponse(){const e=this.variables.filter((e=>e.correctResponse)),t={item:this.identifier,interactions:e.map((e=>({responseIdentifier:e.identifier,responses:{base:{identifier:e.correctResponse}}})))};this.responses=t}processResponse(){if(this.validateResponses()){const e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}return console.info("Item is not valid, call validateResponses first"),!1}set responses(e){if(e){e.interactions.forEach((e=>{const t=this.interactionElements.find((t=>t.getAttribute("response-identifier")===e.responseIdentifier)),s=this.getResponse(e.responseIdentifier);s&&(s.qtiVariable=e.responses);const i=f.getCandidateResponse(e.responses);t.response=i}))}}resetInteractions(){this.interactionElements.forEach((e=>e.reset()))}validateResponses(){let e=!0;return this.interactionElements.forEach((t=>{t.validate()||(e=!1)})),e}getVariableValue(e){return this.variables.find((t=>t.identifier===e)).value}getResponse(e){const t=this.variables.find((t=>t.identifier===e));if(t instanceof f)return t}getOutcome(e){const t=this.variables.find((t=>t.identifier===e));return t instanceof v?t:null}registerFeedbackElement(e){e.stopPropagation(),this.feedbackElements.push(e.detail)}registerInteractionElement(e){e.stopPropagation(),this.interactionElements.push(e.target)}interactionResponse(e){const t=this.getResponse(e.detail.responseIdentifier);t&&(t.qtiVariable=e.detail.responses),e.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent(b.ON_INTERACTION_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.getAttribute("identifier"),interaction:{responseIdentifier:e.detail.responseIdentifier,responses:e.detail.responses}}}))}outcomeChanged(e){this.feedbackElements.forEach((t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)}))}setOutcomeValue(e,t){const s=this.getOutcome(e);s?(s.value=t,this.dispatchEvent(new CustomEvent(b.ON_OUTCOME_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))):this.err(`Can not set qti-outcome-identifier: ${e}, it is not available`)}}customElements.define("qti-assessment-item",_);class C extends e{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}function q(e,t,s,i){var n,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,s,o):n(t,s))||o);return r>3&&o&&Object.defineProperty(t,s,o),o}function x(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}customElements.define("qti-stylesheet",C);let O=class extends e{render(){return t`
|
|
2
2
|
<slot name="qti-rubric-block"></slot>
|
|
3
|
-
<slot></slot>`}};
|
|
3
|
+
<slot></slot>`}};O.styles=s`
|
|
4
4
|
:host {
|
|
5
5
|
display: block;
|
|
6
6
|
}
|
|
7
|
-
`,
|
|
7
|
+
`,O=q([i("qti-item-body")],O);class S extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function R(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,n))}n.call(this,e)}}}}customElements.define("qti-prompt",S);const k=32;let w=class extends E{constructor(){super(...arguments),this.tabindex=0,this.disabled=!1,this.readonly=!1,this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.emit(b.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(b.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===k&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(b.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return a` <slot></slot> `}};q([n({reflect:!0}),x("design:type",String)],w.prototype,"identifier",void 0),q([n({type:Number,reflect:!0}),x("design:type",Object)],w.prototype,"tabindex",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],w.prototype,"disabled",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],w.prototype,"readonly",void 0),q([n({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),x("design:type",Object)],w.prototype,"checked",void 0),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],w.prototype,"handleDisabledChange",null),w=q([i("qti-choice")],w);class A extends e{render(){return t``}}customElements.define("qti-variabledeclaration",A);class N extends A{connectedCallback(){super.connectedCallback();const e=new f({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||g.single,mapping:this.mapping});this.dispatchEvent(new CustomEvent(b.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:e}))}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const s=t.querySelectorAll("qti-value");if(1===s.length)e=s[0].textContent,s[0].remove();else{e=[];for(let t=0;t<s.length;t++)e.push(s[t].textContent),s[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,s=e.querySelectorAll("qti-map-entry");for(let e=0;e<s.length;e++){const i=s[e],n=i.getAttribute("map-key"),r=i.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}q([n({type:String,attribute:"base-type"}),x("design:type",String)],N.prototype,"baseType",void 0),q([n({type:String,attribute:"identifier"}),x("design:type",String)],N.prototype,"identifier",void 0),q([n({type:String,attribute:"cardinality"}),x("design:type",String)],N.prototype,"cardinality",void 0),customElements.define("qti-response-declaration",N);class I extends A{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new v;t.identifier=e,this.dispatchEvent(new CustomEvent(b.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}}customElements.define("qti-outcome-declaration",I);let T=class extends E{};T=q([i("qti-companion-materials-info")],T);const L=l("logger");let D=class extends E{constructor(){super(...arguments),this.logger=new c(this,L,(e=>this.style.display=this.view===e.view?"block":"none"),!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","")}}))}render(){return t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};D.styles=s`
|
|
8
8
|
:host {
|
|
9
9
|
display: block;
|
|
10
10
|
}
|
|
11
|
-
`,
|
|
11
|
+
`,q([n({type:String}),x("design:type",Object)],D.prototype,"id",void 0),q([n({type:String}),x("design:type",String)],D.prototype,"use",void 0),q([n({type:String}),x("design:type",String)],D.prototype,"view",void 0),q([n({type:String,attribute:"class"}),x("design:type",Object)],D.prototype,"classNames",void 0),q([R("classNames",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],D.prototype,"handleclassNamesChange",null),D=q([i("qti-rubric-block")],D);let M=class extends E{render(){return t`<slot></slot>`}};M=q([i("qti-content-body")],M);class H extends e{constructor(){super(),this.showHide="show",this.showFeedback("hide"===this.showHide)}static get properties(){return{showStatus:{type:String,attribute:!0,reflect:!0},showHide:{type:String,attribute:"show-hide"},outcomeIdentifier:{type:String,attribute:"outcome-identifier"},identifier:{type:String}}}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(b.ON_REGISTER_FEEDBACK,{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){this.outcomeIdentifier===e&&(t instanceof Array?this.showFeedback(-1!==t.indexOf(this.identifier)):this.showFeedback(this.identifier===t))}showFeedback(e){this.showStatus=e?"on":"off"}}class $ extends H{constructor(){super(...arguments),this.render=()=>t` <slot class="${this.showStatus}"></slot> `}}$.styles=s`
|
|
12
12
|
.on {
|
|
13
13
|
display: inline-block;
|
|
14
14
|
}
|
|
15
15
|
.off {
|
|
16
16
|
display: none;
|
|
17
17
|
}
|
|
18
|
-
`,customElements.define("qti-feedback-inline"
|
|
18
|
+
`,customElements.define("qti-feedback-inline",$);class j extends H{render(){return t`
|
|
19
19
|
<style>
|
|
20
20
|
.on {
|
|
21
21
|
display: inline-block;
|
|
@@ -27,7 +27,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
27
27
|
<div class="feedback ${this.showStatus}">
|
|
28
28
|
<slot></slot>
|
|
29
29
|
</div>
|
|
30
|
-
`}}customElements.define("qti-modal-feedback",
|
|
30
|
+
`}}customElements.define("qti-modal-feedback",j);class P extends E{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(b.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(b.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}q([n({attribute:"response-identifier"}),x("design:type",Object)],P.prototype,"responseIdentifier",void 0),q([n({reflect:!0,type:Boolean}),x("design:type",Object)],P.prototype,"disabled",void 0),q([n({reflect:!0,type:Boolean}),x("design:type",Object)],P.prototype,"readonly",void 0);const F=s`
|
|
31
31
|
/***
|
|
32
32
|
The new CSS reset - version 1.4.9 (last updated 11.2.2022)
|
|
33
33
|
GitHub page: https://github.com/elad2412/the-new-css-reset
|
|
@@ -107,7 +107,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
107
107
|
:where([draggable='true']) {
|
|
108
108
|
-webkit-user-drag: element;
|
|
109
109
|
}
|
|
110
|
-
`;class
|
|
110
|
+
`;class U extends P{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},P.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String}})}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[F,s`
|
|
111
111
|
/* PK: display host as block, else design will be collapsed */
|
|
112
112
|
:host {
|
|
113
113
|
display: inline-block;
|
|
@@ -123,13 +123,13 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
123
123
|
@keyup="${this.textChanged}"
|
|
124
124
|
@change="${this.textChanged}"
|
|
125
125
|
type="text"
|
|
126
|
-
placeholder="${
|
|
126
|
+
placeholder="${h(this.placeholderText?this.placeholderText:void 0)}"
|
|
127
127
|
.value="${this.value}"
|
|
128
|
-
size="${
|
|
129
|
-
pattern="${
|
|
128
|
+
size="${h(this.expectedLength?this.expectedLength:void 0)}"
|
|
129
|
+
pattern="${h(this.patternMask?this.patternMask:void 0)}"
|
|
130
130
|
?disabled="${this.disabled}"
|
|
131
131
|
?readonly="${this.readonly}"
|
|
132
|
-
/>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}
|
|
132
|
+
/>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}U.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],customElements.define("qti-text-entry-interaction",U);class B extends P{constructor(){super(...arguments),this.textareaRef=p(),this.value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{if(e.startsWith("qti-height-lines")){const t=e.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(t))}}))}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[F,s`
|
|
133
133
|
/* PK: display host as block, else design will be collapsed */
|
|
134
134
|
:host {
|
|
135
135
|
display: block;
|
|
@@ -140,19 +140,19 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
140
140
|
height: 100%;
|
|
141
141
|
}
|
|
142
142
|
`]}render(){return t`<textarea
|
|
143
|
-
${
|
|
143
|
+
${u(this.textareaRef)}
|
|
144
144
|
spellcheck="false"
|
|
145
145
|
autocomplete="off"
|
|
146
146
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
147
147
|
@keyup="${this.textChanged}"
|
|
148
148
|
@change="${this.textChanged}"
|
|
149
|
-
placeholder="${
|
|
150
|
-
maxlength="${
|
|
151
|
-
pattern="${
|
|
149
|
+
placeholder="${h(this.placeholderText?this.placeholderText:void 0)}"
|
|
150
|
+
maxlength="${h(this.expectedLength?this.expectedLength:void 0)}"
|
|
151
|
+
pattern="${h(this.patternMask?this.patternMask:void 0)}"
|
|
152
152
|
?disabled="${this.disabled}"
|
|
153
153
|
?readonly="${this.readonly}"
|
|
154
154
|
.value=${this.value}
|
|
155
|
-
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}
|
|
155
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}B.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],q([n({type:Number,attribute:"expected-length"}),x("design:type",Object)],B.prototype,"expectedLength",void 0),q([n({type:String,attribute:"pattern-mask"}),x("design:type",Object)],B.prototype,"patternMask",void 0),q([n({type:String,attribute:"placeholder-text"}),x("design:type",Object)],B.prototype,"placeholderText",void 0),q([n({type:String}),x("design:type",Object)],B.prototype,"value",void 0),q([n({type:String,attribute:"class"}),x("design:type",Object)],B.prototype,"classNames",void 0),q([R("classNames",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],B.prototype,"handleclassNamesChange",null),customElements.define("qti-extended-text-interaction",B);let G=class extends w{};G=q([i("qti-hottext")],G);class V extends P{constructor(){super(),this._choiceElements=[],this._minChoices=0,this._maxChoices=1,this._handleDisabledChange=(e,t)=>this._choiceElements.forEach((e=>e.disabled=t)),this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach((e=>e.readonly=t)),this._handleMaxChoicesChange=()=>this._determineInputType(),this.addEventListener(b.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(b.ON_LOOSE_CHOICE,this._looseChoiceElement)}reset(){this._choiceElements.forEach((e=>{e.reset()}))}validate(){return this._choiceElements.reduce(((e,t)=>e+(!0===t.checked?1:0)),0)>=this._minChoices}set response(e){this._choiceElements.forEach((e=>{e.checked=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{const t=this.querySelector("[identifier='"+e+"']");t&&(t.checked=!0)}))}connectedCallback(){super.connectedCallback(),this.addEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(b.ON_REGISTER_CHOICE,this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter((e=>e!==t))}_determineInputType(){this._choiceElements.forEach((e=>{this._setInputType(e)}))}_setInputType(e){1===this._maxChoices?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){1===this._maxChoices&&this._choiceElements.filter((t=>t.identifier!==e.detail.identifier)).forEach((e=>{e.checked=!1})),this._choiceElementSelected()}_choiceElementSelected(){const e=this._choiceElements.filter((e=>1==e.checked)).map((e=>e.identifier));let t;this._maxChoices>1&&(this._maxChoices===e.length?this._choiceElements.forEach((e=>e.disabled=!(1==e.checked))):this._choiceElements.forEach((e=>e.disabled=!1))),t=1===this._maxChoices?{base:{identifier:e.length>0?e[0]:""}}:{list:{identifier:e}},this.saveResponse(t)}}q([n({type:Number,attribute:"min-choices"}),x("design:type",Number)],V.prototype,"_minChoices",void 0),q([n({type:Number,attribute:"max-choices"}),x("design:type",Number)],V.prototype,"_maxChoices",void 0),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleDisabledChange",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleReadonlyChange",void 0),q([R("_maxChoices",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleMaxChoicesChange",void 0);class Y extends V{constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",Y);class z extends P{constructor(){super(),this.options=[],this.addEventListener(b.ON_DROPDOWN_SELECTED,this.choiceSelected);const e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map((e=>({textContent:e.innerHTML,value:e.getAttribute("identifier"),selected:!1})))]}static get properties(){return Object.assign(Object.assign({},P.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[F,s`
|
|
156
156
|
:host {
|
|
157
157
|
display: inline-block;
|
|
158
158
|
}
|
|
@@ -170,46 +170,42 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
170
170
|
${this.options.map((e=>t`
|
|
171
171
|
<option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
|
|
172
172
|
`))}
|
|
173
|
-
</select>`}validate(){const e=this.options.find((e=>e.selected));return!!e&&""!==e.value}reset(){this.options=this.options.map(((e,t)=>Object.assign(Object.assign({},e),{selected:0===t})))}set response(e){this.options=this.options.map((t=>(e===t.value&&(t.selected=!0),t)))}choiceSelected(e){const t=e.target.value;this.options=this.options.map((e=>Object.assign(Object.assign({},e),{selected:e.value===t}))),this.saveResponse({base:{string:t}})}}
|
|
173
|
+
</select>`}validate(){const e=this.options.find((e=>e.selected));return!!e&&""!==e.value}reset(){this.options=this.options.map(((e,t)=>Object.assign(Object.assign({},e),{selected:0===t})))}set response(e){this.options=this.options.map((t=>(e===t.value&&(t.selected=!0),t)))}choiceSelected(e){const t=e.target.value;this.options=this.options.map((e=>Object.assign(Object.assign({},e),{selected:e.value===t}))),this.saveResponse({base:{string:t}})}}z.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",z);class X extends V{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>t`
|
|
174
174
|
<slot name="prompt"></slot>
|
|
175
|
-
<slot></slot>`}}
|
|
176
|
-
<slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",te);class se extends te{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",se);class ie extends se{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",ie);class ne extends _{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",ne);class re extends ne{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=oe(s,i[e],t.baseType);return n}return n+=oe(s,i,t.baseType),n}}function oe(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=ae(s,n,t);e===r&&(i+=n[1])}return i}function ae(e,t,s){let i,n;switch(e){case g.string:case g.identifier:case g.directedPair:i=""+t[0],n=""+s;break;case g.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",re);class le extends Z{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",le);class ce extends ne{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",ce);class de extends ne{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",de);class he extends ne{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",he);class pe extends ne{calculate(){return pe.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===g.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",pe);class ue extends ne{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return ue.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",ue);class me extends ne{calculate(){return 2===this.children.length?me.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",me);class ge extends ne{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ge);class be extends ne{render(){return t``}calculate(){return be.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",be);class fe extends ne{render(){return t``}calculate(){return fe.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",fe);class ye extends ne{calculate(){return 1===this.children.length?ye.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",ye);class ve extends _{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){const t=e.querySelectorAll("properties");let s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,s.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",ve);const Ee=(e,t)=>class extends e{connectedCallback(){if(super.connectedCallback(),this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),e.addEventListener("dragend",(t=>{t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging")})),e.setAttribute("draggable","true")}))}},_e=(e,t)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(this.querySelectorAll(t));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,s=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},qe=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:n,height:r});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/n,d=o.height/r;this.state.set(t,{left:s,top:i,width:n,height:r});const{duration:h,easing:p}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:h,easing:p})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return S(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:n})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},Ce=(e,s,i)=>{class n extends(qe(_e(Ee(e,s),i),i,s)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(s)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return t` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(f.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(f.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},xe=s`
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
color: #dddddd;
|
|
192
|
-
font-size: 14px;
|
|
193
|
-
width: fit-content;
|
|
194
|
-
padding: 0.4rem 0.6rem;
|
|
195
|
-
border-radius: 99999px;
|
|
196
|
-
content: 'preview not interactive';
|
|
197
|
-
}
|
|
198
|
-
`;class Oe extends(Ce(_,"qti-simple-associable-choice","drop-list")){render(){return t`
|
|
199
|
-
<slot name="prompt"></slot>
|
|
200
|
-
<slot></slot>`}firstUpdated(e){i(t`
|
|
201
|
-
${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,s)=>t`<div class="associables-container">
|
|
202
|
-
<drop-list class="associables-gap" identifier="droplist${s}_left"></drop-list>
|
|
203
|
-
<drop-list class="associables-gap" identifier="droplist${s}_right"></drop-list>
|
|
204
|
-
</div>`))}
|
|
205
|
-
`,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}Oe.styles=[xe],customElements.define("qti-associate-interaction",Oe);class Se extends e{render(){return t`
|
|
175
|
+
<slot></slot>`}}X.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],X.presentationClass=["","qti-input-control-hidden"],q([n({attribute:"orientation"}),x("design:type",String)],X.prototype,"_orientation",void 0),q([n({attribute:"shuffle",type:Boolean}),x("design:type",Boolean)],X.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",X);let W=class extends w{};W=q([i("qti-simple-choice")],W);class K extends e{render(){return t`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){if(this.getAttribute("template")){const e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0.0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response identifier="RESPONSE"> </qti-map-response>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"map_response_point":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"match_correct":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-match>\n <qti-variable identifier="RESPONSE"></qti-variable>\n <qti-correct identifier="RESPONSE"></qti-correct>\n </qti-match>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">1</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'))}}const e=[...this.children];for(let t=0;t<e.length;t++){e[t].process()}}fragmentFromString(e){return document.createRange().createContextualFragment(e)}}customElements.define("qti-response-processing",K);class Q extends e{render(){return t``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",Q);class J extends Q{render(){return t`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const s=e[t];if(s.calculate())return void s.process()}}}customElements.define("qti-response-condition",J);class Z extends e{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return t`
|
|
176
|
+
<slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",Z);class ee extends Z{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",ee);class te extends ee{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",te);class se extends E{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",se);class ie extends se{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=ne(s,i[e],t.baseType);return n}return n+=ne(s,i,t.baseType),n}}function ne(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=re(s,n,t);e===r&&(i+=n[1])}return i}function re(e,t,s){let i,n;switch(e){case m.string:case m.identifier:case m.directedPair:i=""+t[0],n=""+s;break;case m.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",ie);class oe extends Q{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",oe);class ae extends se{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",ae);class le extends se{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",le);class ce extends se{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",ce);class de extends se{calculate(){return de.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===m.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",de);class he extends se{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return he.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",he);class pe extends se{calculate(){return 2===this.children.length?pe.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",pe);class ue extends se{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ue);class me extends se{render(){return t``}calculate(){return me.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",me);class ge extends se{render(){return t``}calculate(){return ge.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",ge);class be extends se{calculate(){return 1===this.children.length?be.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",be);class ye extends E{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){const t=e.querySelectorAll("properties");let s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,s.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",ye);const fe=(e,t)=>class extends e{connectedCallback(){if(super.connectedCallback(),this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),e.addEventListener("dragend",(t=>{t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging")})),e.setAttribute("qti-draggable","true")}))}},ve=(e,t,s)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const i=Array.from(t?this.shadowRoot.querySelectorAll(s):this.querySelectorAll(s));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),i.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of i)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,s=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`),i=s||this.shadowRoot.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?i.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(i):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}};class Ee{constructor(e){return 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(e,t){this.data[e]=t},getData:function(e){return this.data[e]},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,e.forEach((e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})),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}_touchStart(e){this._touchBegin=Date.now();const{x:t,y:s}=this.getPositionFromEvent(e);this._touchDown={x:t,y:s},this._dragSrc=e.target,this._canDrag=!0,e.preventDefault()}_touchMove(e){if(this._canDrag&&this._dragSrc){const{x:s,y:i}=this.getPositionFromEvent(e),n={clientX:s,clientY:i};if(null===this._dragCopy){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);const e=window.getComputedStyle(this._dragSrc);this._dragCopy.style="";for(const t of e)this._dragCopy.style[t]=e.getPropertyValue(t);this._calculateDragCopyPosition(n),this._dragCopy.style.top=n.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=n.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="absolute",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._getDelta(n)>=this._DRAGDELTA&&(this._dragRunning=!0),this._dragRunning){const s=this;requestAnimationFrame((function(){s._touchEndCalled||null===s._dragCopy||(s._dragCopy.style.top=n.clientY-s._copyOffset.y+"px",s._dragCopy.style.left=n.clientX-s._copyOffset.x+"px")}));var t=this._findDroppable(e);t!=this._lastTarget&&(this._dispatchEvent(t,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=t),this._currentDropContainer=t,this._currentDropContainer&&this._dispatchEvent(t,"dragover"),e.preventDefault()}}}_touchEnd(e){var t;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else{const e=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});e.dataTransfer={dropEffect:"none"},null===(t=this._dragSrc)||void 0===t||t.dispatchEvent(e)}this._reset()}_touchCancel(e){this._reset()}_findDroppable(e){let t;const s=e.composedPath().find((e=>{if(1===e.nodeType&&"SLOT"!==e.nodeName&&e.hasAttribute("dropzone"))return e}));if(s){const i=s.getRootNode(),n=this._getPoint(e);t=i.elementFromPoint(n.x,n.y)}return t}_getPoint(e,t){return e&&e.touches&&(e=e.touches[0]),{x:t?e.pageX:e.clientX,y:t?e.pageY:e.clientY}}_calculateDragCopyPosition(e){const t=this._dragSrc.getBoundingClientRect();this._copyOffset.x=e.clientX-t.left,this._copyOffset.y=e.clientY-t.top}_getDelta(e){return Math.abs(e.clientX-this._touchDown.x)+Math.abs(e.clientY-this._touchDown.y)}_dispatchEvent(e,t,s=!0){if(!e)return!1;const i=new CustomEvent(t,{bubbles:s,cancelable:!0});return i.dataTransfer=this._dataTransfer,e.dispatchEvent(i),i.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(e,t){this.data[e]=t},getData:function(e){return this.data[e]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}getPositionFromEvent(e){let t;if("touchstart"==e.type||"touchmove"==e.type||"touchend"==e.type||"touchcancel"==e.type){const s=void 0===e.originalEvent?e:e.originalEvent,i=s.touches[0]||s.changedTouches[0];t={x:i.pageX,y:i.pageY}}else"mousedown"!=e.type&&"mouseup"!=e.type&&"mousemove"!=e.type&&"mouseover"!=e.type&&"mouseout"!=e.type&&"mouseenter"!=e.type&&"mouseleave"!=e.type||(t={x:e.clientX,y:e.clientY});return t}}const _e=(e,t,s,i)=>{class r extends(((e,t,s)=>class extends e{})(ve(fe(e,t),s,i))){constructor(){if(super(),this.draggables=new Map,this.responseIdentifier="",this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;const e=Array.from(this.querySelectorAll(t));new Ee(e),e.forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if(console.log(e.dataTransfer),"none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}"move"===e.dataTransfer.dropEffect&&console.log(e.dataTransfer),this.saveResponse()}))}))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("qti-draggable"):t.setAttribute("qti-draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("qti-draggable"):t.setAttribute("qti-draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?e.appendChild(i):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=(s?Array.from(this.shadowRoot.querySelectorAll(i)):Array.from(this.querySelectorAll(i))).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:(s?Array.from(this.shadowRoot.querySelectorAll(i)):Array.from(this.querySelectorAll(i))).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(b.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(b.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return q([n({type:String,attribute:"response-identifier"}),x("design:type",String)],r.prototype,"responseIdentifier",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],r.prototype,"disabled",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],r.prototype,"readonly",void 0),q([n({type:Number,reflect:!0,attribute:"min-associations"}),x("design:type",Object)],r.prototype,"minAssociations",void 0),q([n({type:Number,reflect:!0,attribute:"max-associations"}),x("design:type",Object)],r.prototype,"maxAssociations",void 0),r};class Ce extends(_e(E,"qti-simple-associable-choice",!0,"drop-list")){render(){return t` <slot name="prompt"></slot>
|
|
177
|
+
<slot name="qti-simple-associable-choice"></slot>
|
|
178
|
+
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map(((e,s)=>t`<div part="associables-container">
|
|
179
|
+
<drop-list part="drop-list" identifier="droplist${s}_left"></drop-list>
|
|
180
|
+
<drop-list part="drop-list" identifier="droplist${s}_right"></drop-list>
|
|
181
|
+
</div>`))}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}Ce.styles=s`
|
|
182
|
+
:host {
|
|
183
|
+
display: block; /* necessary to calculate scaling position */
|
|
184
|
+
}
|
|
185
|
+
slot[name='qti-simple-associable-choice'] {
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-wrap: wrap;
|
|
188
|
+
gap: 0.5rem;
|
|
189
|
+
}
|
|
190
|
+
`,q([r(),x("design:type",Array)],Ce.prototype,"_childrenMap",void 0),customElements.define("qti-associate-interaction",Ce);class qe extends e{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return t`
|
|
206
191
|
<slot></slot>
|
|
207
|
-
|
|
192
|
+
<slot name="qti-simple-associable-choice"></slot>
|
|
193
|
+
`}}customElements.define("qti-simple-associable-choice",qe);class xe extends(_e(e,"qti-gap-text",!1,"qti-gap")){render(){return t` <slot name="qti-gap-text"></slot>
|
|
194
|
+
<slot></slot>`}}xe.styles=s`
|
|
195
|
+
:host {
|
|
196
|
+
display: block; /* necessary to calculate scaling position */
|
|
197
|
+
}
|
|
198
|
+
slot[name='qti-gap-text'] {
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-wrap: wrap;
|
|
201
|
+
gap: 0.5rem;
|
|
202
|
+
}
|
|
203
|
+
`,customElements.define("qti-gap-match-interaction",xe);class Oe extends e{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return t`<slot></slot>`}}customElements.define("qti-gap-text",Oe);class Se extends e{render(){return t` <slot name="qti-gap-text"></slot>`}}function Re(e,t,s,i){switch(e){case"circle":{const[e,n,r]=t,o=e/s.width*100,a=n/s.height*100,l=r/s.width*100;i.style.left=o-l+"%",i.style.top=a-l+"%",i.style.width=i.style.height=4*l+"px",i.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/s.width*100,l=n/s.height*100,c=r/s.width*100,d=o/s.height*100;i.style.left=a+"%",i.style.top=l+"%",i.style.width=c-a+"%",i.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,s,i)=>{if(s%2==1){const t=e.pop();e[e.length]={x:t,y:i[s]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/s.width*100,c=o/s.height*100,d=r/s.width*100,h=a/s.height*100;i.style.left=n/s.width*100+"%",i.style.top=o/s.height*100+"%",i.style.width=d-l+"%",i.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");i.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",Se);class ke extends V{render(){return t`
|
|
208
204
|
<slot name="prompt"></slot>
|
|
209
205
|
<!-- slot for the prompt -->
|
|
210
206
|
<slot></slot>
|
|
211
207
|
<!-- slot for the image and hotspots -->
|
|
212
|
-
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");
|
|
208
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");Re(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(b.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(b.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}ke.styles=[s`
|
|
213
209
|
slot:not([name='prompt']) {
|
|
214
210
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
215
211
|
display: block;
|
|
@@ -220,18 +216,18 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
220
216
|
pointer-events: none;
|
|
221
217
|
user-select: none;
|
|
222
218
|
}
|
|
223
|
-
`],customElements.define("qti-graphic-associate-interaction",
|
|
224
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(
|
|
219
|
+
`],customElements.define("qti-graphic-associate-interaction",ke);class we extends(_e(E,"qti-gap-img",!1,"qti-associable-hotspot")){render(){return t` <slot></slot>
|
|
220
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(b.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(b.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}we.styles=s`
|
|
225
221
|
slot[name="qti-gap-img"] {
|
|
226
222
|
display: flex;
|
|
227
223
|
gap: 1rem;
|
|
228
224
|
}
|
|
229
|
-
`,customElements.define("qti-graphic-gap-match-interaction",
|
|
225
|
+
`,customElements.define("qti-graphic-gap-match-interaction",we);class Ae extends V{render(){return t`
|
|
230
226
|
<slot name="prompt"></slot>
|
|
231
227
|
<!-- slot for the prompt -->
|
|
232
228
|
<slot></slot>
|
|
233
229
|
<!-- slot for the image and hotspots -->
|
|
234
|
-
`}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");
|
|
230
|
+
`}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");Re(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(b.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(b.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ae.styles=[s`
|
|
235
231
|
slot:not([name='prompt']) {
|
|
236
232
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
237
233
|
display: block;
|
|
@@ -242,12 +238,12 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
242
238
|
pointer-events: none;
|
|
243
239
|
user-select: none;
|
|
244
240
|
}
|
|
245
|
-
`],customElements.define("qti-graphic-order-interaction",
|
|
241
|
+
`],customElements.define("qti-graphic-order-interaction",Ae);class Ne extends V{render(){return t`
|
|
246
242
|
<slot name="prompt"></slot>
|
|
247
243
|
<!-- slot for the prompt -->
|
|
248
244
|
<slot></slot>
|
|
249
245
|
<!-- slot for the image and hotspots -->
|
|
250
|
-
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");
|
|
246
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");Re(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(b.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(b.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ne.styles=[s`
|
|
251
247
|
slot:not([name='prompt']) {
|
|
252
248
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
253
249
|
display: block;
|
|
@@ -258,21 +254,43 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
258
254
|
pointer-events: none;
|
|
259
255
|
user-select: none;
|
|
260
256
|
}
|
|
261
|
-
`],customElements.define("qti-hotspot-interaction",
|
|
257
|
+
`],customElements.define("qti-hotspot-interaction",Ne);class Ie extends w{}Ie.styles=s`
|
|
262
258
|
:host {
|
|
263
259
|
position: absolute;
|
|
264
260
|
}
|
|
265
|
-
`,
|
|
261
|
+
`,q([n({attribute:"aria-ordervalue",type:Number,reflect:!0}),x("design:type",Number)],Ie.prototype,"order",void 0),customElements.define("qti-hotspot-choice",Ie);const Te=s`
|
|
262
|
+
.notification {
|
|
263
|
+
position: absolute;
|
|
264
|
+
z-index: 100000;
|
|
265
|
+
top: 0;
|
|
266
|
+
bottom: 0;
|
|
267
|
+
right: 0;
|
|
268
|
+
left: 0;
|
|
269
|
+
/* background: repeating-linear-gradient(45deg, #606cbc00, #606cbc00 10px, #4652980f 10px, #4652980f 20px); */
|
|
270
|
+
}
|
|
271
|
+
.notification:after {
|
|
272
|
+
position: absolute;
|
|
273
|
+
right: 1rem;
|
|
274
|
+
top: 1rem;
|
|
275
|
+
background-color: #222222;
|
|
276
|
+
color: #dddddd;
|
|
277
|
+
font-size: 14px;
|
|
278
|
+
width: fit-content;
|
|
279
|
+
padding: 0.4rem 0.6rem;
|
|
280
|
+
border-radius: 99999px;
|
|
281
|
+
content: 'preview not interactive';
|
|
282
|
+
}
|
|
283
|
+
`;class Le extends(_e(e,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice")){render(){return t`
|
|
266
284
|
<slot name="prompt"></slot>
|
|
267
|
-
<slot></slot>`}}
|
|
285
|
+
<slot></slot>`}}Le.styles=[Te],customElements.define("qti-match-interaction",Le);class De extends P{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},P.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return t`
|
|
268
286
|
<slot name="prompt"></slot>
|
|
269
|
-
<slot></slot>`}connectedCallback(){super.connectedCallback()}}
|
|
287
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback()}}De.styles=[Te,s``],customElements.define("qti-media-interaction",De);class Me extends(_e(E,"qti-simple-choice",!0,"drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return t` <slot name="prompt"> </slot>
|
|
270
288
|
<div class=${`container ${this._classNames}`}>
|
|
271
289
|
<slot class=${"vertical"===this._orientation?"ver":"hor"}> </slot>
|
|
272
290
|
<div class=${"vertical"===this._orientation?"ver":"hor"}>
|
|
273
|
-
${this.childrenMap.map(((e,s)=>t`<drop-list identifier="droplist${s}"></drop-list>`))}
|
|
291
|
+
${this.childrenMap.map(((e,s)=>t`<drop-list part="drop-list" identifier="droplist${s}"></drop-list>`))}
|
|
274
292
|
</div>
|
|
275
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}
|
|
293
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach((e=>e.setAttribute("part","qti-simple-choice")))}}Me.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Me.styles=[Te,s`
|
|
276
294
|
.hor {
|
|
277
295
|
display: grid;
|
|
278
296
|
gap: var(--qti-gap, 2px);
|
|
@@ -302,19 +320,15 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
302
320
|
.qti-choices-right {
|
|
303
321
|
flex-direction: row-reverse;
|
|
304
322
|
}
|
|
305
|
-
drop-list {
|
|
306
|
-
display: block;
|
|
307
|
-
background: var(--qti-background, #eee);
|
|
308
|
-
padding: var(--qti-padding-x, 0.7rem) var(--qti-padding-y, 0.5rem);
|
|
309
|
-
}
|
|
310
323
|
drop-list:empty::before {
|
|
311
324
|
content: 'drop here';
|
|
312
325
|
color: var(--qti-placeholder-text);
|
|
313
326
|
}
|
|
314
|
-
`],customElements.define("qti-order-interaction",
|
|
315
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}
|
|
316
|
-
<
|
|
317
|
-
|
|
327
|
+
`],customElements.define("qti-order-interaction",Me);class He extends V{constructor(){super()}render(){return t`<slot></slot>
|
|
328
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}He.styles=[Te],customElements.define("qti-select-point-interaction",He);class $e extends P{constructor(){super(...arguments),this._leftValue=0,this._sliderValue=0,this.stepLabel=!1,this.reverse=!1,this._handleDisabledChange=(e,t)=>{},this._handleReadonlyChange=(e,t)=>{}}set min(e){console.log(1,e),this._min=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){console.log(2,e),this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){console.log(3,e),this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){this._sliderValue=e}render(){return t`<slot name="prompt"></slot>
|
|
329
|
+
<div id="rail" @mousedown=${this._onMouseDown} part="rail">
|
|
330
|
+
<div id="knob" part="knob" style="left:${this._leftValue}%"></div>
|
|
331
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=t=>{const s=t.pageX-this._rail.offsetLeft;this.moveSlidieeeeeee(s),e.preventDefault(),e.stopPropagation()},s=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),this.saveResponse({base:{float:this._sliderValue}})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",s);const i=e.pageX-this._rail.offsetLeft;this.moveSlidieeeeeee(i),e.preventDefault(),e.stopPropagation()}moveSlidieeeeeee(e){const t=this.min+(this.max-this.min)*e/this.offsetWidth,s=this.min+Math.round((t-this.min)/this._step)*this._step;this._moveSliderTo(s)}_moveSliderTo(e){this._sliderValue=e;let t=Number(e);t<this.min&&(t=this.min),t>this.max&&(t=this.max),this._leftValue=(t-this.min)/(this.max-this.min)*100}}$e.styles=[s``],q([o("#knob"),x("design:type",HTMLElement)],$e.prototype,"_knob",void 0),q([o("#rail"),x("design:type",HTMLElement)],$e.prototype,"_rail",void 0),q([r(),x("design:type",Number)],$e.prototype,"_leftValue",void 0),q([r(),x("design:type",Number)],$e.prototype,"_sliderValue",void 0),q([n({type:Boolean,attribute:"step-label"}),x("design:type",Object)],$e.prototype,"stepLabel",void 0),q([n({type:Boolean}),x("design:type",Object)],$e.prototype,"reverse",void 0),q([n({type:Number,attribute:"lower-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"min",null),q([n({type:Number,attribute:"upper-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"max",null),q([n({type:Number,attribute:"step"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"step",null),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleDisabledChange",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleReadonlyChange",void 0),customElements.define("qti-slider-interaction",$e);class je extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}levenshtein(e,t){let s;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(s=e,e=t,t=s);const i=e.length,n=t.length,r=Array(i);let o,a,l;for(o=0;o<=i;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=i;a++)s=r[a-1],r[a-1]=l,l=Math.min(s+(t[o-1]!==e[a-1]),l+1,r[a]+1);r[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,s=e.calculate(),i=t.calculate();return this.value=100-this.levenshtein(s.toString().trim(),i.toString().trim())/i.toString().length*100,this.value}}je.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",je);class Pe extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/[^0-9$.,]/g,""):""}}customElements.define("qti-custom-operator-numeric",Pe);class Fe extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return this.value=t?this.parseNumber(t,undefined):"",this.value}parseNumber(e,t=navigator.languages){const s=Intl.NumberFormat(t).format(1.1),i=new RegExp(`[^-+0-9${s.charAt(1)}]`,"g"),n=e.replace(i,"").replace(s.charAt(1),".");return parseFloat(n)}}Fe.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Fe);class Ue extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/ /g,""):""}}customElements.define("qti-custom-operator-remove-spaces",Ue);class Be extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Be);const Ge=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(Ge(e,"on-next-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-item",class extends(Ge(e,"on-request-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(Ge(e,"on-prev-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-check",class extends(Ge(e,"on-check-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-score",class extends(Ge(e,"on-score-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-show-correct",class extends(Ge(e,"on-show-correct")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}});const Ve={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var Ye,ze;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(Ye||(Ye={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(ze||(ze={}));let Xe=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=Ye.nonlinear,this._submissionMode=ze.simultaneous,this.items=[],this.itemIndex=0,this.provider=new d(this,L,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===Ye.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(Ve.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===Ye.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(Ve.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(Ve.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==Ye.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(Ve.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(Ve.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(Ve.ON_NO_RESPONSE_ON_SUBMIT))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(Ve.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(Ve.ON_ITEM_READY,{detail:t}))}render(){return t`
|
|
318
332
|
<slot
|
|
319
333
|
@slotchange=${this._handleSlotchange}
|
|
320
334
|
@on-prev-item=${this._onPrevItem}
|
|
@@ -322,9 +336,10 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
322
336
|
@on-check-item=${this._onCheckItem}
|
|
323
337
|
@on-score-item=${this._onScoreItem}
|
|
324
338
|
@on-request-item=${this._onRequestItem}
|
|
339
|
+
@on-show-correct=${this._onShowCorrect}
|
|
325
340
|
>
|
|
326
341
|
</slot>
|
|
327
|
-
`}emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));this.dispatchEvent(s)}};
|
|
342
|
+
`}emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));this.dispatchEvent(s)}};q([o("qti-test-prev"),x("design:type",HTMLElement)],Xe.prototype,"prevButton",void 0),q([o("qti-test-next"),x("design:type",HTMLElement)],Xe.prototype,"nextButton",void 0),q([n({type:Boolean}),x("design:type",Object)],Xe.prototype,"disabled",void 0),q([n({type:Boolean}),x("design:type",Object)],Xe.prototype,"readonly",void 0),q([n({type:String,attribute:"navigation-mode"}),x("design:type",Object)],Xe.prototype,"_navigationMode",void 0),q([R("_navigationMode",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,String]),x("design:returntype",void 0)],Xe.prototype,"handleNavigationModeChange",null),q([n({type:String,attribute:"submission-mode"}),x("design:type",Object)],Xe.prototype,"_submissionMode",void 0),q([n(),x("design:type",Array)],Xe.prototype,"items",void 0),q([n({type:Number,attribute:"item-index",reflect:!0}),x("design:type",Object)],Xe.prototype,"itemIndex",void 0),q([R("itemIndex",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Number]),x("design:returntype",void 0)],Xe.prototype,"handleItemIndexChange",null),q([r(),x("design:type",_)],Xe.prototype,"_itemRef",void 0),Xe=q([i("qti-test")],Xe);const We=(e,t)=>class extends e{constructor(){super(...arguments),this.scale=1,this.ro=new ResizeObserver((e=>{for(const t of e)this.fitToParent(t.contentRect.width)}))}connectedCallback(){super.connectedCallback(),this.ro.observe(this),this.fitToParent()}static get properties(){return{scales:{type:Boolean,reflect:!0}}}updated(e){e.forEach(((e,t)=>{if("scales"===t)this.scales&&this.fitToParent()}))}fitToParent(e=this.clientWidth){const s=this.querySelector(t);if(s){const t=e/s.clientWidth;this.scale=t,this.marginY=-s.clientHeight*(1-t)+"px",requestAnimationFrame((()=>{s.style.transform=`scale(${this.scale})`,s.style.margin=`0 0 ${this.marginY} 0`}))}}};class Ke extends(We(e,"qti-assessment-item")){constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.processResponse=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.processResponse()},this.validateResponses=()=>!!this._item&&this._item.validateResponses(),this.resetInteractions=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.resetInteractions()},this.render=()=>t`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,t){var s,i;t&&(null===(s=this._item)||void 0===s||s.setAttribute("disabled","")),!t&&(null===(i=this._item)||void 0===i||i.removeAttribute("disabled"))}handleReadonlyChange(e,t){var s,i;t&&(null===(s=this._item)||void 0===s||s.setAttribute("readonly","")),!t&&(null===(i=this._item)||void 0===i||i.removeAttribute("readonly"))}handleResponsesChange(e,t){this._item&&(this._item.responses=t)}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}}Ke.styles=s`
|
|
328
343
|
:host {
|
|
329
344
|
display: block; /* necessary to calculate scaling position */
|
|
330
345
|
width: 100%;
|
|
@@ -340,20 +355,22 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
340
355
|
width: 1024px;
|
|
341
356
|
transform-origin: 0 0;
|
|
342
357
|
}
|
|
343
|
-
`,
|
|
358
|
+
`,q([n({type:Boolean,reflect:!0}),x("design:type",Object)],Ke.prototype,"disabled",void 0),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],Ke.prototype,"handleDisabledChange",null),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],Ke.prototype,"readonly",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],Ke.prototype,"handleReadonlyChange",null),q([n({type:Object,reflect:!0}),x("design:type",Object)],Ke.prototype,"responses",void 0),q([R("responses",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Object]),x("design:returntype",void 0)],Ke.prototype,"handleResponsesChange",null),q([r(),x("design:type",_)],Ke.prototype,"_item",void 0),customElements.define("qti-item",Ke);let Qe=class extends E{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.logger=new c(this,L,(e=>this.style.display="scorer"===e.view?"block":"none"),!0)}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.value=t.value,this.closest("qti-test").manualOutcomeValue=this.value}render(){return t`<input
|
|
344
359
|
part="input"
|
|
345
360
|
type="number"
|
|
346
361
|
spellcheck="false"
|
|
347
362
|
autocomplete="off"
|
|
348
|
-
@keyup
|
|
349
|
-
@change
|
|
363
|
+
@keyup=${this.textChanged}
|
|
364
|
+
@change=${this.textChanged}
|
|
350
365
|
placeholder="score"
|
|
351
|
-
|
|
366
|
+
min=${this.min}
|
|
367
|
+
max=${this.max}
|
|
368
|
+
.value=${this.value}
|
|
352
369
|
size="10"
|
|
353
|
-
?disabled
|
|
354
|
-
?readonly
|
|
355
|
-
/>`}};
|
|
370
|
+
?disabled=${this.disabled}
|
|
371
|
+
?readonly=${this.readonly}
|
|
372
|
+
/>`}};Qe.styles=s`
|
|
356
373
|
:host {
|
|
357
374
|
display: none;
|
|
358
375
|
}
|
|
359
|
-
`,
|
|
376
|
+
`,q([n({type:Boolean}),x("design:type",Object)],Qe.prototype,"disabled",void 0),q([n({type:Boolean}),x("design:type",Object)],Qe.prototype,"readonly",void 0),q([n({type:Number}),x("design:type",String)],Qe.prototype,"value",void 0),q([n({type:Number}),x("design:type",Number)],Qe.prototype,"min",void 0),q([n({type:Number}),x("design:type",Number)],Qe.prototype,"max",void 0),Qe=q([i("qti-manual-scoring")],Qe);export{m as BaseType,g as Cardinality,V as Choices,b as Events,Ye as NavigationMode,v as OutcomeVariable,me as QtiAnd,_ as QtiAssessmentItem,Ce as QtiAssociateInteraction,de as QtiBaseValue,w as QtiChoice,X as QtiChoiceInteraction,T as QtiCompanionMaterialsInfo,he as QtiContains,ae as QtiCorrect,je as QtiCustomOperatorLevenshtein,Pe as QtiCustomOperatorNumericOnly,Fe as QtiCustomOperatorParseNumberLocalNl,Ue as QtiCustomOperatorRemoveAllSpaces,Be as QtiCustomOperatorTrim,se as QtiExpression,B as QtiExtendedTextInteraction,$ as QtiFeedbackInline,Se as QtiGap,xe as QtiGapMatchInteraction,Oe as QtiGapText,ke as QtiGraphicAssociateInteraction,we as QtiGraphicGapMatchInteraction,Ae as QtiGraphicOrderInteraction,pe as QtiGte,Ie as QtiHotspotChoice,Ne as QtiHotspotInteraction,G as QtiHottext,Y as QtiHottextInteraction,z as QtiInlineChoiceInteraction,be as QtiIsNull,Ke as QtiItem,O as QtiItemBody,Qe as QtiManualScoring,ie as QtiMapResponse,ce as QtiMatch,Le as QtiMatchInteraction,De as QtiMediaInteraction,j as QtiModalFeedback,ue as QtiMultiple,ge as QtiOr,Me as QtiOrderInteraction,I as QtiOutcomeDeclaration,ye as QtiPortableCustomInteraction,S as QtiPrompt,J as QtiResponseCondition,N as QtiResponseDeclaration,Z as QtiResponseElse,te as QtiResponseElseIf,ee as QtiResponseIf,K as QtiResponseProcessing,He as QtiSelectPointInteraction,oe as QtiSetOutcomeValue,W as QtiSimpleChoice,$e as QtiSliderInteraction,C as QtiStylesheet,Xe as QtiTest,U as QtiTextEntryInteraction,le as QtiVariable,f as ResponseVariable,y as Status,ze as SubmissionMode,Ve as TestEvents,M as qtiContentBody,D as qtiRubricBlock,qe as qtiSimpleAssociableChoice};
|