@citolab/qti-components 3.0.45 → 3.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -16
- package/index.umd.js +163 -47
- package/lab/qti-manual-scoring/qti-manual-scoring.d.ts +5 -0
- package/lab/qti-test/qti-test.d.ts +3 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{LitElement as e,html as t,css as s,render as i}from"lit";import{customElement as n,property as r,query as o,state as a}from"lit/decorators.js";import{html as l}from"lit/static-html.js";import{createContext as c,ContextConsumer as d,ContextProvider as h}from"@lit-labs/context";import{ifDefined as p}from"lit/directives/if-defined.js";import{createRef as u,ref as m}from"lit/directives/ref.js";var g,b;!function(e){e.boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair"}(g||(g={})),function(e){e.multiple="multiple",e.ordered="ordered",e.single="single"}(b||(b={}));const f={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"},y={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"};class v{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:n}){this._basetype=g.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=v.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class E{}class x 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
|
|
1
|
+
import{LitElement as e,html as t,css as s,render as i}from"lit";import{customElement as n,property as r,query as o,state as a}from"lit/decorators.js";import{html as l}from"lit/static-html.js";import{createContext as c,ContextConsumer as d,ContextProvider as h}from"@lit-labs/context";import{ifDefined as p}from"lit/directives/if-defined.js";import{createRef as u,ref as m}from"lit/directives/ref.js";var g,b;!function(e){e.boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair"}(g||(g={})),function(e){e.multiple="multiple",e.ordered="ordered",e.single="single"}(b||(b={}));const f={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"},y={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"};class v{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:n}){this._basetype=g.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=v.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class E{}class x extends e{emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}err(e){throw e}}class _ extends x{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(f.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(f.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(f.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(f.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(f.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(f.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(f.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(f.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=v.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 v)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 E?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(f.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(f.ON_OUTCOME_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))):this.err(`Can not set qti-outcome-identifier: ${e}, it is not available`)}}customElements.define("qti-assessment-item",_);class q extends e{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}function 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 O(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function S(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())}))}customElements.define("qti-stylesheet",q);let w=class extends e{render(){return t`
|
|
2
2
|
<slot name="qti-rubric-block"></slot>
|
|
3
3
|
<slot></slot>`}};w.styles=s`
|
|
4
4
|
:host {
|
|
5
5
|
display: block;
|
|
6
6
|
}
|
|
7
|
-
`,w=C([n("qti-item-body")],w);class k extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function R(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,n))}n.call(this,e)}}}}customElements.define("qti-prompt",k);const A=32;let N=class extends x{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(f.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(f.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===A&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(f.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return l` <slot></slot> `}};C([r({reflect:!0}),O("design:type",String)],N.prototype,"identifier",void 0),C([r({type:Number,reflect:!0}),O("design:type",Object)],N.prototype,"tabindex",void 0),C([r({type:Boolean,reflect:!0}),O("design:type",Object)],N.prototype,"disabled",void 0),C([r({type:Boolean,reflect:!0}),O("design:type",Object)],N.prototype,"readonly",void 0),C([r({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),O("design:type",Object)],N.prototype,"checked",void 0),C([R("disabled",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Boolean]),O("design:returntype",void 0)],N.prototype,"handleDisabledChange",null),N=C([n("qti-choice")],N);class
|
|
7
|
+
`,w=C([n("qti-item-body")],w);class k extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function R(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,n))}n.call(this,e)}}}}customElements.define("qti-prompt",k);const A=32;let N=class extends x{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(f.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(f.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===A&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(f.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return l` <slot></slot> `}};C([r({reflect:!0}),O("design:type",String)],N.prototype,"identifier",void 0),C([r({type:Number,reflect:!0}),O("design:type",Object)],N.prototype,"tabindex",void 0),C([r({type:Boolean,reflect:!0}),O("design:type",Object)],N.prototype,"disabled",void 0),C([r({type:Boolean,reflect:!0}),O("design:type",Object)],N.prototype,"readonly",void 0),C([r({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),O("design:type",Object)],N.prototype,"checked",void 0),C([R("disabled",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Boolean]),O("design:returntype",void 0)],N.prototype,"handleDisabledChange",null),N=C([n("qti-choice")],N);class T extends e{render(){return t``}}customElements.define("qti-variabledeclaration",T);class I extends T{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 v({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||b.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 $ extends T{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new E;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",$);let L=class extends x{};L=C([n("qti-companion-materials-info")],L);const M=c("logger");let H=class extends x{constructor(){super(...arguments),this.logger=new d(this,M,(e=>this.style.display=this.view===e.view?"block":"none"),!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","")}}))}render(){return t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};H.styles=s`
|
|
8
8
|
:host {
|
|
9
9
|
display: block;
|
|
10
10
|
}
|
|
@@ -173,7 +173,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
173
173
|
</select>`}validate(){const e=this.options.find((e=>e.selected));return!!e&&""!==e.value}reset(){this.options=this.options.map(((e,t)=>Object.assign(Object.assign({},e),{selected:0===t})))}set response(e){this.options=this.options.map((t=>(e===t.value&&(t.selected=!0),t)))}choiceSelected(e){const t=e.target.value;this.options=this.options.map((e=>Object.assign(Object.assign({},e),{selected:e.value===t}))),this.saveResponse({base:{string:t}})}}X.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",X);class Q extends V{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>t`
|
|
174
174
|
<slot name="prompt"></slot>
|
|
175
175
|
<slot></slot>`}}Q.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],Q.presentationClass=["","qti-input-control-hidden"],C([r({attribute:"orientation"}),O("design:type",String)],Q.prototype,"_orientation",void 0),C([r({attribute:"shuffle",type:Boolean}),O("design:type",Boolean)],Q.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",Q);let Y=class extends N{};Y=C([n("qti-simple-choice")],Y);class J 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",J);class Z extends e{render(){return t``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",Z);class ee 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",ee);class te extends e{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return t`
|
|
176
|
-
<slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",te);class se extends te{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",se);class ie extends se{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",ie);class ne extends x{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",ne);class re extends ne{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=oe(s,i[e],t.baseType);return n}return n+=oe(s,i,t.baseType),n}}function oe(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=ae(s,n,t);e===r&&(i+=n[1])}return i}function ae(e,t,s){let i,n;switch(e){case g.string:case g.identifier:case g.directedPair:i=""+t[0],n=""+s;break;case g.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",re);class le extends Z{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",le);class ce extends ne{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",ce);class de extends ne{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",de);class he extends ne{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",he);class pe extends ne{calculate(){return pe.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===g.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",pe);class ue extends ne{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return ue.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",ue);class me extends ne{calculate(){return 2===this.children.length?me.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",me);class ge extends ne{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ge);class be extends ne{render(){return t``}calculate(){return be.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",be);class fe extends ne{render(){return t``}calculate(){return fe.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",fe);class ye extends ne{calculate(){return 1===this.children.length?ye.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",ye);class ve extends x{constructor(){super(...arguments),this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){const t=e.querySelectorAll("properties");let s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,s.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",ve);const Ee=(e,t)=>class extends e{connectedCallback(){if(super.connectedCallback(),this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),e.addEventListener("dragend",(t=>{t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging")})),e.setAttribute("draggable","true")}))}},xe=(e,t)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(this.querySelectorAll(t));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,s=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},qe=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:n,height:r});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/n,d=o.height/r;this.state.set(t,{left:s,top:i,width:n,height:r});const{duration:h,easing:p}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:h,easing:p})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return S(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:n})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},_e=(e,s,i)=>{class n extends(qe(xe(Ee(e,s),i),i,s)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(s)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return t` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(f.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(f.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},Ce=s`
|
|
176
|
+
<slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",te);class se extends te{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",se);class ie extends se{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",ie);class ne extends x{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",ne);class re extends ne{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=oe(s,i[e],t.baseType);return n}return n+=oe(s,i,t.baseType),n}}function oe(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=ae(s,n,t);e===r&&(i+=n[1])}return i}function ae(e,t,s){let i,n;switch(e){case g.string:case g.identifier:case g.directedPair:i=""+t[0],n=""+s;break;case g.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",re);class le extends Z{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",le);class ce extends ne{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",ce);class de extends ne{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",de);class he extends ne{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",he);class pe extends ne{calculate(){return pe.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===g.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",pe);class ue extends ne{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return ue.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",ue);class me extends ne{calculate(){return 2===this.children.length?me.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",me);class ge extends ne{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ge);class be extends ne{render(){return t``}calculate(){return be.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",be);class fe extends ne{render(){return t``}calculate(){return fe.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",fe);class ye extends ne{calculate(){return 1===this.children.length?ye.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",ye);class ve extends x{constructor(){super(...arguments),this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){const t=e.querySelectorAll("properties");let s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,s.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",ve);const Ee=(e,t)=>class extends e{connectedCallback(){if(super.connectedCallback(),this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),e.addEventListener("dragend",(t=>{t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging")})),e.setAttribute("draggable","true")}))}},xe=(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}},_e=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:n,height:r});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/n,d=o.height/r;this.state.set(t,{left:s,top:i,width:n,height:r});const{duration:h,easing:p}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:h,easing:p})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return S(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:n})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},qe=(e,s,i)=>{class n extends(_e(xe(Ee(e,s),i),i,s)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(s)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return t` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(f.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(f.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},Ce=s`
|
|
177
177
|
.notification {
|
|
178
178
|
position: absolute;
|
|
179
179
|
z-index: 100000;
|
|
@@ -195,7 +195,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
195
195
|
border-radius: 99999px;
|
|
196
196
|
content: 'preview not interactive';
|
|
197
197
|
}
|
|
198
|
-
`;class Oe extends(
|
|
198
|
+
`;class Oe extends(qe(x,"qti-simple-associable-choice","drop-list")){render(){return t`
|
|
199
199
|
<slot name="prompt"></slot>
|
|
200
200
|
<slot></slot>`}firstUpdated(e){i(t`
|
|
201
201
|
${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,s)=>t`<div class="associables-container">
|
|
@@ -204,7 +204,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
204
204
|
</div>`))}
|
|
205
205
|
`,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}Oe.styles=[Ce],customElements.define("qti-associate-interaction",Oe);class Se extends e{render(){return t`
|
|
206
206
|
<slot></slot>
|
|
207
|
-
`}}customElements.define("qti-simple-associable-choice",Se);class we extends(
|
|
207
|
+
`}}customElements.define("qti-simple-associable-choice",Se);class we extends(qe(e,"qti-gap-text","qti-gap")){render(){return t`<slot></slot>`}}we.styles=[Ce],customElements.define("qti-gap-match-interaction",we);class ke extends HTMLElement{}customElements.define("qti-gap-text",ke);class Re extends HTMLElement{}function Ae(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",Re);class Ne extends V{render(){return t`
|
|
208
208
|
<slot name="prompt"></slot>
|
|
209
209
|
<!-- slot for the prompt -->
|
|
210
210
|
<slot></slot>
|
|
@@ -220,18 +220,18 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
220
220
|
pointer-events: none;
|
|
221
221
|
user-select: none;
|
|
222
222
|
}
|
|
223
|
-
`],customElements.define("qti-graphic-associate-interaction",Ne);class
|
|
224
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(f.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(f.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}
|
|
223
|
+
`],customElements.define("qti-graphic-associate-interaction",Ne);class Te extends(qe(x,"qti-gap-img","qti-associable-hotspot")){render(){return t` <slot></slot>
|
|
224
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(f.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(f.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}Te.styles=s`
|
|
225
225
|
slot[name="qti-gap-img"] {
|
|
226
226
|
display: flex;
|
|
227
227
|
gap: 1rem;
|
|
228
228
|
}
|
|
229
|
-
`,customElements.define("qti-graphic-gap-match-interaction",
|
|
229
|
+
`,customElements.define("qti-graphic-gap-match-interaction",Te);class Ie extends V{render(){return t`
|
|
230
230
|
<slot name="prompt"></slot>
|
|
231
231
|
<!-- slot for the prompt -->
|
|
232
232
|
<slot></slot>
|
|
233
233
|
<!-- slot for the image and hotspots -->
|
|
234
|
-
`}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");Ae(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(f.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(f.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(f.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(f.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}
|
|
234
|
+
`}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");Ae(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(f.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(f.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(f.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(f.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ie.styles=[s`
|
|
235
235
|
slot:not([name='prompt']) {
|
|
236
236
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
237
237
|
display: block;
|
|
@@ -242,7 +242,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
242
242
|
pointer-events: none;
|
|
243
243
|
user-select: none;
|
|
244
244
|
}
|
|
245
|
-
`],customElements.define("qti-graphic-order-interaction",
|
|
245
|
+
`],customElements.define("qti-graphic-order-interaction",Ie);class $e extends V{render(){return t`
|
|
246
246
|
<slot name="prompt"></slot>
|
|
247
247
|
<!-- slot for the prompt -->
|
|
248
248
|
<slot></slot>
|
|
@@ -262,11 +262,11 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
262
262
|
:host {
|
|
263
263
|
position: absolute;
|
|
264
264
|
}
|
|
265
|
-
`,C([r({attribute:"aria-ordervalue",type:Number,reflect:!0}),O("design:type",Number)],Le.prototype,"order",void 0),customElements.define("qti-hotspot-choice",Le);class Me extends(
|
|
265
|
+
`,C([r({attribute:"aria-ordervalue",type:Number,reflect:!0}),O("design:type",Number)],Le.prototype,"order",void 0),customElements.define("qti-hotspot-choice",Le);class Me extends(qe(e,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return t`
|
|
266
266
|
<slot name="prompt"></slot>
|
|
267
267
|
<slot></slot>`}}Me.styles=[Ce],customElements.define("qti-match-interaction",Me);class He extends U{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},U.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return t`
|
|
268
268
|
<slot name="prompt"></slot>
|
|
269
|
-
<slot></slot>`}connectedCallback(){super.connectedCallback()}}He.styles=[Ce,s``],customElements.define("qti-media-interaction",He);class je extends(
|
|
269
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback()}}He.styles=[Ce,s``],customElements.define("qti-media-interaction",He);class je extends(qe(x,"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
270
|
<div class=${`container ${this._classNames}`}>
|
|
271
271
|
<slot class=${"vertical"===this._orientation?"ver":"hor"}> </slot>
|
|
272
272
|
<div class=${"vertical"===this._orientation?"ver":"hor"}>
|
|
@@ -314,7 +314,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
314
314
|
`],customElements.define("qti-order-interaction",je);class De extends V{constructor(){super()}render(){return t`<slot></slot>
|
|
315
315
|
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}De.styles=[Ce],customElements.define("qti-select-point-interaction",De);const Fe=37,Pe=38,Ue=39,Be=40,Ge=33,ze=34,We=35,Ve=36;class Ke extends U{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`
|
|
316
316
|
<slot name="prompt"></slot>
|
|
317
|
-
<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 Fe:case Be:this._moveSliderTo(s-this.step),t=!0;break;case Ue:case Pe:this._moveSliderTo(s+this.step),t=!0;break;case ze:this._moveSliderTo(s-this.step),t=!0;break;case Ge:this._moveSliderTo(s+this.step),t=!0;break;case Ve:this._moveSliderTo(this.min),t=!0;break;case We: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}%`)}}Ke.styles=[Ce,s``],C([r({type:Number,attribute:"lower-bound"}),O("design:type",Number),O("design:paramtypes",[Number])],Ke.prototype,"min",null),C([r({type:Number,attribute:"upper-bound"}),O("design:type",Number),O("design:paramtypes",[Number])],Ke.prototype,"max",null),C([r({type:Number,attribute:"step"}),O("design:type",Number),O("design:paramtypes",[Number])],Ke.prototype,"step",null),customElements.define("qti-slider-interaction",Ke);class Xe 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}}Xe.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Xe);class Qe 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",Qe);class Ye 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)}}Ye.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Ye);class Je 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",Je);class Ze extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Ze);const et=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(et(e,"on-next-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-item",class extends(et(e,"on-request-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(et(e,"on-prev-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-check",class extends(et(e,"on-check-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-score",class extends(et(e,"on-score-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}});const tt={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished"};var st,it;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(st||(st={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(it||(it={}));let nt=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=st.nonlinear,this._submissionMode=it.simultaneous,this.items=[],this.itemIndex=0,this.provider=new h(this,M,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===st.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.
|
|
317
|
+
<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 Fe:case Be:this._moveSliderTo(s-this.step),t=!0;break;case Ue:case Pe:this._moveSliderTo(s+this.step),t=!0;break;case ze:this._moveSliderTo(s-this.step),t=!0;break;case Ge:this._moveSliderTo(s+this.step),t=!0;break;case Ve:this._moveSliderTo(this.min),t=!0;break;case We: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}%`)}}Ke.styles=[Ce,s``],C([r({type:Number,attribute:"lower-bound"}),O("design:type",Number),O("design:paramtypes",[Number])],Ke.prototype,"min",null),C([r({type:Number,attribute:"upper-bound"}),O("design:type",Number),O("design:paramtypes",[Number])],Ke.prototype,"max",null),C([r({type:Number,attribute:"step"}),O("design:type",Number),O("design:paramtypes",[Number])],Ke.prototype,"step",null),customElements.define("qti-slider-interaction",Ke);class Xe 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}}Xe.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Xe);class Qe 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",Qe);class Ye 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)}}Ye.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Ye);class Je 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",Je);class Ze extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Ze);const et=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(et(e,"on-next-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-item",class extends(et(e,"on-request-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(et(e,"on-prev-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-check",class extends(et(e,"on-check-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-score",class extends(et(e,"on-score-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}});const tt={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var st,it;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(st||(st={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(it||(it={}));let nt=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=st.nonlinear,this._submissionMode=it.simultaneous,this.items=[],this.itemIndex=0,this.provider=new h(this,M,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===st.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(tt.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===st.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(tt.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(tt.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==st.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(tt.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(tt.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(tt.ON_NO_RESPONSE_ON_SUBMIT))}_onRequestItem({detail:e}){this.emit(tt.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(tt.ON_ITEM_READY,{detail:t}))}render(){return t`
|
|
318
318
|
<slot
|
|
319
319
|
@slotchange=${this._handleSlotchange}
|
|
320
320
|
@on-prev-item=${this._onPrevItem}
|
|
@@ -324,7 +324,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
324
324
|
@on-request-item=${this._onRequestItem}
|
|
325
325
|
>
|
|
326
326
|
</slot>
|
|
327
|
-
`}};C([o("qti-test-prev"),O("design:type",HTMLElement)],nt.prototype,"prevButton",void 0),C([o("qti-test-next"),O("design:type",HTMLElement)],nt.prototype,"nextButton",void 0),C([r({type:Boolean}),O("design:type",Object)],nt.prototype,"disabled",void 0),C([r({type:Boolean}),O("design:type",Object)],nt.prototype,"readonly",void 0),C([r({type:String,attribute:"navigation-mode"}),O("design:type",Object)],nt.prototype,"_navigationMode",void 0),C([R("_navigationMode",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,String]),O("design:returntype",void 0)],nt.prototype,"handleNavigationModeChange",null),C([r({type:String,attribute:"submission-mode"}),O("design:type",Object)],nt.prototype,"_submissionMode",void 0),C([r(),O("design:type",Array)],nt.prototype,"items",void 0),C([r({type:Number,attribute:"item-index",reflect:!0}),O("design:type",Object)],nt.prototype,"itemIndex",void 0),C([R("itemIndex",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Number]),O("design:returntype",void 0)],nt.prototype,"handleItemIndexChange",null),C([a(),O("design:type",
|
|
327
|
+
`}emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));this.dispatchEvent(s)}};C([o("qti-test-prev"),O("design:type",HTMLElement)],nt.prototype,"prevButton",void 0),C([o("qti-test-next"),O("design:type",HTMLElement)],nt.prototype,"nextButton",void 0),C([r({type:Boolean}),O("design:type",Object)],nt.prototype,"disabled",void 0),C([r({type:Boolean}),O("design:type",Object)],nt.prototype,"readonly",void 0),C([r({type:String,attribute:"navigation-mode"}),O("design:type",Object)],nt.prototype,"_navigationMode",void 0),C([R("_navigationMode",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,String]),O("design:returntype",void 0)],nt.prototype,"handleNavigationModeChange",null),C([r({type:String,attribute:"submission-mode"}),O("design:type",Object)],nt.prototype,"_submissionMode",void 0),C([r(),O("design:type",Array)],nt.prototype,"items",void 0),C([r({type:Number,attribute:"item-index",reflect:!0}),O("design:type",Object)],nt.prototype,"itemIndex",void 0),C([R("itemIndex",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Number]),O("design:returntype",void 0)],nt.prototype,"handleItemIndexChange",null),C([a(),O("design:type",_)],nt.prototype,"_itemRef",void 0),nt=C([n("qti-test")],nt);const rt=(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 ot extends(rt(e,"qti-assessment-item")){constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.processResponse=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.processResponse()},this.validateResponses=()=>!!this._item&&this._item.validateResponses(),this.resetInteractions=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.resetInteractions()},this.render=()=>t`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,t){var s,i;t&&(null===(s=this._item)||void 0===s||s.setAttribute("disabled","")),!t&&(null===(i=this._item)||void 0===i||i.removeAttribute("disabled"))}handleReadonlyChange(e,t){var s,i;t&&(null===(s=this._item)||void 0===s||s.setAttribute("readonly","")),!t&&(null===(i=this._item)||void 0===i||i.removeAttribute("readonly"))}handleResponsesChange(e,t){this._item&&(this._item.responses=t)}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}}ot.styles=s`
|
|
328
328
|
:host {
|
|
329
329
|
display: block; /* necessary to calculate scaling position */
|
|
330
330
|
width: 100%;
|
|
@@ -340,7 +340,7 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
340
340
|
width: 1024px !important;
|
|
341
341
|
transform-origin: 0 0;
|
|
342
342
|
}
|
|
343
|
-
`,C([r({type:Boolean,reflect:!0}),O("design:type",Object)],ot.prototype,"disabled",void 0),C([R("disabled",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Boolean]),O("design:returntype",void 0)],ot.prototype,"handleDisabledChange",null),C([r({type:Boolean,reflect:!0}),O("design:type",Object)],ot.prototype,"readonly",void 0),C([R("readonly",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Boolean]),O("design:returntype",void 0)],ot.prototype,"handleReadonlyChange",null),C([r({type:Object,reflect:!0}),O("design:type",Object)],ot.prototype,"responses",void 0),C([R("responses",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Object]),O("design:returntype",void 0)],ot.prototype,"handleResponsesChange",null),C([a(),O("design:type",
|
|
343
|
+
`,C([r({type:Boolean,reflect:!0}),O("design:type",Object)],ot.prototype,"disabled",void 0),C([R("disabled",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Boolean]),O("design:returntype",void 0)],ot.prototype,"handleDisabledChange",null),C([r({type:Boolean,reflect:!0}),O("design:type",Object)],ot.prototype,"readonly",void 0),C([R("readonly",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Boolean]),O("design:returntype",void 0)],ot.prototype,"handleReadonlyChange",null),C([r({type:Object,reflect:!0}),O("design:type",Object)],ot.prototype,"responses",void 0),C([R("responses",{waitUntilFirstUpdate:!0}),O("design:type",Function),O("design:paramtypes",[Object,Object]),O("design:returntype",void 0)],ot.prototype,"handleResponsesChange",null),C([a(),O("design:type",_)],ot.prototype,"_item",void 0),customElements.define("qti-item",ot);const at=e=>{let t=e;const s=e=>{const s=(new DOMParser).parseFromString(t,"text/xml"),i=new XSLTProcessor,n=(new DOMParser).parseFromString(e,"text/xml");i.importStylesheet(n);const r=i.transformToFragment(s,document);t=(new XMLSerializer).serializeToString(r)},i={mathml:()=>(s(""),i),removeNamesSpaces:()=>(s('\n <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>\n <xsl:template match="*">\n \x3c!-- remove element prefix --\x3e\n <xsl:element name="{local-name()}">\n \x3c!-- process attributes --\x3e\n <xsl:for-each select="@*">\n \x3c!-- remove attribute prefix --\x3e\n <xsl:attribute name="{local-name()}">\n <xsl:value-of select="."/>\n </xsl:attribute>\n </xsl:for-each>\n <xsl:apply-templates/>\n </xsl:element>\n </xsl:template>\n</xsl:stylesheet>'),i),pciHooks(e){const s=["hook","module"],n=e.substring(0,e.lastIndexOf("/")),r=(new DOMParser).parseFromString(t,"text/xml");for(const t of s){r.querySelectorAll("["+t+"]").forEach((s=>{const i=s.getAttribute(t);i.startsWith("data:")||i.startsWith("http")||(s.setAttribute("base-url",e),s.setAttribute("module",n+"/"+encodeURIComponent(i+(i.endsWith(".js")?"":".js"))))}))}return t=(new XMLSerializer).serializeToString(r),i},assetsLocation(e,s=["src","href","data"]){const n=e.substring(0,e.lastIndexOf("/")),r=(new DOMParser).parseFromString(t,"text/xml");for(const e of s){r.querySelectorAll("["+e+"]").forEach((t=>{const s=t.getAttribute(e);s.startsWith("data:")||s.startsWith("http")||t.setAttribute(e,n+"/"+encodeURIComponent(s))}))}return t=(new XMLSerializer).serializeToString(r),i},customTypes:()=>(s('<?xml version="1.0" encoding="utf-8"?>\n <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qti="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:m="http://www.w3.org/1998/Math/MathML">\n <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>\t \n <xsl:param name="separator" select="\' \'" />\n <xsl:param name="prefix" select="\'type:\'" />\n <xsl:variable name="prefixElements"></xsl:variable>\n <xsl:variable name="suffixElements"></xsl:variable>\n \x3c!-- passthrough --\x3e\n <xsl:template match="*">\n <xsl:copy>\n <xsl:apply-templates select="* | @* | text()" />\n </xsl:copy>\n </xsl:template>\n <xsl:template match="@* | text()">\n <xsl:copy-of select="." />\n </xsl:template>\n \n <xsl:template match="*">\n <xsl:variable name="elementName">\n <xsl:call-template name="getTypedElementName">\n <xsl:with-param name="input" select="." />\n </xsl:call-template>\n </xsl:variable>\n <xsl:element name="{$elementName}">\n <xsl:apply-templates select="* | @* | text()" />\n </xsl:element>\n </xsl:template>\n \n \x3c!-- custom names --\x3e\n <xsl:template name="getType">\n <xsl:param name="input" />\n <xsl:param name="separator" select="$separator" />\n <xsl:param name="prefix" select="$prefix" />\n <xsl:variable name="output">\n <xsl:choose>\n <xsl:when test="contains($input, $separator)">\n <xsl:value-of select="substring-before($input, $separator)" />\n </xsl:when>\n <xsl:otherwise>\n <xsl:value-of select="$input" />\n </xsl:otherwise>\n </xsl:choose>\n </xsl:variable>\n <xsl:choose>\n <xsl:when test="starts-with($output, $prefix) and $output != $prefix">\n <xsl:value-of select="substring-after($output, $prefix)" />\n </xsl:when>\n <xsl:otherwise>\n <xsl:variable name="after" select="substring-after($input, $separator)" />\n <xsl:if test="$after">\n <xsl:call-template name="getType">\n <xsl:with-param name="input" select="$after" />\n <xsl:with-param name="separator" select="$separator" />\n <xsl:with-param name="prefix" select="$prefix" />\n </xsl:call-template>\n </xsl:if>\n </xsl:otherwise>\n </xsl:choose>\n </xsl:template>\n \n <xsl:template name="getTypedElementName">\n <xsl:param name="input" />\n <xsl:variable name="prefixElements" select="document(\'\')//xsl:variable[@name = \'prefixElements\']/element" />\n <xsl:variable name="suffixElements" select="document(\'\')//xsl:variable[@name = \'suffixElements\']/element" />\n <xsl:variable name="originalName" select="name($input)" />\n <xsl:variable name="type">\n <xsl:call-template name="getType">\n <xsl:with-param name="input" select="$input/@class" />\n </xsl:call-template>\n </xsl:variable>\n <xsl:value-of select="$originalName" />\n \x3c!-- Add prefix elements --\x3e\n <xsl:if test="$prefixElements[text() = $originalName]">\n <xsl:text>-</xsl:text>\n </xsl:if>\n \x3c!-- Add suffix to typed elements --\x3e\n <xsl:if test="string-length($type)">\n <xsl:text>-</xsl:text>\n <xsl:value-of select="$type" />\n </xsl:if>\n \x3c!-- Add suffix to elements --\x3e\n <xsl:if test="$suffixElements[text() = $originalName]">\n <xsl:text>-</xsl:text>\n </xsl:if>\n </xsl:template>\n </xsl:stylesheet>'),i),suffix:(e,s)=>(e.forEach((e=>{t=t.replaceAll(e,e+"-"+s)})),i),prefix:(e,s)=>(e.forEach((e=>{t=t.replaceAll(e,s+"-"+e)})),i),fn:e=>(t=e(t),i),elementNameAttributes:e=>(e.forEach((e=>{t=t.replaceAll(e,e+` data-element="${e}" `)})),i),print:()=>(console.log(t),i),xml:()=>(t=lt(t),t)};return i},lt=e=>{const t=e.split("/>");let s="";for(let e=0;e<t.length-1;e++){const i=t[e].split("<");s+=t[e]+"></"+i[i.length-1].split(" ")[0]+">"}return s+t[t.length-1]};let ct=class extends x{constructor(){super(...arguments),this.logger=new d(this,M,(e=>this.style.display="scorer"===e.view?"block":"none"),!0)}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.value=t.value;this.parentElement.querySelector("qti-assessment-item").setOutcomeValue("SCORE",this.value)}render(){return t`<input
|
|
344
344
|
type="number"
|
|
345
345
|
spellcheck="false"
|
|
346
346
|
autocomplete="off"
|
|
@@ -351,4 +351,8 @@ import{LitElement as e,html as t,css as s,render as i}from"lit";import{customEle
|
|
|
351
351
|
size="10"
|
|
352
352
|
?disabled="${!1}"
|
|
353
353
|
?readonly="${!1}"
|
|
354
|
-
/>`}};
|
|
354
|
+
/>`}};ct.styles=s`
|
|
355
|
+
:host {
|
|
356
|
+
display: none;
|
|
357
|
+
}
|
|
358
|
+
`,C([r({type:Number,attribute:!1}),O("design:type",String)],ct.prototype,"value",void 0),ct=C([n("qti-manual-scoring")],ct);export{g as BaseType,b as Cardinality,V as Choices,f as Events,st as NavigationMode,E as OutcomeVariable,be as QtiAnd,_ as QtiAssessmentItem,Oe as QtiAssociateInteraction,pe as QtiBaseValue,N as QtiChoice,Q as QtiChoiceInteraction,L as QtiCompanionMaterialsInfo,ue as QtiContains,ce as QtiCorrect,Xe as QtiCustomOperatorLevenshtein,Qe as QtiCustomOperatorNumericOnly,Ye as QtiCustomOperatorParseNumberLocalNl,Je as QtiCustomOperatorRemoveAllSpaces,Ze as QtiCustomOperatorTrim,ne as QtiExpression,z as QtiExtendedTextInteraction,F as QtiFeedbackInline,Re as QtiGap,we as QtiGapMatchInteraction,ke as QtiGapText,Ne as QtiGraphicAssociateInteraction,Te as QtiGraphicGapMatchInteraction,Ie as QtiGraphicOrderInteraction,me as QtiGte,Le as QtiHotspotChoice,$e as QtiHotspotInteraction,W as QtiHottext,K as QtiHottextInteraction,X as QtiInlineChoiceInteraction,ye as QtiIsNull,ot as QtiItem,w as QtiItemBody,ct as QtiManualScoring,re as QtiMapResponse,he as QtiMatch,Me as QtiMatchInteraction,He as QtiMediaInteraction,P as QtiModalFeedback,ge as QtiMultiple,fe as QtiOr,je as QtiOrderInteraction,$ as QtiOutcomeDeclaration,ve as QtiPortableCustomInteraction,k as QtiPrompt,ee as QtiResponseCondition,I as QtiResponseDeclaration,te as QtiResponseElse,ie as QtiResponseElseIf,se as QtiResponseIf,J as QtiResponseProcessing,De as QtiSelectPointInteraction,le as QtiSetOutcomeValue,Y as QtiSimpleChoice,Ke as QtiSliderInteraction,q as QtiStylesheet,nt as QtiTest,G as QtiTextEntryInteraction,de as QtiVariable,v as ResponseVariable,y as Status,it as SubmissionMode,tt as TestEvents,lt as fixSelfClosingTags,j as qtiContentBody,H as qtiRubricBlock,Se as qtiSimpleAssociableChoice,at as qtiTransform};
|
package/index.umd.js
CHANGED
|
@@ -1,21 +1,106 @@
|
|
|
1
|
-
"
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QtiComponents={})}(this,(function(e){"use strict";var t,s;e.BaseType=void 0,(t=e.BaseType||(e.BaseType={})).boolean="boolean",t.directedPair="directedPair",t.float="float",t.integer="integer",t.string="string",t.identifier="identifier",t.pair="pair",e.Cardinality=void 0,(s=e.Cardinality||(e.Cardinality={})).multiple="multiple",s.ordered="ordered",s.single="single";const i={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"};class n{constructor({mapping:t,correctResponse:s,cardinality:i,baseType:n,identifier:r}){this._basetype=e.BaseType.string,this._mapping=t,this._correctResponse=s,this._cardinality=i,this._basetype=n,this._identifier=r}static getCandidateResponse(e){return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]]}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(e){this._candidateResponse=e}set qtiVariable(e){this._qtiVariable=e,this._candidateResponse=n.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class r{}
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2019 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/const o=window,a=o.ShadowRoot&&(void 0===o.ShadyCSS||o.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),c=new WeakMap;class d{constructor(e,t,s){if(this._$cssResult$=!0,s!==l)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(a&&void 0===e){const s=void 0!==t&&1===t.length;s&&(e=c.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&c.set(t,e))}return e}toString(){return this.cssText}}const h=(e,...t)=>{const s=1===e.length?e[0]:t.reduce(((t,s,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[i+1]),e[0]);return new d(s,e,l)},p=a?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return(e=>new d("string"==typeof e?e:e+"",void 0,l))(t)})(e):e
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2017 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/;var u;const m=window,f=m.trustedTypes,g=f?f.emptyScript:"",b=m.reactiveElementPolyfillSupport,v={toAttribute(e,t){switch(t){case Boolean:e=e?g:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=null!==e;break;case Number:s=null===e?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch(e){s=null}}return s}},y=(e,t)=>t!==e&&(t==t||e==e),E={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:y};class _ extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,s)=>{const i=this._$Ep(s,t);void 0!==i&&(this._$Ev.set(i,s),e.push(i))})),e}static createProperty(e,t=E){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const s="symbol"==typeof e?Symbol():"__"+e,i=this.getPropertyDescriptor(e,s,t);void 0!==i&&Object.defineProperty(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){return{get(){return this[t]},set(i){const n=this[e];this[t]=i,this.requestUpdate(e,n,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||E}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of t)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const e of s)t.unshift(p(e))}else void 0!==e&&t.push(p(e));return t}static _$Ep(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,s;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(s=e.hostConnected)||void 0===s||s.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{a?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const s=document.createElement("style"),i=o.litNonce;void 0!==i&&s.setAttribute("nonce",i),s.textContent=t.cssText,e.appendChild(s)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$EO(e,t,s=E){var i;const n=this.constructor._$Ep(e,s);if(void 0!==n&&!0===s.reflect){const r=(void 0!==(null===(i=s.converter)||void 0===i?void 0:i.toAttribute)?s.converter:v).toAttribute(t,s.type);this._$El=e,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$El=null}}_$AK(e,t){var s;const i=this.constructor,n=i._$Ev.get(e);if(void 0!==n&&this._$El!==n){const e=i.getPropertyOptions(n),r="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(s=e.converter)||void 0===s?void 0:s.fromAttribute)?e.converter:v;this._$El=n,this[n]=r.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,s){let i=!0;void 0!==e&&(((s=s||this.constructor.getPropertyOptions(e)).hasChanged||y)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===s.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,s))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(s)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(s)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2017 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
var x;_.finalized=!0,_.elementProperties=new Map,_.elementStyles=[],_.shadowRootOptions={mode:"open"},null==b||b({ReactiveElement:_}),(null!==(u=m.reactiveElementVersions)&&void 0!==u?u:m.reactiveElementVersions=[]).push("1.4.2");const C=window,A=C.trustedTypes,S=A?A.createPolicy("lit-html",{createHTML:e=>e}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,q="?"+$,O=`<${q}>`,w=document,k=(e="")=>w.createComment(e),R=e=>null===e||"object"!=typeof e&&"function"!=typeof e,T=Array.isArray,N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,M=/>/g,H=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),L=/'/g,P=/"/g,Q=/^(?:script|style|textarea|title)$/i,U=(e=>(t,...s)=>({_$litType$:e,strings:t,values:s}))(1),j=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),B=new WeakMap,F=w.createTreeWalker(w,129,null,!1),z=(e,t)=>{const s=e.length-1,i=[];let n,r=2===t?"<svg>":"",o=N;for(let t=0;t<s;t++){const s=e[t];let a,l,c=-1,d=0;for(;d<s.length&&(o.lastIndex=d,l=o.exec(s),null!==l);)d=o.lastIndex,o===N?"!--"===l[1]?o=I:void 0!==l[1]?o=M:void 0!==l[2]?(Q.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=H):void 0!==l[3]&&(o=H):o===H?">"===l[0]?(o=null!=n?n:N,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?H:'"'===l[3]?P:L):o===P||o===L?o=H:o===I||o===M?o=N:(o=H,n=void 0);const h=o===H&&e[t+1].startsWith("/>")?" ":"";r+=o===N?s+O:c>=0?(i.push(a),s.slice(0,c)+"$lit$"+s.slice(c)+$+h):s+$+(-2===c?(i.push(void 0),t):h)}const a=r+(e[s]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==S?S.createHTML(a):a,i]};class G{constructor({strings:e,_$litType$:t},s){let i;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,c]=z(e,t);if(this.el=G.createElement(l,s),F.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(i=F.nextNode())&&a.length<o;){if(1===i.nodeType){if(i.hasAttributes()){const e=[];for(const t of i.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith($)){const s=c[r++];if(e.push(t),void 0!==s){const e=i.getAttribute(s.toLowerCase()+"$lit$").split($),t=/([.?@])?(.*)/.exec(s);a.push({type:1,index:n,name:t[2],strings:e,ctor:"."===t[1]?X:"?"===t[1]?Z:"@"===t[1]?ee:Y})}else a.push({type:6,index:n})}for(const t of e)i.removeAttribute(t)}if(Q.test(i.tagName)){const e=i.textContent.split($),t=e.length-1;if(t>0){i.textContent=A?A.emptyScript:"";for(let s=0;s<t;s++)i.append(e[s],k()),F.nextNode(),a.push({type:2,index:++n});i.append(e[t],k())}}}else if(8===i.nodeType)if(i.data===q)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=i.data.indexOf($,e+1));)a.push({type:7,index:n}),e+=$.length-1}n++}}static createElement(e,t){const s=w.createElement("template");return s.innerHTML=e,s}}function V(e,t,s=e,i){var n,r,o,a;if(t===j)return t;let l=void 0!==i?null===(n=s._$Co)||void 0===n?void 0:n[i]:s._$Cl;const c=R(t)?void 0:t._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(r=null==l?void 0:l._$AO)||void 0===r||r.call(l,!1),void 0===c?l=void 0:(l=new c(e),l._$AT(e,s,i)),void 0!==i?(null!==(o=(a=s)._$Co)&&void 0!==o?o:a._$Co=[])[i]=l:s._$Cl=l),void 0!==l&&(t=V(e,l._$AS(e,t.values),l,i)),t}class W{constructor(e,t){this.u=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(e){var t;const{el:{content:s},parts:i}=this._$AD,n=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:w).importNode(s,!0);F.currentNode=n;let r=F.nextNode(),o=0,a=0,l=i[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new K(r,r.nextSibling,this,e):1===l.type?t=new l.ctor(r,l.name,l.strings,this,e):6===l.type&&(t=new te(r,this,e)),this.u.push(t),l=i[++a]}o!==(null==l?void 0:l.index)&&(r=F.nextNode(),o++)}return n}p(e){let t=0;for(const s of this.u)void 0!==s&&(void 0!==s.strings?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}}class K{constructor(e,t,s,i){var n;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=i,this._$Cm=null===(n=null==i?void 0:i.isConnected)||void 0===n||n}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cm}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=V(this,e,t),R(e)?e===D||null==e||""===e?(this._$AH!==D&&this._$AR(),this._$AH=D):e!==this._$AH&&e!==j&&this.g(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>T(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this.g(e)}O(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}g(e){this._$AH!==D&&R(this._$AH)?this._$AA.nextSibling.data=e:this.T(w.createTextNode(e)),this._$AH=e}$(e){var t;const{values:s,_$litType$:i}=e,n="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=G.createElement(i.h,this.options)),i);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.p(s);else{const e=new W(n,this),t=e.v(this.options);e.p(s),this.T(t),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return void 0===t&&B.set(e.strings,t=new G(e)),t}k(e){T(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,i=0;for(const n of e)i===t.length?t.push(s=new K(this.O(k()),this.O(k()),this,this.options)):s=t[i],s._$AI(n),i++;i<t.length&&(this._$AR(s&&s._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var s;for(null===(s=this._$AP)||void 0===s||s.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cm=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class Y{constructor(e,t,s,i,n){this.type=1,this._$AH=D,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,s,i){const n=this.strings;let r=!1;if(void 0===n)e=V(this,e,t,0),r=!R(e)||e!==this._$AH&&e!==j,r&&(this._$AH=e);else{const i=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=V(this,i[s+o],t,o),a===j&&(a=this._$AH[o]),r||(r=!R(a)||a!==this._$AH[o]),a===D?e=D:e!==D&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!i&&this.j(e)}j(e){e===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class X extends Y{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===D?void 0:e}}const J=A?A.emptyScript:"";class Z extends Y{constructor(){super(...arguments),this.type=4}j(e){e&&e!==D?this.element.setAttribute(this.name,J):this.element.removeAttribute(this.name)}}class ee extends Y{constructor(e,t,s,i,n){super(e,t,s,i,n),this.type=5}_$AI(e,t=this){var s;if((e=null!==(s=V(this,e,t,0))&&void 0!==s?s:D)===j)return;const i=this._$AH,n=e===D&&i!==D||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==D&&(i===D||n);n&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==s?s:this.element,e):this._$AH.handleEvent(e)}}class te{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){V(this,e)}}const se=C.litHtmlPolyfillSupport;null==se||se(G,K),(null!==(x=C.litHtmlVersions)&&void 0!==x?x:C.litHtmlVersions=[]).push("2.4.0");const ie=(e,t,s)=>{var i,n;const r=null!==(i=null==s?void 0:s.renderBefore)&&void 0!==i?i:t;let o=r._$litPart$;if(void 0===o){const e=null!==(n=null==s?void 0:s.renderBefore)&&void 0!==n?n:null;r._$litPart$=o=new K(t.insertBefore(k(),e),e,void 0,null!=s?s:{})}return o._$AI(e),o
|
|
18
|
+
/**
|
|
19
|
+
* @license
|
|
20
|
+
* Copyright 2017 Google LLC
|
|
21
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
+
*/};var ne,re;class oe extends _{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const s=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=s.firstChild),s}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ie(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return j}}oe.finalized=!0,oe._$litElement$=!0,null===(ne=globalThis.litElementHydrateSupport)||void 0===ne||ne.call(globalThis,{LitElement:oe});const ae=globalThis.litElementPolyfillSupport;null==ae||ae({LitElement:oe}),(null!==(re=globalThis.litElementVersions)&&void 0!==re?re:globalThis.litElementVersions=[]).push("3.2.2");class le extends oe{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 ce extends le{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(i.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(i.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(i.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(i.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return U`<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(i.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(i.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(i.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(i.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=n.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 n)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 r?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(i.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(i.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",ce);class de extends oe{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}function he(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 pe(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function ue(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())}))}
|
|
23
|
+
/**
|
|
24
|
+
* @license
|
|
25
|
+
* Copyright 2017 Google LLC
|
|
26
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
+
*/customElements.define("qti-stylesheet",de);const me=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:s,elements:i}=t;return{kind:s,elements:i,finisher(t){customElements.define(e,t)}}})(e,t)
|
|
28
|
+
/**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2017 Google LLC
|
|
31
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
32
|
+
*/,fe=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(s){s.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(s){s.createProperty(t.key,e)}};function ge(e){return(t,s)=>void 0!==s?((e,t,s)=>{t.constructor.createProperty(s,e)})(e,t,s):fe(e,t)
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2017 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
|
+
*/}function be(e){return ge({...e,state:!0})}
|
|
38
|
+
/**
|
|
39
|
+
* @license
|
|
40
|
+
* Copyright 2017 Google LLC
|
|
41
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/
|
|
48
|
+
function ve(e,t){return(({finisher:e,descriptor:t})=>(s,i)=>{var n;if(void 0===i){const i=null!==(n=s.originalKey)&&void 0!==n?n:s.key,r=null!=t?{kind:"method",placement:"prototype",key:i,descriptor:t(s.key)}:{...s,key:i};return null!=e&&(r.finisher=function(t){e(t,i)}),r}{const n=s.constructor;void 0!==t&&Object.defineProperty(s,i,t(i)),null==e||e(n,i)}})({descriptor:s=>{const i={get(){var t,s;return null!==(s=null===(t=this.renderRoot)||void 0===t?void 0:t.querySelector(e))&&void 0!==s?s:null},enumerable:!0,configurable:!0};if(t){const t="symbol"==typeof s?Symbol():"__"+s;i.get=function(){var s,i;return void 0===this[t]&&(this[t]=null!==(i=null===(s=this.renderRoot)||void 0===s?void 0:s.querySelector(e))&&void 0!==i?i:null),this[t]}}return i}})}
|
|
49
|
+
/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2021 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/var ye;null===(ye=window.HTMLSlotElement)||void 0===ye||ye.prototype.assignedElements,e.QtiItemBody=class extends oe{render(){return U`
|
|
2
54
|
<slot name="qti-rubric-block"></slot>
|
|
3
|
-
<slot></slot>`}},
|
|
55
|
+
<slot></slot>`}},e.QtiItemBody.styles=h`
|
|
4
56
|
:host {
|
|
5
57
|
display: block;
|
|
6
58
|
}
|
|
7
|
-
`,
|
|
59
|
+
`,e.QtiItemBody=he([me("qti-item-body")],e.QtiItemBody);class Ee extends oe{render(){return U` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}customElements.define("qti-prompt",Ee);
|
|
60
|
+
/**
|
|
61
|
+
* @license
|
|
62
|
+
* Copyright 2020 Google LLC
|
|
63
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
64
|
+
*/
|
|
65
|
+
const _e=Symbol.for(""),xe=e=>{if((null==e?void 0:e.r)===_e)return null==e?void 0:e._$litStatic$},Ce=new Map,Ae=(e=>(t,...s)=>{const i=s.length;let n,r;const o=[],a=[];let l,c=0,d=!1;for(;c<i;){for(l=t[c];c<i&&void 0!==(r=s[c],n=xe(r));)l+=n+t[++c],d=!0;a.push(r),o.push(l),c++}if(c===i&&o.push(t[i]),d){const e=o.join("$$lit$$");void 0===(t=Ce.get(e))&&(o.raw=o,Ce.set(e,t=o)),s=a}return e(t,...s)})(U);function Se(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)}}}}const $e=32;e.QtiChoice=class extends le{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(i.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(i.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(i.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return Ae` <slot></slot> `}},he([ge({reflect:!0}),pe("design:type",String)],e.QtiChoice.prototype,"identifier",void 0),he([ge({type:Number,reflect:!0}),pe("design:type",Object)],e.QtiChoice.prototype,"tabindex",void 0),he([ge({type:Boolean,reflect:!0}),pe("design:type",Object)],e.QtiChoice.prototype,"disabled",void 0),he([ge({type:Boolean,reflect:!0}),pe("design:type",Object)],e.QtiChoice.prototype,"readonly",void 0),he([ge({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),pe("design:type",Object)],e.QtiChoice.prototype,"checked",void 0),he([Se("disabled",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],e.QtiChoice.prototype,"handleDisabledChange",null),e.QtiChoice=he([me("qti-choice")],e.QtiChoice);class qe extends oe{render(){return U``}}customElements.define("qti-variabledeclaration",qe);class Oe extends qe{static get properties(){return{baseType:{type:String,attribute:"base-type"},identifier:{type:String,attribute:"identifier"},cardinality:{type:String,attribute:"cardinality"}}}connectedCallback(){super.connectedCallback();const t=new n({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||e.Cardinality.single,mapping:this.mapping});this.closest("qti-assessment-item").variables.push(t)}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",Oe);class we extends qe{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new r;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",we),e.QtiCompanionMaterialsInfo=class extends le{},e.QtiCompanionMaterialsInfo=he([me("qti-companion-materials-info")],e.QtiCompanionMaterialsInfo);
|
|
66
|
+
/**
|
|
67
|
+
* @license
|
|
68
|
+
* Copyright 2021 Google LLC
|
|
69
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
70
|
+
*/
|
|
71
|
+
class ke extends Event{constructor(e,t,s){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.callback=t,this.subscribe=s}}
|
|
72
|
+
/**
|
|
73
|
+
* @license
|
|
74
|
+
* Copyright 2021 Google LLC
|
|
75
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* @license
|
|
79
|
+
* Copyright 2021 Google LLC
|
|
80
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
81
|
+
*/
|
|
82
|
+
class Re{constructor(e,t,s,i=!1){this.host=e,this.context=t,this.callback=s,this.subscribe=i,this.provided=!1,this.value=void 0,this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new ke(this.context,((e,t)=>{this.unsubscribe&&(this.unsubscribe!==t&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=e,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(e,t)),this.unsubscribe=t}),this.subscribe))}}
|
|
83
|
+
/**
|
|
84
|
+
* @license
|
|
85
|
+
* Copyright 2021 Google LLC
|
|
86
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
87
|
+
*/class Te{constructor(e){this.callbacks=new Map,this.updateObservers=()=>{for(const[e,t]of this.callbacks)e(this.t,t)},void 0!==e&&(this.value=e)}get value(){return this.t}set value(e){this.setValue(e)}setValue(e,t=!1){const s=t||!Object.is(e,this.t);this.t=e,s&&this.updateObservers()}addCallback(e,t){t&&(this.callbacks.has(e)||this.callbacks.set(e,(()=>{this.callbacks.delete(e)}))),e(this.value)}clearCallbacks(){this.callbacks.clear()}}
|
|
88
|
+
/**
|
|
89
|
+
* @license
|
|
90
|
+
* Copyright 2021 Google LLC
|
|
91
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
92
|
+
*/class Ne extends Event{constructor(e){super("context-provider",{bubbles:!0,composed:!0}),this.context=e}}class Ie extends Te{constructor(e,t,s){super(s),this.host=e,this.context=t,this.onContextRequest=e=>{e.context===this.context&&e.composedPath()[0]!==this.host&&(e.stopPropagation(),this.addCallback(e.callback,e.subscribe))},this.host.addController(this),this.attachListeners()}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest)}hostConnected(){this.host.dispatchEvent(new Ne(this.context))}}const Me="logger";e.qtiRubricBlock=class extends le{constructor(){super(...arguments),this.logger=new Re(this,Me,(e=>this.style.display=this.view===e.view?"block":"none"),!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","")}}))}render(){return U`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}},e.qtiRubricBlock.styles=h`
|
|
8
93
|
:host {
|
|
9
94
|
display: block;
|
|
10
95
|
}
|
|
11
|
-
`,
|
|
96
|
+
`,he([ge({type:String}),pe("design:type",Object)],e.qtiRubricBlock.prototype,"id",void 0),he([ge({type:String}),pe("design:type",String)],e.qtiRubricBlock.prototype,"use",void 0),he([ge({type:String}),pe("design:type",String)],e.qtiRubricBlock.prototype,"view",void 0),he([ge({type:String,attribute:"class"}),pe("design:type",Object)],e.qtiRubricBlock.prototype,"classNames",void 0),he([Se("classNames",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],e.qtiRubricBlock.prototype,"handleclassNamesChange",null),e.qtiRubricBlock=he([me("qti-rubric-block")],e.qtiRubricBlock),e.qtiContentBody=class extends le{render(){return U`<slot></slot>`}},e.qtiContentBody=he([me("qti-content-body")],e.qtiContentBody);class He extends oe{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(i.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 Le extends He{constructor(){super(...arguments),this.render=()=>U` <slot class="${this.showStatus}"></slot> `}}Le.styles=h`
|
|
12
97
|
.on {
|
|
13
98
|
display: inline-block;
|
|
14
99
|
}
|
|
15
100
|
.off {
|
|
16
101
|
display: none;
|
|
17
102
|
}
|
|
18
|
-
`,customElements.define("qti-feedback-inline",
|
|
103
|
+
`,customElements.define("qti-feedback-inline",Le);class Pe extends He{render(){return U`
|
|
19
104
|
<style>
|
|
20
105
|
.on {
|
|
21
106
|
display: inline-block;
|
|
@@ -27,7 +112,13 @@
|
|
|
27
112
|
<div class="feedback ${this.showStatus}">
|
|
28
113
|
<slot></slot>
|
|
29
114
|
</div>
|
|
30
|
-
`}}customElements.define("qti-modal-feedback",
|
|
115
|
+
`}}customElements.define("qti-modal-feedback",Pe);
|
|
116
|
+
/**
|
|
117
|
+
* @license
|
|
118
|
+
* Copyright 2018 Google LLC
|
|
119
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
120
|
+
*/
|
|
121
|
+
const Qe=e=>null!=e?e:D;class Ue extends le{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(i.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(i.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}he([ge({attribute:"response-identifier"}),pe("design:type",Object)],Ue.prototype,"responseIdentifier",void 0),he([ge({reflect:!0,type:Boolean}),pe("design:type",Object)],Ue.prototype,"disabled",void 0),he([ge({reflect:!0,type:Boolean}),pe("design:type",Object)],Ue.prototype,"readonly",void 0);const je=h`
|
|
31
122
|
/***
|
|
32
123
|
The new CSS reset - version 1.4.9 (last updated 11.2.2022)
|
|
33
124
|
GitHub page: https://github.com/elad2412/the-new-css-reset
|
|
@@ -107,7 +198,7 @@
|
|
|
107
198
|
:where([draggable='true']) {
|
|
108
199
|
-webkit-user-drag: element;
|
|
109
200
|
}
|
|
110
|
-
`;class
|
|
201
|
+
`;class De extends Ue{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},Ue.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[je,h`
|
|
111
202
|
/* PK: display host as block, else design will be collapsed */
|
|
112
203
|
:host {
|
|
113
204
|
display: inline-block;
|
|
@@ -115,7 +206,7 @@
|
|
|
115
206
|
input {
|
|
116
207
|
padding: var(--qti-padding, 0.5rem);
|
|
117
208
|
}
|
|
118
|
-
`]}render(){return
|
|
209
|
+
`]}render(){return U`
|
|
119
210
|
<input
|
|
120
211
|
spellcheck="false"
|
|
121
212
|
autocomplete="off"
|
|
@@ -123,13 +214,34 @@
|
|
|
123
214
|
@keyup="${this.textChanged}"
|
|
124
215
|
@change="${this.textChanged}"
|
|
125
216
|
type="text"
|
|
126
|
-
placeholder="${
|
|
217
|
+
placeholder="${Qe(this.placeholderText?this.placeholderText:void 0)}"
|
|
127
218
|
.value="${this.value}"
|
|
128
|
-
size="${
|
|
129
|
-
pattern="${
|
|
219
|
+
size="${Qe(this.expectedLength?this.expectedLength:void 0)}"
|
|
220
|
+
pattern="${Qe(this.patternMask?this.patternMask:void 0)}"
|
|
130
221
|
?disabled="${this.disabled}"
|
|
131
222
|
?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")}}
|
|
223
|
+
/>`}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")}}De.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],customElements.define("qti-text-entry-interaction",De);
|
|
224
|
+
/**
|
|
225
|
+
* @license
|
|
226
|
+
* Copyright 2020 Google LLC
|
|
227
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
228
|
+
*/
|
|
229
|
+
const Be=2;
|
|
230
|
+
/**
|
|
231
|
+
* @license
|
|
232
|
+
* Copyright 2017 Google LLC
|
|
233
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
234
|
+
*/class Fe{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,s){this._$Ct=e,this._$AM=t,this._$Ci=s}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
|
|
235
|
+
/**
|
|
236
|
+
* @license
|
|
237
|
+
* Copyright 2017 Google LLC
|
|
238
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
239
|
+
*/const ze=(e,t)=>{var s,i;const n=e._$AN;if(void 0===n)return!1;for(const e of n)null===(i=(s=e)._$AO)||void 0===i||i.call(s,t,!1),ze(e,t);return!0},Ge=e=>{let t,s;do{if(void 0===(t=e._$AM))break;s=t._$AN,s.delete(e),e=t}while(0===(null==s?void 0:s.size))},Ve=e=>{for(let t;t=e._$AM;e=t){let s=t._$AN;if(void 0===s)t._$AN=s=new Set;else if(s.has(e))break;s.add(e),Ye(t)}};function We(e){void 0!==this._$AN?(Ge(this),this._$AM=e,Ve(this)):this._$AM=e}function Ke(e,t=!1,s=0){const i=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(t)if(Array.isArray(i))for(let e=s;e<i.length;e++)ze(i[e],!1),Ge(i[e]);else null!=i&&(ze(i,!1),Ge(i));else ze(this,e)}const Ye=e=>{var t,s,i,n;e.type==Be&&(null!==(t=(i=e)._$AP)&&void 0!==t||(i._$AP=Ke),null!==(s=(n=e)._$AQ)&&void 0!==s||(n._$AQ=We))};class Xe extends Fe{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,s){super._$AT(e,t,s),Ve(this),this.isConnected=e._$AU}_$AO(e,t=!0){var s,i;e!==this.isConnected&&(this.isConnected=e,e?null===(s=this.reconnected)||void 0===s||s.call(this):null===(i=this.disconnected)||void 0===i||i.call(this)),t&&(ze(this,e),Ge(this))}setValue(e){if((e=>void 0===e.strings)(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}
|
|
240
|
+
/**
|
|
241
|
+
* @license
|
|
242
|
+
* Copyright 2020 Google LLC
|
|
243
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
244
|
+
*/class Je{}const Ze=new WeakMap,et=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends Xe{render(e){return D}update(e,[t]){var s;const i=t!==this.Y;return i&&void 0!==this.Y&&this.rt(void 0),(i||this.lt!==this.ct)&&(this.Y=t,this.dt=null===(s=e.options)||void 0===s?void 0:s.host,this.rt(this.ct=e.element)),D}rt(e){var t;if("function"==typeof this.Y){const s=null!==(t=this.dt)&&void 0!==t?t:globalThis;let i=Ze.get(s);void 0===i&&(i=new WeakMap,Ze.set(s,i)),void 0!==i.get(this.Y)&&this.Y.call(this.dt,void 0),i.set(this.Y,e),void 0!==e&&this.Y.call(this.dt,e)}else this.Y.value=e}get lt(){var e,t,s;return"function"==typeof this.Y?null===(t=Ze.get(null!==(e=this.dt)&&void 0!==e?e:globalThis))||void 0===t?void 0:t.get(this.Y):null===(s=this.Y)||void 0===s?void 0:s.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});class tt extends Ue{constructor(){super(...arguments),this.textareaRef=new Je,this.value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{if(e.startsWith("qti-height-lines")){const t=e.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(t))}}))}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[je,h`
|
|
133
245
|
/* PK: display host as block, else design will be collapsed */
|
|
134
246
|
:host {
|
|
135
247
|
display: block;
|
|
@@ -139,20 +251,20 @@
|
|
|
139
251
|
width: 100%;
|
|
140
252
|
height: 100%;
|
|
141
253
|
}
|
|
142
|
-
`]}render(){return
|
|
143
|
-
${
|
|
254
|
+
`]}render(){return U`<textarea
|
|
255
|
+
${et(this.textareaRef)}
|
|
144
256
|
spellcheck="false"
|
|
145
257
|
autocomplete="off"
|
|
146
258
|
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
147
259
|
@keyup="${this.textChanged}"
|
|
148
260
|
@change="${this.textChanged}"
|
|
149
|
-
placeholder="${
|
|
150
|
-
maxlength="${
|
|
151
|
-
pattern="${
|
|
261
|
+
placeholder="${Qe(this.placeholderText?this.placeholderText:void 0)}"
|
|
262
|
+
maxlength="${Qe(this.expectedLength?this.expectedLength:void 0)}"
|
|
263
|
+
pattern="${Qe(this.patternMask?this.patternMask:void 0)}"
|
|
152
264
|
?disabled="${this.disabled}"
|
|
153
265
|
?readonly="${this.readonly}"
|
|
154
266
|
.value=${this.value}
|
|
155
|
-
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}
|
|
267
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}tt.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],he([ge({type:Number,attribute:"expected-length"}),pe("design:type",Object)],tt.prototype,"expectedLength",void 0),he([ge({type:String,attribute:"pattern-mask"}),pe("design:type",Object)],tt.prototype,"patternMask",void 0),he([ge({type:String,attribute:"placeholder-text"}),pe("design:type",Object)],tt.prototype,"placeholderText",void 0),he([ge({type:String}),pe("design:type",Object)],tt.prototype,"value",void 0),he([ge({type:String,attribute:"class"}),pe("design:type",Object)],tt.prototype,"classNames",void 0),he([Se("classNames",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],tt.prototype,"handleclassNamesChange",null),customElements.define("qti-extended-text-interaction",tt),e.QtiHottext=class extends e.QtiChoice{},e.QtiHottext=he([me("qti-hottext")],e.QtiHottext);class st extends Ue{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(i.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(i.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(i.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(i.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(i.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)}}he([ge({type:Number,attribute:"min-choices"}),pe("design:type",Number)],st.prototype,"_minChoices",void 0),he([ge({type:Number,attribute:"max-choices"}),pe("design:type",Number)],st.prototype,"_maxChoices",void 0),he([Se("disabled",{waitUntilFirstUpdate:!0}),pe("design:type",Object)],st.prototype,"_handleDisabledChange",void 0),he([Se("readonly",{waitUntilFirstUpdate:!0}),pe("design:type",Object)],st.prototype,"_handleReadonlyChange",void 0),he([Se("_maxChoices",{waitUntilFirstUpdate:!0}),pe("design:type",Object)],st.prototype,"_handleMaxChoicesChange",void 0);class it extends st{constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",it);class nt extends Ue{constructor(){super(),this.options=[],this.addEventListener(i.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({},Ue.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[je,h`
|
|
156
268
|
:host {
|
|
157
269
|
display: inline-block;
|
|
158
270
|
}
|
|
@@ -161,19 +273,19 @@
|
|
|
161
273
|
padding: var(--qti-padding-y) var(--qti-padding-x);
|
|
162
274
|
padding-right: calc(var(--qti-padding-x) + 1ch)
|
|
163
275
|
}
|
|
164
|
-
`]}render(){return
|
|
276
|
+
`]}render(){return U`
|
|
165
277
|
<select
|
|
166
278
|
@change="${this.choiceSelected}"
|
|
167
279
|
?disabled="${this.disabled}"
|
|
168
280
|
?readonly="${this.readonly}"
|
|
169
281
|
>
|
|
170
|
-
${this.options.map((e=>
|
|
282
|
+
${this.options.map((e=>U`
|
|
171
283
|
<option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
|
|
172
284
|
`))}
|
|
173
|
-
</select>`}validate(){const e=this.options.find((e=>e.selected));return!!e&&""!==e.value}reset(){this.options=this.options.map(((e,t)=>Object.assign(Object.assign({},e),{selected:0===t})))}set response(e){this.options=this.options.map((t=>(e===t.value&&(t.selected=!0),t)))}choiceSelected(e){const t=e.target.value;this.options=this.options.map((e=>Object.assign(Object.assign({},e),{selected:e.value===t}))),this.saveResponse({base:{string:t}})}}
|
|
285
|
+
</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}})}}nt.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",nt);class rt extends st{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>U`
|
|
174
286
|
<slot name="prompt"></slot>
|
|
175
|
-
<slot></slot>`}}
|
|
176
|
-
<slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",H);class j extends H{render(){return s.html`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",j);class D extends j{render(){return s.html`${super.render()}`}}customElements.define("qti-response-else-if",D);class P extends p{render(){return s.html``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",P);class B extends P{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=F(s,i[e],t.baseType);return n}return n+=F(s,i,t.baseType),n}}function F(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=U(s,n,t);e===r&&(i+=n[1])}return i}function U(e,t,s){let i,n;switch(e){case exports.BaseType.string:case exports.BaseType.identifier:case exports.BaseType.directedPair:i=""+t[0],n=""+s;break;case exports.BaseType.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",B);class G extends ${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",G);class z extends P{render(){return s.html``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",z);class W extends P{render(){return s.html``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",W);class V extends P{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",V);class K extends P{calculate(){return K.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===exports.BaseType.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",K);class X extends P{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return X.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",X);class Y extends P{calculate(){return 2===this.children.length?Y.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",Y);class J extends P{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",J);class Z extends P{render(){return s.html``}calculate(){return Z.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",Z);class ee extends P{render(){return s.html``}calculate(){return ee.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",ee);class te extends P{calculate(){return 1===this.children.length?te.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",te);class se extends p{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 s.html`<slot></slot>${this._errorMessage&&s.html`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",se);const ie=(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")}))}},ne=(e,t)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(this.querySelectorAll(t));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,s=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},re=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width: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:p,easing:h}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:p,easing:h})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return b(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())}},oe=(e,t,i)=>{class n extends(re(ne(ie(e,t),i),i,t)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,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 s.html` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(l.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(l.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},ae=s.css`
|
|
287
|
+
<slot></slot>`}}rt.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],rt.presentationClass=["","qti-input-control-hidden"],he([ge({attribute:"orientation"}),pe("design:type",String)],rt.prototype,"_orientation",void 0),he([ge({attribute:"shuffle",type:Boolean}),pe("design:type",Boolean)],rt.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",rt),e.QtiSimpleChoice=class extends e.QtiChoice{},e.QtiSimpleChoice=he([me("qti-simple-choice")],e.QtiSimpleChoice);class ot extends oe{render(){return U`<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",ot);class at extends oe{render(){return U``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",at);class lt extends at{render(){return U`<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",lt);class ct extends oe{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return U`
|
|
288
|
+
<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",ct);class dt extends ct{render(){return U`${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",dt);class ht extends dt{render(){return U`${super.render()}`}}customElements.define("qti-response-else-if",ht);class pt extends le{render(){return U``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",pt);class ut extends pt{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+=mt(s,i[e],t.baseType);return n}return n+=mt(s,i,t.baseType),n}}function mt(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=ft(s,n,t);e===r&&(i+=n[1])}return i}function ft(t,s,i){let n,r;switch(t){case e.BaseType.string:case e.BaseType.identifier:case e.BaseType.directedPair:n=""+s[0],r=""+i;break;case e.BaseType.float:n=parseFloat(s[0].replace(",",".")),r=parseFloat(i.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:n,valueTyped:r}}customElements.define("qti-map-response",ut);class gt extends at{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",gt);class bt extends pt{render(){return U``}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",bt);class vt extends pt{render(){return U``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",vt);class yt extends pt{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",yt);class Et extends pt{calculate(){return Et.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(t,s){let i;if(s===e.BaseType.directedPair){const e=t.split(" ");i={destination:e[1],source:e[0]}}else i=t;return i}}customElements.define("qti-base-value",Et);class _t extends pt{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return _t.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)),o=n.filter((e=>r.includes(e)));return o.length>0}}customElements.define("qti-contains",_t);class xt extends pt{calculate(){return 2===this.children.length?xt.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",xt);class Ct extends pt{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",Ct);class At extends pt{render(){return U``}calculate(){return At.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",At);class St extends pt{render(){return U``}calculate(){return St.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",St);class $t extends pt{calculate(){return 1===this.children.length?$t.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",$t);class qt extends le{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 U`<slot></slot>${this._errorMessage&&U`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",qt);const Ot=(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")}))}},wt=(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}},kt=(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 ue(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())}},Rt=(e,t,s)=>{class n extends(kt(wt(Ot(e,t),s),s,t)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,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 U` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(s)),t=e.filter((e=>e.childElementCount>0)).length;if(t>=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(s)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(s)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(i.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(i.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},Tt=h`
|
|
177
289
|
.notification {
|
|
178
290
|
position: absolute;
|
|
179
291
|
z-index: 100000;
|
|
@@ -195,21 +307,21 @@
|
|
|
195
307
|
border-radius: 99999px;
|
|
196
308
|
content: 'preview not interactive';
|
|
197
309
|
}
|
|
198
|
-
`;class
|
|
310
|
+
`;class Nt extends(Rt(le,"qti-simple-associable-choice","drop-list")){render(){return U`
|
|
199
311
|
<slot name="prompt"></slot>
|
|
200
|
-
<slot></slot>`}firstUpdated(e){
|
|
201
|
-
${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,t)=>
|
|
312
|
+
<slot></slot>`}firstUpdated(e){ie(U`
|
|
313
|
+
${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,t)=>U`<div class="associables-container">
|
|
202
314
|
<drop-list class="associables-gap" identifier="droplist${t}_left"></drop-list>
|
|
203
315
|
<drop-list class="associables-gap" identifier="droplist${t}_right"></drop-list>
|
|
204
316
|
</div>`))}
|
|
205
|
-
`,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}
|
|
317
|
+
`,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}Nt.styles=[Tt],customElements.define("qti-associate-interaction",Nt);class It extends oe{render(){return U`
|
|
206
318
|
<slot></slot>
|
|
207
|
-
`}}customElements.define("qti-simple-associable-choice",
|
|
319
|
+
`}}customElements.define("qti-simple-associable-choice",It);class Mt extends(Rt(oe,"qti-gap-text","qti-gap")){render(){return U`<slot></slot>`}}Mt.styles=[Tt],customElements.define("qti-gap-match-interaction",Mt);class Ht extends HTMLElement{}customElements.define("qti-gap-text",Ht);class Lt extends HTMLElement{}function Pt(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",Lt);class Qt extends st{render(){return U`
|
|
208
320
|
<slot name="prompt"></slot>
|
|
209
321
|
<!-- slot for the prompt -->
|
|
210
322
|
<slot></slot>
|
|
211
323
|
<!-- slot for the image and hotspots -->
|
|
212
|
-
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords")
|
|
324
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords"),n=s.getAttribute("shape"),r=i.split(",").map((e=>parseInt(e)));Pt(n,r,t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(i.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(i.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Qt.styles=[h`
|
|
213
325
|
slot:not([name='prompt']) {
|
|
214
326
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
215
327
|
display: block;
|
|
@@ -220,18 +332,18 @@
|
|
|
220
332
|
pointer-events: none;
|
|
221
333
|
user-select: none;
|
|
222
334
|
}
|
|
223
|
-
`],customElements.define("qti-graphic-associate-interaction",
|
|
224
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(
|
|
335
|
+
`],customElements.define("qti-graphic-associate-interaction",Qt);class Ut extends(Rt(le,"qti-gap-img","qti-associable-hotspot")){render(){return U` <slot></slot>
|
|
336
|
+
<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(i.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(i.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}Ut.styles=h`
|
|
225
337
|
slot[name="qti-gap-img"] {
|
|
226
338
|
display: flex;
|
|
227
339
|
gap: 1rem;
|
|
228
340
|
}
|
|
229
|
-
`,customElements.define("qti-graphic-gap-match-interaction",
|
|
341
|
+
`,customElements.define("qti-graphic-gap-match-interaction",Ut);class jt extends st{render(){return U`
|
|
230
342
|
<slot name="prompt"></slot>
|
|
231
343
|
<!-- slot for the prompt -->
|
|
232
344
|
<slot></slot>
|
|
233
345
|
<!-- slot for the image and hotspots -->
|
|
234
|
-
`}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords")
|
|
346
|
+
`}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"),n=s.getAttribute("shape"),r=i.split(",").map((e=>parseInt(e)));Pt(n,r,t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(i.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(i.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(i.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(i.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}jt.styles=[h`
|
|
235
347
|
slot:not([name='prompt']) {
|
|
236
348
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
237
349
|
display: block;
|
|
@@ -242,12 +354,12 @@
|
|
|
242
354
|
pointer-events: none;
|
|
243
355
|
user-select: none;
|
|
244
356
|
}
|
|
245
|
-
`],customElements.define("qti-graphic-order-interaction",
|
|
357
|
+
`],customElements.define("qti-graphic-order-interaction",jt);class Dt extends st{render(){return U`
|
|
246
358
|
<slot name="prompt"></slot>
|
|
247
359
|
<!-- slot for the prompt -->
|
|
248
360
|
<slot></slot>
|
|
249
361
|
<!-- slot for the image and hotspots -->
|
|
250
|
-
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords")
|
|
362
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords"),n=s.getAttribute("shape"),r=i.split(",").map((e=>parseInt(e)));Pt(n,r,t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(i.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(i.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Dt.styles=[h`
|
|
251
363
|
slot:not([name='prompt']) {
|
|
252
364
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
253
365
|
display: block;
|
|
@@ -258,21 +370,21 @@
|
|
|
258
370
|
pointer-events: none;
|
|
259
371
|
user-select: none;
|
|
260
372
|
}
|
|
261
|
-
`],customElements.define("qti-hotspot-interaction",
|
|
373
|
+
`],customElements.define("qti-hotspot-interaction",Dt);class Bt extends e.QtiChoice{}Bt.styles=h`
|
|
262
374
|
:host {
|
|
263
375
|
position: absolute;
|
|
264
376
|
}
|
|
265
|
-
`,
|
|
377
|
+
`,he([ge({attribute:"aria-ordervalue",type:Number,reflect:!0}),pe("design:type",Number)],Bt.prototype,"order",void 0),customElements.define("qti-hotspot-choice",Bt);class Ft extends(Rt(oe,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return U`
|
|
266
378
|
<slot name="prompt"></slot>
|
|
267
|
-
<slot></slot>`}}
|
|
379
|
+
<slot></slot>`}}Ft.styles=[Tt],customElements.define("qti-match-interaction",Ft);class zt extends Ue{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},Ue.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return U`
|
|
268
380
|
<slot name="prompt"></slot>
|
|
269
|
-
<slot></slot>`}connectedCallback(){super.connectedCallback()}}
|
|
381
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback()}}zt.styles=[Tt,h``],customElements.define("qti-media-interaction",zt);class Gt extends(Rt(le,"qti-simple-choice","drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return U` <slot name="prompt"> </slot>
|
|
270
382
|
<div class=${`container ${this._classNames}`}>
|
|
271
383
|
<slot class=${"vertical"===this._orientation?"ver":"hor"}> </slot>
|
|
272
384
|
<div class=${"vertical"===this._orientation?"ver":"hor"}>
|
|
273
|
-
${this.childrenMap.map(((e,t)=>
|
|
385
|
+
${this.childrenMap.map(((e,t)=>U`<drop-list identifier="droplist${t}"></drop-list>`))}
|
|
274
386
|
</div>
|
|
275
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}
|
|
387
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}Gt.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Gt.styles=[Tt,h`
|
|
276
388
|
.hor {
|
|
277
389
|
display: grid;
|
|
278
390
|
gap: var(--qti-gap, 2px);
|
|
@@ -311,10 +423,10 @@
|
|
|
311
423
|
content: 'drop here';
|
|
312
424
|
color: var(--qti-placeholder-text);
|
|
313
425
|
}
|
|
314
|
-
`],customElements.define("qti-order-interaction",
|
|
315
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}
|
|
426
|
+
`],customElements.define("qti-order-interaction",Gt);class Vt extends st{constructor(){super()}render(){return U`<slot></slot>
|
|
427
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}Vt.styles=[Tt],customElements.define("qti-select-point-interaction",Vt);const Wt=37,Kt=38,Yt=39,Xt=40,Jt=33,Zt=34,es=35,ts=36;class ss extends Ue{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 U`
|
|
316
428
|
<slot name="prompt"></slot>
|
|
317
|
-
<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
|
|
429
|
+
<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 Wt:case Xt:this._moveSliderTo(s-this.step),t=!0;break;case Yt:case Kt:this._moveSliderTo(s+this.step),t=!0;break;case Zt:this._moveSliderTo(s-this.step),t=!0;break;case Jt:this._moveSliderTo(s+this.step),t=!0;break;case ts:this._moveSliderTo(this.min),t=!0;break;case es: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}%`)}}ss.styles=[Tt,h``],he([ge({type:Number,attribute:"lower-bound"}),pe("design:type",Number),pe("design:paramtypes",[Number])],ss.prototype,"min",null),he([ge({type:Number,attribute:"upper-bound"}),pe("design:type",Number),pe("design:paramtypes",[Number])],ss.prototype,"max",null),he([ge({type:Number,attribute:"step"}),pe("design:type",Number),pe("design:paramtypes",[Number])],ss.prototype,"step",null),customElements.define("qti-slider-interaction",ss);class is extends oe{constructor(){super(...arguments),this.render=()=>U`${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}}is.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",is);class ns extends oe{render(){return U``}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",ns);class rs extends oe{constructor(){super(...arguments),this.render=()=>U`${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)}}rs.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",rs);class os extends oe{render(){return U``}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",os);class as extends oe{render(){return U``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",as);const ls=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(ls(oe,"on-next-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-item",class extends(ls(oe,"on-request-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(ls(oe,"on-prev-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-check",class extends(ls(oe,"on-check-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-score",class extends(ls(oe,"on-score-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}});const cs={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var ds,hs;e.NavigationMode=void 0,(ds=e.NavigationMode||(e.NavigationMode={})).linear="linear",ds.nonlinear="nonlinear",e.SubmissionMode=void 0,(hs=e.SubmissionMode||(e.SubmissionMode={})).individual="individual",hs.simultaneous="simultaneous",e.QtiTest=class extends oe{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=e.NavigationMode.nonlinear,this._submissionMode=e.SubmissionMode.simultaneous,this.items=[],this.itemIndex=0,this.provider=new Ie(this,Me,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(t,s){this.prevButton.style.visibility=s===e.NavigationMode.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(cs.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set itemResponse(t){this._itemRef&&(this._itemRef.responses=t,this._navigationMode===e.NavigationMode.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(cs.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(cs.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==e.NavigationMode.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(cs.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(cs.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(cs.ON_NO_RESPONSE_ON_SUBMIT))}_onRequestItem({detail:e}){this.emit(cs.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(cs.ON_ITEM_READY,{detail:t}))}render(){return U`
|
|
318
430
|
<slot
|
|
319
431
|
@slotchange=${this._handleSlotchange}
|
|
320
432
|
@on-prev-item=${this._onPrevItem}
|
|
@@ -324,7 +436,7 @@
|
|
|
324
436
|
@on-request-item=${this._onRequestItem}
|
|
325
437
|
>
|
|
326
438
|
</slot>
|
|
327
|
-
`}},
|
|
439
|
+
`}emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));this.dispatchEvent(s)}},he([ve("qti-test-prev"),pe("design:type",HTMLElement)],e.QtiTest.prototype,"prevButton",void 0),he([ve("qti-test-next"),pe("design:type",HTMLElement)],e.QtiTest.prototype,"nextButton",void 0),he([ge({type:Boolean}),pe("design:type",Object)],e.QtiTest.prototype,"disabled",void 0),he([ge({type:Boolean}),pe("design:type",Object)],e.QtiTest.prototype,"readonly",void 0),he([ge({type:String,attribute:"navigation-mode"}),pe("design:type",Object)],e.QtiTest.prototype,"_navigationMode",void 0),he([Se("_navigationMode",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,String]),pe("design:returntype",void 0)],e.QtiTest.prototype,"handleNavigationModeChange",null),he([ge({type:String,attribute:"submission-mode"}),pe("design:type",Object)],e.QtiTest.prototype,"_submissionMode",void 0),he([ge(),pe("design:type",Array)],e.QtiTest.prototype,"items",void 0),he([ge({type:Number,attribute:"item-index",reflect:!0}),pe("design:type",Object)],e.QtiTest.prototype,"itemIndex",void 0),he([Se("itemIndex",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Number]),pe("design:returntype",void 0)],e.QtiTest.prototype,"handleItemIndexChange",null),he([be(),pe("design:type",ce)],e.QtiTest.prototype,"_itemRef",void 0),e.QtiTest=he([me("qti-test")],e.QtiTest);const ps=(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 us extends(ps(oe,"qti-assessment-item")){constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.processResponse=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.processResponse()},this.validateResponses=()=>!!this._item&&this._item.validateResponses(),this.resetInteractions=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.resetInteractions()},this.render=()=>U`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,t){var s,i;t&&(null===(s=this._item)||void 0===s||s.setAttribute("disabled","")),!t&&(null===(i=this._item)||void 0===i||i.removeAttribute("disabled"))}handleReadonlyChange(e,t){var s,i;t&&(null===(s=this._item)||void 0===s||s.setAttribute("readonly","")),!t&&(null===(i=this._item)||void 0===i||i.removeAttribute("readonly"))}handleResponsesChange(e,t){this._item&&(this._item.responses=t)}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}}us.styles=h`
|
|
328
440
|
:host {
|
|
329
441
|
display: block; /* necessary to calculate scaling position */
|
|
330
442
|
width: 100%;
|
|
@@ -340,7 +452,7 @@
|
|
|
340
452
|
width: 1024px !important;
|
|
341
453
|
transform-origin: 0 0;
|
|
342
454
|
}
|
|
343
|
-
`,
|
|
455
|
+
`,he([ge({type:Boolean,reflect:!0}),pe("design:type",Object)],us.prototype,"disabled",void 0),he([Se("disabled",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],us.prototype,"handleDisabledChange",null),he([ge({type:Boolean,reflect:!0}),pe("design:type",Object)],us.prototype,"readonly",void 0),he([Se("readonly",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],us.prototype,"handleReadonlyChange",null),he([ge({type:Object,reflect:!0}),pe("design:type",Object)],us.prototype,"responses",void 0),he([Se("responses",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Object]),pe("design:returntype",void 0)],us.prototype,"handleResponsesChange",null),he([be(),pe("design:type",ce)],us.prototype,"_item",void 0),customElements.define("qti-item",us);const ms=e=>{const t=e.split("/>");let s="";for(let e=0;e<t.length-1;e++){const i=t[e].split("<");s+=t[e]+"></"+i[i.length-1].split(" ")[0]+">"}return s+t[t.length-1]};e.QtiManualScoring=class extends le{constructor(){super(...arguments),this.logger=new Re(this,Me,(e=>this.style.display="scorer"===e.view?"block":"none"),!0)}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.value=t.value;this.parentElement.querySelector("qti-assessment-item").setOutcomeValue("SCORE",this.value)}render(){return U`<input
|
|
344
456
|
type="number"
|
|
345
457
|
spellcheck="false"
|
|
346
458
|
autocomplete="off"
|
|
@@ -351,4 +463,8 @@
|
|
|
351
463
|
size="10"
|
|
352
464
|
?disabled="${!1}"
|
|
353
465
|
?readonly="${!1}"
|
|
354
|
-
/>`}},
|
|
466
|
+
/>`}},e.QtiManualScoring.styles=h`
|
|
467
|
+
:host {
|
|
468
|
+
display: none;
|
|
469
|
+
}
|
|
470
|
+
`,he([ge({type:Number,attribute:!1}),pe("design:type",String)],e.QtiManualScoring.prototype,"value",void 0),e.QtiManualScoring=he([me("qti-manual-scoring")],e.QtiManualScoring),e.Choices=st,e.Events=i,e.OutcomeVariable=r,e.QtiAnd=At,e.QtiAssessmentItem=ce,e.QtiAssociateInteraction=Nt,e.QtiBaseValue=Et,e.QtiChoiceInteraction=rt,e.QtiContains=_t,e.QtiCorrect=bt,e.QtiCustomOperatorLevenshtein=is,e.QtiCustomOperatorNumericOnly=ns,e.QtiCustomOperatorParseNumberLocalNl=rs,e.QtiCustomOperatorRemoveAllSpaces=os,e.QtiCustomOperatorTrim=as,e.QtiExpression=pt,e.QtiExtendedTextInteraction=tt,e.QtiFeedbackInline=Le,e.QtiGap=Lt,e.QtiGapMatchInteraction=Mt,e.QtiGapText=Ht,e.QtiGraphicAssociateInteraction=Qt,e.QtiGraphicGapMatchInteraction=Ut,e.QtiGraphicOrderInteraction=jt,e.QtiGte=xt,e.QtiHotspotChoice=Bt,e.QtiHotspotInteraction=Dt,e.QtiHottextInteraction=it,e.QtiInlineChoiceInteraction=nt,e.QtiIsNull=$t,e.QtiItem=us,e.QtiMapResponse=ut,e.QtiMatch=yt,e.QtiMatchInteraction=Ft,e.QtiMediaInteraction=zt,e.QtiModalFeedback=Pe,e.QtiMultiple=Ct,e.QtiOr=St,e.QtiOrderInteraction=Gt,e.QtiOutcomeDeclaration=we,e.QtiPortableCustomInteraction=qt,e.QtiPrompt=Ee,e.QtiResponseCondition=lt,e.QtiResponseDeclaration=Oe,e.QtiResponseElse=ct,e.QtiResponseElseIf=ht,e.QtiResponseIf=dt,e.QtiResponseProcessing=ot,e.QtiSelectPointInteraction=Vt,e.QtiSetOutcomeValue=gt,e.QtiSliderInteraction=ss,e.QtiStylesheet=de,e.QtiTextEntryInteraction=De,e.QtiVariable=vt,e.ResponseVariable=n,e.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},e.TestEvents=cs,e.fixSelfClosingTags=ms,e.qtiSimpleAssociableChoice=It,e.qtiTransform=e=>{let t=e;const s=e=>{const s=(new DOMParser).parseFromString(t,"text/xml"),i=new XSLTProcessor,n=(new DOMParser).parseFromString(e,"text/xml");i.importStylesheet(n);const r=i.transformToFragment(s,document);t=(new XMLSerializer).serializeToString(r)},i={mathml:()=>(s(""),i),removeNamesSpaces:()=>(s('\n <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>\n <xsl:template match="*">\n \x3c!-- remove element prefix --\x3e\n <xsl:element name="{local-name()}">\n \x3c!-- process attributes --\x3e\n <xsl:for-each select="@*">\n \x3c!-- remove attribute prefix --\x3e\n <xsl:attribute name="{local-name()}">\n <xsl:value-of select="."/>\n </xsl:attribute>\n </xsl:for-each>\n <xsl:apply-templates/>\n </xsl:element>\n </xsl:template>\n</xsl:stylesheet>'),i),pciHooks(e){const s=["hook","module"],n=e.substring(0,e.lastIndexOf("/")),r=(new DOMParser).parseFromString(t,"text/xml");for(const t of s){r.querySelectorAll("["+t+"]").forEach((s=>{const i=s.getAttribute(t);i.startsWith("data:")||i.startsWith("http")||(s.setAttribute("base-url",e),s.setAttribute("module",n+"/"+encodeURIComponent(i+(i.endsWith(".js")?"":".js"))))}))}return t=(new XMLSerializer).serializeToString(r),i},assetsLocation(e,s=["src","href","data"]){const n=e.substring(0,e.lastIndexOf("/")),r=(new DOMParser).parseFromString(t,"text/xml");for(const e of s){r.querySelectorAll("["+e+"]").forEach((t=>{const s=t.getAttribute(e);s.startsWith("data:")||s.startsWith("http")||t.setAttribute(e,n+"/"+encodeURIComponent(s))}))}return t=(new XMLSerializer).serializeToString(r),i},customTypes:()=>(s('<?xml version="1.0" encoding="utf-8"?>\n <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qti="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:m="http://www.w3.org/1998/Math/MathML">\n <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>\t \n <xsl:param name="separator" select="\' \'" />\n <xsl:param name="prefix" select="\'type:\'" />\n <xsl:variable name="prefixElements"></xsl:variable>\n <xsl:variable name="suffixElements"></xsl:variable>\n \x3c!-- passthrough --\x3e\n <xsl:template match="*">\n <xsl:copy>\n <xsl:apply-templates select="* | @* | text()" />\n </xsl:copy>\n </xsl:template>\n <xsl:template match="@* | text()">\n <xsl:copy-of select="." />\n </xsl:template>\n \n <xsl:template match="*">\n <xsl:variable name="elementName">\n <xsl:call-template name="getTypedElementName">\n <xsl:with-param name="input" select="." />\n </xsl:call-template>\n </xsl:variable>\n <xsl:element name="{$elementName}">\n <xsl:apply-templates select="* | @* | text()" />\n </xsl:element>\n </xsl:template>\n \n \x3c!-- custom names --\x3e\n <xsl:template name="getType">\n <xsl:param name="input" />\n <xsl:param name="separator" select="$separator" />\n <xsl:param name="prefix" select="$prefix" />\n <xsl:variable name="output">\n <xsl:choose>\n <xsl:when test="contains($input, $separator)">\n <xsl:value-of select="substring-before($input, $separator)" />\n </xsl:when>\n <xsl:otherwise>\n <xsl:value-of select="$input" />\n </xsl:otherwise>\n </xsl:choose>\n </xsl:variable>\n <xsl:choose>\n <xsl:when test="starts-with($output, $prefix) and $output != $prefix">\n <xsl:value-of select="substring-after($output, $prefix)" />\n </xsl:when>\n <xsl:otherwise>\n <xsl:variable name="after" select="substring-after($input, $separator)" />\n <xsl:if test="$after">\n <xsl:call-template name="getType">\n <xsl:with-param name="input" select="$after" />\n <xsl:with-param name="separator" select="$separator" />\n <xsl:with-param name="prefix" select="$prefix" />\n </xsl:call-template>\n </xsl:if>\n </xsl:otherwise>\n </xsl:choose>\n </xsl:template>\n \n <xsl:template name="getTypedElementName">\n <xsl:param name="input" />\n <xsl:variable name="prefixElements" select="document(\'\')//xsl:variable[@name = \'prefixElements\']/element" />\n <xsl:variable name="suffixElements" select="document(\'\')//xsl:variable[@name = \'suffixElements\']/element" />\n <xsl:variable name="originalName" select="name($input)" />\n <xsl:variable name="type">\n <xsl:call-template name="getType">\n <xsl:with-param name="input" select="$input/@class" />\n </xsl:call-template>\n </xsl:variable>\n <xsl:value-of select="$originalName" />\n \x3c!-- Add prefix elements --\x3e\n <xsl:if test="$prefixElements[text() = $originalName]">\n <xsl:text>-</xsl:text>\n </xsl:if>\n \x3c!-- Add suffix to typed elements --\x3e\n <xsl:if test="string-length($type)">\n <xsl:text>-</xsl:text>\n <xsl:value-of select="$type" />\n </xsl:if>\n \x3c!-- Add suffix to elements --\x3e\n <xsl:if test="$suffixElements[text() = $originalName]">\n <xsl:text>-</xsl:text>\n </xsl:if>\n </xsl:template>\n </xsl:stylesheet>'),i),suffix:(e,s)=>(e.forEach((e=>{t=t.replaceAll(e,e+"-"+s)})),i),prefix:(e,s)=>(e.forEach((e=>{t=t.replaceAll(e,s+"-"+e)})),i),fn:e=>(t=e(t),i),elementNameAttributes:e=>(e.forEach((e=>{t=t.replaceAll(e,e+` data-element="${e}" `)})),i),print:()=>(console.log(t),i),xml:()=>(t=ms(t),t)};return i},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { ContextConsumer } from '@lit-labs/context';
|
|
1
2
|
import QtiElement from '../../lib/utilities/element/qti-element';
|
|
2
3
|
export declare class QtiManualScoring extends QtiElement {
|
|
4
|
+
static styles: import("lit").CSSResult;
|
|
3
5
|
disabled: any;
|
|
4
6
|
readonly: any;
|
|
5
7
|
value: string;
|
|
6
8
|
protected textChanged(event: Event): void;
|
|
9
|
+
logger: ContextConsumer<{
|
|
10
|
+
__context__: import("../qti-context/qti-context").Logger;
|
|
11
|
+
}, this>;
|
|
7
12
|
render(): import("lit-html").TemplateResult<1>;
|
|
8
13
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import { InputResponseFormat, QtiVariableJSON } from '../../lib/qti-utilities/ExpressionResult';
|
|
3
3
|
import './qti-test.scss';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const TestEvents: {
|
|
5
5
|
ON_ITEM_WAS_FINISHED: string;
|
|
6
6
|
ON_NO_RESPONSE_ON_SUBMIT: string;
|
|
7
7
|
ON_REQUEST_ITEM: string;
|
|
8
8
|
ON_TEST_FINISHED: string;
|
|
9
|
+
ON_ITEM_READY: string;
|
|
9
10
|
};
|
|
10
11
|
export declare enum NavigationMode {
|
|
11
12
|
linear = "linear",
|
|
@@ -48,8 +49,8 @@ export declare class QtiTest extends LitElement {
|
|
|
48
49
|
private _onScoreItem;
|
|
49
50
|
private _onPrevItem;
|
|
50
51
|
private _onNextItem;
|
|
51
|
-
private _dispatchRequestItem;
|
|
52
52
|
private _onRequestItem;
|
|
53
53
|
private _handleSlotchange;
|
|
54
54
|
render(): import("lit-html").TemplateResult<1>;
|
|
55
|
+
emit(name: string, options?: CustomEventInit): void;
|
|
55
56
|
}
|