@citolab/qti-components 6.6.1-12 → 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 +59 -59
- package/dist/index.cjs +31 -31
- package/dist/index.js +31 -31
- package/dist/item.css +1 -1
- package/dist/qti-components/index.cjs +1 -1
- package/dist/qti-components/index.js +1 -1
- package/package.json +13 -13
package/dist/item.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
! tailwindcss v3.3.
|
|
2
|
+
! tailwindcss v3.3.5 | MIT License | https://tailwindcss.com
|
|
3
3
|
*//*
|
|
4
4
|
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
5
5
|
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
@@ -1,4 +1,4 @@
|
|
|
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:
|
|
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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as f,b as q,c as n}from"../chunk-BKTGSVMP.js";import{provide as $r}from"@lit/context";import{LitElement as Rr,html as Tr}from"lit";import{customElement as Sr,property as I}from"lit/decorators.js";function y(a,i){let e=f({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)}}}import{createContext as wr}from"@lit/context";var S=wr("item");var A=class extends Rr{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=q(f({},this._context),{variables:this._context.variables});this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",({detail:e})=>{this._context=q(f({},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=q(f({},this._context),{variables:this._context.variables.map(t=>{let r=e.find(s=>s.identifier===t.identifier);return r?f(f({},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 Tr`<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=q(f({},this._context),{variables:this._context.variables.map(r=>r.identifier!==e?r:q(f({},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=q(f({},this._context),{variables:this._context.variables.map(o=>o.identifier!==e?o:q(f({},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}))}};n([I({type:String})],A.prototype,"title",2),n([I({type:String})],A.prototype,"identifier",2),n([I({type:String})],A.prototype,"adaptive",2),n([I({type:String})],A.prototype,"timeDependent",2),n([I({type:Boolean})],A.prototype,"disabled",2),n([y("disabled",{waitUntilFirstUpdate:!0})],A.prototype,"_handleDisabledChange",2),n([I({type:Boolean})],A.prototype,"readonly",2),n([y("readonly",{waitUntilFirstUpdate:!0})],A.prototype,"_handleReadonlyChange",2),n([$r({context:S}),I({attribute:!1})],A.prototype,"_context",2),A=n([Sr("qti-assessment-item")],A);import{html as Lr}from"lit/static-html.js";import{property as ae}from"lit/decorators.js";import{LitElement as Mr}from"lit";var Vr={SPACE:32},_=class extends Mr{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"),Lr` <slot></slot> `}};n([ae({type:String})],_.prototype,"identifier",2),n([ae({type:Number,reflect:!0})],_.prototype,"tabindex",2),n([ae({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:
|
|
1
|
+
import{a as f,b as q,c as n}from"../chunk-BKTGSVMP.js";import{provide as $r}from"@lit/context";import{LitElement as Rr,html as Tr}from"lit";import{customElement as Sr,property as I}from"lit/decorators.js";function y(a,i){let e=f({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)}}}import{createContext as wr}from"@lit/context";var S=wr("item");var A=class extends Rr{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=q(f({},this._context),{variables:this._context.variables});this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",({detail:e})=>{this._context=q(f({},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=q(f({},this._context),{variables:this._context.variables.map(t=>{let r=e.find(s=>s.identifier===t.identifier);return r?f(f({},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 Tr`<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=q(f({},this._context),{variables:this._context.variables.map(r=>r.identifier!==e?r:q(f({},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=q(f({},this._context),{variables:this._context.variables.map(o=>o.identifier!==e?o:q(f({},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}))}};n([I({type:String})],A.prototype,"title",2),n([I({type:String})],A.prototype,"identifier",2),n([I({type:String})],A.prototype,"adaptive",2),n([I({type:String})],A.prototype,"timeDependent",2),n([I({type:Boolean})],A.prototype,"disabled",2),n([y("disabled",{waitUntilFirstUpdate:!0})],A.prototype,"_handleDisabledChange",2),n([I({type:Boolean})],A.prototype,"readonly",2),n([y("readonly",{waitUntilFirstUpdate:!0})],A.prototype,"_handleReadonlyChange",2),n([$r({context:S}),I({attribute:!1})],A.prototype,"_context",2),A=n([Sr("qti-assessment-item")],A);import{html as Lr}from"lit/static-html.js";import{property as ae}from"lit/decorators.js";import{LitElement as Mr}from"lit";var Vr={SPACE:32},_=class extends Mr{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"),Lr` <slot></slot> `}};n([ae({type:String})],_.prototype,"identifier",2),n([ae({type:Number,reflect:!0})],_.prototype,"tabindex",2),n([ae({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:e=>e}})],_.prototype,"disabled",2),n([ae({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:e=>e}})],_.prototype,"readonly",2),n([ae({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>e}})],_.prototype,"checked",2),n([y("disabled",{waitUntilFirstUpdate:!0})],_.prototype,"handleDisabledChange",1);import{customElement as Hr}from"lit/decorators.js";import{html as Dr,LitElement as Pr}from"lit";import{css as Nr}from"lit";var Ft=Nr`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"engines": {
|
|
13
13
|
"node": ">=16.0.0"
|
|
14
14
|
},
|
|
15
|
-
"version": "6.6.1-
|
|
15
|
+
"version": "6.6.1-13",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"main": "dist/index.js",
|
|
18
18
|
"exports": {
|
|
@@ -78,18 +78,18 @@
|
|
|
78
78
|
"@arethetypeswrong/cli": "^0.13.2",
|
|
79
79
|
"@custom-elements-manifest/analyzer": "^0.9.0",
|
|
80
80
|
"@jest/globals": "^29.7.0",
|
|
81
|
-
"@storybook/addon-a11y": "^7.
|
|
82
|
-
"@storybook/addon-essentials": "^7.
|
|
83
|
-
"@storybook/addon-interactions": "^7.
|
|
84
|
-
"@storybook/addon-jest": "^7.
|
|
85
|
-
"@storybook/addon-links": "^7.
|
|
86
|
-
"@storybook/blocks": "^7.
|
|
81
|
+
"@storybook/addon-a11y": "^7.6.3",
|
|
82
|
+
"@storybook/addon-essentials": "^7.6.3",
|
|
83
|
+
"@storybook/addon-interactions": "^7.6.3",
|
|
84
|
+
"@storybook/addon-jest": "^7.6.3",
|
|
85
|
+
"@storybook/addon-links": "^7.6.3",
|
|
86
|
+
"@storybook/blocks": "^7.6.3",
|
|
87
87
|
"@storybook/jest": "^0.2.3",
|
|
88
|
-
"@storybook/preview-api": "^7.
|
|
89
|
-
"@storybook/test-runner": "^0.
|
|
88
|
+
"@storybook/preview-api": "^7.6.3",
|
|
89
|
+
"@storybook/test-runner": "^0.16.0",
|
|
90
90
|
"@storybook/testing-library": "^0.2.2",
|
|
91
|
-
"@storybook/web-components": "^7.
|
|
92
|
-
"@storybook/web-components-vite": "^7.
|
|
91
|
+
"@storybook/web-components": "^7.6.3",
|
|
92
|
+
"@storybook/web-components-vite": "^7.6.3",
|
|
93
93
|
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
|
|
94
94
|
"@tailwindcss/typography": "^0.5.10",
|
|
95
95
|
"@types/node": "^20.9.2",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"react": "^18.2.0",
|
|
119
119
|
"react-dom": "^18.2.0",
|
|
120
120
|
"remark-gfm": "^4.0.0",
|
|
121
|
-
"storybook": "^7.
|
|
121
|
+
"storybook": "^7.6.3",
|
|
122
122
|
"tailwindcss": "^3.3.2",
|
|
123
123
|
"ts-jest": "^29.1.1",
|
|
124
124
|
"ts-node": "^10.9.1",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"typescript": "^5.2.2",
|
|
127
127
|
"vite": "^5.0.0",
|
|
128
128
|
"vite-tsconfig-paths": "^4.2.1",
|
|
129
|
-
"wc-storybook-helpers": "^1.1.
|
|
129
|
+
"wc-storybook-helpers": "^1.1.1"
|
|
130
130
|
},
|
|
131
131
|
"customElements": "custom-elements.json"
|
|
132
132
|
}
|