@citolab/qti-components 6.6.1-11 → 6.6.1-13
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/dist/custom-elements.json +111 -59
- package/dist/index.cjs +72 -72
- package/dist/index.js +69 -69
- package/dist/item.css +1 -1
- package/dist/qti-components/index.cjs +41 -41
- package/dist/qti-components/index.d.cts +20 -1
- package/dist/qti-components/index.d.ts +20 -1
- package/dist/qti-components/index.js +73 -73
- package/package.json +14 -14
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKRFEDZFGcjs = require('../chunk-KRFEDZFG.cjs');var _context2 = require('@lit/context');var _lit = require('lit');var _decoratorsjs = require('lit/decorators.js');function y(a,i){let e=_chunkKRFEDZFGcjs.a.call(void 0, {waitUntilFirstUpdate:!1},i);return(t,r)=>{let{update:s}=t,o=Array.isArray(a)?a:[a];t.update=function(c){o.forEach(l=>{let p=l;if(c.has(p)){let d=c.get(p),u=this[p];d!==u&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[r](d,u)}}),s.call(this,c)}}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKRFEDZFGcjs = require('../chunk-KRFEDZFG.cjs');var _context2 = require('@lit/context');var _lit = require('lit');var _decoratorsjs = require('lit/decorators.js');function y(a,i){let e=_chunkKRFEDZFGcjs.a.call(void 0, {waitUntilFirstUpdate:!1},i);return(t,r)=>{let{update:s}=t,o=Array.isArray(a)?a:[a];t.update=function(c){o.forEach(l=>{let p=l;if(c.has(p)){let d=c.get(p),u=this[p];d!==u&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[r](d,u)}}),s.call(this,c)}}}var S=_context2.createContext.call(void 0, "item");var A=class extends _lit.LitElement{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent="false";this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(r=>r.readonly=t);this._context={identifier:this.getAttribute("identifier"),variables:[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}]};this._initialContext=_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},this._context),{variables:this._context.variables});this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",({detail:e})=>{this._context=_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},this._context),{variables:[...this._context.variables,e.variable]}),this._initialContext=this._context}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let t=e.detail;this._feedbackElements.push(t),t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:r}=e.detail;this.updateResponseVariable(t,"true"),this.processResponse(r)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:r}=e.detail;this.updateOutcomeVariable(t,r)}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context=_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},this._context),{variables:this._context.variables.map(t=>{let r=e.find(s=>s.identifier===t.identifier);return r?_chunkKRFEDZFGcjs.a.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},t),r):t})}),this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);r&&(r.response=t.value)}t.type==="outcome"&&this._feedbackElements.forEach(r=>r.checkShowFeedback(t.identifier))})}firstUpdated(e){super.firstUpdated(e),this._emit("qti-assessment-item-first-updated",this)}disconnectedCallback(){super.disconnectedCallback(),this._emit("qti-item-disconnected")}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=this._interactionElements.find(o=>o.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return _lit.html`<slot></slot>`}showCorrectResponse(e){let r=this._context.variables.filter(s=>"correctResponse"in s&&s.correctResponse).map(s=>({responseIdentifier:s.identifier,response:s.correctResponse}));for(let s of r){let o=this._interactionElements.find(c=>c.getAttribute("response-identifier")===s.responseIdentifier);o&&(o.correctResponse=e?s.response:"")}}processResponse(e=!0){var r;let t=this.querySelector("qti-response-processing");return t?t.process?(t.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+((r=this._context.variables.find(s=>s.identifier==="numAttempts"))==null?void 0:r.value)+1).toString()),this._emit("qti-response-processed"),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}handleUpdateResponseVariable(e){let{responseIdentifier:t,response:r}=e.detail;this.updateResponseVariable(t,r)}updateResponseVariable(e,t){this._context=_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},this._context),{variables:this._context.variables.map(r=>r.identifier!==e?r:_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},r),{value:t}))}),this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:t})}updateOutcomeVariable(e,t){var s;let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context=_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},this._context),{variables:this._context.variables.map(o=>o.identifier!==e?o:_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},o),{value:r.cardinality==="single"?t:[...o.value,t]}))}),this._feedbackElements.forEach(o=>o.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:(s=this._context.variables.find(o=>o.identifier===e))==null?void 0:s.value})}_getCompletionStatus(){return this._interactionElements.every(e=>e.validate())?"completed":this._interactionElements.some(e=>e.validate())?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],A.prototype,"title",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],A.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],A.prototype,"adaptive",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],A.prototype,"timeDependent",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean})],A.prototype,"disabled",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],A.prototype,"_handleDisabledChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean})],A.prototype,"readonly",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("readonly",{waitUntilFirstUpdate:!0})],A.prototype,"_handleReadonlyChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [_context2.provide.call(void 0, {context:S}),_decoratorsjs.property.call(void 0, {attribute:!1})],A.prototype,"_context",2),A= exports.QtiAssessmentItem =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-assessment-item")],A);var _statichtmljs = require('lit/static-html.js');var Vr={SPACE:32},_= exports.QtiChoice =class extends _lit.LitElement{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.dispatchEvent(new CustomEvent("qti-register-choice",{bubbles:!0,cancelable:!1,composed:!0}))}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-loose-choice",{bubbles:!0,cancelable:!1,composed:!0}))}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){if(!e.altKey)switch(e.keyCode){case Vr.SPACE:e.preventDefault(),this._toggleChecked();break;default:}}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("qti-choice-element-selected",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier,checked:this.checked}})))}validateAllProps(){return!!this.getAttribute("identifier")}render(){return this.validateAllProps()||console.warn(`Invalid props for ${this.outerHTML}`,"missing identifier"),_statichtmljs.html` <slot></slot> `}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],_.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0})],_.prototype,"tabindex",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:e=>e}})],_.prototype,"disabled",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:e=>e}})],_.prototype,"readonly",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>e}})],_.prototype,"checked",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],_.prototype,"handleDisabledChange",1);var Ft=_lit.css`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
|
5
|
-
`;var W=class extends _lit.LitElement{render(){return _lit.html`<slot name="qti-rubric-block"></slot><slot></slot>`}};W.styles=
|
|
5
|
+
`;var W=class extends _lit.LitElement{render(){return _lit.html`<slot name="qti-rubric-block"></slot><slot></slot>`}};W.styles=Ft,W=_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-item-body")],W);var Ee=class extends _lit.LitElement{render(){return _lit.html`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Ee= exports.QtiPrompt =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-prompt")],Ee);var tt=class extends _lit.LitElement{constructor(){super()}firstUpdated(e){super.firstUpdated(e);let t=this.closest("qti-assessment-item"),r=this.getAttribute("href");if(r!==null){let s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=r,t.appendChild(s),this.styleLink=s}if(this.textContent!==null){let s=document.createElement("style");s.media="screen",s.textContent=this.textContent,t.appendChild(s),this.styleLink=s}}disconnectedCallback(){let e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(t){console.log("could not remove stylesheet")}}};customElements.define("qti-stylesheet",tt);var F=class extends _lit.LitElement{render(){return _lit.html`<slot></slot>`}defaultValues(i){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(r=>r.innerHTML);return t.length>1||i.cardinality==="multiple"||i.cardinality==="ordered"?t:t[0]}};customElements.define("qti-variabledeclaration",F);var P=class extends F{render(){var t,r;let e=(r=(t=this.itemContext)==null?void 0:t.variables.find(s=>s.identifier===this.identifier))==null?void 0:r.value;return _lit.html`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let r of e.querySelectorAll("qti-interpolation-table-entry")){!r.getAttribute("source-value")&&r.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let s=parseInt(r.getAttribute("source-value")),o=parseInt(r.getAttribute("target-value"));(isNaN(s)||isNaN(o))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,o)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};P.styles=[_lit.css`
|
|
6
6
|
:host {
|
|
7
7
|
display: none;
|
|
8
8
|
}
|
|
9
|
-
`],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"base-type"})],P.prototype,"baseType",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],P.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],P.prototype,"cardinality",2),_chunkKRFEDZFGcjs.c.call(void 0, [_context2.consume.call(void 0, {context:
|
|
10
|
-
\f\r]`,le=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
11
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
|
9
|
+
`],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"base-type"})],P.prototype,"baseType",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],P.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],P.prototype,"cardinality",2),_chunkKRFEDZFGcjs.c.call(void 0, [_context2.consume.call(void 0, {context:S,subscribe:!0}),_decoratorsjs.state.call(void 0, )],P.prototype,"itemContext",2);customElements.define("qti-outcome-declaration",P);var J=globalThis,_e=J.trustedTypes,Xt=_e?_e.createPolicy("lit-html",{createHTML:a=>a}):void 0,Jt="$lit$",O=`lit$${(Math.random()+"").slice(9)}$`,Zt="?"+O,Wr=`<${Zt}>`,B=J.document===void 0?{createTreeWalker:()=>({})}:document,Ce=()=>B.createComment(""),ce=a=>a===null||typeof a!="object"&&typeof a!="function",Gt=Array.isArray,Jr=a=>Gt(a)||typeof(a==null?void 0:a[Symbol.iterator])=="function",it=`[
|
|
10
|
+
\f\r]`,le=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Yt=/-->/g,Bt=/>/g,X=RegExp(`>|${it}(?:([^\\s"'>=/]+)(${it}*=${it}*(?:[^
|
|
11
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),jt=/'/g,Kt=/"/g,Qt=/^(?:script|style|textarea|title)$/i,er=a=>(i,...e)=>({_$litType$:a,strings:i,values:e}),tr=er(1),Cn=er(2),pe=Symbol.for("lit-noChange"),x=Symbol.for("lit-nothing"),zt=new WeakMap,Y=B.createTreeWalker(B,129);function rr(a,i){if(!Array.isArray(a)||!a.hasOwnProperty("raw"))throw Error("invalid template strings array");return Xt!==void 0?Xt.createHTML(i):i}var Zr=(a,i)=>{let e=a.length-1,t=[],r,s=i===2?"<svg>":"",o=le;for(let c=0;c<e;c++){let l=a[c],p,d,u=-1,g=0;for(;g<l.length&&(o.lastIndex=g,d=o.exec(l),d!==null);)g=o.lastIndex,o===le?d[1]==="!--"?o=Yt:d[1]!==void 0?o=Bt:d[2]!==void 0?(Qt.test(d[2])&&(r=RegExp("</"+d[2],"g")),o=X):d[3]!==void 0&&(o=X):o===X?d[0]===">"?(o=r!=null?r:le,u=-1):d[1]===void 0?u=-2:(u=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?X:d[3]==='"'?Kt:jt):o===Kt||o===jt?o=X:o===Yt||o===Bt?o=le:(o=X,r=void 0);let h=o===X&&a[c+1].startsWith("/>")?" ":"";s+=o===le?l+Wr:u>=0?(t.push(p),l.slice(0,u)+Jt+l.slice(u)+O+h):l+O+(u===-2?c:h)}return[rr(a,s+(a[e]||"<?>")+(i===2?"</svg>":"")),t]},de=class a{constructor({strings:i,_$litType$:e},t){let r;this.parts=[];let s=0,o=0,c=i.length-1,l=this.parts,[p,d]=Zr(i,e);if(this.el=a.createElement(p,t),Y.currentNode=this.el.content,e===2){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(r=Y.nextNode())!==null&&l.length<c;){if(r.nodeType===1){if(r.hasAttributes())for(let u of r.getAttributeNames())if(u.endsWith(Jt)){let g=d[o++],h=r.getAttribute(u).split(O),T=/([.?@])?(.*)/.exec(g);l.push({type:1,index:s,name:T[2],strings:h,ctor:T[1]==="."?nt:T[1]==="?"?at:T[1]==="@"?lt:G}),r.removeAttribute(u)}else u.startsWith(O)&&(l.push({type:6,index:s}),r.removeAttribute(u));if(Qt.test(r.tagName)){let u=r.textContent.split(O),g=u.length-1;if(g>0){r.textContent=_e?_e.emptyScript:"";for(let h=0;h<g;h++)r.append(u[h],Ce()),Y.nextNode(),l.push({type:2,index:++s});r.append(u[g],Ce())}}}else if(r.nodeType===8)if(r.data===Zt)l.push({type:2,index:s});else{let u=-1;for(;(u=r.data.indexOf(O,u+1))!==-1;)l.push({type:7,index:s}),u+=O.length-1}s++}}static createElement(i,e){let t=B.createElement("template");return t.innerHTML=i,t}};function Z(a,i,e=a,t){var o,c,l;if(i===pe)return i;let r=t!==void 0?(o=e._$Co)==null?void 0:o[t]:e._$Cl,s=ce(i)?void 0:i._$litDirective$;return(r==null?void 0:r.constructor)!==s&&((c=r==null?void 0:r._$AO)==null||c.call(r,!1),s===void 0?r=void 0:(r=new s(a),r._$AT(a,e,t)),t!==void 0?((l=e._$Co)!=null?l:e._$Co=[])[t]=r:e._$Cl=r),r!==void 0&&(i=Z(a,r._$AS(a,i.values),r,t)),i}var ot=class{constructor(i,e){this._$AV=[],this._$AN=void 0,this._$AD=i,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(i){var p;let{el:{content:e},parts:t}=this._$AD,r=((p=i==null?void 0:i.creationScope)!=null?p:B).importNode(e,!0);Y.currentNode=r;let s=Y.nextNode(),o=0,c=0,l=t[0];for(;l!==void 0;){if(o===l.index){let d;l.type===2?d=new qe(s,s.nextSibling,this,i):l.type===1?d=new l.ctor(s,l.name,l.strings,this,i):l.type===6&&(d=new ct(s,this,i)),this._$AV.push(d),l=t[++c]}o!==(l==null?void 0:l.index)&&(s=Y.nextNode(),o++)}return Y.currentNode=B,r}p(i){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(i,t,e),e+=t.strings.length-2):t._$AI(i[e])),e++}},qe=class a{get _$AU(){var i,e;return(e=(i=this._$AM)==null?void 0:i._$AU)!=null?e:this._$Cv}constructor(i,e,t,r){var s;this.type=2,this._$AH=x,this._$AN=void 0,this._$AA=i,this._$AB=e,this._$AM=t,this.options=r,this._$Cv=(s=r==null?void 0:r.isConnected)!=null?s:!0}get parentNode(){let i=this._$AA.parentNode,e=this._$AM;return e!==void 0&&(i==null?void 0:i.nodeType)===11&&(i=e.parentNode),i}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(i,e=this){i=Z(this,i,e),ce(i)?i===x||i==null||i===""?(this._$AH!==x&&this._$AR(),this._$AH=x):i!==this._$AH&&i!==pe&&this._(i):i._$litType$!==void 0?this.g(i):i.nodeType!==void 0?this.$(i):Jr(i)?this.T(i):this._(i)}k(i){return this._$AA.parentNode.insertBefore(i,this._$AB)}$(i){this._$AH!==i&&(this._$AR(),this._$AH=this.k(i))}_(i){this._$AH!==x&&ce(this._$AH)?this._$AA.nextSibling.data=i:this.$(B.createTextNode(i)),this._$AH=i}g(i){var s;let{values:e,_$litType$:t}=i,r=typeof t=="number"?this._$AC(i):(t.el===void 0&&(t.el=de.createElement(rr(t.h,t.h[0]),this.options)),t);if(((s=this._$AH)==null?void 0:s._$AD)===r)this._$AH.p(e);else{let o=new ot(r,this),c=o.u(this.options);o.p(e),this.$(c),this._$AH=o}}_$AC(i){let e=zt.get(i.strings);return e===void 0&&zt.set(i.strings,e=new de(i)),e}T(i){Gt(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,r=0;for(let s of i)r===e.length?e.push(t=new a(this.k(Ce()),this.k(Ce()),this,this.options)):t=e[r],t._$AI(s),r++;r<e.length&&(this._$AR(t&&t._$AB.nextSibling,r),e.length=r)}_$AR(i=this._$AA.nextSibling,e){var t;for((t=this._$AP)==null?void 0:t.call(this,!1,!0,e);i&&i!==this._$AB;){let r=i.nextSibling;i.remove(),i=r}}setConnected(i){var e;this._$AM===void 0&&(this._$Cv=i,(e=this._$AP)==null||e.call(this,i))}},G=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(i,e,t,r,s){this.type=1,this._$AH=x,this._$AN=void 0,this.element=i,this.name=e,this._$AM=r,this.options=s,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=x}_$AI(i,e=this,t,r){let s=this.strings,o=!1;if(s===void 0)i=Z(this,i,e,0),o=!ce(i)||i!==this._$AH&&i!==pe,o&&(this._$AH=i);else{let c=i,l,p;for(i=s[0],l=0;l<s.length-1;l++)p=Z(this,c[t+l],e,l),p===pe&&(p=this._$AH[l]),o||(o=!ce(p)||p!==this._$AH[l]),p===x?i=x:i!==x&&(i+=(p!=null?p:"")+s[l+1]),this._$AH[l]=p}o&&!r&&this.O(i)}O(i){i===x?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,i!=null?i:"")}},nt=class extends G{constructor(){super(...arguments),this.type=3}O(i){this.element[this.name]=i===x?void 0:i}},at=class extends G{constructor(){super(...arguments),this.type=4}O(i){this.element.toggleAttribute(this.name,!!i&&i!==x)}},lt=class extends G{constructor(i,e,t,r,s){super(i,e,t,r,s),this.type=5}_$AI(i,e=this){var o;if((i=(o=Z(this,i,e,0))!=null?o:x)===pe)return;let t=this._$AH,r=i===x&&t!==x||i.capture!==t.capture||i.once!==t.once||i.passive!==t.passive,s=i!==x&&(t===x||r);r&&this.element.removeEventListener(this.name,this,t),s&&this.element.addEventListener(this.name,this,i),this._$AH=i}handleEvent(i){var e,t;typeof this._$AH=="function"?this._$AH.call((t=(e=this.options)==null?void 0:e.host)!=null?t:this.element,i):this._$AH.handleEvent(i)}},ct=class{constructor(i,e,t){this.element=i,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(i){Z(this,i)}};var st=J.litHtmlPolyfillSupport,Wt;st==null||st(de,qe),((Wt=J.litHtmlVersions)!=null?Wt:J.litHtmlVersions=[]).push("3.1.0");var U=class extends F{render(){var t,r;let e=(r=(t=this.itemContext)==null?void 0:t.variables.find(s=>s.identifier===this.identifier))==null?void 0:r.value;return tr`${JSON.stringify(e,null,2)}`}connectedCallback(){super.connectedCallback();let e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let e,t=this.querySelector("qti-correct-response");if(t){let r=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)e=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){e=[];for(let s=0;s<r.length;s++)e.push(r[s].textContent),r[s].remove()}}return e}get mapping(){return this.querySelector("qti-mapping")}};U.styles=[_lit.css`
|
|
12
12
|
:host {
|
|
13
13
|
display: none;
|
|
14
14
|
}
|
|
15
|
-
`],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"base-type"})],U.prototype,"baseType",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],U.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],U.prototype,"cardinality",2),_chunkKRFEDZFGcjs.c.call(void 0, [_context2.consume.call(void 0, {context:
|
|
15
|
+
`],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"base-type"})],U.prototype,"baseType",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],U.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],U.prototype,"cardinality",2),_chunkKRFEDZFGcjs.c.call(void 0, [_context2.consume.call(void 0, {context:S,subscribe:!0}),_decoratorsjs.state.call(void 0, )],U.prototype,"itemContext",2);customElements.define("qti-response-declaration",U);var Ae=class extends _lit.LitElement{};Ae= exports.QtiCompanionMaterialsInfo =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-companion-materials-info")],Ae);var ke=class extends _lit.LitElement{render(){return _lit.html`<slot></slot>`}};ke= exports.QtiContentBody =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-content-body")],ke);var L=class extends _lit.LitElement{handleclassNamesChange(e,t){this.classNames.split(" ").forEach(s=>{switch(s){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return _lit.html`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};L.styles=_lit.css`
|
|
16
16
|
:host {
|
|
17
17
|
display: block;
|
|
18
18
|
}
|
|
19
|
-
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],
|
|
19
|
+
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],L.prototype,"id",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],L.prototype,"use",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],L.prototype,"view",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"class"})],L.prototype,"classNames",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("classNames",{waitUntilFirstUpdate:!0})],L.prototype,"handleclassNamesChange",1),L= exports.QtiRubricBlock =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-rubric-block")],L);var pi=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),ue=a=>{if(typeof a=="string")return a;let i=pi();return i==="."?a.toLocaleString():a.toString().replace(".","").replace(i,".")};function dt(a){return a==null}var k=class extends _lit.LitElement{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e){let t=this.closest("qti-assessment-item").getOutcome(e);if(this.outcomeIdentifier!==e||!t)return;let r=!1;Array.isArray(t.value)?r=t.value.includes(this.identifier):r=!dt(this.identifier)&&!dt(t==null?void 0:t.value)&&this.identifier===t.value||!1,this.showFeedback(r)}showFeedback(e){this.showStatus=e&&this.showHide==="show"||!e&&this.showHide==="hide"?"on":"off"}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"show-hide"})],k.prototype,"showHide",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],k.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:!1})],k.prototype,"showStatus",2);var Re=class extends k{render(){return _lit.html` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(i){this.checkShowFeedback(this.outcomeIdentifier)}};Re.styles=_lit.css`
|
|
20
20
|
:host {
|
|
21
21
|
display: block;
|
|
22
22
|
}
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
.off {
|
|
27
27
|
display: none;
|
|
28
28
|
}
|
|
29
|
-
`;customElements.define("qti-feedback-block"
|
|
29
|
+
`;customElements.define("qti-feedback-block",Re);var Te=class extends k{constructor(){super(...arguments);this.render=()=>_lit.html` <slot part="feedback" class="${this.showStatus}"></slot> `}};Te.styles=_lit.css`
|
|
30
30
|
.on {
|
|
31
31
|
display: inline-block;
|
|
32
32
|
}
|
|
33
33
|
.off {
|
|
34
34
|
display: none;
|
|
35
35
|
}
|
|
36
|
-
`;customElements.define("qti-feedback-inline",Te);var
|
|
36
|
+
`;customElements.define("qti-feedback-inline",Te);var Se=class extends k{constructor(){super(...arguments);this.render=()=>_lit.html` <slot part="feedback" class="${this.showStatus}"></slot> `}};Se.styles=_lit.css`
|
|
37
37
|
.on {
|
|
38
38
|
display: inline-block;
|
|
39
39
|
}
|
|
40
40
|
.off {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
|
-
`;customElements.define("qti-modal-feedback",
|
|
43
|
+
`;customElements.define("qti-modal-feedback",Se);var _ifdefinedjs = require('lit/directives/if-defined.js');var b=class extends _lit.LitElement{constructor(){super(...arguments);this.responseIdentifier="";this.disabled=!1;this.readonly=!1}set correctResponse(e){console.warn("correctResponse is not implemented")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,cancelable:!1,composed:!0}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,cancelable:!1,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:e}}))}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"response-identifier"})],b.prototype,"responseIdentifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {reflect:!0,type:Boolean})],b.prototype,"disabled",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {reflect:!0,type:Boolean})],b.prototype,"readonly",2);var _refjs = require('lit/directives/ref.js');var M=class extends b{constructor(){super(...arguments);this.textareaRef=_refjs.createRef.call(void 0, );this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(s=>{if(s.startsWith("qti-height-lines")){let o=s.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(o))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[_lit.css`
|
|
44
44
|
/* PK: display host as block, else design will be collapsed */
|
|
45
45
|
:host {
|
|
46
46
|
display: block;
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
?disabled="${this.disabled}"
|
|
66
66
|
?readonly="${this.readonly}"
|
|
67
67
|
.value=${this._value}
|
|
68
|
-
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this._value=t.value,this.saveResponse(t.value))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"expected-length"})],
|
|
68
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this._value=t.value,this.saveResponse(t.value))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"expected-length"})],M.prototype,"expectedLength",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"pattern-mask"})],M.prototype,"patternMask",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"placeholder-text"})],M.prototype,"placeholderText",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],M.prototype,"_value",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"class"})],M.prototype,"classNames",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("classNames",{waitUntilFirstUpdate:!0})],M.prototype,"handleclassNamesChange",1),M= exports.QtiExtendedTextInteraction =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-extended-text-interaction")],M);function ir(a,i){let e,t=_chunkKRFEDZFGcjs.a.call(void 0, {},i);return(r,s)=>{let{connectedCallback:o,disconnectedCallback:c}=r;r.connectedCallback=function(){var d;o.call(this);let l=u=>{let g=Array.from(this.querySelectorAll(a));for(let h of u){let T=Array.from(h.addedNodes).map(H=>H),v=Array.from(h.addedNodes).map(H=>H);h.type==="childList"&&T.find(H=>g.includes(H))&&this[s](T,v)}};e=new MutationObserver(l),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(a))!=null?d:[];this[s](Array.from(p),[])},r.disconnectedCallback=function(){c.call(this),e.disconnect()}}}var w=class extends b{constructor(){super(...arguments);this._value="";this._correctValue="";this._size=5;this.inputRef=_refjs.createRef.call(void 0, )}handleclassNamesChange(e,t){t.split(" ").forEach(s=>{if(s.startsWith("qti-input-width")){let o=s.replace("qti-input-width-","");this._size=parseInt(o)}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[_lit.css`
|
|
69
69
|
:host {
|
|
70
70
|
display: inline-flex;
|
|
71
71
|
display: flex;
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
?disabled="${this.disabled}"
|
|
95
95
|
?readonly="${this.readonly}"
|
|
96
96
|
/>
|
|
97
|
-
`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this._value=t.value,this.saveResponse(t.value))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"expected-length"})],w.prototype,"expectedLength",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"pattern-mask"})],w.prototype,"patternMask",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"placeholder-text"})],w.prototype,"placeholderText",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],w.prototype,"_value",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],w.prototype,"_correctValue",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],w.prototype,"_size",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"class"})],w.prototype,"classNames",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("classNames")],w.prototype,"handleclassNamesChange",1),w= exports.QtiTextEntryInteraction =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-text-entry-interaction")],w);var E=class extends b{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(r=>r.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(r=>r.readonly=t);this._handleMaxChoicesChange=()=>this._determineInputType();this.addEventListener("qti-register-choice",this._registerChoiceElement),this.addEventListener("qti-loose-choice",this._looseChoiceElement)}validate(){return this._choiceElements.reduce((t,r)=>t+(r.checked?1:0),0)>=this.minChoices}set response(e){let t=Array.isArray(e)?e:[e];this._choiceElements.forEach(r=>{r.checked=!!t.find(s=>s===r.identifier)})}set correctResponse(e){let t=Array.isArray(e)?e:[e];if(e==""){this._choiceElements.forEach(r=>{r.removeAttribute("data-correct-response")});return}this._choiceElements.forEach(r=>{r.setAttribute("data-correct-response",t.find(s=>s===r.identifier)?"true":"false")})}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler),this.removeEventListener("qti-register-choice",this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter(r=>r!==t)}_determineInputType(){this._choiceElements.forEach(e=>{this._setInputType(e)})}_setInputType(e){this.maxChoices===1?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){this.maxChoices===1&&this._choiceElements.filter(t=>t.identifier!==e.detail.identifier).forEach(t=>{t.checked=!1}),this._choiceElementSelected()}_choiceElementSelected(){let e=this._choiceElements.filter(r=>r.checked).map(r=>r.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(r=>r.disabled=!r.checked):this._choiceElements.forEach(r=>r.disabled=!1));let t;this.maxChoices===1?t=e.length>0?e[0]:void 0:t=e,this.saveResponse(t)}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"min-choices"})],E.prototype,"minChoices",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"max-choices"})],E.prototype,"maxChoices",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],E.prototype,"_handleDisabledChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("readonly",{waitUntilFirstUpdate:!0})],E.prototype,"_handleReadonlyChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("maxChoices",{waitUntilFirstUpdate:!0})],E.prototype,"_handleMaxChoicesChange",2);var
|
|
97
|
+
`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this._value=t.value,this.saveResponse(t.value))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"expected-length"})],w.prototype,"expectedLength",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"pattern-mask"})],w.prototype,"patternMask",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"placeholder-text"})],w.prototype,"placeholderText",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],w.prototype,"_value",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],w.prototype,"_correctValue",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],w.prototype,"_size",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"class"})],w.prototype,"classNames",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("classNames")],w.prototype,"handleclassNamesChange",1),w= exports.QtiTextEntryInteraction =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-text-entry-interaction")],w);var E=class extends b{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(r=>r.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(r=>r.readonly=t);this._handleMaxChoicesChange=()=>this._determineInputType();this.addEventListener("qti-register-choice",this._registerChoiceElement),this.addEventListener("qti-loose-choice",this._looseChoiceElement)}validate(){return this._choiceElements.reduce((t,r)=>t+(r.checked?1:0),0)>=this.minChoices}set response(e){let t=Array.isArray(e)?e:[e];this._choiceElements.forEach(r=>{r.checked=!!t.find(s=>s===r.identifier)})}set correctResponse(e){let t=Array.isArray(e)?e:[e];if(e==""){this._choiceElements.forEach(r=>{r.removeAttribute("data-correct-response")});return}this._choiceElements.forEach(r=>{r.setAttribute("data-correct-response",t.find(s=>s===r.identifier)?"true":"false")})}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler),this.removeEventListener("qti-register-choice",this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter(r=>r!==t)}_determineInputType(){this._choiceElements.forEach(e=>{this._setInputType(e)})}_setInputType(e){this.maxChoices===1?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){this.maxChoices===1&&this._choiceElements.filter(t=>t.identifier!==e.detail.identifier).forEach(t=>{t.checked=!1}),this._choiceElementSelected()}_choiceElementSelected(){let e=this._choiceElements.filter(r=>r.checked).map(r=>r.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(r=>r.disabled=!r.checked):this._choiceElements.forEach(r=>r.disabled=!1));let t;this.maxChoices===1?t=e.length>0?e[0]:void 0:t=e,this.saveResponse(t)}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"min-choices"})],E.prototype,"minChoices",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"max-choices"})],E.prototype,"maxChoices",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],E.prototype,"_handleDisabledChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("readonly",{waitUntilFirstUpdate:!0})],E.prototype,"_handleReadonlyChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("maxChoices",{waitUntilFirstUpdate:!0})],E.prototype,"_handleMaxChoicesChange",2);var ft=class extends E{constructor(){super(...arguments);this.render=()=>_lit.html`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",ft);var _unsafehtmljs = require('lit/directives/unsafe-html.js');var j=class extends b{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[_lit.css`
|
|
98
98
|
:host {
|
|
99
99
|
display: inline-block;
|
|
100
100
|
}
|
|
@@ -106,13 +106,13 @@
|
|
|
106
106
|
</select>
|
|
107
107
|
|
|
108
108
|
${_unsafehtmljs.unsafeHTML.call(void 0, this.correctOption)}
|
|
109
|
-
`}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(t=>e===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},r),{selected:r.value===t})),this.saveResponse(t)}};
|
|
109
|
+
`}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(t=>e===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>_chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},r),{selected:r.value===t})),this.saveResponse(t)}};j.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],j.prototype,"options",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],j.prototype,"correctOption",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"data-prompt",type:String})],j.prototype,"dataPrompt",2);customElements.define("qti-inline-choice-interaction",j);var cr=_lit.css`
|
|
110
110
|
:host {
|
|
111
111
|
display: flex;
|
|
112
112
|
flex-direction: column;
|
|
113
113
|
// align-items: flex-start;
|
|
114
114
|
}
|
|
115
|
-
`;var Q=class extends E{render(){return _lit.html` <slot name="prompt"></slot><slot part="slot"></slot>`}};Q.styles=
|
|
115
|
+
`;var Q=class extends E{render(){return _lit.html` <slot name="prompt"></slot><slot part="slot"></slot>`}};Q.styles=cr,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],Q.prototype,"orientation",2),Q= exports.QtiChoiceInteraction =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-choice-interaction")],Q);var pr=`<qti-response-processing>
|
|
116
116
|
<qti-response-condition>
|
|
117
117
|
<qti-response-if>
|
|
118
118
|
<qti-match>
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
</qti-set-outcome-value>
|
|
130
130
|
</qti-response-else>
|
|
131
131
|
</qti-response-condition>
|
|
132
|
-
</qti-response-processing>`,
|
|
132
|
+
</qti-response-processing>`,dr=`<qti-response-processing>
|
|
133
133
|
<qti-response-condition>
|
|
134
134
|
<qti-response-if>
|
|
135
135
|
<qti-is-null>
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
</qti-set-outcome-value>
|
|
146
146
|
</qti-response-else>
|
|
147
147
|
</qti-response-condition>
|
|
148
|
-
</qti-response-processing>`,
|
|
148
|
+
</qti-response-processing>`,ur=`<qti-response-processing>
|
|
149
149
|
<qti-response-condition>
|
|
150
150
|
<qti-response-if>
|
|
151
151
|
<qti-is-null>
|
|
@@ -161,19 +161,19 @@
|
|
|
161
161
|
</qti-set-outcome-value>
|
|
162
162
|
</qti-response-else>
|
|
163
163
|
</qti-response-condition>
|
|
164
|
-
</qti-response-processing>`;var
|
|
164
|
+
</qti-response-processing>`;var K=class extends _lit.LitElement{render(){return _lit.html`<slot></slot>`}process(){let i=[...this.children];for(let e of i)e.process()}firstUpdated(i){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(dr).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(ur).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(pr).firstElementChild.firstElementChild);break}}}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};K.styles=[_lit.css`
|
|
165
165
|
:host {
|
|
166
166
|
display: none;
|
|
167
167
|
}
|
|
168
|
-
`],
|
|
168
|
+
`],K= exports.QtiResponseProcessing =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-response-processing")],K);var V=class extends _lit.LitElement{render(){return _lit.html`<slot></slot>`}process(){throw new Error("Not implemented")}};V= exports.QtiRule =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-rule")],V);var Ve=class extends V{get childExpression(){return this.firstElementChild}process(){let e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getVariable(e),r;return t.interpolationTable&&(r=t.interpolationTable.get(parseInt(this.childExpression.calculate()))),r==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:ue(r)}})),r)}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],Ve.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Ve);var bt=class extends V{render(){return _lit.html`<slot></slot>`}process(){let i=[...this.children];for(let e=0;e<i.length;e++){let t=i[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",bt);var gt=class extends V{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,t=e?e.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:Array.isArray(t)?t.map(r=>ue(r)):ue(t)}}))}};customElements.define("qti-set-outcome-value",gt);var me=class extends _lit.LitElement{render(){return _lit.html`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let i=this.getSubRules();for(let e=0;e<i.length;e++)i[e].process()}};customElements.define("qti-response-else",me);var he=class extends me{calculate(){return this.firstElementChild.calculate()}getSubRules(){let i=[];for(let e=1;e<this.children.length;e++)i.push(this.children[e]);return i}};customElements.define("qti-response-if",he);var vt=class extends he{render(){return _lit.html`${super.render()}`}};customElements.define("qti-response-else-if",vt);var m=class extends _lit.LitElement{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent,cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.assessmentItem.getVariable(t)}case"qti-multiple":{let r=e.getResult();return r.length>0?{identifier:"",baseType:r[0].baseType,value:r.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.assessmentItem.getResponse(t);return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch(t){console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return _lit.html`<pre>${JSON.stringify(this.result,null,2)}</pre>
|
|
169
169
|
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};m.styles=_lit.css`
|
|
170
170
|
slot {
|
|
171
171
|
display: none;
|
|
172
172
|
}
|
|
173
|
-
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],m.prototype,"result",2);var $=class extends m{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var He=class extends Zi($){calculate(){return this.calculateChildren(Array.from(this.children))}};function Zi(a){return class extends a{calculateChildren(e){return e.map(r=>{let s=r;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=s.calculate();if(typeof o=="string")if(o==="true")o=!0;else if(o==="false")o=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return o}).every(r=>typeof r=="boolean"&&r)}}}customElements.define("qti-and",He);var Ve=class extends m{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"base-type"})],Ve.prototype,"baseType",2);customElements.define("qti-base-value",Ve);var vt=class extends ${getResult(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,s=t.value;return r.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",vt);var yt=class extends m{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",yt);var Ne=class extends m{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),o=parseFloat(r.value);if(!isNaN(s)&&!isNaN(o))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===o.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${o}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],Ne.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Ne);var T=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),s=parseInt(e,10);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),s=parseFloat(e);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),s=e.split(" ").sort();if(r.length===2&&s.length===2)return t==="pair"&&(r.sort(),s.sort()),r.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var De=class extends m{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):T.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],De.prototype,"toleranceMode",2);customElements.define("qti-equal",De);var xt=class extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",xt);var Et=class extends ${getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",Et);var _t=class extends m{getResult(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",_t);var Ct=class extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Ct);var qt=class extends ${getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",qt);var Pe=class extends m{getResult(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],s=0;for(let o of r){let c=t.mapEntries.find(l=>T.compareSingleValues(l.mapKey,o,e.baseType));c==null||c.mappedValue==null?s+=t.defaultValue:s+=c.mappedValue}return t.lowerBound!=null&&(s=Math.max(t.lowerBound,s)),t.upperBound!=null&&(s=Math.min(t.upperBound,s)),s}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],Pe.prototype,"identifier",2);customElements.define("qti-map-response",Pe);var ee=class extends _lit.LitElement{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"default-value",type:Number})],ee.prototype,"defaultValue",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"lower-bound",type:Number})],ee.prototype,"lowerBound",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"upper-bound",type:Number})],ee.prototype,"upperBound",2);customElements.define("qti-mapping",ee);var kt=class a extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return a.match(e,t)}return console.error("unexpected number of children in match"),null}static match(i,e){var t;if(e.cardinality==="single")return i.value===null?!1:Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):T.compareSingleValues((t=i.value)==null?void 0:t.toString(),e.value.toString(),e.baseType);{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;let r=0;for(let s of e.value){if(e.cardinality==="ordered"){let o=i[r];if(!T.compareSingleValues(s,o,e.baseType))return!1}else{let o=null;for(let c of i.value)if(T.compareSingleValues(s,c,e.baseType)){o=c;break}if(o!==null)i.value.splice(i.value.indexOf(o),1);else return!1}r++}return!0}}};customElements.define("qti-match",kt);var wt=class extends m{getResult(){let i=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=i;if(e.baseType!==t.baseType&&console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let r=e.value;return t.value.includes(r)}};customElements.define("qti-member",wt);var $t=class extends m{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",$t);var Tt=class extends m{render(){return _lit.html`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Tt);var Rt=class extends ${getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-or, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Rt);var St=class extends m{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",St);var fe=class extends _lit.LitElement{render(){var t,r;let e=(r=(t=this.itemContext)==null?void 0:t.variables.find(s=>s.identifier===this.identifier))==null?void 0:r.value;return _lit.html`${JSON.stringify(e,null,2)}`}calculate(){let e=this.closest("qti-assessment-item"),t=this.identifier;return e.getVariable(t).value}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],fe.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_context2.consume.call(void 0, {context:D,subscribe:!0}),_decoratorsjs.state.call(void 0, )],fe.prototype,"itemContext",2);customElements.define("qti-printed-variable",fe);var Lt=class extends m{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch(s){console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",Lt);var Oe=class extends m{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),o=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return T.compareSingleValues(s,o,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"case-sensitive"})],Oe.prototype,"caseSensitive",2);customElements.define("qti-string-match",Oe);var Mt=class extends m{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Mt);var Ht=class extends m{getResult(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariable(i).value}};customElements.define("qti-variable",Ht);var Vt=class extends _lit.LitElement{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){let t=e.querySelectorAll("properties"),r={},s=c=>{let l={},p=c.getAttribute("key");if(p){let d=Array.from(c.children),u=d.map(h=>h.getAttribute("key"));u.length>0&&!u.find(h=>!Number.isInteger(+h))?l[p]=d.map(h=>o(h)):l[p]=c.textContent}return l},o=c=>{if(c){let l={};for(let p of c.children)l=_chunkKRFEDZFGcjs.a.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},l),s(p));return l}};for(let c of t)return c.getAttribute("key")||(r=_chunkKRFEDZFGcjs.a.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},r),o(c))),r;console.log("Can not find qti-custom-interaction config")}register(e){let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let s=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,s,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,s),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(c=>c.getAttribute("href")).forEach(c=>{let l=document.createElement("link");l.rel="stylesheet",l.type="text/css",l.media="screen",l.href=c,r.appendChild(l)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}requirejs.config(e)(["require"],r=>{!r.defined("qtiCustomInteractionContext")&&define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}}));let s=r.defined(this.module);r([this.module],o=>{s&&this.register(o)},o=>{this._errorMessage=o})},r=>{this._errorMessage=r})}render(){return _lit.html`<slot></slot>${this._errorMessage&&_lit.html`<div style="color:red">
|
|
173
|
+
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],m.prototype,"result",2);var $=class extends m{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Ne=class extends Gi($){calculate(){return this.calculateChildren(Array.from(this.children))}};function Gi(a){return class extends a{calculateChildren(e){return e.map(r=>{let s=r;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=s.calculate();if(typeof o=="string")if(o==="true")o=!0;else if(o==="false")o=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return o}).every(r=>typeof r=="boolean"&&r)}}}customElements.define("qti-and",Ne);var He=class extends m{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"base-type"})],He.prototype,"baseType",2);customElements.define("qti-base-value",He);var yt=class extends ${getResult(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,s=t.value;return r.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",yt);var xt=class extends m{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",xt);var De=class extends m{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),o=parseFloat(r.value);if(!isNaN(s)&&!isNaN(o))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===o.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${o}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],De.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",De);var R=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),s=parseInt(e,10);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),s=parseFloat(e);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),s=e.split(" ").sort();if(r.length===2&&s.length===2)return t==="pair"&&(r.sort(),s.sort()),r.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var Pe=class extends m{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):R.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],Pe.prototype,"toleranceMode",2);customElements.define("qti-equal",Pe);var Et=class extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",Et);var _t=class extends ${getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",_t);var Ct=class extends m{getResult(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Ct);var qt=class extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",qt);var At=class extends ${getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",At);var Oe=class extends m{getResult(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],s=0;for(let o of r){let c=t.mapEntries.find(l=>R.compareSingleValues(l.mapKey,o,e.baseType));c==null||c.mappedValue==null?s+=t.defaultValue:s+=c.mappedValue}return t.lowerBound!=null&&(s=Math.max(t.lowerBound,s)),t.upperBound!=null&&(s=Math.min(t.upperBound,s)),s}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],Oe.prototype,"identifier",2);customElements.define("qti-map-response",Oe);var ee=class extends _lit.LitElement{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"default-value",type:Number})],ee.prototype,"defaultValue",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"lower-bound",type:Number})],ee.prototype,"lowerBound",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"upper-bound",type:Number})],ee.prototype,"upperBound",2);customElements.define("qti-mapping",ee);var wt=class a extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return a.match(e,t)}return console.error("unexpected number of children in match"),null}static match(i,e){var t;if(e.cardinality==="single")return i.value===null?!1:Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):R.compareSingleValues((t=i.value)==null?void 0:t.toString(),e.value.toString(),e.baseType);{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;let r=0;for(let s of e.value){if(e.cardinality==="ordered"){let o=i[r];if(!R.compareSingleValues(s,o,e.baseType))return!1}else{let o=null;for(let c of i.value)if(R.compareSingleValues(s,c,e.baseType)){o=c;break}if(o!==null)i.value.splice(i.value.indexOf(o),1);else return!1}r++}return!0}}};customElements.define("qti-match",wt);var $t=class extends m{getResult(){let i=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=i;if(e.baseType!==t.baseType&&console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let r=e.value;return t.value.includes(r)}};customElements.define("qti-member",$t);var Rt=class extends m{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",Rt);var Tt=class extends m{render(){return _lit.html`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Tt);var St=class extends ${getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-or, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",St);var Lt=class extends m{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",Lt);var fe=class extends _lit.LitElement{render(){var t,r;let e=(r=(t=this.itemContext)==null?void 0:t.variables.find(s=>s.identifier===this.identifier))==null?void 0:r.value;return _lit.html`${JSON.stringify(e,null,2)}`}calculate(){let e=this.closest("qti-assessment-item"),t=this.identifier;return e.getVariable(t).value}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],fe.prototype,"identifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_context2.consume.call(void 0, {context:S,subscribe:!0}),_decoratorsjs.state.call(void 0, )],fe.prototype,"itemContext",2);customElements.define("qti-printed-variable",fe);var Mt=class extends m{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch(s){console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",Mt);var Ue=class extends m{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),o=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return R.compareSingleValues(s,o,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"case-sensitive"})],Ue.prototype,"caseSensitive",2);customElements.define("qti-string-match",Ue);var Vt=class extends m{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Vt);var Nt=class extends m{getResult(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariable(i).value}};customElements.define("qti-variable",Nt);var Ht=class extends _lit.LitElement{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){let t=e.querySelectorAll("properties"),r={},s=c=>{let l={},p=c.getAttribute("key");if(p){let d=Array.from(c.children),u=d.map(h=>h.getAttribute("key"));u.length>0&&!u.find(h=>!Number.isInteger(+h))?l[p]=d.map(h=>o(h)):l[p]=c.textContent}return l},o=c=>{if(c){let l={};for(let p of c.children)l=_chunkKRFEDZFGcjs.a.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},l),s(p));return l}};for(let c of t)return c.getAttribute("key")||(r=_chunkKRFEDZFGcjs.a.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},r),o(c))),r;console.log("Can not find qti-custom-interaction config")}register(e){let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let s=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,s,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,s),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(c=>c.getAttribute("href")).forEach(c=>{let l=document.createElement("link");l.rel="stylesheet",l.type="text/css",l.media="screen",l.href=c,r.appendChild(l)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}requirejs.config(e)(["require"],r=>{!r.defined("qtiCustomInteractionContext")&&define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}}));let s=r.defined(this.module);r([this.module],o=>{s&&this.register(o)},o=>{this._errorMessage=o})},r=>{this._errorMessage=r})}render(){return _lit.html`<slot></slot>${this._errorMessage&&_lit.html`<div style="color:red">
|
|
174
174
|
<h1>Error</h1>
|
|
175
175
|
${this._errorMessage}
|
|
176
|
-
</div>`}`}};customElements.define("qti-portable-custom-interaction",Vt);var Ue=class a{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return a._instance?a._instance:(a._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPoint(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPoint(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e=this._getPoint(i);return this.elementFromPoint(e.x,e.y)}elementFromPoint(i,e){let t=document.elementFromPoint(i,e);if(t){for(;t.shadowRoot;){let r=t.shadowRoot.elementFromPoint(i,e);if(r===null||r===t)break;t=r}return t}return null}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}};var mr=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(o){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(o);let c=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),c.forEach(l=>{l.setAttribute("dropzone","move"),l.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(l)});for(let l of c)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{l.hasAttribute("disabled")?this.removeHandler(l):this.attachHandler(l);break}}})}),this.observer.observe(l,{attributes:!0})}attachHandler(o){o.addEventListener("dragover",this.dragoverHandler),o.addEventListener("dragenter",this.dragenterHandler),o.addEventListener("drop",this.dropHandler)}removeHandler(o){o.removeEventListener("dragover",this.dragoverHandler),o.removeEventListener("dragenter",this.dragenterHandler),o.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var o;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(o=this.observer)==null||o.disconnect())}dragenterHandler(o){o.preventDefault()}dragoverHandler(o){return o.preventDefault(),o.currentTarget.setAttribute("active",""),o.dataTransfer.dropEffect="move",!1}dropHandler(o){o.preventDefault();let c=o.currentTarget,l=this.querySelector(`[identifier=${o.dataTransfer.getData("text")}`),p=l||this.shadowRoot.querySelector(`[identifier=${o.dataTransfer.getData("text")}`);return c?p.parentElement.getAttribute("identifier")!==c.getAttribute("identifier")&&c.appendChild(p):console.error(`cannot find droppable, target: ${o.target?JSON.stringify(o.target):"null"}`),c.removeAttribute("active"),!1}dragleaveHandler(o){return o.preventDefault(),o.currentTarget.removeAttribute("active"),o.dataTransfer.dropEffect="none",!1}}return _chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var hr=(a,i,e)=>{class t extends a{}return t};var H=(a,i,e,t)=>{class r extends hr(mr(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(c,l){if(this.classList.contains("qti-match-tabular"))return;c.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(c),c.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",u=>{u.dataTransfer.setData("text",u.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",u=>{if(u.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),(u.dataTransfer.dropEffect==="none"||u.dataTransfer.dropEffect===void 0)&&this.configuration.dragCanBePlacedBack){let g=u.currentTarget,h=this.draggables.get(g),R=h.index<h.parent.children.length?h.index:h.parent.children.length-1,v=h.parent,V=h.parent.children[R];v.insertBefore(g,V),this.saveResponse(),this.checkMaxMatchAssociations()}u.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(c,l){this.dragDropApi.copyStylesDragClone=l.copyStylesDragClone,this.dragDropApi.dragOnClick=l.dragOnClick}handleDisabledChange(c,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("disabled",""):d.removeAttribute("disabled"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(c,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("readonly",""):d.removeAttribute("readonly"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(c){super.firstUpdated(c),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new Ue,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(c=!0){this.draggables.forEach((l,p)=>{let d=l.parent.children,u=l.index<d.length?l.index:d.length;l.parent.insertBefore(p,d[u])}),c&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(c=>{let p=+(c.getAttribute("match-max")||1)<=(c.children.length||0);p?c.setAttribute("disabled",""):c.removeAttribute("disabled"),p?c.removeAttribute("dropzone"):c.setAttribute("dropzone","move")})}set response(c){this.classList.contains("qti-match-tabular")||(this.reset(!1),c!==null&&Array.isArray(c)&&c.forEach(l=>{let[p,...d]=l.split(" ").reverse();if(p){let u=this.droppables.find(g=>g.getAttribute("identifier")===p);d.forEach(g=>{let h=this.querySelector(`[identifier=${g}]`);u?h?(u.appendChild(h),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${g}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let l=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=l}saveResponse(){let c=this.droppables.map(l=>{var d;let p="";return((d=l.children)==null?void 0:d.length)>0&&(p+=Array.from(l.children).map(u=>u.getAttribute("identifier")).join(" ")+" "),p+=l.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:c}}))}}return _chunkKRFEDZFGcjs.c.call(void 0, [rr(i)],r.prototype,"reInitDragAndDrop",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:!1,type:Object})],r.prototype,"configuration",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("configuration")],r.prototype,"handleDragOptionsChanged",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],r.prototype,"disabled",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],r.prototype,"readonly",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};var be=class extends H(_lit.LitElement,"qti-simple-associable-choice",!0,".dl"){render(){return _lit.html` <slot name="prompt"></slot>
|
|
176
|
+
</div>`}`}};customElements.define("qti-portable-custom-interaction",Ht);var Ie=class a{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return a._instance?a._instance:(a._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPoint(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPoint(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e=this._getPoint(i);return this.elementFromPoint(e.x,e.y)}elementFromPoint(i,e){let t=document.elementFromPoint(i,e);if(t){for(;t.shadowRoot;){let r=t.shadowRoot.elementFromPoint(i,e);if(r===null||r===t)break;t=r}return t}return null}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}};var hr=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(o){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(o);let c=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),c.forEach(l=>{l.setAttribute("dropzone","move"),l.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(l)});for(let l of c)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{l.hasAttribute("disabled")?this.removeHandler(l):this.attachHandler(l);break}}})}),this.observer.observe(l,{attributes:!0})}attachHandler(o){o.addEventListener("dragover",this.dragoverHandler),o.addEventListener("dragenter",this.dragenterHandler),o.addEventListener("drop",this.dropHandler)}removeHandler(o){o.removeEventListener("dragover",this.dragoverHandler),o.removeEventListener("dragenter",this.dragenterHandler),o.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var o;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(o=this.observer)==null||o.disconnect())}dragenterHandler(o){o.preventDefault()}dragoverHandler(o){return o.preventDefault(),o.currentTarget.setAttribute("active",""),o.dataTransfer.dropEffect="move",!1}dropHandler(o){o.preventDefault();let c=o.currentTarget,l=this.querySelector(`[identifier=${o.dataTransfer.getData("text")}`),p=l||this.shadowRoot.querySelector(`[identifier=${o.dataTransfer.getData("text")}`);return c?p.parentElement.getAttribute("identifier")!==c.getAttribute("identifier")&&c.appendChild(p):console.error(`cannot find droppable, target: ${o.target?JSON.stringify(o.target):"null"}`),c.removeAttribute("active"),!1}dragleaveHandler(o){return o.preventDefault(),o.currentTarget.removeAttribute("active"),o.dataTransfer.dropEffect="none",!1}}return _chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var fr=(a,i,e)=>{class t extends a{}return t};var N=(a,i,e,t)=>{class r extends fr(hr(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(c,l){if(this.classList.contains("qti-match-tabular"))return;c.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(c),c.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",u=>{u.dataTransfer.setData("text",u.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",u=>{if(u.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),(u.dataTransfer.dropEffect==="none"||u.dataTransfer.dropEffect===void 0)&&this.configuration.dragCanBePlacedBack){let g=u.currentTarget,h=this.draggables.get(g),T=h.index<h.parent.children.length?h.index:h.parent.children.length-1,v=h.parent,H=h.parent.children[T];v.insertBefore(g,H),this.saveResponse(),this.checkMaxMatchAssociations()}u.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(c,l){this.dragDropApi.copyStylesDragClone=l.copyStylesDragClone,this.dragDropApi.dragOnClick=l.dragOnClick}handleDisabledChange(c,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("disabled",""):d.removeAttribute("disabled"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(c,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("readonly",""):d.removeAttribute("readonly"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(c){super.firstUpdated(c),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new Ie,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(c=!0){this.draggables.forEach((l,p)=>{let d=l.parent.children,u=l.index<d.length?l.index:d.length;l.parent.insertBefore(p,d[u])}),c&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(c=>{let p=+(c.getAttribute("match-max")||1)<=(c.children.length||0);p?c.setAttribute("disabled",""):c.removeAttribute("disabled"),p?c.removeAttribute("dropzone"):c.setAttribute("dropzone","move")})}set response(c){this.classList.contains("qti-match-tabular")||(this.reset(!1),c!==null&&Array.isArray(c)&&c.forEach(l=>{let[p,...d]=l.split(" ").reverse();if(p){let u=this.droppables.find(g=>g.getAttribute("identifier")===p);d.forEach(g=>{let h=this.querySelector(`[identifier=${g}]`);u?h?(u.appendChild(h),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${g}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let l=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=l}saveResponse(){let c=this.droppables.map(l=>{var d;let p="";return((d=l.children)==null?void 0:d.length)>0&&(p+=Array.from(l.children).map(u=>u.getAttribute("identifier")).join(" ")+" "),p+=l.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:c}}))}}return _chunkKRFEDZFGcjs.c.call(void 0, [ir(i)],r.prototype,"reInitDragAndDrop",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:!1,type:Object})],r.prototype,"configuration",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("configuration")],r.prototype,"handleDragOptionsChanged",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],r.prototype,"disabled",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],r.prototype,"readonly",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};var be=class extends N(_lit.LitElement,"qti-simple-associable-choice",!0,".dl"){render(){return _lit.html` <slot name="prompt"></slot>
|
|
177
177
|
<slot name="qti-simple-associable-choice"></slot>
|
|
178
178
|
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>_lit.html`<div part="associables-container">
|
|
179
179
|
<div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
|
|
@@ -187,8 +187,8 @@
|
|
|
187
187
|
flex-wrap: wrap;
|
|
188
188
|
gap: 0.5rem;
|
|
189
189
|
}
|
|
190
|
-
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],be.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",be);var
|
|
191
|
-
<slot part="drops"></slot>`}};
|
|
190
|
+
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],be.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",be);var Fe=class extends N(_lit.LitElement,"qti-gap-text",!1,"qti-gap"){render(){return _lit.html` <slot part="drags" name="qti-gap-text"></slot>
|
|
191
|
+
<slot part="drops"></slot>`}};Fe.styles=[_lit.css`
|
|
192
192
|
:host {
|
|
193
193
|
display: flex;
|
|
194
194
|
align-items: flex-start;
|
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
align-items: flex-start;
|
|
212
212
|
flex: 1;
|
|
213
213
|
}
|
|
214
|
-
`];customElements.define("qti-gap-match-interaction",
|
|
214
|
+
`];customElements.define("qti-gap-match-interaction",Fe);function re(a,i,e,t){switch(a){case"circle":{let[r,s,o]=i,c=r/e.width*100,l=s/e.height*100,p=o/e.width*100;t.style.left=c-p+"%",t.style.top=l-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,s,o,c]=i,l=r/e.width*100,p=s/e.height*100,d=o/e.width*100,u=c/e.height*100;t.style.left=l+"%",t.style.top=p+"%",t.style.width=d-l+"%",t.style.height=u-p+"%"}break;case"poly":{let r=i.reduce((v,H,It,Ar)=>{if(It%2===1){let kr=v.pop();v[v.length]={x:kr,y:Ar[It]}}else v.push(H);return v},[]),s=Math.min(...r.map(v=>v.x)),o=Math.max(...r.map(v=>v.x)),c=Math.min(...r.map(v=>v.y)),l=Math.max(...r.map(v=>v.y)),p=s/e.width*100,d=c/e.height*100,u=o/e.width*100,g=l/e.height*100;t.style.left=s/e.width*100+"%",t.style.top=c/e.height*100+"%",t.style.width=u-p+"%",t.style.height=g-d+"%";let T=r.map(v=>({x:(v.x-s)/(o-s)*100,y:(v.y-c)/(l-c)*100})).map(v=>Math.round(v.x)+"% "+Math.round(v.y)+"%").join(",");t.style.clipPath=`polygon(${T})`}break;default:break}}var _repeatjs = require('lit/directives/repeat.js');var D=class extends b{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,s;return _lit.html`<slot name="prompt"></slot>
|
|
215
215
|
<line-container>
|
|
216
216
|
<svg
|
|
217
217
|
width=${_ifdefinedjs.ifDefined.call(void 0, (e=this.grImage[0])==null?void 0:e.width)}
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
/>`}
|
|
242
242
|
</svg>
|
|
243
243
|
<slot></slot>
|
|
244
|
-
</line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),o=r.getAttribute("shape"),c=s.split(",").map(l=>parseInt(l));re(o,c,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=document.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",t=>{this.mouseCoord={x:t.clientX-this.grImage[0].getBoundingClientRect().left,y:t.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",r=>{this.startPoint?this.endPoint||(this.endPoint=r.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=r.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};
|
|
244
|
+
</line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),o=r.getAttribute("shape"),c=s.split(",").map(l=>parseInt(l));re(o,c,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=document.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",t=>{this.mouseCoord={x:t.clientX-this.grImage[0].getBoundingClientRect().left,y:t.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",r=>{this.startPoint?this.endPoint||(this.endPoint=r.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=r.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};D.styles=[_lit.css`
|
|
245
245
|
slot:not([name='prompt']) {
|
|
246
246
|
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
247
247
|
display: block;
|
|
@@ -264,8 +264,8 @@
|
|
|
264
264
|
top: 0px;
|
|
265
265
|
left: 0px;
|
|
266
266
|
}
|
|
267
|
-
`],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],
|
|
268
|
-
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),o=r.split(",").map(c=>parseInt(c));switch(s){case"circle":{let[c,l,p]=o;t.style.left=c-p+"px",t.style.top=l-p+"px",t.style.width=t.style.height=2*p+"px"}break;case"rect":{let[c,l,p,d]=o;t.style.left=c+"px",t.style.top=l+"px",t.style.width=p-c+"px",t.style.height=d-l+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};
|
|
267
|
+
`],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],D.prototype,"_lines",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],D.prototype,"startCoord",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],D.prototype,"mouseCoord",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.query.call(void 0, "svg")],D.prototype,"svgContainer",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.queryAssignedElements.call(void 0, {selector:"img"})],D.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",D);var Xe=class extends N(_lit.LitElement,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return _lit.html` <slot></slot>
|
|
268
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),o=r.split(",").map(c=>parseInt(c));switch(s){case"circle":{let[c,l,p]=o;t.style.left=c-p+"px",t.style.top=l-p+"px",t.style.width=t.style.height=2*p+"px"}break;case"rect":{let[c,l,p,d]=o;t.style.left=c+"px",t.style.top=l+"px",t.style.width=p-c+"px",t.style.height=d-l+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Xe.styles=_lit.css`
|
|
269
269
|
:host {
|
|
270
270
|
display: inline-block;
|
|
271
271
|
position: relative;
|
|
@@ -274,12 +274,12 @@
|
|
|
274
274
|
display: flex;
|
|
275
275
|
gap: 1rem;
|
|
276
276
|
}
|
|
277
|
-
`;customElements.define("qti-graphic-gap-match-interaction",
|
|
277
|
+
`;customElements.define("qti-graphic-gap-match-interaction",Xe);var Ye=class extends E{render(){return _lit.html`
|
|
278
278
|
<slot name="prompt"></slot>
|
|
279
279
|
<!-- slot for the prompt -->
|
|
280
280
|
<slot></slot>
|
|
281
281
|
<!-- slot for the image and hotspots -->
|
|
282
|
-
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(o=>o.getAttribute("identifier")===t),s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(o=>o.order>0).length>=s){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(o=>!!o.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(o=>(o.order>o.order&&o.order--,o)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),o=r.getAttribute("shape"),c=s.split(",").map(l=>parseInt(l));re(o,c,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};
|
|
282
|
+
`}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(o=>o.getAttribute("identifier")===t),s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(o=>o.order>0).length>=s){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(o=>!!o.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(o=>(o.order>o.order&&o.order--,o)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),o=r.getAttribute("shape"),c=s.split(",").map(l=>parseInt(l));re(o,c,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};Ye.styles=[_lit.css`
|
|
283
283
|
slot:not([name='prompt']) {
|
|
284
284
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
285
285
|
display: block;
|
|
@@ -290,12 +290,12 @@
|
|
|
290
290
|
pointer-events: none;
|
|
291
291
|
user-select: none;
|
|
292
292
|
}
|
|
293
|
-
`];customElements.define("qti-graphic-order-interaction",
|
|
293
|
+
`];customElements.define("qti-graphic-order-interaction",Ye);var Be=class extends E{render(){return _lit.html`
|
|
294
294
|
<slot name="prompt"></slot>
|
|
295
295
|
<!-- slot for the prompt -->
|
|
296
296
|
<slot></slot>
|
|
297
297
|
<!-- slot for the image and hotspots -->
|
|
298
|
-
`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),o=r.split(",").map(c=>parseInt(c));re(s,o,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};
|
|
298
|
+
`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),o=r.split(",").map(c=>parseInt(c));re(s,o,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};Be.styles=[_lit.css`
|
|
299
299
|
slot:not([name='prompt']) {
|
|
300
300
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
301
301
|
display: block;
|
|
@@ -307,10 +307,10 @@
|
|
|
307
307
|
user-select: none;
|
|
308
308
|
/* width:100%; */
|
|
309
309
|
}
|
|
310
|
-
`];customElements.define("qti-hotspot-interaction",
|
|
310
|
+
`];customElements.define("qti-hotspot-interaction",Be);var Pt=class extends _lit.LitElement{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return _lit.html`
|
|
311
311
|
<slot></slot>
|
|
312
312
|
<slot name="qti-simple-associable-choice"></slot>
|
|
313
|
-
`}};customElements.define("qti-simple-associable-choice",
|
|
313
|
+
`}};customElements.define("qti-simple-associable-choice",Pt);var ie=class extends N(_lit.LitElement,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){constructor(){super(...arguments);this.response=[];this.responseIdentifier=""}connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}render(){return this.classList.contains("qti-match-tabular")?_lit.html`
|
|
314
314
|
<slot name="prompt"></slot>
|
|
315
315
|
<table>
|
|
316
316
|
<tr>
|
|
@@ -329,8 +329,8 @@
|
|
|
329
329
|
</td>`})}
|
|
330
330
|
</tr>`)}
|
|
331
331
|
</table>
|
|
332
|
-
`:_lit.html`<slot name="prompt"></slot> <slot></slot>`}};ie.styles=[],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],ie.prototype,"response",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"response-identifier"})],ie.prototype,"responseIdentifier",2);customElements.define("qti-match-interaction",ie);var
|
|
333
|
-
<slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this.value++,this.saveResponse(this.value.toString())})}};
|
|
332
|
+
`:_lit.html`<slot name="prompt"></slot> <slot></slot>`}};ie.styles=[],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],ie.prototype,"response",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"response-identifier"})],ie.prototype,"responseIdentifier",2);customElements.define("qti-match-interaction",ie);var je=class extends b{constructor(){super();this.value=0}reset(){}validate(){return!0}set response(e){}static get properties(){return _chunkKRFEDZFGcjs.b.call(void 0, _chunkKRFEDZFGcjs.a.call(void 0, {},b.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return _lit.html` <slot name="prompt"></slot>
|
|
333
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this.value++,this.saveResponse(this.value.toString())})}};je.styles=[_lit.css``];customElements.define("qti-media-interaction",je);var se=class extends N(_lit.LitElement,"qti-simple-choice",!0,"drop-list"){render(){return _lit.html` <slot name="prompt"> </slot>
|
|
334
334
|
<div part="container">
|
|
335
335
|
<slot part="drags"> </slot>
|
|
336
336
|
<div part="drops">
|
|
@@ -395,12 +395,12 @@
|
|
|
395
395
|
left: 50%;
|
|
396
396
|
transform: translateX(-50%);
|
|
397
397
|
}
|
|
398
|
-
`];customElements.define("qti-position-object-interaction",Ke);var
|
|
398
|
+
`];customElements.define("qti-position-object-interaction",Ke);var ze=class extends _lit.LitElement{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return _lit.html`<slot></slot>`}dragElementHandler(e){e.preventDefault();let t=e.clientX-this.startX,r=e.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+t+"px",this.dragElement.style.top=this.dragElement.offsetTop+r+"px",this.startX=e.clientX,this.startY=e.clientY}firstUpdated(e){super.firstUpdated(e),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",t=>{this.startX=t.clientX,this.startY=t.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(e){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};ze.styles=[_lit.css`
|
|
399
399
|
:host {
|
|
400
400
|
display: inline-block;
|
|
401
401
|
position: relative;
|
|
402
402
|
}
|
|
403
|
-
`];customElements.define("qti-position-object-stage",
|
|
403
|
+
`];customElements.define("qti-position-object-stage",ze);var _stylemapjs = require('lit/directives/style-map.js');var z=class extends b{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return _lit.html` <slot name="prompt"></slot>
|
|
404
404
|
<point-container>
|
|
405
405
|
${_repeatjs.repeat.call(void 0, this._points,e=>e,(e,t)=>_lit.html`
|
|
406
406
|
<button
|
|
@@ -431,16 +431,16 @@
|
|
|
431
431
|
${this.csLive.getPropertyValue("--show-value")=="true"?_lit.html`<div id="value" part="value">${this.value}</div>`:_lit.nothing}
|
|
432
432
|
</div>
|
|
433
433
|
</div>
|
|
434
|
-
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=c=>{let{x:l}=this.getPositionFromEvent(c),p=l-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),c.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:s}=this.getPositionFromEvent(e),o=s-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.stopPropagation()}_onMouseDown(e){let t=o=>{let c=o.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(c),o.preventDefault(),o.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let s=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,s=r.touches[0]||r.changedTouches[0];t={x:s.pageX,y:s.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};C.styles=[_lit.css``],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.query.call(void 0, "#knob")],C.prototype,"_knob",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.query.call(void 0, "#rail")],C.prototype,"_rail",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number})],C.prototype,"value",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,attribute:"step-label"})],C.prototype,"stepLabel",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean})],C.prototype,"reverse",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"lower-bound"})],C.prototype,"min",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"upper-bound"})],C.prototype,"max",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"step"})],C.prototype,"step",1),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],C.prototype,"_handleDisabledChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("readonly",{waitUntilFirstUpdate:!0})],C.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",C);var ne=class extends b{constructor(){super(...arguments);this.countAttempt="true"}validate(){return!0}set response(e){}render(){return _lit.html`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"count-attempt"})],ne.prototype,"countAttempt",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],ne.prototype,"title",2),ne= exports.QtiEndAttemptInteraction =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-end-attempt-interaction")],ne);var
|
|
434
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=c=>{let{x:l}=this.getPositionFromEvent(c),p=l-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),c.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:s}=this.getPositionFromEvent(e),o=s-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.stopPropagation()}_onMouseDown(e){let t=o=>{let c=o.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(c),o.preventDefault(),o.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let s=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,s=r.touches[0]||r.changedTouches[0];t={x:s.pageX,y:s.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};C.styles=[_lit.css``],_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.query.call(void 0, "#knob")],C.prototype,"_knob",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.query.call(void 0, "#rail")],C.prototype,"_rail",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number})],C.prototype,"value",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,attribute:"step-label"})],C.prototype,"stepLabel",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean})],C.prototype,"reverse",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"lower-bound"})],C.prototype,"min",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"upper-bound"})],C.prototype,"max",1),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"step"})],C.prototype,"step",1),_chunkKRFEDZFGcjs.c.call(void 0, [y("disabled",{waitUntilFirstUpdate:!0})],C.prototype,"_handleDisabledChange",2),_chunkKRFEDZFGcjs.c.call(void 0, [y("readonly",{waitUntilFirstUpdate:!0})],C.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",C);var ne=class extends b{constructor(){super(...arguments);this.countAttempt="true"}validate(){return!0}set response(e){}render(){return _lit.html`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"count-attempt"})],ne.prototype,"countAttempt",2),_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String})],ne.prototype,"title",2),ne= exports.QtiEndAttemptInteraction =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-end-attempt-interaction")],ne);var Je=class extends _lit.LitElement{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return _lit.html` <slot name="qti-gap-img"></slot> `}};Je.styles=_lit.css`
|
|
435
435
|
:host {
|
|
436
436
|
position: absolute;
|
|
437
437
|
}
|
|
438
|
-
`;customElements.define("qti-associable-hotspot",
|
|
438
|
+
`;customElements.define("qti-associable-hotspot",Je);var Ze=class extends _lit.LitElement{constructor(){super(...arguments);this.tabindex=0}render(){return _lit.html` <slot name="qti-gap-text"></slot>`}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0})],Ze.prototype,"tabindex",2);customElements.define("qti-gap",Ze);var Ge=class extends _lit.LitElement{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0})],Ge.prototype,"tabindex",2);customElements.define("qti-gap-img",Ge);var Qe=class extends _lit.LitElement{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return _lit.html`<slot></slot>`}};_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,reflect:!0})],Qe.prototype,"tabindex",2);customElements.define("qti-gap-text",Qe);var ve=class extends _{};ve.styles=_lit.css`
|
|
439
439
|
:host {
|
|
440
440
|
position: absolute;
|
|
441
441
|
}
|
|
442
|
-
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"aria-ordervalue",type:Number,reflect:!0})],ve.prototype,"order",2);customElements.define("qti-hotspot-choice",ve);var
|
|
443
|
-
<slot></slot> `}};
|
|
442
|
+
`,_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {attribute:"aria-ordervalue",type:Number,reflect:!0})],ve.prototype,"order",2);customElements.define("qti-hotspot-choice",ve);var et=class extends _{render(){return _lit.html`<div part="ch"><div part="cha"></div></div>
|
|
443
|
+
<slot></slot> `}};et= exports.QtiHottext =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-hottext")],et);var Ut=class extends _lit.LitElement{};customElements.define("qti-inline-choice",Ut);var ye=class extends _{render(){return _lit.html`<div part="ch"><div part="cha"></div></div>
|
|
444
444
|
<slot part="slot"></slot> `}};ye.styles=_lit.css`
|
|
445
445
|
:host {
|
|
446
446
|
display: flex;
|
|
@@ -449,7 +449,7 @@
|
|
|
449
449
|
width: 100%;
|
|
450
450
|
display: block;
|
|
451
451
|
}
|
|
452
|
-
`,ye= exports.QtiSimpleChoice =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-simple-choice")],ye);exports.Interaction = b; exports.QtPrintedVariable = fe; exports.QtiAnd =
|
|
452
|
+
`,ye= exports.QtiSimpleChoice =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-simple-choice")],ye);var xe=class extends _lit.LitElement{render(){return _lit.html`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(e){var r,s,o;let t=Array.from((s=(r=this.firstElementChild)==null?void 0:r.childNodes)!=null?s:[]).find(c=>c.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",(o=t.textContent)!=null?o:"")}catch(c){console.error("custom-operator contains invalid javascript code",c)}}calculate(){let e={variable:r=>{var s,o,c;return(c=(o=(s=this._context)==null?void 0:s.variables.find(l=>l.identifier===r))==null?void 0:o.value)!=null?c:""},correct:r=>{var s,o,c;return(c=(o=(s=this._context)==null?void 0:s.variables.find(l=>l.identifier===r))==null?void 0:o.correctResponse)!=null?c:""}},t={getVariable:r=>{var s;return(s=this._context)==null?void 0:s.variables.find(o=>o.identifier===r)},updateOutcomeVariable:(r,s)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:s}}))}};return this.operatorFunction(this._context,e,t)}};_chunkKRFEDZFGcjs.c.call(void 0, [_context2.consume.call(void 0, {context:S,subscribe:!0}),_decoratorsjs.state.call(void 0, )],xe.prototype,"_context",2),xe= exports.QtiCustomOperator =_chunkKRFEDZFGcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-custom-operator")],xe);exports.Interaction = b; exports.QtPrintedVariable = fe; exports.QtiAnd = Ne; exports.QtiAssessmentItem = A; exports.QtiAssociableHotspot = Je; exports.QtiAssociateInteraction = be; exports.QtiBaseValue = He; exports.QtiChoice = _; exports.QtiChoiceInteraction = Q; exports.QtiCompanionMaterialsInfo = Ae; exports.QtiConditionExpression = $; exports.QtiContains = yt; exports.QtiContentBody = ke; exports.QtiCorrect = xt; exports.QtiCustomOperator = xe; exports.QtiEndAttemptInteraction = ne; exports.QtiEqual = Pe; exports.QtiEqualRounded = De; exports.QtiExpression = m; exports.QtiExtendedTextInteraction = M; exports.QtiFeedbackBlock = Re; exports.QtiFeedbackInline = Te; exports.QtiGap = Ze; exports.QtiGapImg = Ge; exports.QtiGapMatchInteraction = Fe; exports.QtiGapText = Qe; exports.QtiGraphicAssociateInteraction = D; exports.QtiGraphicGapMatchInteraction = Xe; exports.QtiGraphicOrderInteraction = Ye; exports.QtiGt = Et; exports.QtiGte = _t; exports.QtiHotspotChoice = ve; exports.QtiHotspotInteraction = Be; exports.QtiHottext = et; exports.QtiHottextInteraction = ft; exports.QtiInlineChoice = Ut; exports.QtiInlineChoiceInteraction = j; exports.QtiIsNull = Ct; exports.QtiLookupOutcomeValue = Ve; exports.QtiLt = qt; exports.QtiLte = At; exports.QtiMapResponse = Oe; exports.QtiMapping = ee; exports.QtiMatch = wt; exports.QtiMatchInteraction = ie; exports.QtiMediaInteraction = je; exports.QtiMember = $t; exports.QtiModalFeedback = Se; exports.QtiMultiple = Rt; exports.QtiNot = Tt; exports.QtiOr = St; exports.QtiOrderInteraction = se; exports.QtiOrdered = Lt; exports.QtiOutcomeDeclaration = P; exports.QtiPortableCustomInteraction = Ht; exports.QtiPositionObjectStage = ze; exports.QtiProduct = Mt; exports.QtiPrompt = Ee; exports.QtiResponseCondition = bt; exports.QtiResponseDeclaration = U; exports.QtiResponseElse = me; exports.QtiResponseElseIf = vt; exports.QtiResponseIf = he; exports.QtiResponseProcessing = K; exports.QtiRubricBlock = L; exports.QtiRule = V; exports.QtiSPositionObjectInteraction = Ke; exports.QtiSelectPointInteraction = z; exports.QtiSetOutcomeValue = gt; exports.QtiSimpleAssociableChoice = Pt; exports.QtiSimpleChoice = ye; exports.QtiSliderInteraction = C; exports.QtiStringMatch = Ue; exports.QtiStylesheet = tt; exports.QtiSum = Vt; exports.QtiTextEntryInteraction = w; exports.QtiVariable = Nt; exports.itemContext = S; exports.qtiAndMixin = Gi;
|
|
453
453
|
/*! Bundled license information:
|
|
454
454
|
|
|
455
455
|
lit-html/node/lit-html.js:
|