@citolab/qti-components 7.13.0 → 7.14.1
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/cdn/index.global.js +1 -1
- package/cdn/index.js +103 -103
- package/custom-elements.json +1128 -315
- package/dist/chunks/{chunk-IHE5M7QU.js → chunk-7567ZPN6.js} +4 -4
- package/dist/chunks/chunk-7567ZPN6.js.map +1 -0
- package/dist/chunks/{chunk-TFNRSY74.js → chunk-TISKSGJE.js} +24 -19
- package/dist/chunks/chunk-TISKSGJE.js.map +1 -0
- package/dist/chunks/{chunk-WFUXZ4UT.js → chunk-XBPO6E25.js} +27 -37
- package/dist/chunks/chunk-XBPO6E25.js.map +1 -0
- package/dist/chunks/{chunk-XI7S3HP2.js → chunk-XEKFVRIO.js} +363 -337
- package/dist/chunks/chunk-XEKFVRIO.js.map +1 -0
- package/dist/exports/qti-test.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +47 -36
- package/dist/index.js.map +1 -1
- package/dist/qti-components/index.d.ts +10 -9
- package/dist/qti-components/index.js +4 -2
- package/dist/qti-components-jsx.d.ts +15 -15
- package/dist/qti-item/index.js +2 -2
- package/dist/qti-loader/index.js +2 -2
- package/dist/qti-loader/index.js.map +1 -1
- package/dist/qti-test/index.d.ts +3 -3
- package/dist/qti-test/index.js +3 -3
- package/dist/{qti-test-DEJqAn7G.d.ts → qti-test-Db7oNIWY.d.ts} +1 -1
- package/dist/{qti-transform-test-DkSRdVBF.d.ts → qti-transform-test-Bz9A3hmD.d.ts} +2 -5
- package/dist/qti-transformers/index.d.ts +3 -3
- package/dist/qti-transformers/index.js +1 -1
- package/dist/vscode.html-custom-data.json +4 -21
- package/package.json +10 -1
- package/dist/chunks/chunk-IHE5M7QU.js.map +0 -1
- package/dist/chunks/chunk-TFNRSY74.js.map +0 -1
- package/dist/chunks/chunk-WFUXZ4UT.js.map +0 -1
- package/dist/chunks/chunk-XI7S3HP2.js.map +0 -1
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-ELDMXTUQ.js";
|
|
7
7
|
import {
|
|
8
8
|
qtiTransformItem
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XBPO6E25.js";
|
|
10
10
|
import {
|
|
11
11
|
computedItemContext
|
|
12
12
|
} from "./chunk-4OGJBG35.js";
|
|
@@ -33,8 +33,8 @@ var ItemContainer = class extends LitElement {
|
|
|
33
33
|
async handleItemURLChange() {
|
|
34
34
|
if (!this.itemURL) return;
|
|
35
35
|
try {
|
|
36
|
-
const
|
|
37
|
-
this.itemDoc =
|
|
36
|
+
const api = await qtiTransformItem().load(this.itemURL);
|
|
37
|
+
this.itemDoc = api.htmlDoc();
|
|
38
38
|
} catch (error) {
|
|
39
39
|
console.error("Error loading or parsing XML:", error);
|
|
40
40
|
}
|
|
@@ -362,4 +362,4 @@ export {
|
|
|
362
362
|
ItemShowCorrectResponse,
|
|
363
363
|
QtiItem
|
|
364
364
|
};
|
|
365
|
-
//# sourceMappingURL=chunk-
|
|
365
|
+
//# sourceMappingURL=chunk-7567ZPN6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-item/components/item-container.ts","../../src/lib/qti-item/components/print-item-variables.ts","../../src/lib/qti-item/components/item-show-correct-response.ts","../../src/lib/qti-item/components/styles.ts","../../src/lib/qti-item/core/qti-item.ts"],"sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { until } from 'lit/directives/until.js';\n\nimport { watch } from '../../decorators/watch';\nimport itemCss from '../../../item.css?inline';\nimport { qtiTransformItem } from '../../qti-transformers';\n\n/**\n * `<item-container>` is a custom element designed for hosting the qti-assessment-item.\n * The `qti-assessment-item` will be placed inside the shadow DOM of this element.\n * The element loads the item from the provided URL and renders it inside the shadow DOM.\n *\n * ### Styling\n * Add a class to the element for styling.\n *\n * ```html\n * <qti-item>\n * <item-container class=\"m-4 bg-white\" item-url=\"./path/to/item.xml\"></item-container>\n * </qti-item>\n * ```\n */\n@customElement('item-container')\nexport class ItemContainer extends LitElement {\n /** URL of the item to load */\n @property({ type: String, attribute: 'item-url' })\n itemURL: string = null;\n\n /** A parsed HTML document */\n @state()\n itemDoc: DocumentFragment = null;\n\n /** The raw XML string */\n @state()\n itemXML: string = null;\n\n /** Template content if provided */\n private templateContent = null;\n\n @watch('itemURL', { waitUntilFirstUpdate: true })\n protected async handleItemURLChange() {\n if (!this.itemURL) return;\n try {\n const api = await qtiTransformItem().load(this.itemURL);\n this.itemDoc = api.htmlDoc();\n } catch (error) {\n console.error('Error loading or parsing XML:', error);\n }\n }\n\n @watch('itemXML', { waitUntilFirstUpdate: true })\n protected handleItemXMLChange() {\n if (!this.itemXML) return;\n try {\n this.itemDoc = qtiTransformItem().parse(this.itemXML).htmlDoc();\n } catch (error) {\n console.error('Error parsing XML:', error);\n }\n }\n\n async connectedCallback(): Promise<void> {\n super.connectedCallback();\n this.initializeTemplateContent();\n this.applyStyles();\n if (this.itemURL) {\n this.handleItemURLChange();\n }\n if (this.itemXML) {\n this.handleItemXMLChange();\n }\n }\n\n private initializeTemplateContent() {\n const template = this.querySelector('template') as HTMLTemplateElement;\n this.templateContent = template ? template.content : html``;\n }\n\n private applyStyles() {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(itemCss);\n this.shadowRoot.adoptedStyleSheets = [sheet];\n }\n\n render() {\n return html`\n ${this.templateContent}\n <slot></slot>\n ${until(this.itemDoc, html`<span>Loading...</span>`)}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'item-container': ItemContainer;\n }\n}\n","import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\nimport { customElement } from 'lit/decorators.js';\n\nimport { computedItemContext } from '../../exports/computed-item.context';\n\nimport type { ResponseVariable } from '../../exports/variables';\nimport type { ComputedItemContext } from '../../exports/computed-item.context';\n\n@customElement('print-item-variables')\nexport class PrintItemVariables extends LitElement {\n @consume({ context: computedItemContext, subscribe: true })\n protected computedContext?: ComputedItemContext;\n\n static styles = css`\n table {\n width: 100%;\n border-collapse: collapse;\n margin: 20px 0;\n font-size: 14px;\n text-align: left;\n }\n th,\n td {\n border: 1px solid #ddd;\n padding: 8px;\n }\n th {\n background-color: #f4f4f4;\n font-weight: bold;\n }\n h3 {\n margin-top: 20px;\n font-size: 16px;\n }\n `;\n\n render() {\n const activeItem = this.computedContext;\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const responseVariables: ResponseVariable[] = activeItem.variables.filter(v => v.type === 'response');\n const outcomeVariables = activeItem.variables.filter(v => v.type === 'outcome');\n\n const renderTable = (variables: ResponseVariable[], title: string) => html`\n <h3>${title}</h3>\n <table>\n <thead>\n <tr>\n <th>Identifier</th>\n <th>Value</th>\n <th>Cardinality</th>\n <th>Base Type</th>\n <th>Correct Response / Mappings</th>\n </tr>\n </thead>\n <tbody>\n ${variables.map(v => {\n const correctResponse = v.correctResponse\n ? Array.isArray(v.correctResponse)\n ? v.correctResponse.join(', ')\n : v.correctResponse\n : '';\n\n const mapEntries = v.mapping?.mapEntries?.map(m => `${m.mapKey}=${m.mappedValue}pt`).join(', ') || '';\n\n const areaMapEntries =\n v.areaMapping?.areaMapEntries?.map(m => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(', ') || '';\n\n return html`\n <tr>\n <td>${v.identifier}</td>\n <td>${Array.isArray(v.value) ? v.value.join(', ') : v.value}</td>\n <td>${v.cardinality}</td>\n <td>${v.baseType}</td>\n <td>${correctResponse || mapEntries || areaMapEntries}</td>\n </tr>\n `;\n })}\n </tbody>\n </table>\n `;\n\n return html`\n ${renderTable(responseVariables, 'Response Variables')} ${renderTable(outcomeVariables, 'Outcome Variables')}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'print-item-variables': PrintItemVariables;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport * as styles from './styles';\nimport { computedItemContext } from '../../exports/computed-item.context';\n\nimport type { ComputedItemContext } from '../../exports/computed-item.context';\n\n@customElement('item-show-correct-response')\nexport class ItemShowCorrectResponse extends LitElement {\n @consume({ context: computedItemContext, subscribe: true })\n public computedContext?: ComputedItemContext;\n\n static styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: Boolean, reflect: true }) shown = false;\n @property({ type: Boolean, reflect: true }) disabled = false; // Reflects to `disabled` attribute\n @property({ type: String }) showCorrectText = 'Show correct response';\n @property({ type: String }) hideCorrectText = 'Hide correct response';\n @property({ type: String }) noCorrectResponseText = 'No correct response specified';\n\n private _hasCorrectResponse = false; // correct response is removed on certain point\n private _previousActiveItem = ''; // Store previous active item reference\n\n updated() {\n if (!this._hasCorrectResponse || this._previousActiveItem !== this.computedContext?.identifier) {\n this._previousActiveItem = this.computedContext?.identifier;\n const containsCorrectResponse = !!this.computedContext?.variables.some(v => v['correctResponse']);\n const containsMapping = !!this.computedContext?.variables.some(v => {\n return v['mapping']?.mapEntries?.length > 0 || v['areaMapping']?.areaMapEntries?.length > 0;\n });\n this._hasCorrectResponse = containsCorrectResponse || containsMapping;\n }\n this.disabled = !this._hasCorrectResponse;\n }\n\n private _toggleState() {\n if (this.disabled) return; // Prevent toggle if disabled\n\n this.dispatchEvent(\n new CustomEvent('item-show-correct-response', {\n detail: !this.shown,\n bubbles: true\n })\n );\n }\n\n private _getDisplayedText(): string {\n return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;\n }\n\n render() {\n return html` <div @click=\"${this._toggleState}\">${this._getDisplayedText()}</div> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'item-show-correct-response': ItemShowCorrectResponse;\n }\n}\n","// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n padding: 0.5rem 1rem;\n border-radius: 0.25rem;\n user-select: none;\n`;\n\nexport const btn = css`\n background-color: lightgray;\n ${form};\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.8;\n`;\n\nexport const ind = css`\n ${form};\n border: 1px solid gray;\n`;\n","import { provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { customElement, state } from 'lit/decorators.js';\n\nimport { computedItemContext } from '../../exports/computed-item.context';\nimport { configContext } from '../../exports/config.context.ts';\n\nimport type { QtiAssessmentItem } from '../../qti-components/qti-assessment-item/qti-assessment-item.ts';\nimport type { ConfigContext, CorrectResponseMode } from '../../exports/config.context.ts';\nimport type { ItemContext } from '../../exports/item.context';\nimport type { VariableDeclaration } from '../../exports/variables';\nimport type { ComputedItemContext } from '../../exports/computed-item.context';\n\n/**\n * `<qti-item>` is a custom element designed for rendering a single `qti-assessment-item`.\n * It can also host some functionalities to interact with the item like scoring, showing feedback, etc.\n * Placing a mandatory `<item-container>` inside '<qti-item>' will load or parse the item and render it.\n * See `<item-container>` for more details.\n *\n * ```html\n * <qti-item>\n * <item-container class=\"m-4 bg-white\" item-url=\"./path/to/item.xml\"></item-container>\n * </qti-item>\n * ```\n */\n@customElement('qti-item')\nexport class QtiItem extends LitElement {\n @state()\n @provide({ context: computedItemContext })\n public computedContext: ComputedItemContext;\n private _qtiAssessmentItem?: QtiAssessmentItem;\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n // Store event handlers as instance properties\n private _onItemContextChanged = this._handleItemContextChanged.bind(this);\n private _onAssessmentItemConnected = this._handleAssessmentItemConnected.bind(this);\n\n private _onHandleShowCorrectResponse = this._handleShowCorrectResponse.bind(this);\n private _onHandleShowCandidateCorrection = this._handleShowCandidateCorrection.bind(this);\n private _onHandleSwitchCorrectResponseMode = this._handleSwitchCorrectResponseMode.bind(this);\n\n constructor() {\n super();\n this.addEventListener('qti-item-context-updated', this._onItemContextChanged);\n this.addEventListener('qti-assessment-item-connected', this._onAssessmentItemConnected);\n this.addEventListener('item-show-correct-response', this._onHandleShowCorrectResponse);\n this.addEventListener('item-show-candidate-correction', this._onHandleShowCandidateCorrection);\n this.addEventListener('item-switch-correct-response-mode', this._onHandleSwitchCorrectResponseMode);\n }\n\n private _handleItemContextChanged(e: CustomEvent<{ itemContext: ItemContext }>) {\n this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail?.itemContext?.variables || []);\n }\n\n private _handleAssessmentItemConnected(e: CustomEvent<QtiAssessmentItem>) {\n const fullVariables = (e.detail as any)._context.variables;\n this._qtiAssessmentItem = e.detail;\n this.computedContext =\n this.computedContext?.identifier === this._qtiAssessmentItem.identifier\n ? { ...this.computedContext, title: this._qtiAssessmentItem.title }\n : ({\n identifier: this._qtiAssessmentItem.identifier,\n title: this._qtiAssessmentItem.title,\n adaptive: this._qtiAssessmentItem.getAttribute('adaptive')?.toLowerCase() === 'true' || false,\n variables: fullVariables,\n correctResponseMode: 'internal'\n } as ComputedItemContext);\n this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier, fullVariables || []);\n }\n\n private _handleShowCorrectResponse(e: CustomEvent<boolean>) {\n if (this._qtiAssessmentItem) {\n this._qtiAssessmentItem.showCorrectResponse(e.detail);\n }\n }\n\n private _handleShowCandidateCorrection(e: CustomEvent<boolean>) {\n if (this._qtiAssessmentItem) {\n this._qtiAssessmentItem.showCandidateCorrection(e.detail);\n }\n }\n\n private _handleSwitchCorrectResponseMode(e: CustomEvent<CorrectResponseMode>) {\n // Switch off the correct response first\n this._handleShowCorrectResponse(new CustomEvent('item-show-correct-response', { detail: false, bubbles: true }));\n\n this.configContext = {\n ...this.configContext,\n correctResponseMode: e.detail\n };\n }\n\n private _updateItemVariablesInTestContext(\n identifier: string,\n variables: readonly VariableDeclaration<string | string[] | null>[]\n ): void {\n const rawscore = variables?.find(vr => vr.identifier == 'SCORE')?.value;\n const score = parseFloat(rawscore?.toString());\n const completionStatus = variables?.find(v => v.identifier === 'completionStatus')?.value;\n\n const correct = score !== undefined && !isNaN(score) && score > 0;\n const incorrect = score !== undefined && !isNaN(score) && score <= 0;\n const completed = completionStatus === 'completed';\n this.computedContext = {\n ...this.computedContext,\n identifier,\n correct,\n incorrect,\n completed,\n variables\n };\n }\n\n render() {\n return html`<slot></slot>`;\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('qti-item-context-changed', this._onItemContextChanged);\n this.removeEventListener('qti-assessment-item-connected', this._onAssessmentItemConnected);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-item': QtiItem;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,YAAY;AACjC,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,aAAa;AAqBf,IAAM,gBAAN,cAA4B,WAAW;AAAA,EAAvC;AAAA;AAGL,mBAAkB;AAIlB,mBAA4B;AAI5B,mBAAkB;AAGlB;AAAA,SAAQ,kBAAkB;AAAA;AAAA,EAG1B,MAAgB,sBAAsB;AACpC,QAAI,CAAC,KAAK,QAAS;AACnB,QAAI;AACF,YAAM,MAAM,MAAM,iBAAiB,EAAE,KAAK,KAAK,OAAO;AACtD,WAAK,UAAU,IAAI,QAAQ;AAAA,IAC7B,SAAS,OAAO;AACd,cAAQ,MAAM,iCAAiC,KAAK;AAAA,IACtD;AAAA,EACF;AAAA,EAGU,sBAAsB;AAC9B,QAAI,CAAC,KAAK,QAAS;AACnB,QAAI;AACF,WAAK,UAAU,iBAAiB,EAAE,MAAM,KAAK,OAAO,EAAE,QAAQ;AAAA,IAChE,SAAS,OAAO;AACd,cAAQ,MAAM,sBAAsB,KAAK;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,MAAM,oBAAmC;AACvC,UAAM,kBAAkB;AACxB,SAAK,0BAA0B;AAC/B,SAAK,YAAY;AACjB,QAAI,KAAK,SAAS;AAChB,WAAK,oBAAoB;AAAA,IAC3B;AACA,QAAI,KAAK,SAAS;AAChB,WAAK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AW,KAAK,OAAK,EAAE,eAAe,kBAAkB,GAAG;AAEpF,UAAM,UAAU,UAAU,UAAa,CAAC,MAAM,KAAK,KAAK,QAAQ;AAChE,UAAM,YAAY,UAAU,UAAa,CAAC,MAAM,KAAK,KAAK,SAAS;AACnE,UAAM,YAAY,qBAAqB;AACvC,SAAK,kBAAkB;AAAA,MACrB,GAAG,KAAK;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAOC;AAAA,EACT;AAAA,EAES,uBAAuB;AAC9B,UAAM,qBAAqB;AAC3B,SAAK,oBAAoB,4BAA4B,KAAK,qBAAqB;AAC/E,SAAK,oBAAoB,iCAAiC,KAAK,0BAA0B;AAAA,EAC3F;AACF;AAhGS;AAAA,EAFNC,OAAM;AAAA,EACN,QAAQ,EAAE,SAAS,oBAAoB,CAAC;AAAA,GAF9B,QAGJ;AAKA;AAAA,EAFNA,OAAM;AAAA,EACN,QAAQ,EAAE,SAAS,cAAc,CAAC;AAAA,GAPxB,QAQJ;AARI,UAAN;AAAA,EADNC,eAAc,UAAU;AAAA,GACZ;","names":["html","LitElement","customElement","LitElement","html","customElement","css","html","LitElement","customElement","property","consume","css","LitElement","html","css","consume","property","customElement","html","LitElement","customElement","state","LitElement","html","state","customElement"]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-ELDMXTUQ.js";
|
|
10
10
|
import {
|
|
11
11
|
qtiTransformItem
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XBPO6E25.js";
|
|
13
13
|
import {
|
|
14
14
|
QtiConditionExpression
|
|
15
15
|
} from "./chunk-SV4K25ZI.js";
|
|
@@ -188,7 +188,6 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
188
188
|
this._attachEventListeners();
|
|
189
189
|
super.connectedCallback();
|
|
190
190
|
this.updateComplete.then(() => {
|
|
191
|
-
this._processTemplates();
|
|
192
191
|
this.dispatchEvent(
|
|
193
192
|
new CustomEvent("qti-assessment-item-connected", {
|
|
194
193
|
bubbles: true,
|
|
@@ -196,6 +195,7 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
196
195
|
detail: this
|
|
197
196
|
})
|
|
198
197
|
);
|
|
198
|
+
this._processTemplates();
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
disconnectedCallback() {
|
|
@@ -426,6 +426,16 @@ QtiAssessmentItem = __decorateClass([
|
|
|
426
426
|
// src/lib/qti-components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref.ts
|
|
427
427
|
import { LitElement as LitElement2 } from "lit";
|
|
428
428
|
import { customElement as customElement2, property as property2 } from "lit/decorators.js";
|
|
429
|
+
var QtiAssessmentStimulusRefConnectedEvent = class _QtiAssessmentStimulusRefConnectedEvent extends Event {
|
|
430
|
+
constructor(element, item) {
|
|
431
|
+
super(_QtiAssessmentStimulusRefConnectedEvent.eventName, { bubbles: true, composed: true, cancelable: true });
|
|
432
|
+
this.element = element;
|
|
433
|
+
this.item = item;
|
|
434
|
+
}
|
|
435
|
+
static {
|
|
436
|
+
this.eventName = "qti-assessment-stimulus-ref-connected";
|
|
437
|
+
}
|
|
438
|
+
};
|
|
429
439
|
var QtiAssessmentStimulusRef = class extends LitElement2 {
|
|
430
440
|
constructor() {
|
|
431
441
|
super(...arguments);
|
|
@@ -434,24 +444,18 @@ var QtiAssessmentStimulusRef = class extends LitElement2 {
|
|
|
434
444
|
}
|
|
435
445
|
/**
|
|
436
446
|
* Lifecycle method called when the element is connected to the DOM.
|
|
437
|
-
*
|
|
447
|
+
* First checks if there's a data-stimulus-idref element. If found, loads the stimulus directly.
|
|
448
|
+
* If not found, delegates to the delivery platform via an event.
|
|
438
449
|
*/
|
|
439
450
|
async connectedCallback() {
|
|
440
451
|
super.connectedCallback();
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const item = this.closest("qti-assessment-item");
|
|
449
|
-
const stimulusRef = item.querySelector(`[data-stimulus-idref=${this.identifier}]`);
|
|
450
|
-
if (stimulusRef) {
|
|
451
|
-
await this.updateStimulusRef(stimulusRef);
|
|
452
|
-
} else {
|
|
453
|
-
console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`);
|
|
454
|
-
}
|
|
452
|
+
await this.updateComplete;
|
|
453
|
+
const item = this.closest("qti-assessment-item");
|
|
454
|
+
const event = new QtiAssessmentStimulusRefConnectedEvent(this, item);
|
|
455
|
+
this.dispatchEvent(event);
|
|
456
|
+
const stimulusRef = item?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);
|
|
457
|
+
if (!event.defaultPrevented && stimulusRef) {
|
|
458
|
+
await this.updateStimulusRef(stimulusRef);
|
|
455
459
|
}
|
|
456
460
|
}
|
|
457
461
|
/**
|
|
@@ -459,7 +463,7 @@ var QtiAssessmentStimulusRef = class extends LitElement2 {
|
|
|
459
463
|
* @param stimulusRef - The element to which the stimulus will be appended.
|
|
460
464
|
*/
|
|
461
465
|
async updateStimulusRef(stimulusRef) {
|
|
462
|
-
const stimulus = await qtiTransformItem().load(this.href).
|
|
466
|
+
const stimulus = await qtiTransformItem().load(this.href).then((api) => api.htmlDoc());
|
|
463
467
|
if (stimulus) {
|
|
464
468
|
const elements = stimulus.querySelectorAll("qti-stimulus-body, qti-stylesheet");
|
|
465
469
|
stimulusRef.innerHTML = "";
|
|
@@ -8726,6 +8730,7 @@ QtiResponseDeclaration = __decorateClass([
|
|
|
8726
8730
|
|
|
8727
8731
|
export {
|
|
8728
8732
|
QtiAssessmentItem,
|
|
8733
|
+
QtiAssessmentStimulusRefConnectedEvent,
|
|
8729
8734
|
QtiAssessmentStimulusRef,
|
|
8730
8735
|
QtiCompanionMaterialsInfo,
|
|
8731
8736
|
QtiCustomOperator,
|
|
@@ -8822,4 +8827,4 @@ export {
|
|
|
8822
8827
|
QtiOutcomeDeclaration,
|
|
8823
8828
|
QtiResponseDeclaration
|
|
8824
8829
|
};
|
|
8825
|
-
//# sourceMappingURL=chunk-
|
|
8830
|
+
//# sourceMappingURL=chunk-TISKSGJE.js.map
|