@citolab/qti-components 3.0.37 → 3.0.39

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.
@@ -0,0 +1,6 @@
1
+ export declare const environment: {
2
+ production: boolean;
3
+ api: string;
4
+ app: string;
5
+ qtic: string;
6
+ };
@@ -0,0 +1,6 @@
1
+ export declare const environment: {
2
+ production: boolean;
3
+ api: string;
4
+ app: string;
5
+ qtic: string;
6
+ };
package/index.cjs CHANGED
@@ -8,7 +8,7 @@
8
8
  <slot name="qti-rubric-block" />
9
9
  </header>
10
10
  -->
11
- <slot></slot>`}}customElements.define("qti-item-body",u);class m extends s.LitElement{render(){return s.html` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function g(e,t,s,i){var r,n=arguments.length,o=n<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--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o}function b(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(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 y(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{const{update:r}=t;if(e in t){const n=e;t.update=function(e){if(e.has(n)){const t=e.get(n),r=this[n];t!==r&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,r))}r.call(this,e)}}}}customElements.define("qti-prompt",m);const E=32;exports.QtiChoice=class extends d{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(a.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(a.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===E&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(a.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return r.html` <slot></slot> `}},g([i.property({reflect:!0}),b("design:type",String)],exports.QtiChoice.prototype,"identifier",void 0),g([i.property({type:Number,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"tabindex",void 0),g([i.property({type:Boolean,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"disabled",void 0),g([i.property({type:Boolean,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"readonly",void 0),g([i.property({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),b("design:type",Object)],exports.QtiChoice.prototype,"checked",void 0),g([y("disabled",{waitUntilFirstUpdate:!0}),b("design:type",Function),b("design:paramtypes",[Object,Boolean]),b("design:returntype",void 0)],exports.QtiChoice.prototype,"handleDisabledChange",null),exports.QtiChoice=g([i.customElement("qti-choice")],exports.QtiChoice);class v extends s.LitElement{render(){return s.html``}}customElements.define("qti-variabledeclaration",v);class x extends v{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 l({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||exports.Cardinality.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],r=i.getAttribute("map-key"),n=i.getAttribute("mapped-value");t.set(r,n?parseFloat(n):null)}return t}return null}}customElements.define("qti-response-declaration",x);class C extends v{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new c;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",C);class q extends s.LitElement{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(a.ON_REGISTER_FEEDBACK,{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){this.outcomeIdentifier===e&&(t instanceof Array?this.showFeedback(-1!==t.indexOf(this.identifier)):this.showFeedback(this.identifier===t))}showFeedback(e){this.showStatus=e?"on":"off"}}class _ extends q{constructor(){super(...arguments),this.render=()=>s.html` <slot class="${this.showStatus}"></slot> `}}_.styles=s.css`
11
+ <slot></slot>`}}customElements.define("qti-item-body",u);class m extends s.LitElement{render(){return s.html` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function g(e,t,s,i){var r,n=arguments.length,o=n<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--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o}function b(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(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 y(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{const{update:r}=t;if(e in t){const n=e;t.update=function(e){if(e.has(n)){const t=e.get(n),r=this[n];t!==r&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,r))}r.call(this,e)}}}}customElements.define("qti-prompt",m);const E=32;exports.QtiChoice=class extends d{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(a.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(a.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===E&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(a.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return r.html` <slot></slot> `}},g([i.property({reflect:!0}),b("design:type",String)],exports.QtiChoice.prototype,"identifier",void 0),g([i.property({type:Number,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"tabindex",void 0),g([i.property({type:Boolean,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"disabled",void 0),g([i.property({type:Boolean,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"readonly",void 0),g([i.property({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),b("design:type",Object)],exports.QtiChoice.prototype,"checked",void 0),g([y("disabled",{waitUntilFirstUpdate:!0}),b("design:type",Function),b("design:paramtypes",[Object,Boolean]),b("design:returntype",void 0)],exports.QtiChoice.prototype,"handleDisabledChange",null),exports.QtiChoice=g([i.customElement("qti-choice")],exports.QtiChoice);class v extends s.LitElement{render(){return s.html``}}customElements.define("qti-variabledeclaration",v);class x extends v{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 l({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||exports.Cardinality.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],r=i.getAttribute("map-key"),n=i.getAttribute("mapped-value");t.set(r,n?parseFloat(n):null)}return t}return null}}customElements.define("qti-response-declaration",x);class C extends v{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new c;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",C),exports.qtiCompanionMaterialsInfo=class extends d{},exports.qtiCompanionMaterialsInfo=g([i.customElement("qti-companion-materials-info")],exports.qtiCompanionMaterialsInfo),exports.qtiRubricBlock=class extends d{},exports.qtiRubricBlock=g([i.customElement("qti-rubric-block")],exports.qtiRubricBlock),exports.qtiContentBody=class extends d{},exports.qtiContentBody=g([i.customElement("qti-content-body")],exports.qtiContentBody);class q extends s.LitElement{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(a.ON_REGISTER_FEEDBACK,{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){this.outcomeIdentifier===e&&(t instanceof Array?this.showFeedback(-1!==t.indexOf(this.identifier)):this.showFeedback(this.identifier===t))}showFeedback(e){this.showStatus=e?"on":"off"}}class _ extends q{constructor(){super(...arguments),this.render=()=>s.html` <slot class="${this.showStatus}"></slot> `}}_.styles=s.css`
12
12
  .on {
13
13
  display: inline-block;
14
14
  }
@@ -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 k=s.css`
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 I 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[k,s.css`
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")}}I.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",I);class R 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[k,s.css`
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
- ${this.value}</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")}}R.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],customElements.define("qti-extended-text-interaction",R),exports.QtiHottext=class extends exports.QtiChoice{},exports.QtiHottext=g([i.customElement("qti-hottext")],exports.QtiHottext);class T 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)],T.prototype,"_minChoices",void 0),g([i.property({type:Number,attribute:"max-choices"}),b("design:type",Number)],T.prototype,"_maxChoices",void 0),g([y("disabled",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleDisabledChange",void 0),g([y("readonly",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleReadonlyChange",void 0),g([y("_maxChoices",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleMaxChoicesChange",void 0);class A extends T{constructor(){super(...arguments),this.render=()=>s.html`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",A);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[k,s.css`
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 T 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)],T.prototype,"_minChoices",void 0),g([i.property({type:Number,attribute:"max-choices"}),b("design:type",Number)],T.prototype,"_maxChoices",void 0),g([y("disabled",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleDisabledChange",void 0),g([y("readonly",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleReadonlyChange",void 0),g([y("_maxChoices",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleMaxChoicesChange",void 0);class A extends T{constructor(){super(...arguments),this.render=()=>s.html`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",A);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
  }
@@ -313,18 +313,19 @@ ${this.value}</textarea
313
313
  color: var(--qti-placeholder-text);
314
314
  }
315
315
  `],customElements.define("qti-order-interaction",ve);class xe extends T{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,ke=34,Ie=35,Re=36;class Te 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`
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 Te 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 ke:this._moveSliderTo(s-this.step),t=!0;break;case Se:this._moveSliderTo(s+this.step),t=!0;break;case Re:this._moveSliderTo(this.min),t=!0;break;case Ie: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}%`)}}Te.styles=[oe,s.css``],g([i.property({type:Number,attribute:"lower-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"min",null),g([i.property({type:Number,attribute:"upper-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"max",null),g([i.property({type:Number,attribute:"step"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"step",null),customElements.define("qti-slider-interaction",Te);class Ae 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}}Ae.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Ae);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._submitted=!1,this.itemIndex=0,this.itemNames=[]}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._item.validateResponses()&&(this._item.processResponse(),!0)}onScoreItem(){this.onCheckItem()&&this._item.processResponse()}set itemResponse(e){this._submitted=!0,this._item.responses=e,this._navigationMode===exports.NavigationMode.linear&&(this._item.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._item.validateResponses()?this.itemIndex<this.itemNames.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=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))}))}render(){return s.html`
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}%`)}}Te.styles=[oe,s.css``],g([i.property({type:Number,attribute:"lower-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"min",null),g([i.property({type:Number,attribute:"upper-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"max",null),g([i.property({type:Number,attribute:"step"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"step",null),customElements.define("qti-slider-interaction",Te);class Ae 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}}Ae.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Ae);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}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===exports.NavigationMode.linear?"hidden":"visible"}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))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_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
- @on-prev-item=${this.onPrevItem}
321
- @on-next-item=${this.onNextItem}
322
- @on-check-item=${this.onCheckItem}
323
- @on-score-item=${this.onScoreItem}
324
- @on-request-item=${this.onRequestItem}
320
+ @slotchange=${this._handleSlotchange}
321
+ @on-prev-item=${this._onPrevItem}
322
+ @on-next-item=${this._onNextItem}
323
+ @on-check-item=${this._onCheckItem}
324
+ @on-score-item=${this._onScoreItem}
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({type:Boolean}),b("design:type",Object)],exports.QtiTest.prototype,"_submitted",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",p)],exports.QtiTest.prototype,"_item",void 0),g([i.property(),b("design:type",Array)],exports.QtiTest.prototype,"itemNames",void 0),g([i.property(),b("design:type",Object)],exports.QtiTest.prototype,"responses",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
+ `}},g([i.query("qti-test-prev"),b("design:type",HTMLElement)],exports.QtiTest.prototype,"prevButton",void 0),g([i.query("qti-test-next"),b("design:type",HTMLElement)],exports.QtiTest.prototype,"nextButton",void 0),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([y("_navigationMode",{waitUntilFirstUpdate:!0}),b("design:type",Function),b("design:paramtypes",[Object,String]),b("design:returntype",void 0)],exports.QtiTest.prototype,"handleNavigationModeChange",null),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",p)],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=T,exports.Events=a,exports.OutcomeVariable=c,exports.QtiAnd=J,exports.QtiAssessmentItem=p,exports.QtiAssociateInteraction=ae,exports.QtiBaseValue=W,exports.QtiChoiceInteraction=w,exports.QtiContains=K,exports.QtiCorrect=G,exports.QtiCustomOperatorLevenshtein=Ae,exports.QtiCustomOperatorNumericOnly=Ne,exports.QtiCustomOperatorParseNumberLocalNl=we,exports.QtiCustomOperatorRemoveAllSpaces=Le,exports.QtiCustomOperatorTrim=Me,exports.QtiExpression=P,exports.QtiExtendedTextInteraction=R,exports.QtiFeedbackInline=_,exports.QtiGap=pe,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=A,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=Te,exports.QtiStylesheet=h,exports.QtiTextEntryInteraction=I,exports.QtiVariable=V,exports.ResponseVariable=l,exports.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},exports.qtiSimpleAssociableChoice=le;
342
+ `,customElements.define("qti-item",Pe),exports.AssessmentTestEvents=He,exports.Choices=T,exports.Events=a,exports.OutcomeVariable=c,exports.QtiAnd=J,exports.QtiAssessmentItem=p,exports.QtiAssociateInteraction=ae,exports.QtiBaseValue=W,exports.QtiChoiceInteraction=w,exports.QtiContains=K,exports.QtiCorrect=G,exports.QtiCustomOperatorLevenshtein=Ae,exports.QtiCustomOperatorNumericOnly=Ne,exports.QtiCustomOperatorParseNumberLocalNl=we,exports.QtiCustomOperatorRemoveAllSpaces=Le,exports.QtiCustomOperatorTrim=Me,exports.QtiExpression=P,exports.QtiExtendedTextInteraction=I,exports.QtiFeedbackInline=_,exports.QtiGap=pe,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=A,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=Te,exports.QtiStylesheet=h,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\.nav {
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\.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 {
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\.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 {
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\.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 {
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\.nav qti-test\.progress {
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\.nav qti-test\.progress qti-test\.item {
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\.nav qti-test\.progress qti-test\.item:hover {
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\.nav qti-test\.progress qti-test\.item:active {
16959
+ qti-test qti-test-nav qti-test-progress qti-test-item:active {
16960
16960
  background: #aeaeae;
16961
16961
  }
16962
- qti-test qti-test\.nav qti-test\.progress qti-test\.item[checked] {
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.d.ts CHANGED
@@ -11,6 +11,9 @@ export * from './lib/qti-base/qti-prompt/qti-prompt';
11
11
  export * from './lib/qti-base/qti-choice/qti-choice';
12
12
  export * from './lib/qti-base/qti-variabledeclaration/qti-responsedeclaration/qti-responsedeclaration';
13
13
  export * from './lib/qti-base/qti-variabledeclaration/qti-outcomedeclaration/qti-outcomedeclaration';
14
+ export * from './lib/qti-base/qti-companion-materials-info/qti-companion-materials-info';
15
+ export * from './lib/qti-base/qti-rubric-block/qti-rubric-block';
16
+ export * from './lib/qti-base/qti-rubric-block/qti-content-body';
14
17
  export * from './lib/qti-base/qti-feedback/qti-feedback-inline/qti-feedback-inline';
15
18
  export * from './lib/qti-base/qti-feedback/qti-modal-feedback/qti-modal-feedback';
16
19
  export * from './lib/qti-base/qti-interaction/qti-text-entry-interaction/qti-text-entry-interaction';
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{LitElement as e,html as t,css as s,render as i}from"lit";import{property as n,customElement as r,state as o}from"lit/decorators.js";import{html as a}from"lit/static-html.js";import{ifDefined as l}from"lit/directives/if-defined.js";import{createRef as c,ref as d}from"lit/directives/ref.js";var h,p;!function(e){e.boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair"}(h||(h={})),function(e){e.multiple="multiple",e.ordered="ordered",e.single="single"}(p||(p={}));const u={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"},m={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"};class g{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:n}){this._basetype=h.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=n}static getCandidateResponse(e){return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]]}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(e){this._candidateResponse=e}set qtiVariable(e){this._qtiVariable=e,this._candidateResponse=g.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class b{}class f extends e{emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}err(e){throw e}}class y extends f{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(u.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(u.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(u.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(u.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return t`<slot></slot>`}updated(e){e.forEach(((e,t)=>{switch(t){case"disabled":this.interactionElements.forEach((e=>e.disabled=this.disabled));break;case"readonly":this.interactionElements.forEach((e=>e.readonly=this.readonly))}}))}disconnectedCallback(){this.removeEventListener(u.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(u.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(u.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(u.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=g.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 g)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 b?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(u.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(u.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",y);class E extends e{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}customElements.define("qti-stylesheet",E);class v extends e{render(){return t` <style>
1
+ import{LitElement as e,html as t,css as s,render as i}from"lit";import{property as n,customElement as r,query as o,state as a}from"lit/decorators.js";import{html as l}from"lit/static-html.js";import{ifDefined as c}from"lit/directives/if-defined.js";import{createRef as d,ref as h}from"lit/directives/ref.js";var p,u;!function(e){e.boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair"}(p||(p={})),function(e){e.multiple="multiple",e.ordered="ordered",e.single="single"}(u||(u={}));const m={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"},g={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"};class b{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:n}){this._basetype=p.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=n}static getCandidateResponse(e){return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]]}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(e){this._candidateResponse=e}set qtiVariable(e){this._qtiVariable=e,this._candidateResponse=b.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class f{}class y extends e{emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}err(e){throw e}}class v extends y{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(m.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(m.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(m.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(m.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return t`<slot></slot>`}updated(e){e.forEach(((e,t)=>{switch(t){case"disabled":this.interactionElements.forEach((e=>e.disabled=this.disabled));break;case"readonly":this.interactionElements.forEach((e=>e.readonly=this.readonly))}}))}disconnectedCallback(){this.removeEventListener(m.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(m.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(m.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(m.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=b.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 b)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 f?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(m.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(m.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",v);class E extends e{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}customElements.define("qti-stylesheet",E);class _ extends e{render(){return t` <style>
2
2
  :host {
3
3
  display: block;
4
4
  }
@@ -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 N 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 w extends N{constructor(){super(...arguments),this.render=()=>t` <slot class="${this.showStatus}"></slot> `}}w.styles=s`
11
+ <slot></slot>`}}customElements.define("qti-item-body",_);class q extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function C(e,t,s,i){var n,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,s,o):n(t,s))||o);return r>3&&o&&Object.defineProperty(t,s,o),o}function x(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function O(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 S(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 k=32;let R=class extends y{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(m.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(m.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===k&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(m.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return l` <slot></slot> `}};C([n({reflect:!0}),x("design:type",String)],R.prototype,"identifier",void 0),C([n({type:Number,reflect:!0}),x("design:type",Object)],R.prototype,"tabindex",void 0),C([n({type:Boolean,reflect:!0}),x("design:type",Object)],R.prototype,"disabled",void 0),C([n({type:Boolean,reflect:!0}),x("design:type",Object)],R.prototype,"readonly",void 0),C([n({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),x("design:type",Object)],R.prototype,"checked",void 0),C([S("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],R.prototype,"handleDisabledChange",null),R=C([r("qti-choice")],R);class A extends e{render(){return t``}}customElements.define("qti-variabledeclaration",A);class I extends A{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 b({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||u.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",I);class w extends A{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new f;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",w);let N=class extends y{};N=C([r("qti-companion-materials-info")],N);let T=class extends y{};T=C([r("qti-rubric-block")],T);let L=class extends y{};L=C([r("qti-content-body")],L);class H extends e{constructor(){super(),this.showHide="show",this.showFeedback("hide"===this.showHide)}static get properties(){return{showStatus:{type:String,attribute:!0,reflect:!0},showHide:{type:String,attribute:"show-hide"},outcomeIdentifier:{type:String,attribute:"outcome-identifier"},identifier:{type:String}}}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(m.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 M extends H{constructor(){super(...arguments),this.render=()=>t` <slot class="${this.showStatus}"></slot> `}}M.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",w);class T extends N{render(){return t`
18
+ `,customElements.define("qti-feedback-inline",M);class $ extends H{render(){return t`
19
19
  <style>
20
20
  .on {
21
21
  display: inline-block;
@@ -27,7 +27,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{property
27
27
  <div class="feedback ${this.showStatus}">
28
28
  <slot></slot>
29
29
  </div>
30
- `}}customElements.define("qti-modal-feedback",T);class L extends f{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(u.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(u.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}_([n({attribute:"response-identifier"}),C("design:type",Object)],L.prototype,"responseIdentifier",void 0),_([n({reflect:!0,type:Boolean}),C("design:type",Object)],L.prototype,"disabled",void 0),_([n({reflect:!0,type:Boolean}),C("design:type",Object)],L.prototype,"readonly",void 0);const H=s`
30
+ `}}customElements.define("qti-modal-feedback",$);class D extends y{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(m.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(m.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}C([n({attribute:"response-identifier"}),x("design:type",Object)],D.prototype,"responseIdentifier",void 0),C([n({reflect:!0,type:Boolean}),x("design:type",Object)],D.prototype,"disabled",void 0),C([n({reflect:!0,type:Boolean}),x("design:type",Object)],D.prototype,"readonly",void 0);const P=s`
31
31
  /***
32
32
  The new CSS reset - version 1.4.9 (last updated 11.2.2022)
33
33
  GitHub page: https://github.com/elad2412/the-new-css-reset
@@ -107,7 +107,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{property
107
107
  :where([draggable='true']) {
108
108
  -webkit-user-drag: element;
109
109
  }
110
- `;class M extends L{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},L.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[H,s`
110
+ `;class j extends D{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},D.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[P,s`
111
111
  /* PK: display host as block, else design will be collapsed */
112
112
  :host {
113
113
  display: inline-block;
@@ -123,13 +123,13 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{property
123
123
  @keyup="${this.textChanged}"
124
124
  @change="${this.textChanged}"
125
125
  type="text"
126
- placeholder="${l(this.placeholderText?this.placeholderText:void 0)}"
126
+ placeholder="${c(this.placeholderText?this.placeholderText:void 0)}"
127
127
  .value="${this.value}"
128
- size="${l(this.expectedLength?this.expectedLength:void 0)}"
129
- pattern="${l(this.patternMask?this.patternMask:void 0)}"
128
+ size="${c(this.expectedLength?this.expectedLength:void 0)}"
129
+ pattern="${c(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")}}M.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",M);class $ extends L{constructor(){super(...arguments),this.value="",this.textareaRef=c()}static get properties(){return Object.assign(Object.assign({},L.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[H,s`
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")}}j.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",j);class F extends D{constructor(){super(...arguments),this.value="",this.textareaRef=d()}static get properties(){return Object.assign(Object.assign({},D.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[P,s`
133
133
  /* PK: display host as block, else design will be collapsed */
134
134
  :host {
135
135
  display: block;
@@ -140,20 +140,20 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{property
140
140
  height: 100%;
141
141
  }
142
142
  `]}render(){return t`<textarea
143
- ${d(this.textareaRef)}
143
+ ${h(this.textareaRef)}
144
144
  spellcheck="false"
145
145
  autocomplete="off"
146
146
  @keydown="${e=>e.stopImmediatePropagation()}"
147
147
  @keyup="${this.textChanged}"
148
148
  @change="${this.textChanged}"
149
- placeholder="${l(this.placeholderText?this.placeholderText:void 0)}"
150
- maxlength="${l(this.expectedLength?this.expectedLength:void 0)}"
151
- pattern="${l(this.patternMask?this.patternMask:void 0)}"
149
+ placeholder="${c(this.placeholderText?this.placeholderText:void 0)}"
150
+ maxlength="${c(this.expectedLength?this.expectedLength:void 0)}"
151
+ pattern="${c(this.patternMask?this.patternMask:void 0)}"
152
152
  ?disabled="${this.disabled}"
153
153
  ?readonly="${this.readonly}"
154
- >
155
- ${this.value}</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")}}$.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`
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")}}F.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],customElements.define("qti-extended-text-interaction",F);let U=class extends R{};U=C([r("qti-hottext")],U);class B extends D{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(m.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(m.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(m.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(m.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(m.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)}}C([n({type:Number,attribute:"min-choices"}),x("design:type",Number)],B.prototype,"_minChoices",void 0),C([n({type:Number,attribute:"max-choices"}),x("design:type",Number)],B.prototype,"_maxChoices",void 0),C([S("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],B.prototype,"_handleDisabledChange",void 0),C([S("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],B.prototype,"_handleReadonlyChange",void 0),C([S("_maxChoices",{waitUntilFirstUpdate:!0}),x("design:type",Object)],B.prototype,"_handleMaxChoicesChange",void 0);class G extends B{constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",G);class z extends D{constructor(){super(),this.options=[],this.addEventListener(m.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({},D.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[P,s`
157
157
  :host {
158
158
  display: inline-block;
159
159
  }
@@ -171,10 +171,10 @@ ${this.value}</textarea
171
171
  ${this.options.map((e=>t`
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}})}}F.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",F);class U extends P{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>t`
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}})}}z.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],customElements.define("qti-inline-choice-interaction",z);class W extends B{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>t`
175
175
  <slot name="prompt"></slot>
176
- <slot></slot>`}}U.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],U.presentationClass=["","qti-input-control-hidden"],_([n({attribute:"orientation"}),C("design:type",String)],U.prototype,"_orientation",void 0),_([n({attribute:"shuffle",type:Boolean}),C("design:type",Boolean)],U.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",U);let B=class extends k{};B=_([r("qti-simple-choice")],B);class G extends e{render(){return t`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){if(this.getAttribute("template")){const e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0.0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response identifier="RESPONSE"> </qti-map-response>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"map_response_point":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"match_correct":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-match>\n <qti-variable identifier="RESPONSE"></qti-variable>\n <qti-correct identifier="RESPONSE"></qti-correct>\n </qti-match>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">1</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'))}}const e=[...this.children];for(let t=0;t<e.length;t++){e[t].process()}}fragmentFromString(e){return document.createRange().createContextualFragment(e)}}customElements.define("qti-response-processing",G);class z extends e{render(){return t``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",z);class W extends z{render(){return t`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const s=e[t];if(s.calculate())return void s.process()}}}customElements.define("qti-response-condition",W);class K extends e{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return t`
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",K);class V extends K{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",V);class Q extends V{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",Q);class X extends f{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",X);class Y extends X{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=J(s,i[e],t.baseType);return n}return n+=J(s,i,t.baseType),n}}function J(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=Z(s,n,t);e===r&&(i+=n[1])}return i}function Z(e,t,s){let i,n;switch(e){case h.string:case h.identifier:case h.directedPair:i=""+t[0],n=""+s;break;case h.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",Y);class ee extends z{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",ee);class te extends X{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",te);class se extends X{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",se);class ie extends X{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",ie);class ne extends X{calculate(){return ne.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===h.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",ne);class re extends X{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return re.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",re);class oe extends X{calculate(){return 2===this.children.length?oe.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",oe);class ae extends X{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ae);class le extends X{render(){return t``}calculate(){return le.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",le);class ce extends X{render(){return t``}calculate(){return ce.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",ce);class de extends X{calculate(){return 1===this.children.length?de.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",de);class he extends f{constructor(){super(...arguments),this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){const t=e.querySelectorAll("properties");let s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,s.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",he);const pe=(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")}))}},ue=(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}},me=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:n,height:r});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/n,d=o.height/r;this.state.set(t,{left:s,top:i,width:n,height:r});const{duration:h,easing:p}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:h,easing:p})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return x(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:n})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},ge=(e,s,i)=>{class n extends(me(ue(pe(e,s),i),i,s)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(s)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return t` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(u.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(u.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},be=s`
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"],C([n({attribute:"orientation"}),x("design:type",String)],W.prototype,"_orientation",void 0),C([n({attribute:"shuffle",type:Boolean}),x("design:type",Boolean)],W.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",W);let K=class extends R{};K=C([r("qti-simple-choice")],K);class V extends e{render(){return t`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){if(this.getAttribute("template")){const e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0.0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response identifier="RESPONSE"> </qti-map-response>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"map_response_point":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"match_correct":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-match>\n <qti-variable identifier="RESPONSE"></qti-variable>\n <qti-correct identifier="RESPONSE"></qti-correct>\n </qti-match>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">1</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'))}}const e=[...this.children];for(let t=0;t<e.length;t++){e[t].process()}}fragmentFromString(e){return document.createRange().createContextualFragment(e)}}customElements.define("qti-response-processing",V);class Q extends e{render(){return t``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",Q);class X extends Q{render(){return t`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const s=e[t];if(s.calculate())return void s.process()}}}customElements.define("qti-response-condition",X);class Y extends e{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return t`
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",Y);class J extends Y{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",J);class Z extends J{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",Z);class ee extends y{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",ee);class te extends ee{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=se(s,i[e],t.baseType);return n}return n+=se(s,i,t.baseType),n}}function se(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=ie(s,n,t);e===r&&(i+=n[1])}return i}function ie(e,t,s){let i,n;switch(e){case p.string:case p.identifier:case p.directedPair:i=""+t[0],n=""+s;break;case p.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",te);class ne extends Q{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",ne);class re extends ee{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",re);class oe extends ee{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",oe);class ae extends ee{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",ae);class le extends ee{calculate(){return le.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===p.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",le);class ce extends ee{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return ce.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",ce);class de extends ee{calculate(){return 2===this.children.length?de.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",de);class he extends ee{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",he);class pe extends ee{render(){return t``}calculate(){return pe.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",pe);class ue extends ee{render(){return t``}calculate(){return ue.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",ue);class me extends ee{calculate(){return 1===this.children.length?me.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",me);class ge extends y{constructor(){super(...arguments),this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){const t=e.querySelectorAll("properties");let s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,s.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",ge);const be=(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")}))}},fe=(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}},ye=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:n,height:r});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/n,d=o.height/r;this.state.set(t,{left:s,top:i,width:n,height:r});const{duration:h,easing:p}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:h,easing:p})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return O(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:n})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},ve=(e,s,i)=>{class n extends(ye(fe(be(e,s),i),i,s)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(s)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return t` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(m.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(m.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},Ee=s`
178
178
  .notification {
179
179
  position: absolute;
180
180
  z-index: 100000;
@@ -196,21 +196,21 @@ ${this.value}</textarea
196
196
  border-radius: 99999px;
197
197
  content: 'preview not interactive';
198
198
  }
199
- `;class fe extends(ge(f,"qti-simple-associable-choice","drop-list")){render(){return t`
199
+ `;class _e extends(ve(y,"qti-simple-associable-choice","drop-list")){render(){return t`
200
200
  <slot name="prompt"></slot>
201
201
  <slot></slot>`}firstUpdated(e){i(t`
202
202
  ${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,s)=>t`<div class="associables-container">
203
203
  <drop-list class="associables-gap" identifier="droplist${s}_left"></drop-list>
204
204
  <drop-list class="associables-gap" identifier="droplist${s}_right"></drop-list>
205
205
  </div>`))}
206
- `,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}fe.styles=[be],customElements.define("qti-associate-interaction",fe);class ye extends e{render(){return t`
206
+ `,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}_e.styles=[Ee],customElements.define("qti-associate-interaction",_e);class qe extends e{render(){return t`
207
207
  <slot></slot>
208
- `}}customElements.define("qti-simple-associable-choice",ye);class Ee extends(ge(e,"qti-gap-text","qti-gap")){render(){return t`<slot></slot>`}}Ee.styles=[be],customElements.define("qti-gap-match-interaction",Ee);class ve extends HTMLElement{}customElements.define("qti-gap-text",ve);class qe extends HTMLElement{}function _e(e,t,s,i){switch(e){case"circle":{const[e,n,r]=t,o=e/s.width*100,a=n/s.height*100,l=r/s.width*100;i.style.left=o-l+"%",i.style.top=a-l+"%",i.style.width=i.style.height=4*l+"px",i.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/s.width*100,l=n/s.height*100,c=r/s.width*100,d=o/s.height*100;i.style.left=a+"%",i.style.top=l+"%",i.style.width=c-a+"%",i.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,s,i)=>{if(s%2==1){const t=e.pop();e[e.length]={x:t,y:i[s]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/s.width*100,c=o/s.height*100,d=r/s.width*100,h=a/s.height*100;i.style.left=n/s.width*100+"%",i.style.top=o/s.height*100+"%",i.style.width=d-l+"%",i.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");i.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",qe);class Ce extends P{render(){return t`
208
+ `}}customElements.define("qti-simple-associable-choice",qe);class Ce extends(ve(e,"qti-gap-text","qti-gap")){render(){return t`<slot></slot>`}}Ce.styles=[Ee],customElements.define("qti-gap-match-interaction",Ce);class xe extends HTMLElement{}customElements.define("qti-gap-text",xe);class Oe extends HTMLElement{}function Se(e,t,s,i){switch(e){case"circle":{const[e,n,r]=t,o=e/s.width*100,a=n/s.height*100,l=r/s.width*100;i.style.left=o-l+"%",i.style.top=a-l+"%",i.style.width=i.style.height=4*l+"px",i.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/s.width*100,l=n/s.height*100,c=r/s.width*100,d=o/s.height*100;i.style.left=a+"%",i.style.top=l+"%",i.style.width=c-a+"%",i.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,s,i)=>{if(s%2==1){const t=e.pop();e[e.length]={x:t,y:i[s]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/s.width*100,c=o/s.height*100,d=r/s.width*100,h=a/s.height*100;i.style.left=n/s.width*100+"%",i.style.top=o/s.height*100+"%",i.style.width=d-l+"%",i.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");i.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",Oe);class ke extends B{render(){return t`
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");_e(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ce.styles=[s`
213
+ `}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");Se(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(m.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(m.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}ke.styles=[s`
214
214
  slot:not([name='prompt']) {
215
215
  position: relative; /* qti-hotspot-choice relative to the slot */
216
216
  display: block;
@@ -221,18 +221,18 @@ ${this.value}</textarea
221
221
  pointer-events: none;
222
222
  user-select: none;
223
223
  }
224
- `],customElements.define("qti-graphic-associate-interaction",Ce);class xe extends(ge(f,"qti-gap-img","qti-associable-hotspot")){render(){return t` <slot></slot>
225
- <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}xe.styles=s`
224
+ `],customElements.define("qti-graphic-associate-interaction",ke);class Re extends(ve(y,"qti-gap-img","qti-associable-hotspot")){render(){return t` <slot></slot>
225
+ <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(m.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(m.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}Re.styles=s`
226
226
  slot[name="qti-gap-img"] {
227
227
  display: flex;
228
228
  gap: 1rem;
229
229
  }
230
- `,customElements.define("qti-graphic-gap-match-interaction",xe);class Oe extends P{render(){return t`
230
+ `,customElements.define("qti-graphic-gap-match-interaction",Re);class Ae extends B{render(){return t`
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");_e(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Oe.styles=[s`
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");Se(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(m.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(m.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(m.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(m.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ae.styles=[s`
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",Oe);class Se extends P{render(){return t`
246
+ `],customElements.define("qti-graphic-order-interaction",Ae);class Ie extends B{render(){return t`
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");_e(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Se.styles=[s`
251
+ `}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");Se(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(m.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(m.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ie.styles=[s`
252
252
  slot:not([name='prompt']) {
253
253
  position: relative; /* qti-hotspot-choice relative to the slot */
254
254
  display: block;
@@ -259,21 +259,21 @@ ${this.value}</textarea
259
259
  pointer-events: none;
260
260
  user-select: none;
261
261
  }
262
- `],customElements.define("qti-hotspot-interaction",Se);class ke extends k{}ke.styles=s`
262
+ `],customElements.define("qti-hotspot-interaction",Ie);class we extends R{}we.styles=s`
263
263
  :host {
264
264
  position: absolute;
265
265
  }
266
- `,_([n({attribute:"aria-ordervalue",type:Number,reflect:!0}),C("design:type",Number)],ke.prototype,"order",void 0),customElements.define("qti-hotspot-choice",ke);class Re extends(ge(e,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return t`
266
+ `,C([n({attribute:"aria-ordervalue",type:Number,reflect:!0}),x("design:type",Number)],we.prototype,"order",void 0),customElements.define("qti-hotspot-choice",we);class Ne extends(ve(e,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return t`
267
267
  <slot name="prompt"></slot>
268
- <slot></slot>`}}Re.styles=[be],customElements.define("qti-match-interaction",Re);class Ae extends L{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},L.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return t`
268
+ <slot></slot>`}}Ne.styles=[Ee],customElements.define("qti-match-interaction",Ne);class Te extends D{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},D.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return t`
269
269
  <slot name="prompt"></slot>
270
- <slot></slot>`}connectedCallback(){super.connectedCallback()}}Ae.styles=[be,s``],customElements.define("qti-media-interaction",Ae);class Ie extends(ge(f,"qti-simple-choice","drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return t` <slot name="prompt"> </slot>
270
+ <slot></slot>`}connectedCallback(){super.connectedCallback()}}Te.styles=[Ee,s``],customElements.define("qti-media-interaction",Te);class Le extends(ve(y,"qti-simple-choice","drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return t` <slot name="prompt"> </slot>
271
271
  <div class=${`container ${this._classNames}`}>
272
272
  <slot class=${"vertical"===this._orientation?"ver":"hor"}> </slot>
273
273
  <div class=${"vertical"===this._orientation?"ver":"hor"}>
274
274
  ${this.childrenMap.map(((e,s)=>t`<drop-list identifier="droplist${s}"></drop-list>`))}
275
275
  </div>
276
- </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}Ie.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Ie.styles=[be,s`
276
+ </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}Le.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Le.styles=[Ee,s`
277
277
  .hor {
278
278
  display: grid;
279
279
  gap: var(--qti-gap, 2px);
@@ -312,19 +312,20 @@ ${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 Ne extends P{constructor(){super()}render(){return t`<slot></slot>
316
- <div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}Ne.styles=[be],customElements.define("qti-select-point-interaction",Ne);const we=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`
315
+ `],customElements.define("qti-order-interaction",Le);class He extends B{constructor(){super()}render(){return t`<slot></slot>
316
+ <div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}He.styles=[Ee],customElements.define("qti-select-point-interaction",He);const Me=37,$e=38,De=39,Pe=40,je=33,Fe=34,Ue=35,Be=36;class Ge extends D{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 we: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._submitted=!1,this.itemIndex=0,this.itemNames=[]}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._item.validateResponses()&&(this._item.processResponse(),!0)}onScoreItem(){this.onCheckItem()&&this._item.processResponse()}set itemResponse(e){this._submitted=!0,this._item.responses=e,this._navigationMode===Ke.linear&&(this._item.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._item.validateResponses()?this.itemIndex<this.itemNames.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=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))}))}render(){return t`
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 Me:case Pe:this._moveSliderTo(s-this.step),t=!0;break;case De:case $e:this._moveSliderTo(s+this.step),t=!0;break;case Fe:this._moveSliderTo(s-this.step),t=!0;break;case je:this._moveSliderTo(s+this.step),t=!0;break;case Be:this._moveSliderTo(this.min),t=!0;break;case Ue: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}%`)}}Ge.styles=[Ee,s``],C([n({type:Number,attribute:"lower-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],Ge.prototype,"min",null),C([n({type:Number,attribute:"upper-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],Ge.prototype,"max",null),C([n({type:Number,attribute:"step"}),x("design:type",Number),x("design:paramtypes",[Number])],Ge.prototype,"step",null),customElements.define("qti-slider-interaction",Ge);class ze 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}}ze.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",ze);class We 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",We);class Ke 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)}}Ke.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Ke);class Ve 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",Ve);class Qe extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Qe);const Xe={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished"};var Ye,Je;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(Ye||(Ye={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(Je||(Je={}));let Ze=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=Ye.nonlinear,this._submissionMode=Je.simultaneous,this.items=[],this.itemIndex=0}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===Ye.linear?"hidden":"visible"}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===Ye.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(Xe.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this._dispatchRequestItem(this.itemIndex-1)}_onNextItem(){this._navigationMode!==Ye.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this._dispatchRequestItem(this.itemIndex+1):this.dispatchEvent(new CustomEvent(Xe.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(Xe.ON_NO_RESPONSE_ON_SUBMIT))}_dispatchRequestItem(e){this.dispatchEvent(new CustomEvent(Xe.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
- @on-prev-item=${this.onPrevItem}
321
- @on-next-item=${this.onNextItem}
322
- @on-check-item=${this.onCheckItem}
323
- @on-score-item=${this.onScoreItem}
324
- @on-request-item=${this.onRequestItem}
320
+ @slotchange=${this._handleSlotchange}
321
+ @on-prev-item=${this._onPrevItem}
322
+ @on-next-item=${this._onNextItem}
323
+ @on-check-item=${this._onCheckItem}
324
+ @on-score-item=${this._onScoreItem}
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({type:Boolean}),C("design:type",Object)],Qe.prototype,"_submitted",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,"_item",void 0),_([n(),C("design:type",Array)],Qe.prototype,"itemNames",void 0),_([n(),C("design:type",Object)],Qe.prototype,"responses",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
+ `}};C([o("qti-test-prev"),x("design:type",HTMLElement)],Ze.prototype,"prevButton",void 0),C([o("qti-test-next"),x("design:type",HTMLElement)],Ze.prototype,"nextButton",void 0),C([n({type:Boolean}),x("design:type",Object)],Ze.prototype,"disabled",void 0),C([n({type:Boolean}),x("design:type",Object)],Ze.prototype,"readonly",void 0),C([n({type:String,attribute:"navigation-mode"}),x("design:type",Object)],Ze.prototype,"_navigationMode",void 0),C([S("_navigationMode",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,String]),x("design:returntype",void 0)],Ze.prototype,"handleNavigationModeChange",null),C([n({type:String,attribute:"submission-mode"}),x("design:type",Object)],Ze.prototype,"_submissionMode",void 0),C([n(),x("design:type",Array)],Ze.prototype,"items",void 0),C([n({type:Number,attribute:"item-index",reflect:!0}),x("design:type",Object)],Ze.prototype,"itemIndex",void 0),C([a(),x("design:type",v)],Ze.prototype,"_itemRef",void 0),Ze=C([r("qti-test")],Ze);const et=(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 tt extends(et(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))}))}}tt.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,w 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,Ne 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};
342
+ `,customElements.define("qti-item",tt);export{Xe as AssessmentTestEvents,p as BaseType,u as Cardinality,B as Choices,m as Events,Ye as NavigationMode,f as OutcomeVariable,pe as QtiAnd,v as QtiAssessmentItem,_e as QtiAssociateInteraction,le as QtiBaseValue,R as QtiChoice,W as QtiChoiceInteraction,ce as QtiContains,re as QtiCorrect,ze as QtiCustomOperatorLevenshtein,We as QtiCustomOperatorNumericOnly,Ke as QtiCustomOperatorParseNumberLocalNl,Ve as QtiCustomOperatorRemoveAllSpaces,Qe as QtiCustomOperatorTrim,ee as QtiExpression,F as QtiExtendedTextInteraction,M as QtiFeedbackInline,Oe as QtiGap,Ce as QtiGapMatchInteraction,xe as QtiGapText,ke as QtiGraphicAssociateInteraction,Re as QtiGraphicGapMatchInteraction,Ae as QtiGraphicOrderInteraction,de as QtiGte,we as QtiHotspotChoice,Ie as QtiHotspotInteraction,U as QtiHottext,G as QtiHottextInteraction,z as QtiInlineChoiceInteraction,me as QtiIsNull,tt as QtiItem,_ as QtiItemBody,te as QtiMapResponse,ae as QtiMatch,Ne as QtiMatchInteraction,Te as QtiMediaInteraction,$ as QtiModalFeedback,he as QtiMultiple,ue as QtiOr,Le as QtiOrderInteraction,w as QtiOutcomeDeclaration,ge as QtiPortableCustomInteraction,q as QtiPrompt,X as QtiResponseCondition,I as QtiResponseDeclaration,Y as QtiResponseElse,Z as QtiResponseElseIf,J as QtiResponseIf,V as QtiResponseProcessing,He as QtiSelectPointInteraction,ne as QtiSetOutcomeValue,K as QtiSimpleChoice,Ge as QtiSliderInteraction,E as QtiStylesheet,Ze as QtiTest,j as QtiTextEntryInteraction,oe as QtiVariable,b as ResponseVariable,g as Status,Je as SubmissionMode,N as qtiCompanionMaterialsInfo,L as qtiContentBody,T as qtiRubricBlock,qe as qtiSimpleAssociableChoice};
@@ -16,25 +16,35 @@ export declare enum SubmissionMode {
16
16
  simultaneous = "simultaneous"
17
17
  }
18
18
  export declare class QtiTest extends LitElement {
19
- private disabled;
20
- private readonly;
19
+ prevButton: HTMLElement;
20
+ nextButton: HTMLElement;
21
+ /** TEST CHANGES */
22
+ /** if test is disabled every item in the test will be disabled */
23
+ private readonly disabled;
24
+ /** if test is readonly every item in the test will be readonly */
25
+ private readonly readonly;
21
26
  /** 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
27
  private _navigationMode;
28
+ handleNavigationModeChange(old: any, navMode: NavigationMode): void;
23
29
  /** The submission mode is set to individual mode requiring the candidate to submit their responses on an item-by-item basis */
24
30
  private _submissionMode;
25
- private _submitted;
26
- private itemIndex;
27
- private _item;
28
- itemNames: unknown[];
29
- responses: InputResponseFormat<QtiVariableJSON>;
30
- updated(changedProperties: any): void;
31
- onCheckItem(): boolean;
32
- onScoreItem(): void;
31
+ /** All the items in the test with, href=file (used for location), identifier=uniqueInTest (used for responses) */
32
+ items: {
33
+ href: string;
34
+ identifier: string;
35
+ }[];
36
+ /** ITEM CHANGES */
37
+ /** The item index, set from outside */
38
+ readonly itemIndex = 0;
39
+ private _itemRef;
40
+ set itemXML(xml: string);
33
41
  set itemResponse(val: InputResponseFormat<QtiVariableJSON>);
34
- private onPrevItem;
35
- private onNextItem;
36
- private dispatchRequestItem;
37
- private onRequestItem;
38
- handleSlotchange(e: any): void;
42
+ private _onCheckItem;
43
+ private _onScoreItem;
44
+ private _onPrevItem;
45
+ private _onNextItem;
46
+ private _dispatchRequestItem;
47
+ private _onRequestItem;
48
+ private _handleSlotchange;
39
49
  render(): import("lit-html").TemplateResult<1>;
40
50
  }
@@ -0,0 +1,3 @@
1
+ import QtiElement from '../../utilities/element/qti-element';
2
+ export declare class qtiCompanionMaterialsInfo extends QtiElement {
3
+ }
@@ -0,0 +1,3 @@
1
+ import QtiElement from '../../utilities/element/qti-element';
2
+ export declare class qtiContentBody extends QtiElement {
3
+ }
@@ -0,0 +1,3 @@
1
+ import QtiElement from '../../utilities/element/qti-element';
2
+ export declare class qtiRubricBlock extends QtiElement {
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citolab/qti-components",
3
- "version": "3.0.37",
3
+ "version": "3.0.39",
4
4
  "repository": "@citolab/qti-components",
5
5
  "author": "Patrick de Klein",
6
6
  "license": "MIT",
@@ -9,11 +9,10 @@
9
9
  "main": "./index.cjs",
10
10
  "type": "module",
11
11
  "types": "./index.d.ts",
12
- "dependencies": {},
13
- "peerDependencies": {
12
+ "dependencies": {
14
13
  "lit": "2.4.1",
15
14
  "@storybook/addon-actions": "6.5.13",
16
- "lit-html": "2.4.0",
17
- "haunted": "5.0.0"
18
- }
15
+ "lit-html": "2.4.0"
16
+ },
17
+ "peerDependencies": {}
19
18
  }