@citolab/qti-components 3.0.37 → 3.0.38
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/environments/environment.d.ts +6 -0
- package/environments/environment.prod.d.ts +6 -0
- package/index.cjs +21 -20
- package/index.css +9 -9
- package/index.js +10 -9
- package/lab/qti-test/qti-test.d.ts +16 -8
- package/package.json +4 -2
- package/lab/qti-transform/qti-transform.d.ts +0 -13
package/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,s=require("lit"),i=require("lit/decorators.js"),r=require("lit/static-html.js"),n=require("lit/directives/if-defined.js"),o=require("lit/directives/ref.js");exports.BaseType=void 0,(e=exports.BaseType||(exports.BaseType={})).boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair",exports.Cardinality=void 0,(t=exports.Cardinality||(exports.Cardinality={})).multiple="multiple",t.ordered="ordered",t.single="single";const a={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",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"};class l{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:r}){this._basetype=exports.BaseType.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=r}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=l.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class c{}class d extends s.LitElement{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
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,s=require("lit"),i=require("lit/decorators.js"),r=require("lit/static-html.js"),n=require("lit/directives/if-defined.js"),o=require("lit/directives/ref.js");exports.BaseType=void 0,(e=exports.BaseType||(exports.BaseType={})).boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair",exports.Cardinality=void 0,(t=exports.Cardinality||(exports.Cardinality={})).multiple="multiple",t.ordered="ordered",t.single="single";const a={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",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"};class l{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:r}){this._basetype=exports.BaseType.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=r}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=l.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class c{}class d extends s.LitElement{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 h extends d{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(a.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(a.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(a.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(a.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return s.html`<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(a.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(a.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(a.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(a.ON_INTERACTION_RESPONSE,this.interactionResponse)}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=l.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 l)return t;this.err(`qti-response-variable ${e} not found, make sure you registered it`)}getOutcome(e){const t=this.variables.find((t=>t.identifier===e));return t instanceof c?t:(this.err(`qti-outcome-variable ${e} not found, make sure you registered it`),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(a.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(a.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",h);class p extends s.LitElement{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")}}}customElements.define("qti-stylesheet",p);class u extends s.LitElement{render(){return s.html` <style>
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
<div class="feedback ${this.showStatus}">
|
|
28
28
|
<slot></slot>
|
|
29
29
|
</div>
|
|
30
|
-
`}}customElements.define("qti-modal-feedback",O);class S extends d{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(a.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(a.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}g([i.property({attribute:"response-identifier"}),b("design:type",Object)],S.prototype,"responseIdentifier",void 0),g([i.property({reflect:!0,type:Boolean}),b("design:type",Object)],S.prototype,"disabled",void 0),g([i.property({reflect:!0,type:Boolean}),b("design:type",Object)],S.prototype,"readonly",void 0);const
|
|
30
|
+
`}}customElements.define("qti-modal-feedback",O);class S extends d{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(a.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(a.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}g([i.property({attribute:"response-identifier"}),b("design:type",Object)],S.prototype,"responseIdentifier",void 0),g([i.property({reflect:!0,type:Boolean}),b("design:type",Object)],S.prototype,"disabled",void 0),g([i.property({reflect:!0,type:Boolean}),b("design:type",Object)],S.prototype,"readonly",void 0);const R=s.css`
|
|
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 @@
|
|
|
107
107
|
:where([draggable='true']) {
|
|
108
108
|
-webkit-user-drag: element;
|
|
109
109
|
}
|
|
110
|
-
`;class
|
|
110
|
+
`;class k extends S{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},S.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[R,s.css`
|
|
111
111
|
/* PK: display host as block, else design will be collapsed */
|
|
112
112
|
:host {
|
|
113
113
|
display: inline-block;
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
pattern="${n.ifDefined(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")}}k.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",k);class I extends S{constructor(){super(...arguments),this.value="",this.textareaRef=o.createRef()}static get properties(){return Object.assign(Object.assign({},S.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String},classNames:{type:String,attribute:"class"}})}updated(e){e.has("classNames")&&this.changeRowsOnClassChange()}changeRowsOnClassChange(){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[R,s.css`
|
|
133
133
|
/* PK: display host as block, else design will be collapsed */
|
|
134
134
|
:host {
|
|
135
135
|
display: block;
|
|
@@ -151,9 +151,9 @@
|
|
|
151
151
|
pattern="${n.ifDefined(this.patternMask?this.patternMask:void 0)}"
|
|
152
152
|
?disabled="${this.disabled}"
|
|
153
153
|
?readonly="${this.readonly}"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
>`}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")}}
|
|
154
|
+
.value=${this.value}
|
|
155
|
+
></textarea
|
|
156
|
+
>`}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")}}I.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],customElements.define("qti-extended-text-interaction",I),exports.QtiHottext=class extends exports.QtiChoice{},exports.QtiHottext=g([i.customElement("qti-hottext")],exports.QtiHottext);class A extends S{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(a.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(a.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(a.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(a.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)}}g([i.property({type:Number,attribute:"min-choices"}),b("design:type",Number)],A.prototype,"_minChoices",void 0),g([i.property({type:Number,attribute:"max-choices"}),b("design:type",Number)],A.prototype,"_maxChoices",void 0),g([y("disabled",{waitUntilFirstUpdate:!0}),b("design:type",Object)],A.prototype,"_handleDisabledChange",void 0),g([y("readonly",{waitUntilFirstUpdate:!0}),b("design:type",Object)],A.prototype,"_handleReadonlyChange",void 0),g([y("_maxChoices",{waitUntilFirstUpdate:!0}),b("design:type",Object)],A.prototype,"_handleMaxChoicesChange",void 0);class T extends A{constructor(){super(...arguments),this.render=()=>s.html`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",T);class N extends S{constructor(){super(),this.options=[],this.addEventListener(a.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({},S.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[R,s.css`
|
|
157
157
|
:host {
|
|
158
158
|
display: inline-block;
|
|
159
159
|
}
|
|
@@ -171,10 +171,10 @@ ${this.value}</textarea
|
|
|
171
171
|
${this.options.map((e=>s.html`
|
|
172
172
|
<option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
|
|
173
173
|
`))}
|
|
174
|
-
</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}})}}N.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",N);class w extends
|
|
174
|
+
</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}})}}N.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",N);class w extends A{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>s.html`
|
|
175
175
|
<slot name="prompt"></slot>
|
|
176
176
|
<slot></slot>`}}w.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],w.presentationClass=["","qti-input-control-hidden"],g([i.property({attribute:"orientation"}),b("design:type",String)],w.prototype,"_orientation",void 0),g([i.property({attribute:"shuffle",type:Boolean}),b("design:type",Boolean)],w.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",w),exports.QtiSimpleChoice=class extends exports.QtiChoice{},exports.QtiSimpleChoice=g([i.customElement("qti-simple-choice")],exports.QtiSimpleChoice);class L extends s.LitElement{render(){return s.html`<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",L);class M extends s.LitElement{render(){return s.html``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",M);class H extends M{render(){return s.html`<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",H);class Q extends s.LitElement{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return s.html`
|
|
177
|
-
<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",Q);class $ extends Q{render(){return s.html`${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",$);class D extends ${render(){return s.html`${super.render()}`}}customElements.define("qti-response-else-if",D);class P extends d{render(){return s.html``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",P);class j extends P{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 r=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)r+=B(s,i[e],t.baseType);return r}return r+=B(s,i,t.baseType),r}}function B(e,t,s){let i=0;for(const r of e.entries()){const{entryTyped:e,valueTyped:n}=F(s,r,t);e===n&&(i+=r[1])}return i}function F(e,t,s){let i,r;switch(e){case exports.BaseType.string:case exports.BaseType.identifier:case exports.BaseType.directedPair:i=""+t[0],r=""+s;break;case exports.BaseType.float:i=parseFloat(t[0].replace(",",".")),r=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:r}}customElements.define("qti-map-response",j);class U extends M{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",U);class G extends P{render(){return s.html``}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",G);class V extends P{render(){return s.html``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",V);class z extends P{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",z);class W extends P{calculate(){return W.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===exports.BaseType.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",W);class K extends P{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return K.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),r=s.map((e=>e.source+" "+e.destination)),n=i.map((e=>e.source+" "+e.destination));return r.filter((e=>n.includes(e))).length>0}}customElements.define("qti-contains",K);class X extends P{calculate(){return 2===this.children.length?X.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",X);class Y extends P{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",Y);class J extends P{render(){return s.html``}calculate(){return J.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",J);class Z extends P{render(){return s.html``}calculate(){return Z.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",Z);class ee extends P{calculate(){return 1===this.children.length?ee.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",ee);class te extends d{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),n=i.map((e=>e.getAttribute("key"))),o=n.length>0&&!n.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>r(e))):e.textContent}return t},r=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),r(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 s.html`<slot></slot>${this._errorMessage&&s.html`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",te);const se=(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")}))}},ie=(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}},re=(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:r,height:n}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:r,height:n});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/r,d=o.height/n;this.state.set(t,{left:s,top:i,width:r,height:n});const{duration:p,easing:h}={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:p,easing:h})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return f(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:r}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:r})})),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())}},ne=(e,t,i)=>{class r extends(re(ie(se(e,t),i),i,t)){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(t)).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,r=s.parent,n=s.parent.children[i];r.insertBefore(t,n)}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 s.html` <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(a.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(a.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return r},oe=s.css`
|
|
177
|
+
<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",Q);class $ extends Q{render(){return s.html`${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",$);class D extends ${render(){return s.html`${super.render()}`}}customElements.define("qti-response-else-if",D);class P extends d{render(){return s.html``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",P);class j extends P{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 r=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)r+=F(s,i[e],t.baseType);return r}return r+=F(s,i,t.baseType),r}}function F(e,t,s){let i=0;for(const r of e.entries()){const{entryTyped:e,valueTyped:n}=B(s,r,t);e===n&&(i+=r[1])}return i}function B(e,t,s){let i,r;switch(e){case exports.BaseType.string:case exports.BaseType.identifier:case exports.BaseType.directedPair:i=""+t[0],r=""+s;break;case exports.BaseType.float:i=parseFloat(t[0].replace(",",".")),r=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:r}}customElements.define("qti-map-response",j);class U extends M{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",U);class G extends P{render(){return s.html``}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",G);class V extends P{render(){return s.html``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",V);class z extends P{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",z);class W extends P{calculate(){return W.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===exports.BaseType.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",W);class K extends P{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return K.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),r=s.map((e=>e.source+" "+e.destination)),n=i.map((e=>e.source+" "+e.destination));return r.filter((e=>n.includes(e))).length>0}}customElements.define("qti-contains",K);class X extends P{calculate(){return 2===this.children.length?X.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",X);class Y extends P{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",Y);class J extends P{render(){return s.html``}calculate(){return J.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",J);class Z extends P{render(){return s.html``}calculate(){return Z.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",Z);class ee extends P{calculate(){return 1===this.children.length?ee.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",ee);class te extends d{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),n=i.map((e=>e.getAttribute("key"))),o=n.length>0&&!n.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>r(e))):e.textContent}return t},r=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),r(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 s.html`<slot></slot>${this._errorMessage&&s.html`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",te);const se=(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")}))}},ie=(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}},re=(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:r,height:n}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:r,height:n});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/r,d=o.height/n;this.state.set(t,{left:s,top:i,width:r,height:n});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 f(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:r}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:r})})),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())}},ne=(e,t,i)=>{class r extends(re(ie(se(e,t),i),i,t)){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(t)).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,r=s.parent,n=s.parent.children[i];r.insertBefore(t,n)}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 s.html` <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(a.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(a.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return r},oe=s.css`
|
|
178
178
|
.notification {
|
|
179
179
|
position: absolute;
|
|
180
180
|
z-index: 100000;
|
|
@@ -205,12 +205,12 @@ ${this.value}</textarea
|
|
|
205
205
|
</div>`))}
|
|
206
206
|
`,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}ae.styles=[oe],customElements.define("qti-associate-interaction",ae);class le extends s.LitElement{render(){return s.html`
|
|
207
207
|
<slot></slot>
|
|
208
|
-
`}}customElements.define("qti-simple-associable-choice",le);class ce extends(ne(s.LitElement,"qti-gap-text","qti-gap")){render(){return s.html`<slot></slot>`}}ce.styles=[oe],customElements.define("qti-gap-match-interaction",ce);class de extends HTMLElement{}customElements.define("qti-gap-text",de);class
|
|
208
|
+
`}}customElements.define("qti-simple-associable-choice",le);class ce extends(ne(s.LitElement,"qti-gap-text","qti-gap")){render(){return s.html`<slot></slot>`}}ce.styles=[oe],customElements.define("qti-gap-match-interaction",ce);class de extends HTMLElement{}customElements.define("qti-gap-text",de);class he extends HTMLElement{}function pe(e,t,s,i){switch(e){case"circle":{const[e,r,n]=t,o=e/s.width*100,a=r/s.height*100,l=n/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,r,n,o]=t,a=e/s.width*100,l=r/s.height*100,c=n/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}),[]),r=Math.min(...e.map((e=>e.x))),n=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=r/s.width*100,c=o/s.height*100,d=n/s.width*100,h=a/s.height*100;i.style.left=r/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-r)/(n-r)*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",he);class ue extends A{render(){return s.html`
|
|
209
209
|
<slot name="prompt"></slot>
|
|
210
210
|
<!-- slot for the prompt -->
|
|
211
211
|
<slot></slot>
|
|
212
212
|
<!-- slot for the image and hotspots -->
|
|
213
|
-
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");
|
|
213
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");pe(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}ue.styles=[s.css`
|
|
214
214
|
slot:not([name='prompt']) {
|
|
215
215
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
216
216
|
display: block;
|
|
@@ -227,12 +227,12 @@ ${this.value}</textarea
|
|
|
227
227
|
display: flex;
|
|
228
228
|
gap: 1rem;
|
|
229
229
|
}
|
|
230
|
-
`,customElements.define("qti-graphic-gap-match-interaction",me);class ge extends
|
|
230
|
+
`,customElements.define("qti-graphic-gap-match-interaction",me);class ge extends A{render(){return s.html`
|
|
231
231
|
<slot name="prompt"></slot>
|
|
232
232
|
<!-- slot for the prompt -->
|
|
233
233
|
<slot></slot>
|
|
234
234
|
<!-- slot for the image and hotspots -->
|
|
235
|
-
`}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");
|
|
235
|
+
`}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");pe(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}ge.styles=[s.css`
|
|
236
236
|
slot:not([name='prompt']) {
|
|
237
237
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
238
238
|
display: block;
|
|
@@ -243,12 +243,12 @@ ${this.value}</textarea
|
|
|
243
243
|
pointer-events: none;
|
|
244
244
|
user-select: none;
|
|
245
245
|
}
|
|
246
|
-
`],customElements.define("qti-graphic-order-interaction",ge);class be extends
|
|
246
|
+
`],customElements.define("qti-graphic-order-interaction",ge);class be extends A{render(){return s.html`
|
|
247
247
|
<slot name="prompt"></slot>
|
|
248
248
|
<!-- slot for the prompt -->
|
|
249
249
|
<slot></slot>
|
|
250
250
|
<!-- slot for the image and hotspots -->
|
|
251
|
-
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");
|
|
251
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");pe(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}be.styles=[s.css`
|
|
252
252
|
slot:not([name='prompt']) {
|
|
253
253
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
254
254
|
display: block;
|
|
@@ -312,11 +312,12 @@ ${this.value}</textarea
|
|
|
312
312
|
content: 'drop here';
|
|
313
313
|
color: var(--qti-placeholder-text);
|
|
314
314
|
}
|
|
315
|
-
`],customElements.define("qti-order-interaction",ve);class xe extends
|
|
316
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}xe.styles=[oe],customElements.define("qti-select-point-interaction",xe);const Ce=37,qe=38,_e=39,Oe=40,Se=33,
|
|
315
|
+
`],customElements.define("qti-order-interaction",ve);class xe extends A{constructor(){super()}render(){return s.html`<slot></slot>
|
|
316
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}xe.styles=[oe],customElements.define("qti-select-point-interaction",xe);const Ce=37,qe=38,_e=39,Oe=40,Se=33,Re=34,ke=35,Ie=36;class Ae extends S{constructor(){super(),this.addEventListener("keydown",this._onKeyDown.bind(this))}reset(){}validate(){return!0}set response(e){}set min(e){this._min=e,this.style.setProperty("--qti-slider-interaction-lower-bounds",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--qti-slider-interaction-upper-bounds",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--qti-slider-interaction-step",`${this._step}`)}get step(){return this._step}render(){return s.html`
|
|
317
317
|
<slot name="prompt"></slot>
|
|
318
|
-
<slot></slot>`}firstUpdated(){this.addEventListener("mousedown",this._onMouseDown.bind(this)),this.style.setProperty("--qti-slider-interaction-step",this.step?this.step.toString():"10");const e=this.getAttribute("value");this._moveSliderTo(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get RAIL_WIDTH(){return this.offsetWidth}_onKeyDown(e){let t=!1;const s=this.value;switch(e.keyCode){case Ce:case Oe:this._moveSliderTo(s-this.step),t=!0;break;case _e:case qe:this._moveSliderTo(s+this.step),t=!0;break;case
|
|
318
|
+
<slot></slot>`}firstUpdated(){this.addEventListener("mousedown",this._onMouseDown.bind(this)),this.style.setProperty("--qti-slider-interaction-step",this.step?this.step.toString():"10");const e=this.getAttribute("value");this._moveSliderTo(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get RAIL_WIDTH(){return this.offsetWidth}_onKeyDown(e){let t=!1;const s=this.value;switch(e.keyCode){case Ce:case Oe:this._moveSliderTo(s-this.step),t=!0;break;case _e:case qe:this._moveSliderTo(s+this.step),t=!0;break;case Re:this._moveSliderTo(s-this.step),t=!0;break;case Se:this._moveSliderTo(s+this.step),t=!0;break;case Ie:this._moveSliderTo(this.min),t=!0;break;case ke:this._moveSliderTo(this.max),t=!0}t&&(e.preventDefault(),e.stopPropagation())}_onMouseDown(e){const t=e.target,s=this.min,i=this.max,r=e=>{const r=e.pageX-t.offsetLeft,n=s+(i-s)*r/this.RAIL_WIDTH;this._moveSliderTo(n),e.preventDefault(),e.stopPropagation()},n=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",r),document.addEventListener("mouseup",n),e.preventDefault(),e.stopPropagation(),e.target.focus();const o=e.pageX-t.offsetLeft,a=s+(i-s)*o/this.RAIL_WIDTH;this._moveSliderTo(a)}_moveSliderTo(e){const t=this.min,s=this.max;let i=Number(e);i<t&&(i=t),i>s&&(i=s);const r=(i-t)/(s-t)*100;this.style.setProperty("--qti-slider-interaction-aria-valuenow",`${r}%`)}}Ae.styles=[oe,s.css``],g([i.property({type:Number,attribute:"lower-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Ae.prototype,"min",null),g([i.property({type:Number,attribute:"upper-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Ae.prototype,"max",null),g([i.property({type:Number,attribute:"step"}),b("design:type",Number),b("design:paramtypes",[Number])],Ae.prototype,"step",null),customElements.define("qti-slider-interaction",Ae);class Te extends s.LitElement{constructor(){super(...arguments),this.render=()=>s.html`${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,r=t.length,n=Array(i);let o,a,l;for(o=0;o<=i;o++)n[o]=o;for(o=1;o<=r;o++){for(l=o,a=1;a<=i;a++)s=n[a-1],n[a-1]=l,l=Math.min(s+(t[o-1]!==e[a-1]),l+1,n[a]+1);n[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}}Te.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Te);class Ne extends s.LitElement{render(){return s.html``}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",Ne);class we extends s.LitElement{constructor(){super(...arguments),this.render=()=>s.html`${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"),r=e.replace(i,"").replace(s.charAt(1),".");return parseFloat(r)}}we.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",we);class Le extends s.LitElement{render(){return s.html``}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",Le);class Me extends s.LitElement{render(){return s.html``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Me);const He={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished"};var Qe,$e;exports.NavigationMode=void 0,(Qe=exports.NavigationMode||(exports.NavigationMode={})).linear="linear",Qe.nonlinear="nonlinear",exports.SubmissionMode=void 0,($e=exports.SubmissionMode||(exports.SubmissionMode={})).individual="individual",$e.simultaneous="simultaneous",exports.QtiTest=class extends s.LitElement{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=exports.NavigationMode.nonlinear,this._submissionMode=exports.SubmissionMode.simultaneous,this.items=[],this.itemIndex=0}updated(e){const t=this.querySelector("qti-test\\.prev");e.forEach(((e,s)=>{if("navigationMode"===s)this._navigationMode===exports.NavigationMode.linear&&(t.style.visibility="hidden"),this._navigationMode===exports.NavigationMode.nonlinear&&(t.style.visibility="visible")}))}onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}onScoreItem(){this.onCheckItem()&&this._itemRef.processResponse()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===exports.NavigationMode.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(He.ON_ITEM_WAS_FINISHED))))}onPrevItem(){this.itemIndex>0&&this._dispatchRequestItem(this.itemIndex-1)}onNextItem(){this._navigationMode!==exports.NavigationMode.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this._dispatchRequestItem(this.itemIndex+1):this.dispatchEvent(new CustomEvent(He.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(He.ON_NO_RESPONSE_ON_SUBMIT))}_dispatchRequestItem(e){this.dispatchEvent(new CustomEvent(He.ON_REQUEST_ITEM,{bubbles:!0,composed:!0,detail:e}))}onRequestItem(e){this._dispatchRequestItem(e.detail)}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",""))}render(){return s.html`
|
|
319
319
|
<slot
|
|
320
|
+
@slotchange=${this.handleSlotchange}
|
|
320
321
|
@on-prev-item=${this.onPrevItem}
|
|
321
322
|
@on-next-item=${this.onNextItem}
|
|
322
323
|
@on-check-item=${this.onCheckItem}
|
|
@@ -324,7 +325,7 @@ ${this.value}</textarea
|
|
|
324
325
|
@on-request-item=${this.onRequestItem}
|
|
325
326
|
>
|
|
326
327
|
</slot>
|
|
327
|
-
`}},g([i.property({type:Boolean}),b("design:type",Object)],exports.QtiTest.prototype,"disabled",void 0),g([i.property({type:Boolean}),b("design:type",Object)],exports.QtiTest.prototype,"readonly",void 0),g([i.property({type:String,attribute:"navigation-mode"}),b("design:type",Object)],exports.QtiTest.prototype,"_navigationMode",void 0),g([i.property({type:String,attribute:"submission-mode"}),b("design:type",Object)],exports.QtiTest.prototype,"_submissionMode",void 0),g([i.property(
|
|
328
|
+
`}},g([i.property({type:Boolean}),b("design:type",Object)],exports.QtiTest.prototype,"disabled",void 0),g([i.property({type:Boolean}),b("design:type",Object)],exports.QtiTest.prototype,"readonly",void 0),g([i.property({type:String,attribute:"navigation-mode"}),b("design:type",Object)],exports.QtiTest.prototype,"_navigationMode",void 0),g([i.property({type:String,attribute:"submission-mode"}),b("design:type",Object)],exports.QtiTest.prototype,"_submissionMode",void 0),g([i.property(),b("design:type",Array)],exports.QtiTest.prototype,"items",void 0),g([i.property({type:Number,attribute:"item-index",reflect:!0}),b("design:type",Object)],exports.QtiTest.prototype,"itemIndex",void 0),g([i.state(),b("design:type",h)],exports.QtiTest.prototype,"_itemRef",void 0),exports.QtiTest=g([i.customElement("qti-test")],exports.QtiTest);const De=(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 Pe extends(De(s.LitElement,"qti-assessment-item")){constructor(){super(...arguments),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=()=>s.html`<slot @slotchange=${this.handleSlotchange}></slot>`}static get properties(){return{disabled:{type:Boolean},readonly:{type:Boolean},responses:{type:Object}}}updated(e){e.forEach(((e,t)=>{var s,i;switch(t){case"disabled":null===(s=this._item)||void 0===s||s.setAttribute("disabled","");break;case"readonly":null===(i=this._item)||void 0===i||i.setAttribute("readonly","");break;case"responses":this._item&&(this._item.responses=this.responses)}}))}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))}))}}Pe.styles=s.css`
|
|
328
329
|
:host {
|
|
329
330
|
display: block; /* necessary to calculate scaling position */
|
|
330
331
|
width: 100%;
|
|
@@ -338,4 +339,4 @@ ${this.value}</textarea
|
|
|
338
339
|
width: 640px !important;
|
|
339
340
|
transform-origin: 0 0;
|
|
340
341
|
}
|
|
341
|
-
`,customElements.define("qti-item",Pe),exports.AssessmentTestEvents=He,exports.Choices=
|
|
342
|
+
`,customElements.define("qti-item",Pe),exports.AssessmentTestEvents=He,exports.Choices=A,exports.Events=a,exports.OutcomeVariable=c,exports.QtiAnd=J,exports.QtiAssessmentItem=h,exports.QtiAssociateInteraction=ae,exports.QtiBaseValue=W,exports.QtiChoiceInteraction=w,exports.QtiContains=K,exports.QtiCorrect=G,exports.QtiCustomOperatorLevenshtein=Te,exports.QtiCustomOperatorNumericOnly=Ne,exports.QtiCustomOperatorParseNumberLocalNl=we,exports.QtiCustomOperatorRemoveAllSpaces=Le,exports.QtiCustomOperatorTrim=Me,exports.QtiExpression=P,exports.QtiExtendedTextInteraction=I,exports.QtiFeedbackInline=_,exports.QtiGap=he,exports.QtiGapMatchInteraction=ce,exports.QtiGapText=de,exports.QtiGraphicAssociateInteraction=ue,exports.QtiGraphicGapMatchInteraction=me,exports.QtiGraphicOrderInteraction=ge,exports.QtiGte=X,exports.QtiHotspotChoice=fe,exports.QtiHotspotInteraction=be,exports.QtiHottextInteraction=T,exports.QtiInlineChoiceInteraction=N,exports.QtiIsNull=ee,exports.QtiItem=Pe,exports.QtiItemBody=u,exports.QtiMapResponse=j,exports.QtiMatch=z,exports.QtiMatchInteraction=ye,exports.QtiMediaInteraction=Ee,exports.QtiModalFeedback=O,exports.QtiMultiple=Y,exports.QtiOr=Z,exports.QtiOrderInteraction=ve,exports.QtiOutcomeDeclaration=C,exports.QtiPortableCustomInteraction=te,exports.QtiPrompt=m,exports.QtiResponseCondition=H,exports.QtiResponseDeclaration=x,exports.QtiResponseElse=Q,exports.QtiResponseElseIf=D,exports.QtiResponseIf=$,exports.QtiResponseProcessing=L,exports.QtiSelectPointInteraction=xe,exports.QtiSetOutcomeValue=U,exports.QtiSliderInteraction=Ae,exports.QtiStylesheet=p,exports.QtiTextEntryInteraction=k,exports.QtiVariable=V,exports.ResponseVariable=l,exports.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},exports.qtiSimpleAssociableChoice=le;
|
package/index.css
CHANGED
|
@@ -16902,12 +16902,12 @@ qti-test qti-assessment-item {
|
|
|
16902
16902
|
qti-test qti-assessment-item qti-item-body {
|
|
16903
16903
|
display: block;
|
|
16904
16904
|
}
|
|
16905
|
-
qti-test qti-test
|
|
16905
|
+
qti-test qti-test-nav {
|
|
16906
16906
|
display: flex;
|
|
16907
16907
|
gap: 1rem;
|
|
16908
16908
|
justify-content: space-between;
|
|
16909
16909
|
}
|
|
16910
|
-
qti-test qti-test
|
|
16910
|
+
qti-test qti-test-nav qti-test-check, qti-test qti-test-nav qti-test-score, qti-test qti-test-nav qti-test-prev, qti-test qti-test-nav qti-test-next {
|
|
16911
16911
|
color: rgb(56, 56, 56);
|
|
16912
16912
|
text-decoration: none;
|
|
16913
16913
|
padding: 5px 10px;
|
|
@@ -16924,18 +16924,18 @@ qti-test qti-test\.nav qti-test\.check, qti-test qti-test\.nav qti-test\.score,
|
|
|
16924
16924
|
color: rgb(83, 83, 83);
|
|
16925
16925
|
background: #eeeeee;
|
|
16926
16926
|
}
|
|
16927
|
-
qti-test qti-test
|
|
16927
|
+
qti-test qti-test-nav qti-test-check:hover, qti-test qti-test-nav qti-test-score:hover, qti-test qti-test-nav qti-test-prev:hover, qti-test qti-test-nav qti-test-next:hover {
|
|
16928
16928
|
background: #dadada;
|
|
16929
16929
|
transition: all 0.3s ease;
|
|
16930
16930
|
}
|
|
16931
|
-
qti-test qti-test
|
|
16931
|
+
qti-test qti-test-nav qti-test-check:active, qti-test qti-test-nav qti-test-score:active, qti-test qti-test-nav qti-test-prev:active, qti-test qti-test-nav qti-test-next:active {
|
|
16932
16932
|
background: #aeaeae;
|
|
16933
16933
|
}
|
|
16934
|
-
qti-test qti-test
|
|
16934
|
+
qti-test qti-test-nav qti-test-progress {
|
|
16935
16935
|
display: flex;
|
|
16936
16936
|
overflow-x: scroll;
|
|
16937
16937
|
}
|
|
16938
|
-
qti-test qti-test
|
|
16938
|
+
qti-test qti-test-nav qti-test-progress qti-test-item {
|
|
16939
16939
|
color: rgb(56, 56, 56);
|
|
16940
16940
|
text-decoration: none;
|
|
16941
16941
|
padding: 5px 10px;
|
|
@@ -16952,14 +16952,14 @@ qti-test qti-test\.nav qti-test\.progress qti-test\.item {
|
|
|
16952
16952
|
color: rgb(83, 83, 83);
|
|
16953
16953
|
background: #eeeeee;
|
|
16954
16954
|
}
|
|
16955
|
-
qti-test qti-test
|
|
16955
|
+
qti-test qti-test-nav qti-test-progress qti-test-item:hover {
|
|
16956
16956
|
background: #dadada;
|
|
16957
16957
|
transition: all 0.3s ease;
|
|
16958
16958
|
}
|
|
16959
|
-
qti-test qti-test
|
|
16959
|
+
qti-test qti-test-nav qti-test-progress qti-test-item:active {
|
|
16960
16960
|
background: #aeaeae;
|
|
16961
16961
|
}
|
|
16962
|
-
qti-test qti-test
|
|
16962
|
+
qti-test qti-test-nav qti-test-progress qti-test-item[checked] {
|
|
16963
16963
|
background: darkblue;
|
|
16964
16964
|
color: white;
|
|
16965
16965
|
}
|
package/index.js
CHANGED
|
@@ -8,14 +8,14 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{property
|
|
|
8
8
|
<slot name="qti-rubric-block" />
|
|
9
9
|
</header>
|
|
10
10
|
-->
|
|
11
|
-
<slot></slot>`}}customElements.define("qti-item-body",v);class q extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function _(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 C(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function x(e,t,s,i){return new(s||(s=Promise))((function(n,r){function o(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}function O(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",q);const S=32;let k=class extends f{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(u.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(u.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===S&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(u.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return a` <slot></slot> `}};_([n({reflect:!0}),C("design:type",String)],k.prototype,"identifier",void 0),_([n({type:Number,reflect:!0}),C("design:type",Object)],k.prototype,"tabindex",void 0),_([n({type:Boolean,reflect:!0}),C("design:type",Object)],k.prototype,"disabled",void 0),_([n({type:Boolean,reflect:!0}),C("design:type",Object)],k.prototype,"readonly",void 0),_([n({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),C("design:type",Object)],k.prototype,"checked",void 0),_([O("disabled",{waitUntilFirstUpdate:!0}),C("design:type",Function),C("design:paramtypes",[Object,Boolean]),C("design:returntype",void 0)],k.prototype,"handleDisabledChange",null),k=_([r("qti-choice")],k);class R extends e{render(){return t``}}customElements.define("qti-variabledeclaration",R);class A extends R{static get properties(){return{baseType:{type:String,attribute:"base-type"},identifier:{type:String,attribute:"identifier"},cardinality:{type:String,attribute:"cardinality"}}}connectedCallback(){super.connectedCallback();const e=new g({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||p.single,mapping:this.mapping});this.closest("qti-assessment-item").variables.push(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}}customElements.define("qti-response-declaration",A);class I extends R{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new b;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",I);class
|
|
11
|
+
<slot></slot>`}}customElements.define("qti-item-body",v);class q extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function _(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 C(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function x(e,t,s,i){return new(s||(s=Promise))((function(n,r){function o(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}function O(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",q);const S=32;let k=class extends f{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(u.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(u.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===S&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(u.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return a` <slot></slot> `}};_([n({reflect:!0}),C("design:type",String)],k.prototype,"identifier",void 0),_([n({type:Number,reflect:!0}),C("design:type",Object)],k.prototype,"tabindex",void 0),_([n({type:Boolean,reflect:!0}),C("design:type",Object)],k.prototype,"disabled",void 0),_([n({type:Boolean,reflect:!0}),C("design:type",Object)],k.prototype,"readonly",void 0),_([n({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),C("design:type",Object)],k.prototype,"checked",void 0),_([O("disabled",{waitUntilFirstUpdate:!0}),C("design:type",Function),C("design:paramtypes",[Object,Boolean]),C("design:returntype",void 0)],k.prototype,"handleDisabledChange",null),k=_([r("qti-choice")],k);class R extends e{render(){return t``}}customElements.define("qti-variabledeclaration",R);class A extends R{static get properties(){return{baseType:{type:String,attribute:"base-type"},identifier:{type:String,attribute:"identifier"},cardinality:{type:String,attribute:"cardinality"}}}connectedCallback(){super.connectedCallback();const e=new g({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||p.single,mapping:this.mapping});this.closest("qti-assessment-item").variables.push(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}}customElements.define("qti-response-declaration",A);class I extends R{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new b;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",I);class w 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(u.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 N extends w{constructor(){super(...arguments),this.render=()=>t` <slot class="${this.showStatus}"></slot> `}}N.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",N);class T extends w{render(){return t`
|
|
19
19
|
<style>
|
|
20
20
|
.on {
|
|
21
21
|
display: inline-block;
|
|
@@ -151,8 +151,8 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{property
|
|
|
151
151
|
pattern="${l(this.patternMask?this.patternMask:void 0)}"
|
|
152
152
|
?disabled="${this.disabled}"
|
|
153
153
|
?readonly="${this.readonly}"
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
.value=${this.value}
|
|
155
|
+
></textarea
|
|
156
156
|
>`}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")}}$.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],customElements.define("qti-extended-text-interaction",$);let D=class extends k{};D=_([r("qti-hottext")],D);class P extends L{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(u.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(u.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(u.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(u.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)}}_([n({type:Number,attribute:"min-choices"}),C("design:type",Number)],P.prototype,"_minChoices",void 0),_([n({type:Number,attribute:"max-choices"}),C("design:type",Number)],P.prototype,"_maxChoices",void 0),_([O("disabled",{waitUntilFirstUpdate:!0}),C("design:type",Object)],P.prototype,"_handleDisabledChange",void 0),_([O("readonly",{waitUntilFirstUpdate:!0}),C("design:type",Object)],P.prototype,"_handleReadonlyChange",void 0),_([O("_maxChoices",{waitUntilFirstUpdate:!0}),C("design:type",Object)],P.prototype,"_handleMaxChoicesChange",void 0);class j extends P{constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",j);class F extends L{constructor(){super(),this.options=[],this.addEventListener(u.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({},L.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[H,s`
|
|
157
157
|
:host {
|
|
158
158
|
display: inline-block;
|
|
@@ -312,11 +312,12 @@ ${this.value}</textarea
|
|
|
312
312
|
content: 'drop here';
|
|
313
313
|
color: var(--qti-placeholder-text);
|
|
314
314
|
}
|
|
315
|
-
`],customElements.define("qti-order-interaction",Ie);class
|
|
316
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}
|
|
315
|
+
`],customElements.define("qti-order-interaction",Ie);class we extends P{constructor(){super()}render(){return t`<slot></slot>
|
|
316
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}we.styles=[be],customElements.define("qti-select-point-interaction",we);const Ne=37,Te=38,Le=39,He=40,Me=33,$e=34,De=35,Pe=36;class je extends L{constructor(){super(),this.addEventListener("keydown",this._onKeyDown.bind(this))}reset(){}validate(){return!0}set response(e){}set min(e){this._min=e,this.style.setProperty("--qti-slider-interaction-lower-bounds",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--qti-slider-interaction-upper-bounds",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--qti-slider-interaction-step",`${this._step}`)}get step(){return this._step}render(){return t`
|
|
317
317
|
<slot name="prompt"></slot>
|
|
318
|
-
<slot></slot>`}firstUpdated(){this.addEventListener("mousedown",this._onMouseDown.bind(this)),this.style.setProperty("--qti-slider-interaction-step",this.step?this.step.toString():"10");const e=this.getAttribute("value");this._moveSliderTo(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get RAIL_WIDTH(){return this.offsetWidth}_onKeyDown(e){let t=!1;const s=this.value;switch(e.keyCode){case
|
|
318
|
+
<slot></slot>`}firstUpdated(){this.addEventListener("mousedown",this._onMouseDown.bind(this)),this.style.setProperty("--qti-slider-interaction-step",this.step?this.step.toString():"10");const e=this.getAttribute("value");this._moveSliderTo(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get RAIL_WIDTH(){return this.offsetWidth}_onKeyDown(e){let t=!1;const s=this.value;switch(e.keyCode){case Ne:case He:this._moveSliderTo(s-this.step),t=!0;break;case Le:case Te:this._moveSliderTo(s+this.step),t=!0;break;case $e:this._moveSliderTo(s-this.step),t=!0;break;case Me:this._moveSliderTo(s+this.step),t=!0;break;case Pe:this._moveSliderTo(this.min),t=!0;break;case De:this._moveSliderTo(this.max),t=!0}t&&(e.preventDefault(),e.stopPropagation())}_onMouseDown(e){const t=e.target,s=this.min,i=this.max,n=e=>{const n=e.pageX-t.offsetLeft,r=s+(i-s)*n/this.RAIL_WIDTH;this._moveSliderTo(r),e.preventDefault(),e.stopPropagation()},r=()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",n),document.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),e.target.focus();const o=e.pageX-t.offsetLeft,a=s+(i-s)*o/this.RAIL_WIDTH;this._moveSliderTo(a)}_moveSliderTo(e){const t=this.min,s=this.max;let i=Number(e);i<t&&(i=t),i>s&&(i=s);const n=(i-t)/(s-t)*100;this.style.setProperty("--qti-slider-interaction-aria-valuenow",`${n}%`)}}je.styles=[be,s``],_([n({type:Number,attribute:"lower-bound"}),C("design:type",Number),C("design:paramtypes",[Number])],je.prototype,"min",null),_([n({type:Number,attribute:"upper-bound"}),C("design:type",Number),C("design:paramtypes",[Number])],je.prototype,"max",null),_([n({type:Number,attribute:"step"}),C("design:type",Number),C("design:paramtypes",[Number])],je.prototype,"step",null),customElements.define("qti-slider-interaction",je);class Fe 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}}Fe.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",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(/[^0-9$.,]/g,""):""}}customElements.define("qti-custom-operator-numeric",Ue);class Be 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)}}Be.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Be);class Ge 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",Ge);class ze extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",ze);const We={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished"};var Ke,Ve;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(Ke||(Ke={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(Ve||(Ve={}));let Qe=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=Ke.nonlinear,this._submissionMode=Ve.simultaneous,this.items=[],this.itemIndex=0}updated(e){const t=this.querySelector("qti-test\\.prev");e.forEach(((e,s)=>{if("navigationMode"===s)this._navigationMode===Ke.linear&&(t.style.visibility="hidden"),this._navigationMode===Ke.nonlinear&&(t.style.visibility="visible")}))}onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}onScoreItem(){this.onCheckItem()&&this._itemRef.processResponse()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===Ke.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(We.ON_ITEM_WAS_FINISHED))))}onPrevItem(){this.itemIndex>0&&this._dispatchRequestItem(this.itemIndex-1)}onNextItem(){this._navigationMode!==Ke.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this._dispatchRequestItem(this.itemIndex+1):this.dispatchEvent(new CustomEvent(We.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(We.ON_NO_RESPONSE_ON_SUBMIT))}_dispatchRequestItem(e){this.dispatchEvent(new CustomEvent(We.ON_REQUEST_ITEM,{bubbles:!0,composed:!0,detail:e}))}onRequestItem(e){this._dispatchRequestItem(e.detail)}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",""))}render(){return t`
|
|
319
319
|
<slot
|
|
320
|
+
@slotchange=${this.handleSlotchange}
|
|
320
321
|
@on-prev-item=${this.onPrevItem}
|
|
321
322
|
@on-next-item=${this.onNextItem}
|
|
322
323
|
@on-check-item=${this.onCheckItem}
|
|
@@ -324,7 +325,7 @@ ${this.value}</textarea
|
|
|
324
325
|
@on-request-item=${this.onRequestItem}
|
|
325
326
|
>
|
|
326
327
|
</slot>
|
|
327
|
-
`}};_([n({type:Boolean}),C("design:type",Object)],Qe.prototype,"disabled",void 0),_([n({type:Boolean}),C("design:type",Object)],Qe.prototype,"readonly",void 0),_([n({type:String,attribute:"navigation-mode"}),C("design:type",Object)],Qe.prototype,"_navigationMode",void 0),_([n({type:String,attribute:"submission-mode"}),C("design:type",Object)],Qe.prototype,"_submissionMode",void 0),_([n(
|
|
328
|
+
`}};_([n({type:Boolean}),C("design:type",Object)],Qe.prototype,"disabled",void 0),_([n({type:Boolean}),C("design:type",Object)],Qe.prototype,"readonly",void 0),_([n({type:String,attribute:"navigation-mode"}),C("design:type",Object)],Qe.prototype,"_navigationMode",void 0),_([n({type:String,attribute:"submission-mode"}),C("design:type",Object)],Qe.prototype,"_submissionMode",void 0),_([n(),C("design:type",Array)],Qe.prototype,"items",void 0),_([n({type:Number,attribute:"item-index",reflect:!0}),C("design:type",Object)],Qe.prototype,"itemIndex",void 0),_([o(),C("design:type",y)],Qe.prototype,"_itemRef",void 0),Qe=_([r("qti-test")],Qe);const Xe=(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 Ye extends(Xe(e,"qti-assessment-item")){constructor(){super(...arguments),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>`}static get properties(){return{disabled:{type:Boolean},readonly:{type:Boolean},responses:{type:Object}}}updated(e){e.forEach(((e,t)=>{var s,i;switch(t){case"disabled":null===(s=this._item)||void 0===s||s.setAttribute("disabled","");break;case"readonly":null===(i=this._item)||void 0===i||i.setAttribute("readonly","");break;case"responses":this._item&&(this._item.responses=this.responses)}}))}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))}))}}Ye.styles=s`
|
|
328
329
|
:host {
|
|
329
330
|
display: block; /* necessary to calculate scaling position */
|
|
330
331
|
width: 100%;
|
|
@@ -338,4 +339,4 @@ ${this.value}</textarea
|
|
|
338
339
|
width: 640px !important;
|
|
339
340
|
transform-origin: 0 0;
|
|
340
341
|
}
|
|
341
|
-
`,customElements.define("qti-item",Ye);export{We as AssessmentTestEvents,h as BaseType,p as Cardinality,P as Choices,u as Events,Ke as NavigationMode,b as OutcomeVariable,le as QtiAnd,y as QtiAssessmentItem,fe as QtiAssociateInteraction,ne as QtiBaseValue,k as QtiChoice,U as QtiChoiceInteraction,re as QtiContains,te as QtiCorrect,Fe as QtiCustomOperatorLevenshtein,Ue as QtiCustomOperatorNumericOnly,Be as QtiCustomOperatorParseNumberLocalNl,Ge as QtiCustomOperatorRemoveAllSpaces,ze as QtiCustomOperatorTrim,X as QtiExpression,$ as QtiExtendedTextInteraction,
|
|
342
|
+
`,customElements.define("qti-item",Ye);export{We as AssessmentTestEvents,h as BaseType,p as Cardinality,P as Choices,u as Events,Ke as NavigationMode,b as OutcomeVariable,le as QtiAnd,y as QtiAssessmentItem,fe as QtiAssociateInteraction,ne as QtiBaseValue,k as QtiChoice,U as QtiChoiceInteraction,re as QtiContains,te as QtiCorrect,Fe as QtiCustomOperatorLevenshtein,Ue as QtiCustomOperatorNumericOnly,Be as QtiCustomOperatorParseNumberLocalNl,Ge as QtiCustomOperatorRemoveAllSpaces,ze as QtiCustomOperatorTrim,X as QtiExpression,$ as QtiExtendedTextInteraction,N as QtiFeedbackInline,qe as QtiGap,Ee as QtiGapMatchInteraction,ve as QtiGapText,Ce as QtiGraphicAssociateInteraction,xe as QtiGraphicGapMatchInteraction,Oe as QtiGraphicOrderInteraction,oe as QtiGte,ke as QtiHotspotChoice,Se as QtiHotspotInteraction,D as QtiHottext,j as QtiHottextInteraction,F as QtiInlineChoiceInteraction,de as QtiIsNull,Ye as QtiItem,v as QtiItemBody,Y as QtiMapResponse,ie as QtiMatch,Re as QtiMatchInteraction,Ae as QtiMediaInteraction,T as QtiModalFeedback,ae as QtiMultiple,ce as QtiOr,Ie as QtiOrderInteraction,I as QtiOutcomeDeclaration,he as QtiPortableCustomInteraction,q as QtiPrompt,W as QtiResponseCondition,A as QtiResponseDeclaration,K as QtiResponseElse,Q as QtiResponseElseIf,V as QtiResponseIf,G as QtiResponseProcessing,we as QtiSelectPointInteraction,ee as QtiSetOutcomeValue,B as QtiSimpleChoice,je as QtiSliderInteraction,E as QtiStylesheet,Qe as QtiTest,M as QtiTextEntryInteraction,se as QtiVariable,g as ResponseVariable,m as Status,Ve as SubmissionMode,ye as qtiSimpleAssociableChoice};
|
|
@@ -16,24 +16,32 @@ export declare enum SubmissionMode {
|
|
|
16
16
|
simultaneous = "simultaneous"
|
|
17
17
|
}
|
|
18
18
|
export declare class QtiTest extends LitElement {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/** TEST CHANGES */
|
|
20
|
+
/** if test is disabled every item in the test will be disabled */
|
|
21
|
+
private readonly disabled;
|
|
22
|
+
/** if test is readonly every item in the test will be readonly */
|
|
23
|
+
private readonly readonly;
|
|
21
24
|
/** The navigation mode is set to linear mode restricting the candidate to attempt each item in turn. Once the candidate moves on they are not permitted to return */
|
|
22
25
|
private _navigationMode;
|
|
23
26
|
/** The submission mode is set to individual mode requiring the candidate to submit their responses on an item-by-item basis */
|
|
24
27
|
private _submissionMode;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/** All the items in the test with, href=file (used for location), identifier=uniqueInTest (used for responses) */
|
|
29
|
+
items: {
|
|
30
|
+
href: string;
|
|
31
|
+
identifier: string;
|
|
32
|
+
}[];
|
|
33
|
+
/** ITEM CHANGES */
|
|
34
|
+
/** The item index, set from outside */
|
|
35
|
+
readonly itemIndex = 0;
|
|
36
|
+
private _itemRef;
|
|
30
37
|
updated(changedProperties: any): void;
|
|
31
38
|
onCheckItem(): boolean;
|
|
32
39
|
onScoreItem(): void;
|
|
40
|
+
set itemXML(xml: string);
|
|
33
41
|
set itemResponse(val: InputResponseFormat<QtiVariableJSON>);
|
|
34
42
|
private onPrevItem;
|
|
35
43
|
private onNextItem;
|
|
36
|
-
private
|
|
44
|
+
private _dispatchRequestItem;
|
|
37
45
|
private onRequestItem;
|
|
38
46
|
handleSlotchange(e: any): void;
|
|
39
47
|
render(): import("lit-html").TemplateResult<1>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citolab/qti-components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.38",
|
|
4
4
|
"repository": "@citolab/qti-components",
|
|
5
5
|
"author": "Patrick de Klein",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"types": "./index.d.ts",
|
|
12
12
|
"dependencies": {},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
+
"tsconfig-paths-webpack-plugin": "4.0.0",
|
|
14
15
|
"lit": "2.4.1",
|
|
15
16
|
"@storybook/addon-actions": "6.5.13",
|
|
16
17
|
"lit-html": "2.4.0",
|
|
17
|
-
"haunted": "5.0.0"
|
|
18
|
+
"haunted": "5.0.0",
|
|
19
|
+
"@citolab/qti-transform": "0.0.1"
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const qtiTransform: (xmlValue: string) => {
|
|
2
|
-
mathml(): any;
|
|
3
|
-
pciHooks(uri: string): any;
|
|
4
|
-
assetsLocation(uri: string, attributes?: string[]): any;
|
|
5
|
-
customTypes(): any;
|
|
6
|
-
suffix(elements: string[], suffix: string): any;
|
|
7
|
-
prefix(elements: string[], prefix: string): any;
|
|
8
|
-
fn(fn: (xmlString: string) => string): any;
|
|
9
|
-
elementNameAttributes(elements: string[]): any;
|
|
10
|
-
print(): any;
|
|
11
|
-
xml(): string;
|
|
12
|
-
};
|
|
13
|
-
export declare const fixSelfClosingTags: (xml: string) => string;
|