@citolab/qti-components 3.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +341 -0
- package/index.css +16965 -0
- package/index.d.ts +47 -0
- package/index.js +341 -0
- package/lab/qti-api/qti-api.stories.d.ts +7 -0
- package/lab/qti-custom/qti-custom-operator/qti-custom-operator-levenshtein.d.ts +11 -0
- package/lab/qti-custom/qti-custom-operator/qti-custom-operator-numeric-parse-nl.d.ts +11 -0
- package/lab/qti-custom/qti-custom-operator/qti-custom-operator-numeric.d.ts +6 -0
- package/lab/qti-custom/qti-custom-operator/qti-custom-operator-remove-spaces.d.ts +6 -0
- package/lab/qti-custom/qti-custom-operator/qti-custom-operator-trim.d.ts +6 -0
- package/lab/qti-custom/qti-custom-operator/qti-custom-operator.stories.d.ts +12 -0
- package/lab/qti-dashboard/qti-item-dashboard.stories.d.ts +8 -0
- package/lab/qti-item/qti-item.d.ts +30 -0
- package/lab/qti-item/qti-item.stories.d.ts +8 -0
- package/lab/qti-test/qti-test-buttons.d.ts +1 -0
- package/lab/qti-test/qti-test.d.ts +40 -0
- package/lab/qti-test/qti-test.stories.d.ts +9 -0
- package/lib/qti-base/qti-assessment-item/qti-assessment-item.d.ts +43 -0
- package/lib/qti-base/qti-choice/qti-choice.d.ts +34 -0
- package/lib/qti-base/qti-choice/qti-hottext/qti-hottext.d.ts +9 -0
- package/lib/qti-base/qti-choice/qti-simple-choice/qti-simple-choice.d.ts +9 -0
- package/lib/qti-base/qti-feedback/qti-feedback-inline/qti-feedback-inline.d.ts +5 -0
- package/lib/qti-base/qti-feedback/qti-feedback.d.ts +30 -0
- package/lib/qti-base/qti-feedback/qti-feedback.stories.d.ts +8 -0
- package/lib/qti-base/qti-feedback/qti-modal-feedback/qti-modal-feedback.d.ts +5 -0
- package/lib/qti-base/qti-interaction/qti-choice-interaction/qti-choice-interaction.d.ts +11 -0
- package/lib/qti-base/qti-interaction/qti-choice-interaction/qti-choice-interaction.stories.d.ts +45 -0
- package/lib/qti-base/qti-interaction/qti-extended-text-interaction/qti-extended-text-interaction.d.ts +41 -0
- package/lib/qti-base/qti-interaction/qti-extended-text-interaction/qti-extended-text-interaction.stories.d.ts +9 -0
- package/lib/qti-base/qti-interaction/qti-hottext-interaction/qti-hottext-interaction.d.ts +6 -0
- package/lib/qti-base/qti-interaction/qti-hottext-interaction/qti-hottext-interaction.stories.d.ts +20 -0
- package/lib/qti-base/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.d.ts +27 -0
- package/lib/qti-base/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.stories.d.ts +43 -0
- package/lib/qti-base/qti-interaction/qti-text-entry-interaction/qti-text-entry-interaction.d.ts +34 -0
- package/lib/qti-base/qti-interaction/qti-text-entry-interaction/qti-text-entry-interaction.stories.d.ts +31 -0
- package/lib/qti-base/qti-item-body/qti-item-body.d.ts +4 -0
- package/lib/qti-base/qti-preview/qti-associable-hotspot.d.ts +6 -0
- package/lib/qti-base/qti-preview/qti-associate-interaction/qti-associate-interaction.d.ts +11 -0
- package/lib/qti-base/qti-preview/qti-associate-interaction/qti-associate-interaction.stories.d.ts +7 -0
- package/lib/qti-base/qti-preview/qti-associate-interaction/qti-simple-associable-choice.d.ts +4 -0
- package/lib/qti-base/qti-preview/qti-custom-interaction/qti-portable-custom-interaction.d.ts +34 -0
- package/lib/qti-base/qti-preview/qti-custom-interaction/qti-portable-custom-interaction.stories.d.ts +7 -0
- package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-match-interaction.d.ts +8 -0
- package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-match-interaction.stories.d.ts +31 -0
- package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-text.d.ts +2 -0
- package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap.d.ts +2 -0
- package/lib/qti-base/qti-preview/qti-graphic-associate-interaction/qti-graphic-associate-interaction.d.ts +10 -0
- package/lib/qti-base/qti-preview/qti-graphic-associate-interaction/qti-graphic-associate-interaction.stories.d.ts +7 -0
- package/lib/qti-base/qti-preview/qti-graphic-gap-match-interaction/qti-gap-img.d.ts +3 -0
- package/lib/qti-base/qti-preview/qti-graphic-gap-match-interaction/qti-graphic-gap-match-interaction.d.ts +11 -0
- package/lib/qti-base/qti-preview/qti-graphic-gap-match-interaction/qti-graphic-gap-match-interaction.stories.d.ts +26 -0
- package/lib/qti-base/qti-preview/qti-graphic-order-interaction/qti-graphic-order-interaction.d.ts +11 -0
- package/lib/qti-base/qti-preview/qti-graphic-order-interaction/qti-graphic-order-interaction.stories.d.ts +7 -0
- package/lib/qti-base/qti-preview/qti-hotspot-choice.d.ts +5 -0
- package/lib/qti-base/qti-preview/qti-hotspot-interaction/qti-hotspot-interaction.d.ts +9 -0
- package/lib/qti-base/qti-preview/qti-hotspot-interaction/qti-hotspot-interaction.stories.d.ts +9 -0
- package/lib/qti-base/qti-preview/qti-match-interaction/qti-match-interaction.d.ts +8 -0
- package/lib/qti-base/qti-preview/qti-match-interaction/qti-match-interaction.stories.d.ts +8 -0
- package/lib/qti-base/qti-preview/qti-media-interaction/qti-media-interaction.d.ts +19 -0
- package/lib/qti-base/qti-preview/qti-media-interaction/qti-media-interaction.stories.d.ts +25 -0
- package/lib/qti-base/qti-preview/qti-order-interaction/qti-order-interaction.d.ts +23 -0
- package/lib/qti-base/qti-preview/qti-order-interaction/qti-order-interaction.stories.d.ts +21 -0
- package/lib/qti-base/qti-preview/qti-preview-badge.d.ts +1 -0
- package/lib/qti-base/qti-preview/qti-select-point-interaction/qti-select-point-interaction.d.ts +10 -0
- package/lib/qti-base/qti-preview/qti-select-point-interaction/qti-select-point-interaction.stories.d.ts +7 -0
- package/lib/qti-base/qti-preview/qti-slider-interaction/qti-slider-interaction.d.ts +26 -0
- package/lib/qti-base/qti-preview/qti-slider-interaction/qti-slider-interaction.stories.d.ts +48 -0
- package/lib/qti-base/qti-prompt/qti-prompt.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/index.d.ts +18 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-and/qti-and.d.ts +7 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-basevalue/qti-basevalue.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-contains/qti-contains.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-correct/qti-correct.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-expression.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-gte/qti-gte.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-is-null/qti-is-null.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-mapresponse/qti-mapresponse.d.ts +4 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-match/qti-match.d.ts +4 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-multiple/qti-multiple.d.ts +4 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-or/qti-or.d.ts +7 -0
- package/lib/qti-base/qti-responseprocessing/qti-expression/qti-variable/qti-variable.d.ts +6 -0
- package/lib/qti-base/qti-responseprocessing/qti-responseelse/qti-responseelse.d.ts +15 -0
- package/lib/qti-base/qti-responseprocessing/qti-responseelse/qti-responseif/qti-responseelseif/qti-responseelseif.d.ts +4 -0
- package/lib/qti-base/qti-responseprocessing/qti-responseelse/qti-responseif/qti-responseif.d.ts +7 -0
- package/lib/qti-base/qti-responseprocessing/qti-responseprocessing/qti-responseprocessing.d.ts +7 -0
- package/lib/qti-base/qti-responseprocessing/qti-rule/qti-responsecondition/qti-responsecondition.d.ts +5 -0
- package/lib/qti-base/qti-responseprocessing/qti-rule/qti-rule.d.ts +5 -0
- package/lib/qti-base/qti-responseprocessing/qti-rule/qti-setoutcomevalue/qti-setoutcomevalue.d.ts +4 -0
- package/lib/qti-base/qti-stylesheet/qti-stylesheet.d.ts +7 -0
- package/lib/qti-base/qti-variabledeclaration/qti-outcomedeclaration/qti-outcomedeclaration.d.ts +5 -0
- package/lib/qti-base/qti-variabledeclaration/qti-responsedeclaration/qti-responsedeclaration.d.ts +24 -0
- package/lib/qti-base/qti-variabledeclaration/qti-variabledeclaration.d.ts +4 -0
- package/lib/qti-utilities/EventStrings.d.ts +18 -0
- package/lib/qti-utilities/EventTypes.d.ts +7 -0
- package/lib/qti-utilities/ExpressionResult.d.ts +43 -0
- package/lib/qti-utilities/OutcomeVariable.d.ts +8 -0
- package/lib/qti-utilities/ResponseVariable.d.ts +28 -0
- package/lib/qti-utilities/TemplateStrings.d.ts +3 -0
- package/lib/qti-utilities/VariableDeclaration.d.ts +7 -0
- package/lib/utilities/choice/choices.d.ts +23 -0
- package/lib/utilities/drag-drop/drag-drop-interaction-mixin.d.ts +5 -0
- package/lib/utilities/drag-drop/draggables-mixin.d.ts +6 -0
- package/lib/utilities/drag-drop/droppables-mixin.d.ts +6 -0
- package/lib/utilities/drag-drop/flippables-mixin.d.ts +8 -0
- package/lib/utilities/element/qti-element.d.ts +6 -0
- package/lib/utilities/hotspots/hotspot.d.ts +2 -0
- package/lib/utilities/interaction/interaction.d.ts +14 -0
- package/lib/utilities/interaction/interaction.interface.d.ts +8 -0
- package/lib/utilities/reset-styles/reset-shadowroot-styles.d.ts +1 -0
- package/lib/utilities/scale-to-fit/scale-to-fit.mixin.d.ts +6 -0
- package/lib/utilities/watch/watch.d.ts +14 -0
- package/package.json +20 -0
- package/styles/qti-classes.stories.d.ts +5 -0
- package/styles/qti-layout-styles.stories.d.ts +6 -0
- package/styles/qti-styles.stories.d.ts +5 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import './styles.scss';
|
|
2
|
+
export * from './lib/qti-utilities/ExpressionResult';
|
|
3
|
+
export * from './lib/qti-utilities/EventTypes';
|
|
4
|
+
export * from './lib/qti-utilities/EventStrings';
|
|
5
|
+
export * from './lib/qti-utilities/ResponseVariable';
|
|
6
|
+
export * from './lib/qti-utilities/OutcomeVariable';
|
|
7
|
+
export * from './lib/qti-base/qti-assessment-item/qti-assessment-item';
|
|
8
|
+
export * from './lib/qti-base/qti-stylesheet/qti-stylesheet';
|
|
9
|
+
export * from './lib/qti-base/qti-item-body/qti-item-body';
|
|
10
|
+
export * from './lib/qti-base/qti-prompt/qti-prompt';
|
|
11
|
+
export * from './lib/qti-base/qti-choice/qti-choice';
|
|
12
|
+
export * from './lib/qti-base/qti-variabledeclaration/qti-responsedeclaration/qti-responsedeclaration';
|
|
13
|
+
export * from './lib/qti-base/qti-variabledeclaration/qti-outcomedeclaration/qti-outcomedeclaration';
|
|
14
|
+
export * from './lib/qti-base/qti-feedback/qti-feedback-inline/qti-feedback-inline';
|
|
15
|
+
export * from './lib/qti-base/qti-feedback/qti-modal-feedback/qti-modal-feedback';
|
|
16
|
+
export * from './lib/qti-base/qti-interaction/qti-text-entry-interaction/qti-text-entry-interaction';
|
|
17
|
+
export * from './lib/qti-base/qti-interaction/qti-extended-text-interaction/qti-extended-text-interaction';
|
|
18
|
+
export * from './lib/qti-base/qti-choice/qti-hottext/qti-hottext';
|
|
19
|
+
export * from './lib/qti-base/qti-interaction/qti-hottext-interaction/qti-hottext-interaction';
|
|
20
|
+
export * from './lib/qti-base/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction';
|
|
21
|
+
export * from './lib/qti-base/qti-interaction/qti-choice-interaction/qti-choice-interaction';
|
|
22
|
+
export * from './lib/qti-base/qti-choice/qti-simple-choice/qti-simple-choice';
|
|
23
|
+
export * from './lib/qti-base/qti-responseprocessing';
|
|
24
|
+
export * from './lib/qti-base/qti-preview/qti-custom-interaction/qti-portable-custom-interaction';
|
|
25
|
+
export * from './lib/qti-base/qti-preview/qti-associate-interaction/qti-associate-interaction';
|
|
26
|
+
export * from './lib/qti-base/qti-preview/qti-associate-interaction/qti-simple-associable-choice';
|
|
27
|
+
export * from './lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-match-interaction';
|
|
28
|
+
export * from './lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-text';
|
|
29
|
+
export * from './lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap';
|
|
30
|
+
export * from './lib/qti-base/qti-preview/qti-graphic-associate-interaction/qti-graphic-associate-interaction';
|
|
31
|
+
export * from './lib/qti-base/qti-preview/qti-graphic-gap-match-interaction/qti-graphic-gap-match-interaction';
|
|
32
|
+
export * from './lib/qti-base/qti-preview/qti-graphic-order-interaction/qti-graphic-order-interaction';
|
|
33
|
+
export * from './lib/qti-base/qti-preview/qti-hotspot-interaction/qti-hotspot-interaction';
|
|
34
|
+
export * from './lib/qti-base/qti-preview/qti-hotspot-choice';
|
|
35
|
+
export * from './lib/qti-base/qti-preview/qti-match-interaction/qti-match-interaction';
|
|
36
|
+
export * from './lib/qti-base/qti-preview/qti-media-interaction/qti-media-interaction';
|
|
37
|
+
export * from './lib/qti-base/qti-preview/qti-order-interaction/qti-order-interaction';
|
|
38
|
+
export * from './lib/qti-base/qti-preview/qti-select-point-interaction/qti-select-point-interaction';
|
|
39
|
+
export * from './lib/qti-base/qti-preview/qti-slider-interaction/qti-slider-interaction';
|
|
40
|
+
export * from './lab/qti-custom/qti-custom-operator/qti-custom-operator-levenshtein';
|
|
41
|
+
export * from './lab/qti-custom/qti-custom-operator/qti-custom-operator-numeric';
|
|
42
|
+
export * from './lab/qti-custom/qti-custom-operator/qti-custom-operator-numeric-parse-nl';
|
|
43
|
+
export * from './lab/qti-custom/qti-custom-operator/qti-custom-operator-remove-spaces';
|
|
44
|
+
export * from './lab/qti-custom/qti-custom-operator/qti-custom-operator-trim';
|
|
45
|
+
export * from './lab/qti-test/qti-test';
|
|
46
|
+
export * from './lab/qti-item/qti-item';
|
|
47
|
+
export * from './lib/utilities/choice/choices';
|
package/index.js
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import{LitElement as e,html as t,css as s,render as i}from"lit";import{property as n,customElement as r,state as o}from"lit/decorators.js";import{html as a}from"lit/static-html.js";import{ifDefined as l}from"lit/directives/if-defined.js";import{createRef as c,ref as d}from"lit/directives/ref.js";var h,p;!function(e){e.boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair"}(h||(h={})),function(e){e.multiple="multiple",e.ordered="ordered",e.single="single"}(p||(p={}));const u={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"},m={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"};class g{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:n}){this._basetype=h.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=n}static getCandidateResponse(e){return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]]}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(e){this._candidateResponse=e}set qtiVariable(e){this._qtiVariable=e,this._candidateResponse=g.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class b{}class f extends e{emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}err(e){throw e}}class y extends f{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(u.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(u.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(u.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(u.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return t`<slot></slot>`}updated(e){e.forEach(((e,t)=>{switch(t){case"disabled":this.interactionElements.forEach((e=>e.disabled=this.disabled));break;case"readonly":this.interactionElements.forEach((e=>e.readonly=this.readonly))}}))}disconnectedCallback(){this.removeEventListener(u.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(u.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(u.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(u.ON_INTERACTION_RESPONSE,this.interactionResponse)}processResponse(){if(this.validateResponses()){const e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}return console.info("Item is not valid, call validateResponses first"),!1}set responses(e){if(e){e.interactions.forEach((e=>{const t=this.interactionElements.find((t=>t.getAttribute("response-identifier")===e.responseIdentifier)),s=this.getResponse(e.responseIdentifier);s&&(s.qtiVariable=e.responses);const i=g.getCandidateResponse(e.responses);t.response=i}))}}resetInteractions(){this.interactionElements.forEach((e=>e.reset()))}validateResponses(){let e=!0;return this.interactionElements.forEach((t=>{t.validate()||(e=!1)})),e}getVariableValue(e){return this.variables.find((t=>t.identifier===e)).value}getResponse(e){const t=this.variables.find((t=>t.identifier===e));if(t instanceof g)return t;this.err(`qti-response-variable ${e} not found, make sure you registered it`)}getOutcome(e){const t=this.variables.find((t=>t.identifier===e));return t instanceof b?t:(this.err(`qti-outcome-variable ${e} not found, make sure you registered it`),null)}registerFeedbackElement(e){e.stopPropagation(),this.feedbackElements.push(e.detail)}registerInteractionElement(e){e.stopPropagation(),this.interactionElements.push(e.target)}interactionResponse(e){const t=this.getResponse(e.detail.responseIdentifier);t&&(t.qtiVariable=e.detail.responses),e.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent(u.ON_INTERACTION_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.getAttribute("identifier"),interaction:{responseIdentifier:e.detail.responseIdentifier,responses:e.detail.responses}}}))}outcomeChanged(e){this.feedbackElements.forEach((t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)}))}setOutcomeValue(e,t){const s=this.getOutcome(e);s?(s.value=t,this.dispatchEvent(new CustomEvent(u.ON_OUTCOME_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))):this.err(`Can not set qti-outcome-identifier: ${e}, it is not available`)}}customElements.define("qti-assessment-item",y);class E extends e{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}customElements.define("qti-stylesheet",E);class v extends e{render(){return t` <style>
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
</style>
|
|
6
|
+
<!--
|
|
7
|
+
<header>
|
|
8
|
+
<slot name="qti-rubric-block" />
|
|
9
|
+
</header>
|
|
10
|
+
-->
|
|
11
|
+
<slot></slot>`}}customElements.define("qti-item-body",v);class q extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function _(e,t,s,i){var n,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,s,o):n(t,s))||o);return r>3&&o&&Object.defineProperty(t,s,o),o}function C(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function x(e,t,s,i){return new(s||(s=Promise))((function(n,r){function o(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}function O(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,n))}n.call(this,e)}}}}customElements.define("qti-prompt",q);const S=32;let k=class extends f{constructor(){super(...arguments),this.tabindex=0,this.disabled=!1,this.readonly=!1,this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.emit(u.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(u.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===S&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(u.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return a` <slot></slot> `}};_([n({reflect:!0}),C("design:type",String)],k.prototype,"identifier",void 0),_([n({type:Number,reflect:!0}),C("design:type",Object)],k.prototype,"tabindex",void 0),_([n({type:Boolean,reflect:!0}),C("design:type",Object)],k.prototype,"disabled",void 0),_([n({type:Boolean,reflect:!0}),C("design:type",Object)],k.prototype,"readonly",void 0),_([n({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),C("design:type",Object)],k.prototype,"checked",void 0),_([O("disabled",{waitUntilFirstUpdate:!0}),C("design:type",Function),C("design:paramtypes",[Object,Boolean]),C("design:returntype",void 0)],k.prototype,"handleDisabledChange",null),k=_([r("qti-choice")],k);class R extends e{render(){return t``}}customElements.define("qti-variabledeclaration",R);class A extends R{static get properties(){return{baseType:{type:String,attribute:"base-type"},identifier:{type:String,attribute:"identifier"},cardinality:{type:String,attribute:"cardinality"}}}connectedCallback(){super.connectedCallback();const e=new g({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||p.single,mapping:this.mapping});this.closest("qti-assessment-item").variables.push(e)}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const s=t.querySelectorAll("qti-value");if(1===s.length)e=s[0].textContent,s[0].remove();else{e=[];for(let t=0;t<s.length;t++)e.push(s[t].textContent),s[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,s=e.querySelectorAll("qti-map-entry");for(let e=0;e<s.length;e++){const i=s[e],n=i.getAttribute("map-key"),r=i.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}customElements.define("qti-response-declaration",A);class I extends R{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new b;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",I);class N extends e{constructor(){super(),this.showHide="show",this.showFeedback("hide"===this.showHide)}static get properties(){return{showStatus:{type:String,attribute:!0,reflect:!0},showHide:{type:String,attribute:"show-hide"},outcomeIdentifier:{type:String,attribute:"outcome-identifier"},identifier:{type:String}}}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(u.ON_REGISTER_FEEDBACK,{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){this.outcomeIdentifier===e&&(t instanceof Array?this.showFeedback(-1!==t.indexOf(this.identifier)):this.showFeedback(this.identifier===t))}showFeedback(e){this.showStatus=e?"on":"off"}}class w extends N{constructor(){super(...arguments),this.render=()=>t` <slot class="${this.showStatus}"></slot> `}}w.styles=s`
|
|
12
|
+
.on {
|
|
13
|
+
display: inline-block;
|
|
14
|
+
}
|
|
15
|
+
.off {
|
|
16
|
+
display: none;
|
|
17
|
+
}
|
|
18
|
+
`,customElements.define("qti-feedback-inline",w);class T extends N{render(){return t`
|
|
19
|
+
<style>
|
|
20
|
+
.on {
|
|
21
|
+
display: inline-block;
|
|
22
|
+
}
|
|
23
|
+
.off {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
<div class="feedback ${this.showStatus}">
|
|
28
|
+
<slot></slot>
|
|
29
|
+
</div>
|
|
30
|
+
`}}customElements.define("qti-modal-feedback",T);class L extends f{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(u.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(u.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}_([n({attribute:"response-identifier"}),C("design:type",Object)],L.prototype,"responseIdentifier",void 0),_([n({reflect:!0,type:Boolean}),C("design:type",Object)],L.prototype,"disabled",void 0),_([n({reflect:!0,type:Boolean}),C("design:type",Object)],L.prototype,"readonly",void 0);const H=s`
|
|
31
|
+
/***
|
|
32
|
+
The new CSS reset - version 1.4.9 (last updated 11.2.2022)
|
|
33
|
+
GitHub page: https://github.com/elad2412/the-new-css-reset
|
|
34
|
+
***/
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
|
|
38
|
+
- The "symbol *" part is to solve Firefox SVG sprite bug
|
|
39
|
+
*/
|
|
40
|
+
*:where(:not(iframe, canvas, img, svg, video, object):not(svg *, symbol *)) {
|
|
41
|
+
all: unset;
|
|
42
|
+
display: revert;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Preferred box-sizing value */
|
|
46
|
+
*,
|
|
47
|
+
*::before,
|
|
48
|
+
*::after {
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Reapply the pointer cursor for anchor tags */
|
|
53
|
+
a,
|
|
54
|
+
button {
|
|
55
|
+
cursor: revert;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Remove list styles (bullets/numbers) */
|
|
59
|
+
ol,
|
|
60
|
+
ul,
|
|
61
|
+
menu {
|
|
62
|
+
list-style: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* For images to not be able to exceed their container */
|
|
66
|
+
img {
|
|
67
|
+
max-width: 100%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* removes spacing between cells in tables */
|
|
71
|
+
table {
|
|
72
|
+
border-collapse: collapse;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* revert the 'white-space' property for textarea elements on Safari */
|
|
76
|
+
textarea {
|
|
77
|
+
white-space: revert;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* minimum style to allow to style meter element */
|
|
81
|
+
meter {
|
|
82
|
+
-webkit-appearance: revert;
|
|
83
|
+
appearance: revert;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* reset default text opacity of input placeholder */
|
|
87
|
+
::placeholder {
|
|
88
|
+
all: unset;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* fix the feature of 'hidden' attribute.
|
|
92
|
+
display:revert; revert to element instead of attribute */
|
|
93
|
+
:where([hidden]) {
|
|
94
|
+
display: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* revert for bug in Chromium browsers
|
|
98
|
+
- fix for the content editable attribute will work properly. */
|
|
99
|
+
:where([contenteditable]) {
|
|
100
|
+
-moz-user-modify: read-write;
|
|
101
|
+
-webkit-user-modify: read-write;
|
|
102
|
+
overflow-wrap: break-word;
|
|
103
|
+
-webkit-line-break: after-white-space;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* apply back the draggable feature - exist only in Chromium and Safari */
|
|
107
|
+
:where([draggable='true']) {
|
|
108
|
+
-webkit-user-drag: element;
|
|
109
|
+
}
|
|
110
|
+
`;class M extends L{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},L.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String}})}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[H,s`
|
|
111
|
+
/* PK: display host as block, else design will be collapsed */
|
|
112
|
+
:host {
|
|
113
|
+
display: inline-block;
|
|
114
|
+
}
|
|
115
|
+
input {
|
|
116
|
+
padding: var(--qti-padding, 0.5rem);
|
|
117
|
+
}
|
|
118
|
+
`]}render(){return t`
|
|
119
|
+
<input
|
|
120
|
+
spellcheck="false"
|
|
121
|
+
autocomplete="off"
|
|
122
|
+
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
123
|
+
@keyup="${this.textChanged}"
|
|
124
|
+
@change="${this.textChanged}"
|
|
125
|
+
type="text"
|
|
126
|
+
placeholder="${l(this.placeholderText?this.placeholderText:void 0)}"
|
|
127
|
+
.value="${this.value}"
|
|
128
|
+
size="${l(this.expectedLength?this.expectedLength:void 0)}"
|
|
129
|
+
pattern="${l(this.patternMask?this.patternMask:void 0)}"
|
|
130
|
+
?disabled="${this.disabled}"
|
|
131
|
+
?readonly="${this.readonly}"
|
|
132
|
+
/>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}M.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],customElements.define("qti-text-entry-interaction",M);class $ extends L{constructor(){super(...arguments),this.value="",this.textareaRef=c()}static get properties(){return Object.assign(Object.assign({},L.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String},classNames:{type:String,attribute:"class"}})}updated(e){e.has("classNames")&&this.changeRowsOnClassChange()}changeRowsOnClassChange(){this.classNames.split(" ").forEach((e=>{if(e.startsWith("qti-height-lines")){const t=e.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(t))}}))}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[H,s`
|
|
133
|
+
/* PK: display host as block, else design will be collapsed */
|
|
134
|
+
:host {
|
|
135
|
+
display: block;
|
|
136
|
+
}
|
|
137
|
+
textarea {
|
|
138
|
+
padding: var(--qti-padding, 0.5rem);
|
|
139
|
+
width: 100%;
|
|
140
|
+
height: 100%;
|
|
141
|
+
}
|
|
142
|
+
`]}render(){return t`<textarea
|
|
143
|
+
${d(this.textareaRef)}
|
|
144
|
+
spellcheck="false"
|
|
145
|
+
autocomplete="off"
|
|
146
|
+
@keydown="${e=>e.stopImmediatePropagation()}"
|
|
147
|
+
@keyup="${this.textChanged}"
|
|
148
|
+
@change="${this.textChanged}"
|
|
149
|
+
placeholder="${l(this.placeholderText?this.placeholderText:void 0)}"
|
|
150
|
+
maxlength="${l(this.expectedLength?this.expectedLength:void 0)}"
|
|
151
|
+
pattern="${l(this.patternMask?this.patternMask:void 0)}"
|
|
152
|
+
?disabled="${this.disabled}"
|
|
153
|
+
?readonly="${this.readonly}"
|
|
154
|
+
>
|
|
155
|
+
${this.value}</textarea
|
|
156
|
+
>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}$.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],customElements.define("qti-extended-text-interaction",$);let D=class extends k{};D=_([r("qti-hottext")],D);class P extends L{constructor(){super(),this._choiceElements=[],this._minChoices=0,this._maxChoices=1,this._handleDisabledChange=(e,t)=>this._choiceElements.forEach((e=>e.disabled=t)),this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach((e=>e.readonly=t)),this._handleMaxChoicesChange=()=>this._determineInputType(),this.addEventListener(u.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(u.ON_LOOSE_CHOICE,this._looseChoiceElement)}reset(){this._choiceElements.forEach((e=>{e.reset()}))}validate(){return this._choiceElements.reduce(((e,t)=>e+(!0===t.checked?1:0)),0)>=this._minChoices}set response(e){this._choiceElements.forEach((e=>{e.checked=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{const t=this.querySelector("[identifier='"+e+"']");t&&(t.checked=!0)}))}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(u.ON_REGISTER_CHOICE,this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter((e=>e!==t))}_determineInputType(){this._choiceElements.forEach((e=>{this._setInputType(e)}))}_setInputType(e){1===this._maxChoices?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){1===this._maxChoices&&this._choiceElements.filter((t=>t.identifier!==e.detail.identifier)).forEach((e=>{e.checked=!1})),this._choiceElementSelected()}_choiceElementSelected(){const e=this._choiceElements.filter((e=>1==e.checked)).map((e=>e.identifier));let t;this._maxChoices>1&&(this._maxChoices===e.length?this._choiceElements.forEach((e=>e.disabled=!(1==e.checked))):this._choiceElements.forEach((e=>e.disabled=!1))),t=1===this._maxChoices?{base:{identifier:e.length>0?e[0]:""}}:{list:{identifier:e}},this.saveResponse(t)}}_([n({type:Number,attribute:"min-choices"}),C("design:type",Number)],P.prototype,"_minChoices",void 0),_([n({type:Number,attribute:"max-choices"}),C("design:type",Number)],P.prototype,"_maxChoices",void 0),_([O("disabled",{waitUntilFirstUpdate:!0}),C("design:type",Object)],P.prototype,"_handleDisabledChange",void 0),_([O("readonly",{waitUntilFirstUpdate:!0}),C("design:type",Object)],P.prototype,"_handleReadonlyChange",void 0),_([O("_maxChoices",{waitUntilFirstUpdate:!0}),C("design:type",Object)],P.prototype,"_handleMaxChoicesChange",void 0);class j extends P{constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",j);class F extends L{constructor(){super(),this.options=[],this.addEventListener(u.ON_DROPDOWN_SELECTED,this.choiceSelected);const e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map((e=>({textContent:e.innerHTML,value:e.getAttribute("identifier"),selected:!1})))]}static get properties(){return Object.assign(Object.assign({},L.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[H,s`
|
|
157
|
+
:host {
|
|
158
|
+
display: inline-block;
|
|
159
|
+
}
|
|
160
|
+
select {
|
|
161
|
+
width:100%;
|
|
162
|
+
padding: var(--qti-padding-y) var(--qti-padding-x);
|
|
163
|
+
padding-right: calc(var(--qti-padding-x) + 1ch)
|
|
164
|
+
}
|
|
165
|
+
`]}render(){return t`
|
|
166
|
+
<select
|
|
167
|
+
@change="${this.choiceSelected}"
|
|
168
|
+
?disabled="${this.disabled}"
|
|
169
|
+
?readonly="${this.readonly}"
|
|
170
|
+
>
|
|
171
|
+
${this.options.map((e=>t`
|
|
172
|
+
<option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
|
|
173
|
+
`))}
|
|
174
|
+
</select>`}validate(){const e=this.options.find((e=>e.selected));return!!e&&""!==e.value}reset(){this.options=this.options.map(((e,t)=>Object.assign(Object.assign({},e),{selected:0===t})))}set response(e){this.options=this.options.map((t=>(e===t.value&&(t.selected=!0),t)))}choiceSelected(e){const t=e.target.value;this.options=this.options.map((e=>Object.assign(Object.assign({},e),{selected:e.value===t}))),this.saveResponse({base:{string:t}})}}F.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],customElements.define("qti-inline-choice-interaction",F);class U extends P{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>t`
|
|
175
|
+
<slot name="prompt"></slot>
|
|
176
|
+
<slot></slot>`}}U.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],U.presentationClass=["","qti-input-control-hidden"],_([n({attribute:"orientation"}),C("design:type",String)],U.prototype,"_orientation",void 0),_([n({attribute:"shuffle",type:Boolean}),C("design:type",Boolean)],U.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",U);let B=class extends k{};B=_([r("qti-simple-choice")],B);class G extends e{render(){return t`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){if(this.getAttribute("template")){const e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0.0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response identifier="RESPONSE"> </qti-map-response>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"map_response_point":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"match_correct":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-match>\n <qti-variable identifier="RESPONSE"></qti-variable>\n <qti-correct identifier="RESPONSE"></qti-correct>\n </qti-match>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">1</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'))}}const e=[...this.children];for(let t=0;t<e.length;t++){e[t].process()}}fragmentFromString(e){return document.createRange().createContextualFragment(e)}}customElements.define("qti-response-processing",G);class z extends e{render(){return t``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",z);class W extends z{render(){return t`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const s=e[t];if(s.calculate())return void s.process()}}}customElements.define("qti-response-condition",W);class K extends e{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return t`
|
|
177
|
+
<slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",K);class V extends K{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",V);class Q extends V{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",Q);class X extends f{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",X);class Y extends X{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=J(s,i[e],t.baseType);return n}return n+=J(s,i,t.baseType),n}}function J(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=Z(s,n,t);e===r&&(i+=n[1])}return i}function Z(e,t,s){let i,n;switch(e){case h.string:case h.identifier:case h.directedPair:i=""+t[0],n=""+s;break;case h.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",Y);class ee extends z{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",ee);class te extends X{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",te);class se extends X{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",se);class ie extends X{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",ie);class ne extends X{calculate(){return ne.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===h.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",ne);class re extends X{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return re.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",re);class oe extends X{calculate(){return 2===this.children.length?oe.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",oe);class ae extends X{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ae);class le extends X{render(){return t``}calculate(){return le.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",le);class ce extends X{render(){return t``}calculate(){return ce.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",ce);class de extends X{calculate(){return 1===this.children.length?de.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",de);class he extends f{constructor(){super(...arguments),this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){const t=e.querySelectorAll("properties");let s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,s.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",he);const pe=(e,t)=>class extends e{connectedCallback(){if(super.connectedCallback(),this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),e.addEventListener("dragend",(t=>{t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging")})),e.setAttribute("draggable","true")}))}},ue=(e,t)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(this.querySelectorAll(t));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,s=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},me=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:n,height:r});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/n,d=o.height/r;this.state.set(t,{left:s,top:i,width:n,height:r});const{duration:h,easing:p}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:h,easing:p})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return x(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:n})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},ge=(e,s,i)=>{class n extends(me(ue(pe(e,s),i),i,s)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(s)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return t` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(u.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(u.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},be=s`
|
|
178
|
+
.notification {
|
|
179
|
+
position: absolute;
|
|
180
|
+
z-index: 100000;
|
|
181
|
+
top: 0;
|
|
182
|
+
bottom: 0;
|
|
183
|
+
right: 0;
|
|
184
|
+
left: 0;
|
|
185
|
+
/* background: repeating-linear-gradient(45deg, #606cbc00, #606cbc00 10px, #4652980f 10px, #4652980f 20px); */
|
|
186
|
+
}
|
|
187
|
+
.notification:after {
|
|
188
|
+
position: absolute;
|
|
189
|
+
right: 1rem;
|
|
190
|
+
top: 1rem;
|
|
191
|
+
background-color: #222222;
|
|
192
|
+
color: #dddddd;
|
|
193
|
+
font-size: 14px;
|
|
194
|
+
width: fit-content;
|
|
195
|
+
padding: 0.4rem 0.6rem;
|
|
196
|
+
border-radius: 99999px;
|
|
197
|
+
content: 'preview not interactive';
|
|
198
|
+
}
|
|
199
|
+
`;class fe extends(ge(f,"qti-simple-associable-choice","drop-list")){render(){return t`
|
|
200
|
+
<slot name="prompt"></slot>
|
|
201
|
+
<slot></slot>`}firstUpdated(e){i(t`
|
|
202
|
+
${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,s)=>t`<div class="associables-container">
|
|
203
|
+
<drop-list class="associables-gap" identifier="droplist${s}_left"></drop-list>
|
|
204
|
+
<drop-list class="associables-gap" identifier="droplist${s}_right"></drop-list>
|
|
205
|
+
</div>`))}
|
|
206
|
+
`,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}fe.styles=[be],customElements.define("qti-associate-interaction",fe);class ye extends e{render(){return t`
|
|
207
|
+
<slot></slot>
|
|
208
|
+
`}}customElements.define("qti-simple-associable-choice",ye);class Ee extends(ge(e,"qti-gap-text","qti-gap")){render(){return t`<slot></slot>`}}Ee.styles=[be],customElements.define("qti-gap-match-interaction",Ee);class ve extends HTMLElement{}customElements.define("qti-gap-text",ve);class qe extends HTMLElement{}function _e(e,t,s,i){switch(e){case"circle":{const[e,n,r]=t,o=e/s.width*100,a=n/s.height*100,l=r/s.width*100;i.style.left=o-l+"%",i.style.top=a-l+"%",i.style.width=i.style.height=4*l+"px",i.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/s.width*100,l=n/s.height*100,c=r/s.width*100,d=o/s.height*100;i.style.left=a+"%",i.style.top=l+"%",i.style.width=c-a+"%",i.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,s,i)=>{if(s%2==1){const t=e.pop();e[e.length]={x:t,y:i[s]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/s.width*100,c=o/s.height*100,d=r/s.width*100,h=a/s.height*100;i.style.left=n/s.width*100+"%",i.style.top=o/s.height*100+"%",i.style.width=d-l+"%",i.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");i.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",qe);class Ce extends P{render(){return t`
|
|
209
|
+
<slot name="prompt"></slot>
|
|
210
|
+
<!-- slot for the prompt -->
|
|
211
|
+
<slot></slot>
|
|
212
|
+
<!-- slot for the image and hotspots -->
|
|
213
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");_e(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ce.styles=[s`
|
|
214
|
+
slot:not([name='prompt']) {
|
|
215
|
+
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
216
|
+
display: block;
|
|
217
|
+
width: fit-content; /* hotspots not stretching further if image is at max size */
|
|
218
|
+
}
|
|
219
|
+
::slotted(img) {
|
|
220
|
+
/* image not selectable anymore */
|
|
221
|
+
pointer-events: none;
|
|
222
|
+
user-select: none;
|
|
223
|
+
}
|
|
224
|
+
`],customElements.define("qti-graphic-associate-interaction",Ce);class xe extends(ge(f,"qti-gap-img","qti-associable-hotspot")){render(){return t` <slot></slot>
|
|
225
|
+
<slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}xe.styles=s`
|
|
226
|
+
slot[name="qti-gap-img"] {
|
|
227
|
+
display: flex;
|
|
228
|
+
gap: 1rem;
|
|
229
|
+
}
|
|
230
|
+
`,customElements.define("qti-graphic-gap-match-interaction",xe);class Oe extends P{render(){return t`
|
|
231
|
+
<slot name="prompt"></slot>
|
|
232
|
+
<!-- slot for the prompt -->
|
|
233
|
+
<slot></slot>
|
|
234
|
+
<!-- slot for the image and hotspots -->
|
|
235
|
+
`}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");_e(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Oe.styles=[s`
|
|
236
|
+
slot:not([name='prompt']) {
|
|
237
|
+
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
238
|
+
display: block;
|
|
239
|
+
width: fit-content; /* hotspots not stretching further if image is at max size */
|
|
240
|
+
}
|
|
241
|
+
::slotted(img) {
|
|
242
|
+
/* image not selectable anymore */
|
|
243
|
+
pointer-events: none;
|
|
244
|
+
user-select: none;
|
|
245
|
+
}
|
|
246
|
+
`],customElements.define("qti-graphic-order-interaction",Oe);class Se extends P{render(){return t`
|
|
247
|
+
<slot name="prompt"></slot>
|
|
248
|
+
<!-- slot for the prompt -->
|
|
249
|
+
<slot></slot>
|
|
250
|
+
<!-- slot for the image and hotspots -->
|
|
251
|
+
`}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");_e(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Se.styles=[s`
|
|
252
|
+
slot:not([name='prompt']) {
|
|
253
|
+
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
254
|
+
display: block;
|
|
255
|
+
width: fit-content; /* hotspots not stretching further if image is at max size */
|
|
256
|
+
}
|
|
257
|
+
::slotted(img) {
|
|
258
|
+
/* image not selectable anymore */
|
|
259
|
+
pointer-events: none;
|
|
260
|
+
user-select: none;
|
|
261
|
+
}
|
|
262
|
+
`],customElements.define("qti-hotspot-interaction",Se);class ke extends k{}ke.styles=s`
|
|
263
|
+
:host {
|
|
264
|
+
position: absolute;
|
|
265
|
+
}
|
|
266
|
+
`,_([n({attribute:"aria-ordervalue",type:Number,reflect:!0}),C("design:type",Number)],ke.prototype,"order",void 0),customElements.define("qti-hotspot-choice",ke);class Re extends(ge(e,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return t`
|
|
267
|
+
<slot name="prompt"></slot>
|
|
268
|
+
<slot></slot>`}}Re.styles=[be],customElements.define("qti-match-interaction",Re);class Ae extends L{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},L.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return t`
|
|
269
|
+
<slot name="prompt"></slot>
|
|
270
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback()}}Ae.styles=[be,s``],customElements.define("qti-media-interaction",Ae);class Ie extends(ge(f,"qti-simple-choice","drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return t` <slot name="prompt"> </slot>
|
|
271
|
+
<div class=${`container ${this._classNames}`}>
|
|
272
|
+
<slot class=${"vertical"===this._orientation?"ver":"hor"}> </slot>
|
|
273
|
+
<div class=${"vertical"===this._orientation?"ver":"hor"}>
|
|
274
|
+
${this.childrenMap.map(((e,s)=>t`<drop-list identifier="droplist${s}"></drop-list>`))}
|
|
275
|
+
</div>
|
|
276
|
+
</div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}Ie.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Ie.styles=[be,s`
|
|
277
|
+
.hor {
|
|
278
|
+
display: grid;
|
|
279
|
+
gap: var(--qti-gap, 2px);
|
|
280
|
+
grid-auto-flow: column;
|
|
281
|
+
grid-auto-columns: 1fr;
|
|
282
|
+
}
|
|
283
|
+
.ver {
|
|
284
|
+
width:50%;
|
|
285
|
+
display: grid;
|
|
286
|
+
gap: var(--qti-gap, 2px);
|
|
287
|
+
grid-auto-flow: row;
|
|
288
|
+
grid-auto-columns: 1fr;
|
|
289
|
+
}
|
|
290
|
+
.container {
|
|
291
|
+
display: flex;
|
|
292
|
+
gap: var(--qti-gap, 2px);
|
|
293
|
+
}
|
|
294
|
+
.qti-choices-top {
|
|
295
|
+
flex-direction: column;
|
|
296
|
+
}
|
|
297
|
+
.qti-choices-bottom {
|
|
298
|
+
flex-direction: column-reverse;
|
|
299
|
+
}
|
|
300
|
+
.qti-choices-left {
|
|
301
|
+
flex-direction: row;
|
|
302
|
+
}
|
|
303
|
+
.qti-choices-right {
|
|
304
|
+
flex-direction: row-reverse;
|
|
305
|
+
}
|
|
306
|
+
drop-list {
|
|
307
|
+
display: block;
|
|
308
|
+
background: var(--qti-background, #eee);
|
|
309
|
+
padding: var(--qti-padding-x, 0.7rem) var(--qti-padding-y, 0.5rem);
|
|
310
|
+
}
|
|
311
|
+
drop-list:empty::before {
|
|
312
|
+
content: 'drop here';
|
|
313
|
+
color: var(--qti-placeholder-text);
|
|
314
|
+
}
|
|
315
|
+
`],customElements.define("qti-order-interaction",Ie);class Ne extends P{constructor(){super()}render(){return t`<slot></slot>
|
|
316
|
+
<div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}Ne.styles=[be],customElements.define("qti-select-point-interaction",Ne);const we=37,Te=38,Le=39,He=40,Me=33,$e=34,De=35,Pe=36;class je extends L{constructor(){super(),this.addEventListener("keydown",this._onKeyDown.bind(this))}reset(){}validate(){return!0}set response(e){}set min(e){this._min=e,this.style.setProperty("--qti-slider-interaction-lower-bounds",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--qti-slider-interaction-upper-bounds",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--qti-slider-interaction-step",`${this._step}`)}get step(){return this._step}render(){return t`
|
|
317
|
+
<slot name="prompt"></slot>
|
|
318
|
+
<slot></slot>`}firstUpdated(){this.addEventListener("mousedown",this._onMouseDown.bind(this)),this.style.setProperty("--qti-slider-interaction-step",this.step?this.step.toString():"10");const e=this.getAttribute("value");this._moveSliderTo(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get RAIL_WIDTH(){return this.offsetWidth}_onKeyDown(e){let t=!1;const s=this.value;switch(e.keyCode){case we:case He:this._moveSliderTo(s-this.step),t=!0;break;case Le:case Te:this._moveSliderTo(s+this.step),t=!0;break;case $e:this._moveSliderTo(s-this.step),t=!0;break;case Me:this._moveSliderTo(s+this.step),t=!0;break;case Pe:this._moveSliderTo(this.min),t=!0;break;case De:this._moveSliderTo(this.max),t=!0}t&&(e.preventDefault(),e.stopPropagation())}_onMouseDown(e){const t=e.target,s=this.min,i=this.max,n=e=>{const n=e.pageX-t.offsetLeft,r=s+(i-s)*n/this.RAIL_WIDTH;this._moveSliderTo(r),e.preventDefault(),e.stopPropagation()},r=()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",n),document.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),e.target.focus();const o=e.pageX-t.offsetLeft,a=s+(i-s)*o/this.RAIL_WIDTH;this._moveSliderTo(a)}_moveSliderTo(e){const t=this.min,s=this.max;let i=Number(e);i<t&&(i=t),i>s&&(i=s);const n=(i-t)/(s-t)*100;this.style.setProperty("--qti-slider-interaction-aria-valuenow",`${n}%`)}}je.styles=[be,s``],_([n({type:Number,attribute:"lower-bound"}),C("design:type",Number),C("design:paramtypes",[Number])],je.prototype,"min",null),_([n({type:Number,attribute:"upper-bound"}),C("design:type",Number),C("design:paramtypes",[Number])],je.prototype,"max",null),_([n({type:Number,attribute:"step"}),C("design:type",Number),C("design:paramtypes",[Number])],je.prototype,"step",null),customElements.define("qti-slider-interaction",je);class Fe extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}levenshtein(e,t){let s;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(s=e,e=t,t=s);const i=e.length,n=t.length,r=Array(i);let o,a,l;for(o=0;o<=i;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=i;a++)s=r[a-1],r[a-1]=l,l=Math.min(s+(t[o-1]!==e[a-1]),l+1,r[a]+1);r[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,s=e.calculate(),i=t.calculate();return this.value=100-this.levenshtein(s.toString().trim(),i.toString().trim())/i.toString().length*100,this.value}}Fe.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Fe);class Ue extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/[^0-9$.,]/g,""):""}}customElements.define("qti-custom-operator-numeric",Ue);class Be extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return this.value=t?this.parseNumber(t,undefined):"",this.value}parseNumber(e,t=navigator.languages){const s=Intl.NumberFormat(t).format(1.1),i=new RegExp(`[^-+0-9${s.charAt(1)}]`,"g"),n=e.replace(i,"").replace(s.charAt(1),".");return parseFloat(n)}}Be.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Be);class Ge extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/ /g,""):""}}customElements.define("qti-custom-operator-remove-spaces",Ge);class ze extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",ze);const We={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished"};var Ke,Ve;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(Ke||(Ke={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(Ve||(Ve={}));let Qe=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=Ke.nonlinear,this._submissionMode=Ve.simultaneous,this._submitted=!1,this.itemIndex=0,this.itemNames=[]}updated(e){const t=this.querySelector("qti-test\\.prev");e.forEach(((e,s)=>{if("navigationMode"===s)this._navigationMode===Ke.linear&&(t.style.visibility="hidden"),this._navigationMode===Ke.nonlinear&&(t.style.visibility="visible")}))}onCheckItem(){return!!this._item.validateResponses()&&(this._item.processResponse(),!0)}onScoreItem(){this.onCheckItem()&&this._item.processResponse()}set itemResponse(e){this._submitted=!0,this._item.responses=e,this._navigationMode===Ke.linear&&(this._item.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(We.ON_ITEM_WAS_FINISHED)))}onPrevItem(){this.itemIndex>0&&this.dispatchRequestItem(this.itemIndex-1)}onNextItem(){this._navigationMode!==Ke.linear||this._item.validateResponses()?this.itemIndex<this.itemNames.length-1?this.dispatchRequestItem(this.itemIndex+1):this.dispatchEvent(new CustomEvent(We.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(We.ON_NO_RESPONSE_ON_SUBMIT))}dispatchRequestItem(e){this.dispatchEvent(new CustomEvent(We.ON_REQUEST_ITEM,{bubbles:!0,composed:!0,detail:e}))}onRequestItem(e){this.dispatchRequestItem(e.detail)}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}render(){return t`
|
|
319
|
+
<slot
|
|
320
|
+
@on-prev-item=${this.onPrevItem}
|
|
321
|
+
@on-next-item=${this.onNextItem}
|
|
322
|
+
@on-check-item=${this.onCheckItem}
|
|
323
|
+
@on-score-item=${this.onScoreItem}
|
|
324
|
+
@on-request-item=${this.onRequestItem}
|
|
325
|
+
>
|
|
326
|
+
</slot>
|
|
327
|
+
`}};_([n({type:Boolean}),C("design:type",Object)],Qe.prototype,"disabled",void 0),_([n({type:Boolean}),C("design:type",Object)],Qe.prototype,"readonly",void 0),_([n({type:String,attribute:"navigation-mode"}),C("design:type",Object)],Qe.prototype,"_navigationMode",void 0),_([n({type:String,attribute:"submission-mode"}),C("design:type",Object)],Qe.prototype,"_submissionMode",void 0),_([n({type:Boolean}),C("design:type",Object)],Qe.prototype,"_submitted",void 0),_([n({type:Number,attribute:"item-index",reflect:!0}),C("design:type",Object)],Qe.prototype,"itemIndex",void 0),_([o(),C("design:type",y)],Qe.prototype,"_item",void 0),_([n(),C("design:type",Array)],Qe.prototype,"itemNames",void 0),_([n(),C("design:type",Object)],Qe.prototype,"responses",void 0),Qe=_([r("qti-test")],Qe);const Xe=(e,t)=>class extends e{constructor(){super(...arguments),this.scale=1,this.ro=new ResizeObserver((e=>{for(const t of e)this.fitToParent(t.contentRect.width)}))}connectedCallback(){super.connectedCallback(),this.ro.observe(this),this.fitToParent()}static get properties(){return{scales:{type:Boolean,reflect:!0}}}updated(e){e.forEach(((e,t)=>{if("scales"===t)this.scales&&this.fitToParent()}))}fitToParent(e=this.clientWidth){const s=this.querySelector(t);if(s){const t=e/s.clientWidth;this.scale=t,this.marginY=-s.clientHeight*(1-t)+"px",requestAnimationFrame((()=>{s.style.transform=`scale(${this.scale})`,s.style.margin=`0 0 ${this.marginY} 0`}))}}};class Ye extends(Xe(e,"qti-assessment-item")){constructor(){super(...arguments),this.processResponse=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.processResponse()},this.validateResponses=()=>!!this._item&&this._item.validateResponses(),this.resetInteractions=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.resetInteractions()},this.render=()=>t`<slot @slotchange=${this.handleSlotchange}></slot>`}static get properties(){return{disabled:{type:Boolean},readonly:{type:Boolean},responses:{type:Object}}}updated(e){e.forEach(((e,t)=>{var s,i;switch(t){case"disabled":null===(s=this._item)||void 0===s||s.setAttribute("disabled","");break;case"readonly":null===(i=this._item)||void 0===i||i.setAttribute("readonly","");break;case"responses":this._item&&(this._item.responses=this.responses)}}))}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}}Ye.styles=s`
|
|
328
|
+
:host {
|
|
329
|
+
display: block; /* necessary to calculate scaling position */
|
|
330
|
+
width: 100%;
|
|
331
|
+
}
|
|
332
|
+
::slotted(qti-assessment-item) {
|
|
333
|
+
display: block; /* necessary to calculate scaling position */
|
|
334
|
+
width: 100%;
|
|
335
|
+
}
|
|
336
|
+
:host([scales]) ::slotted(qti-assessment-item) {
|
|
337
|
+
aspect-ratio: 4 / 3;
|
|
338
|
+
width: 640px !important;
|
|
339
|
+
transform-origin: 0 0;
|
|
340
|
+
}
|
|
341
|
+
`,customElements.define("qti-item",Ye);export{We as AssessmentTestEvents,h as BaseType,p as Cardinality,P as Choices,u as Events,Ke as NavigationMode,b as OutcomeVariable,le as QtiAnd,y as QtiAssessmentItem,fe as QtiAssociateInteraction,ne as QtiBaseValue,k as QtiChoice,U as QtiChoiceInteraction,re as QtiContains,te as QtiCorrect,Fe as QtiCustomOperatorLevenshtein,Ue as QtiCustomOperatorNumericOnly,Be as QtiCustomOperatorParseNumberLocalNl,Ge as QtiCustomOperatorRemoveAllSpaces,ze as QtiCustomOperatorTrim,X as QtiExpression,$ as QtiExtendedTextInteraction,w as QtiFeedbackInline,qe as QtiGap,Ee as QtiGapMatchInteraction,ve as QtiGapText,Ce as QtiGraphicAssociateInteraction,xe as QtiGraphicGapMatchInteraction,Oe as QtiGraphicOrderInteraction,oe as QtiGte,ke as QtiHotspotChoice,Se as QtiHotspotInteraction,D as QtiHottext,j as QtiHottextInteraction,F as QtiInlineChoiceInteraction,de as QtiIsNull,Ye as QtiItem,v as QtiItemBody,Y as QtiMapResponse,ie as QtiMatch,Re as QtiMatchInteraction,Ae as QtiMediaInteraction,T as QtiModalFeedback,ae as QtiMultiple,ce as QtiOr,Ie as QtiOrderInteraction,I as QtiOutcomeDeclaration,he as QtiPortableCustomInteraction,q as QtiPrompt,W as QtiResponseCondition,A as QtiResponseDeclaration,K as QtiResponseElse,Q as QtiResponseElseIf,V as QtiResponseIf,G as QtiResponseProcessing,Ne as QtiSelectPointInteraction,ee as QtiSetOutcomeValue,B as QtiSimpleChoice,je as QtiSliderInteraction,E as QtiStylesheet,Qe as QtiTest,M as QtiTextEntryInteraction,se as QtiVariable,g as ResponseVariable,m as Status,Ve as SubmissionMode,ye as qtiSimpleAssociableChoice};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Calculate } from '../../../lib/qti-utilities/ExpressionResult';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
export declare class QtiCustomOperatorLevenshtein extends LitElement implements Calculate {
|
|
4
|
+
value: any;
|
|
5
|
+
static properties: {
|
|
6
|
+
value: {};
|
|
7
|
+
};
|
|
8
|
+
render: () => import("lit-html").TemplateResult<1>;
|
|
9
|
+
private levenshtein;
|
|
10
|
+
calculate(): any;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Calculate } from '../../../lib/qti-utilities/ExpressionResult';
|
|
3
|
+
export declare class QtiCustomOperatorParseNumberLocalNl extends LitElement implements Calculate {
|
|
4
|
+
value: any;
|
|
5
|
+
static properties: {
|
|
6
|
+
value: {};
|
|
7
|
+
};
|
|
8
|
+
render: () => import("lit-html").TemplateResult<1>;
|
|
9
|
+
calculate(): any;
|
|
10
|
+
private parseNumber;
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import { Calculate } from '../../../lib/qti-utilities/ExpressionResult';
|
|
3
|
+
export declare class QtiCustomOperatorNumericOnly extends LitElement implements Calculate {
|
|
4
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
5
|
+
calculate(): string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import { Calculate } from '../../../lib/qti-utilities/ExpressionResult';
|
|
3
|
+
export declare class QtiCustomOperatorRemoveAllSpaces extends LitElement implements Calculate {
|
|
4
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
5
|
+
calculate(): string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Calculate } from '../../../lib/qti-utilities/ExpressionResult';
|
|
3
|
+
export declare class QtiCustomOperatorTrim extends LitElement implements Calculate {
|
|
4
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
5
|
+
calculate(): string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '../../../index';
|
|
2
|
+
import './qti-custom-operator-numeric-parse-nl';
|
|
3
|
+
import './qti-custom-operator-numeric';
|
|
4
|
+
import './qti-custom-operator-remove-spaces';
|
|
5
|
+
import './qti-custom-operator-trim';
|
|
6
|
+
import './qti-custom-operator-levenshtein';
|
|
7
|
+
declare const _default: {
|
|
8
|
+
title: string;
|
|
9
|
+
decorators: ((story: any) => import("lit-html").TemplateResult<1>)[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
export declare const levenshtein: () => import("lit-html").TemplateResult<1>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InputResponseFormat, QtiVariableJSON } from '../../lib/qti-utilities/ExpressionResult';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import './qti-item.scss';
|
|
4
|
+
declare const QtiItem_base: (new (...args: any[]) => import("../../lib/utilities/scale-to-fit/scale-to-fit.mixin").ScaleToFitInterface) & typeof LitElement;
|
|
5
|
+
export declare class QtiItem extends QtiItem_base {
|
|
6
|
+
private _item;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
readonly: boolean;
|
|
9
|
+
responses: InputResponseFormat<QtiVariableJSON>;
|
|
10
|
+
observer: any;
|
|
11
|
+
static styles: import("lit").CSSResult;
|
|
12
|
+
static get properties(): {
|
|
13
|
+
disabled: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
};
|
|
16
|
+
readonly: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
};
|
|
19
|
+
responses: {
|
|
20
|
+
type: ObjectConstructor;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
processResponse: () => boolean;
|
|
24
|
+
validateResponses: () => boolean;
|
|
25
|
+
resetInteractions: () => void;
|
|
26
|
+
protected updated(changedProperties: any): void;
|
|
27
|
+
private handleSlotchange;
|
|
28
|
+
render: () => import("lit-html").TemplateResult<1>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|