@citolab/qti-components 6.0.2-1 → 6.0.2

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.
@@ -0,0 +1,17 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2TX3IEPDcjs = require('../chunk-2TX3IEPD.cjs');var _chunkHOQW4KDAcjs = require('../chunk-HOQW4KDA.cjs');var _lit = require('lit');var h=(p,d)=>{class e extends p{constructor(){super(...arguments);this.scale=1;this.ro=new ResizeObserver(t=>{for(let r of t)this.fitToParent(r.contentRect.width)})}connectedCallback(){super.connectedCallback(),this.ro.observe(this),this.fitToParent()}static get properties(){return{scales:{type:Boolean,reflect:!0}}}updated(t){t.forEach((r,n)=>{switch(n){case"scales":this.scales&&this.fitToParent();break}})}fitToParent(t=this.clientWidth){let r=this.querySelector(d);if(r){let n=t/r.clientWidth;this.scale=n,this.marginY=-r.clientHeight*(1-n)+"px",requestAnimationFrame(()=>{r.style.transform=`scale(${this.scale})`,r.style.margin=`0 0 ${this.marginY} 0`})}}}return e};var _decoratorsjs = require('lit/decorators.js');var s=class extends h(_lit.LitElement,"qti-assessment-item"){constructor(){super(...arguments);this.disabled=!1;this.readonly=!1;this.processResponse=()=>{var e;return(e=this._item)==null?void 0:e.processResponse()};this.validateResponses=()=>this._item?this._item.validateResponses():!1;this.resetInteractions=()=>{var e;return(e=this._item)==null?void 0:e.resetInteractions()};this.render=()=>_lit.html`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,i){var o,t;i&&((o=this._item)==null||o.setAttribute("disabled","")),!i&&((t=this._item)==null||t.removeAttribute("disabled"))}handleReadonlyChange(e,i){var o,t;i&&((o=this._item)==null||o.setAttribute("readonly","")),!i&&((t=this._item)==null||t.removeAttribute("readonly"))}handleResponsesChange(e,i){this._item&&(this._item.responses=i)}handleSlotchange(e){let i=e.target.assignedNodes({flatten:!0});this._item=null,i.forEach(o=>{o.nodeName=="QTI-ASSESSMENT-ITEM"&&(this._item=o,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))})}};s.styles=_lit.css`
2
+ :host {
3
+ display: block; /* necessary to calculate scaling position */
4
+ width: 100%;
5
+ height: 100%;
6
+ overflow: auto;
7
+ }
8
+ ::slotted(qti-assessment-item) {
9
+ display: block; /* necessary to calculate scaling position */
10
+ width: 100%;
11
+ }
12
+ :host([scales]) ::slotted(qti-assessment-item) {
13
+ aspect-ratio: 4 / 3;
14
+ width: 1024px;
15
+ transform-origin: 0 0;
16
+ }
17
+ `,_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],s.prototype,"disabled",2),_chunkHOQW4KDAcjs.c.call(void 0, [_chunk2TX3IEPDcjs.a.call(void 0, "disabled",{waitUntilFirstUpdate:!0})],s.prototype,"handleDisabledChange",1),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean,reflect:!0})],s.prototype,"readonly",2),_chunkHOQW4KDAcjs.c.call(void 0, [_chunk2TX3IEPDcjs.a.call(void 0, "readonly",{waitUntilFirstUpdate:!0})],s.prototype,"handleReadonlyChange",1),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Object,reflect:!0})],s.prototype,"responses",2),_chunkHOQW4KDAcjs.c.call(void 0, [_chunk2TX3IEPDcjs.a.call(void 0, "responses",{waitUntilFirstUpdate:!0})],s.prototype,"handleResponsesChange",1),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],s.prototype,"_item",2);customElements.define("qti-item",s);exports.QtiItem = s;
@@ -1,8 +1,8 @@
1
1
  import * as lit_html from 'lit-html';
2
2
  import * as lit from 'lit';
3
3
  import { LitElement } from 'lit';
4
- import { R as ResponseInteraction } from '../ExpressionResult-b1ac7b27.js';
5
- import { Q as QtiAssessmentItem } from '../qti-assessment-item-219cef9e.js';
4
+ import { I as InputResponseFormat, Q as QtiVariableJSON } from '../ExpressionResult-2192c3d8.js';
5
+ import { a as QtiAssessmentItem } from '../qti-assessment-item-e9f437d6.js';
6
6
 
7
7
  declare class ScaleToFitInterface {
8
8
  }
@@ -13,21 +13,14 @@ declare class QtiItem extends QtiItem_base {
13
13
  handleDisabledChange(old: any, disabled: boolean): void;
14
14
  readonly: boolean;
15
15
  handleReadonlyChange(old: any, readonly: boolean): void;
16
- responses: ResponseInteraction[];
17
- handleResponsesChange(old: any, responses: ResponseInteraction[]): void;
18
- set qtiContext(context: {
19
- view: 'author' | 'candidate' | 'proctor' | 'scorer' | 'testConstructor' | 'tutor';
20
- });
21
- private provider;
22
- private _xml;
23
- get _item(): QtiAssessmentItem;
24
- set xml(val: string);
25
- get xml(): string;
16
+ responses: InputResponseFormat<QtiVariableJSON>;
17
+ handleResponsesChange(old: any, responses: InputResponseFormat<QtiVariableJSON>): void;
18
+ _item: QtiAssessmentItem;
26
19
  static styles: lit.CSSResult;
27
20
  processResponse: () => boolean;
28
21
  validateResponses: () => boolean;
29
22
  resetInteractions: () => void;
30
- connectedCallback(): void;
23
+ private handleSlotchange;
31
24
  render: () => lit_html.TemplateResult<1>;
32
25
  }
33
26
 
@@ -1 +1,17 @@
1
- import{a as o}from"../chunk-M3YT56HW.js";import"../chunk-DLLHO3W2.js";import"../chunk-NMCIOGD2.js";export{o as QtiItem};
1
+ import{a as l}from"../chunk-JQY6IKDF.js";import{c as a}from"../chunk-NMCIOGD2.js";import{css as m,html as u,LitElement as f}from"lit";var h=(p,d)=>{class e extends p{constructor(){super(...arguments);this.scale=1;this.ro=new ResizeObserver(t=>{for(let r of t)this.fitToParent(r.contentRect.width)})}connectedCallback(){super.connectedCallback(),this.ro.observe(this),this.fitToParent()}static get properties(){return{scales:{type:Boolean,reflect:!0}}}updated(t){t.forEach((r,n)=>{switch(n){case"scales":this.scales&&this.fitToParent();break}})}fitToParent(t=this.clientWidth){let r=this.querySelector(d);if(r){let n=t/r.clientWidth;this.scale=n,this.marginY=-r.clientHeight*(1-n)+"px",requestAnimationFrame(()=>{r.style.transform=`scale(${this.scale})`,r.style.margin=`0 0 ${this.marginY} 0`})}}}return e};import{property as c,state as b}from"lit/decorators.js";var s=class extends h(f,"qti-assessment-item"){constructor(){super(...arguments);this.disabled=!1;this.readonly=!1;this.processResponse=()=>{var e;return(e=this._item)==null?void 0:e.processResponse()};this.validateResponses=()=>this._item?this._item.validateResponses():!1;this.resetInteractions=()=>{var e;return(e=this._item)==null?void 0:e.resetInteractions()};this.render=()=>u`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,i){var o,t;i&&((o=this._item)==null||o.setAttribute("disabled","")),!i&&((t=this._item)==null||t.removeAttribute("disabled"))}handleReadonlyChange(e,i){var o,t;i&&((o=this._item)==null||o.setAttribute("readonly","")),!i&&((t=this._item)==null||t.removeAttribute("readonly"))}handleResponsesChange(e,i){this._item&&(this._item.responses=i)}handleSlotchange(e){let i=e.target.assignedNodes({flatten:!0});this._item=null,i.forEach(o=>{o.nodeName=="QTI-ASSESSMENT-ITEM"&&(this._item=o,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))})}};s.styles=m`
2
+ :host {
3
+ display: block; /* necessary to calculate scaling position */
4
+ width: 100%;
5
+ height: 100%;
6
+ overflow: auto;
7
+ }
8
+ ::slotted(qti-assessment-item) {
9
+ display: block; /* necessary to calculate scaling position */
10
+ width: 100%;
11
+ }
12
+ :host([scales]) ::slotted(qti-assessment-item) {
13
+ aspect-ratio: 4 / 3;
14
+ width: 1024px;
15
+ transform-origin: 0 0;
16
+ }
17
+ `,a([c({type:Boolean,reflect:!0})],s.prototype,"disabled",2),a([l("disabled",{waitUntilFirstUpdate:!0})],s.prototype,"handleDisabledChange",1),a([c({type:Boolean,reflect:!0})],s.prototype,"readonly",2),a([l("readonly",{waitUntilFirstUpdate:!0})],s.prototype,"handleReadonlyChange",1),a([c({type:Object,reflect:!0})],s.prototype,"responses",2),a([l("responses",{waitUntilFirstUpdate:!0})],s.prototype,"handleResponsesChange",1),a([b()],s.prototype,"_item",2);customElements.define("qti-item",s);export{s as QtiItem};
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJLKCCEGGcjs = require('../chunk-JLKCCEGG.cjs');var _chunk2TX3IEPDcjs = require('../chunk-2TX3IEPD.cjs');var _chunkHOQW4KDAcjs = require('../chunk-HOQW4KDA.cjs');var _lit = require('lit');var m=(n,c)=>{class e extends n{_dispatch(){this.dispatchEvent(new CustomEvent(c,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}}return e};customElements.define("qti-test-next",class extends m(_lit.LitElement,"on-next-item"){constructor(){super(...arguments);this.render=()=>_lit.html`<slot></slot>`}});customElements.define("qti-test-item",class extends m(_lit.LitElement,"on-request-item"){constructor(){super(...arguments);this.render=()=>_lit.html`<slot></slot>`}});customElements.define("qti-test-prev",class extends m(_lit.LitElement,"on-prev-item"){constructor(){super(...arguments);this.render=()=>_lit.html`<slot></slot>`}});customElements.define("qti-test-check",class extends m(_lit.LitElement,"on-check-item"){constructor(){super(...arguments);this.render=()=>_lit.html`<slot></slot>`}});customElements.define("qti-test-score",class extends m(_lit.LitElement,"on-score-item"){constructor(){super(...arguments);this.render=()=>_lit.html`<slot></slot>`}});customElements.define("qti-test-show-correct",class extends m(_lit.LitElement,"on-show-correct"){constructor(){super(...arguments);this.render=()=>_lit.html`<slot></slot>`}});var _context = require('@lit-labs/context');var _decoratorsjs = require('lit/decorators.js');var o={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"},b= exports.NavigationMode =(e=>(e.linear="linear",e.nonlinear="nonlinear",e))(b||{}),x= exports.SubmissionMode =(e=>(e.individual="individual",e.simultaneous="simultaneous",e))(x||{}),t= exports.QtiTest =class extends _lit.LitElement{constructor(){super(...arguments);this.disabled=!1;this.readonly=!1;this._navigationMode="nonlinear";this._submissionMode="simultaneous";this.items=[];this.itemIndex=0;this.provider=new (0, _context.ContextProvider)(this,_chunkJLKCCEGGcjs.a,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,s){this.prevButton.style.visibility=s==="linear"?"hidden":"visible"}handleItemIndexChange(e,s){this.emit(o.ON_REQUEST_ITEM,{detail:s})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode==="linear"&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(o.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return this._itemRef.validateResponses()?(this._itemRef.processResponse(),!0):!1}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(o.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){if(this._navigationMode==="linear"&&!this._itemRef.validateResponses()){this.dispatchEvent(new CustomEvent(o.ON_NO_RESPONSE_ON_SUBMIT));return}this.itemIndex<this.items.length-1?this.emit(o.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(o.ON_TEST_FINISHED))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(o.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){let s=this.querySelector("qti-assessment-item");s&&(this._itemRef=s,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(o.ON_ITEM_READY,{detail:s}))}render(){return _lit.html`
2
+ <slot
3
+ @slotchange=${this._handleSlotchange}
4
+ @on-prev-item=${this._onPrevItem}
5
+ @on-next-item=${this._onNextItem}
6
+ @on-check-item=${this._onCheckItem}
7
+ @on-score-item=${this._onScoreItem}
8
+ @on-request-item=${this._onRequestItem}
9
+ @on-show-correct=${this._onShowCorrect}
10
+ >
11
+ </slot>
12
+ `}emit(e,s){let v=new CustomEvent(e,_chunkHOQW4KDAcjs.a.call(void 0, {bubbles:!0,cancelable:!1,composed:!0,detail:{}},s));this.dispatchEvent(v)}};_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.query.call(void 0, "qti-test-prev")],t.prototype,"prevButton",2),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.query.call(void 0, "qti-test-next")],t.prototype,"nextButton",2),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean})],t.prototype,"disabled",2),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Boolean})],t.prototype,"readonly",2),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"navigation-mode"})],t.prototype,"_navigationMode",2),_chunkHOQW4KDAcjs.c.call(void 0, [_chunk2TX3IEPDcjs.a.call(void 0, "_navigationMode",{waitUntilFirstUpdate:!0})],t.prototype,"handleNavigationModeChange",1),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:String,attribute:"submission-mode"})],t.prototype,"_submissionMode",2),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, )],t.prototype,"items",2),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.property.call(void 0, {type:Number,attribute:"item-index",reflect:!0})],t.prototype,"itemIndex",2),_chunkHOQW4KDAcjs.c.call(void 0, [_chunk2TX3IEPDcjs.a.call(void 0, "itemIndex",{waitUntilFirstUpdate:!0})],t.prototype,"handleItemIndexChange",1),_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.state.call(void 0, )],t.prototype,"_itemRef",2),t= exports.QtiTest =_chunkHOQW4KDAcjs.c.call(void 0, [_decoratorsjs.customElement.call(void 0, "qti-test")],t);exports.NavigationMode = b; exports.QtiTest = t; exports.SubmissionMode = x; exports.TestEvents = o;
@@ -1,6 +1,6 @@
1
1
  import * as lit_html from 'lit-html';
2
2
  import { LitElement } from 'lit';
3
- import { R as ResponseInteraction } from '../ExpressionResult-b1ac7b27.js';
3
+ import { I as InputResponseFormat, Q as QtiVariableJSON } from '../ExpressionResult-2192c3d8.js';
4
4
 
5
5
  declare const TestEvents: {
6
6
  ON_ITEM_WAS_FINISHED: string;
@@ -45,7 +45,7 @@ declare class QtiTest extends LitElement {
45
45
  });
46
46
  set itemXML(xml: string);
47
47
  set manualOutcomeValue(value: any);
48
- set itemResponse(val: ResponseInteraction[]);
48
+ set itemResponse(val: InputResponseFormat<QtiVariableJSON>);
49
49
  private provider;
50
50
  private _onCheckItem;
51
51
  private _onScoreItem;
@@ -1,14 +1,12 @@
1
- import{a as d,b as u}from"../chunk-DLLHO3W2.js";import{a as h,c as i}from"../chunk-NMCIOGD2.js";import{LitElement as r,html as a}from"lit";var m=(n,c)=>{class e extends n{_dispatch(){this.dispatchEvent(new CustomEvent(c,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}}return e};customElements.define("qti-test-next",class extends m(r,"on-next-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-item",class extends m(r,"on-request-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-prev",class extends m(r,"on-prev-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-check",class extends m(r,"on-check-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-score",class extends m(r,"on-score-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-show-correct",class extends m(r,"on-show-correct"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});import{html as _,LitElement as E}from"lit";import{ContextProvider as f}from"@lit-labs/context";import{customElement as I,property as l,query as p,state as R}from"lit/decorators.js";var o={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"},b=(e=>(e.linear="linear",e.nonlinear="nonlinear",e))(b||{}),x=(e=>(e.individual="individual",e.simultaneous="simultaneous",e))(x||{}),t=class extends E{constructor(){super(...arguments);this.disabled=!1;this.readonly=!1;this._navigationMode="nonlinear";this._submissionMode="simultaneous";this.items=[];this.itemIndex=0;this.provider=new f(this,u,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,s){this.prevButton.style.visibility=s==="linear"?"hidden":"visible"}handleItemIndexChange(e,s){this.emit(o.ON_REQUEST_ITEM,{detail:s})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode==="linear"&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(o.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return this._itemRef.validateResponses()?(this._itemRef.processResponse(),!0):!1}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(o.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){if(this._navigationMode==="linear"&&!this._itemRef.validateResponses()){this.dispatchEvent(new CustomEvent(o.ON_NO_RESPONSE_ON_SUBMIT));return}this.itemIndex<this.items.length-1?this.emit(o.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(o.ON_TEST_FINISHED))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(o.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){let s=this.querySelector("qti-assessment-item");s&&(this._itemRef=s,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(o.ON_ITEM_READY,{detail:s}))}render(){return _`
2
- <slot name="qti-item"></slot>
3
- <slot
4
- @slotchange=${this._handleSlotchange}
5
- @on-prev-item=${this._onPrevItem}
6
- @on-next-item=${this._onNextItem}
7
- @on-check-item=${this._onCheckItem}
8
- @on-score-item=${this._onScoreItem}
9
- @on-request-item=${this._onRequestItem}
10
- @on-show-correct=${this._onShowCorrect}
11
- >
12
- </slot>
1
+ import{a as u}from"../chunk-L6436D6O.js";import{a as d}from"../chunk-JQY6IKDF.js";import{a as h,c as i}from"../chunk-NMCIOGD2.js";import{LitElement as r,html as a}from"lit";var m=(n,c)=>{class e extends n{_dispatch(){this.dispatchEvent(new CustomEvent(c,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}}return e};customElements.define("qti-test-next",class extends m(r,"on-next-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-item",class extends m(r,"on-request-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-prev",class extends m(r,"on-prev-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-check",class extends m(r,"on-check-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-score",class extends m(r,"on-score-item"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});customElements.define("qti-test-show-correct",class extends m(r,"on-show-correct"){constructor(){super(...arguments);this.render=()=>a`<slot></slot>`}});import{html as _,LitElement as E}from"lit";import{ContextProvider as f}from"@lit-labs/context";import{customElement as I,property as l,query as p,state as R}from"lit/decorators.js";var o={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"},b=(e=>(e.linear="linear",e.nonlinear="nonlinear",e))(b||{}),x=(e=>(e.individual="individual",e.simultaneous="simultaneous",e))(x||{}),t=class extends E{constructor(){super(...arguments);this.disabled=!1;this.readonly=!1;this._navigationMode="nonlinear";this._submissionMode="simultaneous";this.items=[];this.itemIndex=0;this.provider=new f(this,u,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,s){this.prevButton.style.visibility=s==="linear"?"hidden":"visible"}handleItemIndexChange(e,s){this.emit(o.ON_REQUEST_ITEM,{detail:s})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode==="linear"&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(o.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return this._itemRef.validateResponses()?(this._itemRef.processResponse(),!0):!1}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(o.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){if(this._navigationMode==="linear"&&!this._itemRef.validateResponses()){this.dispatchEvent(new CustomEvent(o.ON_NO_RESPONSE_ON_SUBMIT));return}this.itemIndex<this.items.length-1?this.emit(o.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(o.ON_TEST_FINISHED))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(o.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){let s=this.querySelector("qti-assessment-item");s&&(this._itemRef=s,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(o.ON_ITEM_READY,{detail:s}))}render(){return _`
2
+ <slot
3
+ @slotchange=${this._handleSlotchange}
4
+ @on-prev-item=${this._onPrevItem}
5
+ @on-next-item=${this._onNextItem}
6
+ @on-check-item=${this._onCheckItem}
7
+ @on-score-item=${this._onScoreItem}
8
+ @on-request-item=${this._onRequestItem}
9
+ @on-show-correct=${this._onShowCorrect}
10
+ >
13
11
  </slot>
14
- `}emit(e,s){let v=new CustomEvent(e,h({bubbles:!0,cancelable:!1,composed:!0,detail:{}},s));this.dispatchEvent(v)}};i([p("qti-test-prev")],t.prototype,"prevButton",2),i([p("qti-test-next")],t.prototype,"nextButton",2),i([l({type:Boolean})],t.prototype,"disabled",2),i([l({type:Boolean})],t.prototype,"readonly",2),i([l({type:String,attribute:"navigation-mode"})],t.prototype,"_navigationMode",2),i([d("_navigationMode",{waitUntilFirstUpdate:!0})],t.prototype,"handleNavigationModeChange",1),i([l({type:String,attribute:"submission-mode"})],t.prototype,"_submissionMode",2),i([l({attribute:!1})],t.prototype,"items",2),i([l({type:Number,attribute:"item-index",reflect:!0})],t.prototype,"itemIndex",2),i([d("itemIndex",{waitUntilFirstUpdate:!0})],t.prototype,"handleItemIndexChange",1),i([R()],t.prototype,"_itemRef",2),t=i([I("qti-test")],t);export{b as NavigationMode,t as QtiTest,x as SubmissionMode,o as TestEvents};
12
+ `}emit(e,s){let v=new CustomEvent(e,h({bubbles:!0,cancelable:!1,composed:!0,detail:{}},s));this.dispatchEvent(v)}};i([p("qti-test-prev")],t.prototype,"prevButton",2),i([p("qti-test-next")],t.prototype,"nextButton",2),i([l({type:Boolean})],t.prototype,"disabled",2),i([l({type:Boolean})],t.prototype,"readonly",2),i([l({type:String,attribute:"navigation-mode"})],t.prototype,"_navigationMode",2),i([d("_navigationMode",{waitUntilFirstUpdate:!0})],t.prototype,"handleNavigationModeChange",1),i([l({type:String,attribute:"submission-mode"})],t.prototype,"_submissionMode",2),i([l()],t.prototype,"items",2),i([l({type:Number,attribute:"item-index",reflect:!0})],t.prototype,"itemIndex",2),i([d("itemIndex",{waitUntilFirstUpdate:!0})],t.prototype,"handleItemIndexChange",1),i([R()],t.prototype,"_itemRef",2),t=i([I("qti-test")],t);export{b as NavigationMode,t as QtiTest,x as SubmissionMode,o as TestEvents};
@@ -0,0 +1,102 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }require('../chunk-HOQW4KDA.cjs');var _cheerio = require('cheerio'); var p = _interopRequireWildcard(_cheerio);var u=(x="type")=>`<?xml version="1.0" encoding="utf-8"?>
2
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qti="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:m="http://www.w3.org/1998/Math/MathML">
3
+ <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
4
+ <xsl:param name="separator" select="' '" />
5
+ <xsl:param name="prefix" select="'type:'" />
6
+ <xsl:variable name="prefixElements"></xsl:variable>
7
+ <xsl:variable name="suffixElements"></xsl:variable>
8
+ <!-- passthrough -->
9
+ <xsl:template match="*">
10
+ <xsl:copy>
11
+ <xsl:apply-templates select="* | @* | text()" />
12
+ </xsl:copy>
13
+ </xsl:template>
14
+ <xsl:template match="@* | text()">
15
+ <xsl:copy-of select="." />
16
+ </xsl:template>
17
+
18
+ <xsl:template match="*">
19
+ <xsl:variable name="elementName">
20
+ <xsl:call-template name="getTypedElementName">
21
+ <xsl:with-param name="input" select="." />
22
+ </xsl:call-template>
23
+ </xsl:variable>
24
+ <xsl:element name="{$elementName}">
25
+ <xsl:apply-templates select="* | @* | text()" />
26
+ </xsl:element>
27
+ </xsl:template>
28
+
29
+ <!-- custom names -->
30
+ <xsl:template name="getType">
31
+ <xsl:param name="input" />
32
+ <xsl:param name="separator" select="$separator" />
33
+ <xsl:param name="prefix" select="$prefix" />
34
+ <xsl:variable name="output">
35
+ <xsl:choose>
36
+ <xsl:when test="contains($input, $separator)">
37
+ <xsl:value-of select="substring-before($input, $separator)" />
38
+ </xsl:when>
39
+ <xsl:otherwise>
40
+ <xsl:value-of select="$input" />
41
+ </xsl:otherwise>
42
+ </xsl:choose>
43
+ </xsl:variable>
44
+ <xsl:choose>
45
+ <xsl:when test="starts-with($output, $prefix) and $output != $prefix">
46
+ <xsl:value-of select="substring-after($output, $prefix)" />
47
+ </xsl:when>
48
+ <xsl:otherwise>
49
+ <xsl:variable name="after" select="substring-after($input, $separator)" />
50
+ <xsl:if test="$after">
51
+ <xsl:call-template name="getType">
52
+ <xsl:with-param name="input" select="$after" />
53
+ <xsl:with-param name="separator" select="$separator" />
54
+ <xsl:with-param name="prefix" select="$prefix" />
55
+ </xsl:call-template>
56
+ </xsl:if>
57
+ </xsl:otherwise>
58
+ </xsl:choose>
59
+ </xsl:template>
60
+
61
+ <xsl:template name="getTypedElementName">
62
+ <xsl:param name="input" />
63
+ <xsl:variable name="prefixElements" select="document('')//xsl:variable[@name = 'prefixElements']/element" />
64
+ <xsl:variable name="suffixElements" select="document('')//xsl:variable[@name = 'suffixElements']/element" />
65
+ <xsl:variable name="originalName" select="name($input)" />
66
+ <xsl:variable name="type">
67
+ <xsl:call-template name="getType">
68
+ <xsl:with-param name="input" select="$input/@class" />
69
+ </xsl:call-template>
70
+ </xsl:variable>
71
+ <xsl:value-of select="$originalName" />
72
+ <!-- Add prefix elements -->
73
+ <xsl:if test="$prefixElements[text() = $originalName]">
74
+ <xsl:text>-</xsl:text>
75
+ </xsl:if>
76
+ <!-- Add suffix to typed elements -->
77
+ <xsl:if test="string-length($type)">
78
+ <xsl:text>-</xsl:text>
79
+ <xsl:value-of select="$type" />
80
+ </xsl:if>
81
+ <!-- Add suffix to elements -->
82
+ <xsl:if test="$suffixElements[text() = $originalName]">
83
+ <xsl:text>-</xsl:text>
84
+ </xsl:if>
85
+ </xsl:template>
86
+ </xsl:stylesheet>`,f=`
87
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
88
+ <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
89
+ <xsl:template match="*">
90
+ <!-- remove element prefix -->
91
+ <xsl:element name="{local-name()}">
92
+ <!-- process attributes -->
93
+ <xsl:for-each select="@*">
94
+ <!-- remove attribute prefix -->
95
+ <xsl:attribute name="{local-name()}">
96
+ <xsl:value-of select="."/>
97
+ </xsl:attribute>
98
+ </xsl:for-each>
99
+ <xsl:apply-templates/>
100
+ </xsl:element>
101
+ </xsl:template>
102
+ </xsl:stylesheet>`,b= exports.qtiTransform =x=>{let e=x,i=t=>{let l=new DOMParser().parseFromString(e,"text/xml"),a=new XSLTProcessor,n=new DOMParser().parseFromString(t,"text/xml");a.importStylesheet(n);let r=a.transformToFragment(l,document);e=new XMLSerializer().serializeToString(r)},s={mathml(){let t=p.load(e,{xmlMode:!0,xml:!0});return t("math").each((l,a)=>{a.tagName="math-ml"}).find("*").each((l,a)=>{a.tagName=`math-${a.tagName.substring(1)}`}),e=t.xml(),s},removeNamesSpaces(){return i(f),s},pciHooks(t){let l=["hook","module"],a=t.substring(0,t.lastIndexOf("/")),n=new DOMParser().parseFromString(e,"text/xml");for(let r of l)n.querySelectorAll("["+r+"]").forEach(o=>{let m=o.getAttribute(r);!m.startsWith("data:")&&!m.startsWith("http")&&(o.setAttribute("base-url",t),o.setAttribute("module",a+"/"+encodeURIComponent(m+(m.endsWith(".js")?"":".js"))))});return e=new XMLSerializer().serializeToString(n),s},assetsLocation(t,l=["src","href","data"]){let a=t.substring(0,t.lastIndexOf("/")),n=new DOMParser().parseFromString(e,"text/xml");for(let r of l)n.querySelectorAll("["+r+"]").forEach(o=>{let m=o.getAttribute(r);!m.startsWith("data:")&&!m.startsWith("http")&&o.setAttribute(r,a+"/"+encodeURIComponent(m))});return e=new XMLSerializer().serializeToString(n),s},customTypes(){return i(u()),s},suffix(t,l){let a=p.load(e,{xml:!0,xmlMode:!0});return a("*").each((n,r)=>{t.includes(r.name)&&(r.name=`${r.name}-${l}`)}),e=a.xml(),s},fn(t){return e=t(e),s},fnCh(t){let l=p.load(e,{xml:!0,xmlMode:!0});return t(l),e=l.xml(),s},elementNameAttributes(t){return t.forEach(l=>{e=g(e,l,l+` data-element="${l}" `)}),s},print(){return console.log(e),s},xml(){return e=h(e),e}};return s},h= exports.fixSelfClosingTags =x=>{let e=x.split("/>"),i="";for(let s=0;s<e.length-1;s++){let t=e[s].split("<");i+=e[s]+"></"+t[t.length-1].split(" ")[0]+">"}return i+e[e.length-1]};function g(x,e,i){return x.replace(new RegExp(e,"g"),i)}exports.fixSelfClosingTags = h; exports.qtiTransform = b;