@citolab/qti-components 3.0.54 → 3.0.55
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
CHANGED
|
@@ -325,10 +325,10 @@ import{LitElement as e,html as t,css as s}from"lit";import{customElement as i,pr
|
|
|
325
325
|
color: var(--qti-placeholder-text);
|
|
326
326
|
}
|
|
327
327
|
`],customElements.define("qti-order-interaction",Me);class He extends V{constructor(){super()}render(){return t`<slot></slot>
|
|
328
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}He.styles=[Te],customElements.define("qti-select-point-interaction",He);class $e extends P{constructor(){super(...arguments),this.
|
|
328
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}He.styles=[Te],customElements.define("qti-select-point-interaction",He);class $e extends P{constructor(){super(...arguments),this.stepLabel=!1,this.reverse=!1,this._handleDisabledChange=(e,t)=>{},this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){this.value=e}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);const e=(this.value-this.min)/(this.max-this.min)*100;return t`<slot name="prompt"></slot>
|
|
329
329
|
<div id="rail" @mousedown=${this._onMouseDown} part="rail">
|
|
330
|
-
<div id="knob" part="knob" style="left:${
|
|
331
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=t=>{const s=t.pageX-this._rail.offsetLeft;this.
|
|
330
|
+
<div id="knob" part="knob" style="left:${e}%"></div>
|
|
331
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=t=>{const s=t.pageX-this._rail.offsetLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()},s=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",s);const i=e.pageX-this._rail.offsetLeft;this.calculateValue(i),e.preventDefault(),e.stopPropagation()}calculateValue(e){const t=this.min+(this.max-this.min)*e/this.offsetWidth,s=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=s}}$e.styles=[s``],q([o("#knob"),x("design:type",HTMLElement)],$e.prototype,"_knob",void 0),q([o("#rail"),x("design:type",HTMLElement)],$e.prototype,"_rail",void 0),q([n({attribute:!1}),x("design:type",Number)],$e.prototype,"value",void 0),q([n({type:Boolean,attribute:"step-label"}),x("design:type",Object)],$e.prototype,"stepLabel",void 0),q([n({type:Boolean}),x("design:type",Object)],$e.prototype,"reverse",void 0),q([n({type:Number,attribute:"lower-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"min",null),q([n({type:Number,attribute:"upper-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"max",null),q([n({type:Number,attribute:"step"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"step",null),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleDisabledChange",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleReadonlyChange",void 0),customElements.define("qti-slider-interaction",$e);class je extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}levenshtein(e,t){let s;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(s=e,e=t,t=s);const i=e.length,n=t.length,r=Array(i);let o,a,l;for(o=0;o<=i;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=i;a++)s=r[a-1],r[a-1]=l,l=Math.min(s+(t[o-1]!==e[a-1]),l+1,r[a]+1);r[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,s=e.calculate(),i=t.calculate();return this.value=100-this.levenshtein(s.toString().trim(),i.toString().trim())/i.toString().length*100,this.value}}je.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",je);class Pe extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/[^0-9$.,]/g,""):""}}customElements.define("qti-custom-operator-numeric",Pe);class Fe extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return this.value=t?this.parseNumber(t,undefined):"",this.value}parseNumber(e,t=navigator.languages){const s=Intl.NumberFormat(t).format(1.1),i=new RegExp(`[^-+0-9${s.charAt(1)}]`,"g"),n=e.replace(i,"").replace(s.charAt(1),".");return parseFloat(n)}}Fe.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Fe);class Ue extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/ /g,""):""}}customElements.define("qti-custom-operator-remove-spaces",Ue);class Be extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Be);const Ge=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(Ge(e,"on-next-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-item",class extends(Ge(e,"on-request-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(Ge(e,"on-prev-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-check",class extends(Ge(e,"on-check-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-score",class extends(Ge(e,"on-score-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-show-correct",class extends(Ge(e,"on-show-correct")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}});const Ve={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var Ye,ze;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(Ye||(Ye={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(ze||(ze={}));let Xe=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=Ye.nonlinear,this._submissionMode=ze.simultaneous,this.items=[],this.itemIndex=0,this.provider=new d(this,L,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===Ye.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(Ve.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===Ye.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(Ve.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(Ve.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==Ye.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(Ve.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(Ve.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(Ve.ON_NO_RESPONSE_ON_SUBMIT))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(Ve.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(Ve.ON_ITEM_READY,{detail:t}))}render(){return t`
|
|
332
332
|
<slot
|
|
333
333
|
@slotchange=${this._handleSlotchange}
|
|
334
334
|
@on-prev-item=${this._onPrevItem}
|
package/index.umd.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
var C;E.finalized=!0,E.elementProperties=new Map,E.elementStyles=[],E.shadowRootOptions={mode:"open"},null==v||v({ReactiveElement:E}),(null!==(u=m.reactiveElementVersions)&&void 0!==u?u:m.reactiveElementVersions=[]).push("1.4.2");const A=window,x=A.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:e=>e}):void 0,q=`lit$${(Math.random()+"").slice(9)}$`,O="?"+q,$=`<${O}>`,R=document,k=(e="")=>R.createComment(e),w=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,L=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),H=/'/g,P=/"/g,Q=/^(?:script|style|textarea|title)$/i,D=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),U=Symbol.for("lit-noChange"),j=Symbol.for("lit-nothing"),B=new WeakMap,F=R.createTreeWalker(R,129,null,!1),
|
|
17
|
+
var C;E.finalized=!0,E.elementProperties=new Map,E.elementStyles=[],E.shadowRootOptions={mode:"open"},null==v||v({ReactiveElement:E}),(null!==(u=m.reactiveElementVersions)&&void 0!==u?u:m.reactiveElementVersions=[]).push("1.4.2");const A=window,x=A.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:e=>e}):void 0,q=`lit$${(Math.random()+"").slice(9)}$`,O="?"+q,$=`<${O}>`,R=document,k=(e="")=>R.createComment(e),w=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,L=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),H=/'/g,P=/"/g,Q=/^(?:script|style|textarea|title)$/i,D=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),U=Symbol.for("lit-noChange"),j=Symbol.for("lit-nothing"),B=new WeakMap,F=R.createTreeWalker(R,129,null,!1),G=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":"",o=N;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,d=0;for(;d<i.length&&(o.lastIndex=d,l=o.exec(i),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=L):void 0!==l[3]&&(o=L):o===L?">"===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]?L:'"'===l[3]?P:H):o===P||o===H?o=L:o===I||o===M?o=N:(o=L,n=void 0);const h=o===L&&e[t+1].startsWith("/>")?" ":"";r+=o===N?i+$:c>=0?(s.push(a),i.slice(0,c)+"$lit$"+i.slice(c)+q+h):i+q+(-2===c?(s.push(void 0),t):h)}const a=r+(e[i]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==S?S.createHTML(a):a,s]};class V{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,c]=G(e,t);if(this.el=V.createElement(l,i),F.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=F.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes()){const e=[];for(const t of s.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(q)){const i=c[r++];if(e.push(t),void 0!==i){const e=s.getAttribute(i.toLowerCase()+"$lit$").split(q),t=/([.?@])?(.*)/.exec(i);a.push({type:1,index:n,name:t[2],strings:e,ctor:"."===t[1]?X:"?"===t[1]?Z:"@"===t[1]?ee:K})}else a.push({type:6,index:n})}for(const t of e)s.removeAttribute(t)}if(Q.test(s.tagName)){const e=s.textContent.split(q),t=e.length-1;if(t>0){s.textContent=x?x.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],k()),F.nextNode(),a.push({type:2,index:++n});s.append(e[t],k())}}}else if(8===s.nodeType)if(s.data===O)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(q,e+1));)a.push({type:7,index:n}),e+=q.length-1}n++}}static createElement(e,t){const i=R.createElement("template");return i.innerHTML=e,i}}function z(e,t,i=e,s){var n,r,o,a;if(t===U)return t;let l=void 0!==s?null===(n=i._$Co)||void 0===n?void 0:n[s]:i._$Cl;const c=w(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,i,s)),void 0!==s?(null!==(o=(a=i)._$Co)&&void 0!==o?o:a._$Co=[])[s]=l:i._$Cl=l),void 0!==l&&(t=z(e,l._$AS(e,t.values),l,s)),t}class Y{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:i},parts:s}=this._$AD,n=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:R).importNode(i,!0);F.currentNode=n;let r=F.nextNode(),o=0,a=0,l=s[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new W(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=s[++a]}o!==(null==l?void 0:l.index)&&(r=F.nextNode(),o++)}return n}p(e){let t=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class W{constructor(e,t,i,s){var n;this.type=2,this._$AH=j,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cm=null===(n=null==s?void 0:s.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=z(this,e,t),w(e)?e===j||null==e||""===e?(this._$AH!==j&&this._$AR(),this._$AH=j):e!==this._$AH&&e!==U&&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!==j&&w(this._$AH)?this._$AA.nextSibling.data=e:this.T(R.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,n="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=V.createElement(s.h,this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.p(i);else{const e=new Y(n,this),t=e.v(this.options);e.p(i),this.T(t),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return void 0===t&&B.set(e.strings,t=new V(e)),t}k(e){T(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new W(this.O(k()),this.O(k()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for(null===(i=this._$AP)||void 0===i||i.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 K{constructor(e,t,i,s,n){this.type=1,this._$AH=j,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=j}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=z(this,e,t,0),r=!w(e)||e!==this._$AH&&e!==U,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=z(this,s[i+o],t,o),a===U&&(a=this._$AH[o]),r||(r=!w(a)||a!==this._$AH[o]),a===j?e=j:e!==j&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===j?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class X extends K{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===j?void 0:e}}const J=x?x.emptyScript:"";class Z extends K{constructor(){super(...arguments),this.type=4}j(e){e&&e!==j?this.element.setAttribute(this.name,J):this.element.removeAttribute(this.name)}}class ee extends K{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){var i;if((e=null!==(i=z(this,e,t,0))&&void 0!==i?i:j)===U)return;const s=this._$AH,n=e===j&&s!==j||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==j&&(s===j||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==i?i:this.element,e):this._$AH.handleEvent(e)}}class te{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){z(this,e)}}const ie=A.litHtmlPolyfillSupport;null==ie||ie(V,W),(null!==(C=A.litHtmlVersions)&&void 0!==C?C:A.litHtmlVersions=[]).push("2.4.0");
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
@@ -237,7 +237,7 @@ const Ue=2;
|
|
|
237
237
|
* @license
|
|
238
238
|
* Copyright 2017 Google LLC
|
|
239
239
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
240
|
-
*/const Be=(e,t)=>{var i,s;const n=e._$AN;if(void 0===n)return!1;for(const e of n)null===(s=(i=e)._$AO)||void 0===s||s.call(i,t,!1),Be(e,t);return!0},Fe=e=>{let t,i;do{if(void 0===(t=e._$AM))break;i=t._$AN,i.delete(e),e=t}while(0===(null==i?void 0:i.size))},
|
|
240
|
+
*/const Be=(e,t)=>{var i,s;const n=e._$AN;if(void 0===n)return!1;for(const e of n)null===(s=(i=e)._$AO)||void 0===s||s.call(i,t,!1),Be(e,t);return!0},Fe=e=>{let t,i;do{if(void 0===(t=e._$AM))break;i=t._$AN,i.delete(e),e=t}while(0===(null==i?void 0:i.size))},Ge=e=>{for(let t;t=e._$AM;e=t){let i=t._$AN;if(void 0===i)t._$AN=i=new Set;else if(i.has(e))break;i.add(e),Ye(t)}};function Ve(e){void 0!==this._$AN?(Fe(this),this._$AM=e,Ge(this)):this._$AM=e}function ze(e,t=!1,i=0){const s=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(t)if(Array.isArray(s))for(let e=i;e<s.length;e++)Be(s[e],!1),Fe(s[e]);else null!=s&&(Be(s,!1),Fe(s));else Be(this,e)}const Ye=e=>{var t,i,s,n;e.type==Ue&&(null!==(t=(s=e)._$AP)&&void 0!==t||(s._$AP=ze),null!==(i=(n=e)._$AQ)&&void 0!==i||(n._$AQ=Ve))};class We extends je{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),Ge(this),this.isConnected=e._$AU}_$AO(e,t=!0){var i,s;e!==this.isConnected&&(this.isConnected=e,e?null===(i=this.reconnected)||void 0===i||i.call(this):null===(s=this.disconnected)||void 0===s||s.call(this)),t&&(Be(this,e),Fe(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(){}}
|
|
241
241
|
/**
|
|
242
242
|
* @license
|
|
243
243
|
* Copyright 2020 Google LLC
|
|
@@ -437,11 +437,11 @@ const Ue=2;
|
|
|
437
437
|
content: 'drop here';
|
|
438
438
|
color: var(--qti-placeholder-text);
|
|
439
439
|
}
|
|
440
|
-
`],customElements.define("qti-order-interaction",Ft);class
|
|
441
|
-
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}
|
|
440
|
+
`],customElements.define("qti-order-interaction",Ft);class Gt extends et{constructor(){super()}render(){return D`<slot></slot>
|
|
441
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}Gt.styles=[Ut],customElements.define("qti-select-point-interaction",Gt);class Vt extends Pe{constructor(){super(...arguments),this.stepLabel=!1,this.reverse=!1,this._handleDisabledChange=(e,t)=>{},this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){this.value=e}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);const e=(this.value-this.min)/(this.max-this.min)*100;return D`<slot name="prompt"></slot>
|
|
442
442
|
<div id="rail" @mousedown=${this._onMouseDown} part="rail">
|
|
443
|
-
<div id="knob" part="knob" style="left:${
|
|
444
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=t=>{const i=t.pageX-this._rail.offsetLeft;this.
|
|
443
|
+
<div id="knob" part="knob" style="left:${e}%"></div>
|
|
444
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=t=>{const i=t.pageX-this._rail.offsetLeft;this.calculateValue(i),e.preventDefault(),e.stopPropagation()},i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i);const s=e.pageX-this._rail.offsetLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()}calculateValue(e){const t=this.min+(this.max-this.min)*e/this.offsetWidth,i=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=i}}Vt.styles=[h``],de([be("#knob"),he("design:type",HTMLElement)],Vt.prototype,"_knob",void 0),de([be("#rail"),he("design:type",HTMLElement)],Vt.prototype,"_rail",void 0),de([me({attribute:!1}),he("design:type",Number)],Vt.prototype,"value",void 0),de([me({type:Boolean,attribute:"step-label"}),he("design:type",Object)],Vt.prototype,"stepLabel",void 0),de([me({type:Boolean}),he("design:type",Object)],Vt.prototype,"reverse",void 0),de([me({type:Number,attribute:"lower-bound"}),he("design:type",Number),he("design:paramtypes",[Number])],Vt.prototype,"min",null),de([me({type:Number,attribute:"upper-bound"}),he("design:type",Number),he("design:paramtypes",[Number])],Vt.prototype,"max",null),de([me({type:Number,attribute:"step"}),he("design:type",Number),he("design:paramtypes",[Number])],Vt.prototype,"step",null),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Object)],Vt.prototype,"_handleDisabledChange",void 0),de([Ae("readonly",{waitUntilFirstUpdate:!0}),he("design:type",Object)],Vt.prototype,"_handleReadonlyChange",void 0),customElements.define("qti-slider-interaction",Vt);class zt extends re{constructor(){super(...arguments),this.render=()=>D`${this.value}`}levenshtein(e,t){let i;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(i=e,e=t,t=i);const s=e.length,n=t.length,r=Array(s);let o,a,l;for(o=0;o<=s;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=s;a++)i=r[a-1],r[a-1]=l,l=Math.min(i+(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,i=e.calculate(),s=t.calculate();return this.value=100-this.levenshtein(i.toString().trim(),s.toString().trim())/s.toString().length*100,this.value}}zt.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",zt);class Yt extends re{render(){return D``}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",Yt);class Wt extends re{constructor(){super(...arguments),this.render=()=>D`${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 i=Intl.NumberFormat(t).format(1.1),s=new RegExp(`[^-+0-9${i.charAt(1)}]`,"g"),n=e.replace(s,"").replace(i.charAt(1),".");return parseFloat(n)}}Wt.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Wt);class Kt extends re{render(){return D``}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",Kt);class Xt extends re{render(){return D``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Xt);const Jt=(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(Jt(re,"on-next-item")){constructor(){super(...arguments),this.render=()=>D`<slot></slot>`}}),customElements.define("qti-test-item",class extends(Jt(re,"on-request-item")){constructor(){super(...arguments),this.render=()=>D`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(Jt(re,"on-prev-item")){constructor(){super(...arguments),this.render=()=>D`<slot></slot>`}}),customElements.define("qti-test-check",class extends(Jt(re,"on-check-item")){constructor(){super(...arguments),this.render=()=>D`<slot></slot>`}}),customElements.define("qti-test-score",class extends(Jt(re,"on-score-item")){constructor(){super(...arguments),this.render=()=>D`<slot></slot>`}}),customElements.define("qti-test-show-correct",class extends(Jt(re,"on-show-correct")){constructor(){super(...arguments),this.render=()=>D`<slot></slot>`}});const Zt={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var ei,ti;e.NavigationMode=void 0,(ei=e.NavigationMode||(e.NavigationMode={})).linear="linear",ei.nonlinear="nonlinear",e.SubmissionMode=void 0,(ti=e.SubmissionMode||(e.SubmissionMode={})).individual="individual",ti.simultaneous="simultaneous",e.QtiTest=class extends re{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 Te(this,Ne,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(t,i){this.prevButton.style.visibility=i===e.NavigationMode.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(Zt.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(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(Zt.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(Zt.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==e.NavigationMode.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(Zt.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(Zt.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(Zt.ON_NO_RESPONSE_ON_SUBMIT))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(Zt.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(Zt.ON_ITEM_READY,{detail:t}))}render(){return D`
|
|
445
445
|
<slot
|
|
446
446
|
@slotchange=${this._handleSlotchange}
|
|
447
447
|
@on-prev-item=${this._onPrevItem}
|
|
@@ -486,4 +486,4 @@ const Ue=2;
|
|
|
486
486
|
:host {
|
|
487
487
|
display: none;
|
|
488
488
|
}
|
|
489
|
-
`,de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"disabled",void 0),de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"readonly",void 0),de([me({type:Number}),he("design:type",String)],e.QtiManualScoring.prototype,"value",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"min",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"max",void 0),e.QtiManualScoring=de([pe("qti-manual-scoring")],e.QtiManualScoring),e.Choices=et,e.Events=s,e.OutcomeVariable=r,e.QtiAnd=Ct,e.QtiAssessmentItem=le,e.QtiAssociateInteraction=kt,e.QtiBaseValue=ft,e.QtiChoiceInteraction=st,e.QtiContains=yt,e.QtiCorrect=gt,e.QtiCustomOperatorLevenshtein=zt,e.QtiCustomOperatorNumericOnly=Yt,e.QtiCustomOperatorParseNumberLocalNl=Wt,e.QtiCustomOperatorRemoveAllSpaces=Kt,e.QtiCustomOperatorTrim=Xt,e.QtiExpression=dt,e.QtiExtendedTextInteraction=Ze,e.QtiFeedbackInline=Me,e.QtiGap=It,e.QtiGapMatchInteraction=Tt,e.QtiGapText=Nt,e.QtiGraphicAssociateInteraction=Lt,e.QtiGraphicGapMatchInteraction=Ht,e.QtiGraphicOrderInteraction=Pt,e.QtiGte=_t,e.QtiHotspotChoice=Dt,e.QtiHotspotInteraction=Qt,e.QtiHottextInteraction=tt,e.QtiInlineChoiceInteraction=it,e.QtiIsNull=xt,e.QtiItem=si,e.QtiMapResponse=ht,e.QtiMatch=vt,e.QtiMatchInteraction=jt,e.QtiMediaInteraction=Bt,e.QtiModalFeedback=Le,e.QtiMultiple=Et,e.QtiOr=At,e.QtiOrderInteraction=Ft,e.QtiOutcomeDeclaration=Oe,e.QtiPortableCustomInteraction=St,e.QtiPrompt=fe,e.QtiResponseCondition=ot,e.QtiResponseDeclaration=qe,e.QtiResponseElse=at,e.QtiResponseElseIf=ct,e.QtiResponseIf=lt,e.QtiResponseProcessing=nt,e.QtiSelectPointInteraction=
|
|
489
|
+
`,de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"disabled",void 0),de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"readonly",void 0),de([me({type:Number}),he("design:type",String)],e.QtiManualScoring.prototype,"value",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"min",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"max",void 0),e.QtiManualScoring=de([pe("qti-manual-scoring")],e.QtiManualScoring),e.Choices=et,e.Events=s,e.OutcomeVariable=r,e.QtiAnd=Ct,e.QtiAssessmentItem=le,e.QtiAssociateInteraction=kt,e.QtiBaseValue=ft,e.QtiChoiceInteraction=st,e.QtiContains=yt,e.QtiCorrect=gt,e.QtiCustomOperatorLevenshtein=zt,e.QtiCustomOperatorNumericOnly=Yt,e.QtiCustomOperatorParseNumberLocalNl=Wt,e.QtiCustomOperatorRemoveAllSpaces=Kt,e.QtiCustomOperatorTrim=Xt,e.QtiExpression=dt,e.QtiExtendedTextInteraction=Ze,e.QtiFeedbackInline=Me,e.QtiGap=It,e.QtiGapMatchInteraction=Tt,e.QtiGapText=Nt,e.QtiGraphicAssociateInteraction=Lt,e.QtiGraphicGapMatchInteraction=Ht,e.QtiGraphicOrderInteraction=Pt,e.QtiGte=_t,e.QtiHotspotChoice=Dt,e.QtiHotspotInteraction=Qt,e.QtiHottextInteraction=tt,e.QtiInlineChoiceInteraction=it,e.QtiIsNull=xt,e.QtiItem=si,e.QtiMapResponse=ht,e.QtiMatch=vt,e.QtiMatchInteraction=jt,e.QtiMediaInteraction=Bt,e.QtiModalFeedback=Le,e.QtiMultiple=Et,e.QtiOr=At,e.QtiOrderInteraction=Ft,e.QtiOutcomeDeclaration=Oe,e.QtiPortableCustomInteraction=St,e.QtiPrompt=fe,e.QtiResponseCondition=ot,e.QtiResponseDeclaration=qe,e.QtiResponseElse=at,e.QtiResponseElseIf=ct,e.QtiResponseIf=lt,e.QtiResponseProcessing=nt,e.QtiSelectPointInteraction=Gt,e.QtiSetOutcomeValue=mt,e.QtiSliderInteraction=Vt,e.QtiStylesheet=ce,e.QtiTextEntryInteraction=De,e.QtiVariable=bt,e.ResponseVariable=n,e.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},e.TestEvents=Zt,e.qtiSimpleAssociableChoice=wt,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -4,8 +4,7 @@ import './qti-slider-interaction.scss';
|
|
|
4
4
|
export declare class QtiSliderInteraction extends Interaction {
|
|
5
5
|
private _knob;
|
|
6
6
|
private _rail;
|
|
7
|
-
|
|
8
|
-
private _sliderValue;
|
|
7
|
+
value: number;
|
|
9
8
|
stepLabel: boolean;
|
|
10
9
|
reverse: boolean;
|
|
11
10
|
private _min;
|
|
@@ -26,8 +25,6 @@ export declare class QtiSliderInteraction extends Interaction {
|
|
|
26
25
|
render(): import("lit-html").TemplateResult<1>;
|
|
27
26
|
connectedCallback(): void;
|
|
28
27
|
private _onMouseDown;
|
|
29
|
-
/**
|
|
30
|
-
private
|
|
31
|
-
/** moveSliderTo gets the real slider value, and brings it back te percentages */
|
|
32
|
-
private _moveSliderTo;
|
|
28
|
+
/** calculateValue gets x position and compares this with the total width in pixels */
|
|
29
|
+
private calculateValue;
|
|
33
30
|
}
|