@pie-qti/item-player 1.0.0-beta.4 → 1.0.0-beta.6
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/README.md +34 -6
- package/dist/catalog/applyGlossaryTriggers.js +14 -2
- package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
- package/dist/catalog/catalogExtractor.js +2 -4
- package/dist/catalog/catalogExtractor.js.map +1 -1
- package/dist/catalog/sessionCatalog.d.ts +46 -0
- package/dist/catalog/sessionCatalog.js +87 -0
- package/dist/catalog/sessionCatalog.js.map +1 -0
- package/dist/components/utils/endAttempt.d.ts +16 -0
- package/dist/components/utils/endAttempt.js +28 -0
- package/dist/components/utils/endAttempt.js.map +1 -0
- package/dist/components/utils/focus.d.ts +19 -0
- package/dist/components/utils/focus.js +67 -0
- package/dist/components/utils/focus.js.map +1 -0
- package/dist/components/utils/itemBodyRenderer.d.ts +44 -0
- package/dist/components/utils/itemBodyRenderer.js +177 -0
- package/dist/components/utils/itemBodyRenderer.js.map +1 -0
- package/dist/components/utils/sentenceContext.d.ts +6 -0
- package/dist/components/utils/sentenceContext.js +16 -0
- package/dist/components/utils/sentenceContext.js.map +1 -0
- package/dist/core/AssessmentItemDefinition.d.ts +20 -1
- package/dist/core/AssessmentItemDefinition.js +12 -31
- package/dist/core/AssessmentItemDefinition.js.map +1 -1
- package/dist/core/ComponentRegistry.d.ts +92 -0
- package/dist/core/ComponentRegistry.js +7 -1
- package/dist/core/ComponentRegistry.js.map +1 -1
- package/dist/core/ItemSession.d.ts +18 -1
- package/dist/core/ItemSession.js +79 -41
- package/dist/core/ItemSession.js.map +1 -1
- package/dist/core/Player.d.ts +118 -141
- package/dist/core/Player.js +390 -1233
- package/dist/core/Player.js.map +1 -1
- package/dist/core/compliance.d.ts +72 -0
- package/dist/core/compliance.js +147 -0
- package/dist/core/compliance.js.map +1 -0
- package/dist/core/declarations/declarationBuilder.d.ts +29 -0
- package/dist/core/declarations/declarationBuilder.js +284 -0
- package/dist/core/declarations/declarationBuilder.js.map +1 -0
- package/dist/core/declarations/declarationValues.d.ts +11 -0
- package/dist/core/declarations/declarationValues.js +168 -0
- package/dist/core/declarations/declarationValues.js.map +1 -0
- package/dist/core/matchGroups.d.ts +36 -0
- package/dist/core/matchGroups.js +100 -0
- package/dist/core/matchGroups.js.map +1 -0
- package/dist/core/nameMappers.d.ts +35 -0
- package/dist/core/nameMappers.js +47 -0
- package/dist/core/nameMappers.js.map +1 -0
- package/dist/core/parsingLimits.d.ts +4 -0
- package/dist/core/parsingLimits.js +5 -2
- package/dist/core/parsingLimits.js.map +1 -1
- package/dist/core/processing/responseProcessing.d.ts +88 -0
- package/dist/core/processing/responseProcessing.js +317 -0
- package/dist/core/processing/responseProcessing.js.map +1 -0
- package/dist/core/processing/responseValidation.d.ts +55 -0
- package/dist/core/processing/responseValidation.js +335 -0
- package/dist/core/processing/responseValidation.js.map +1 -0
- package/dist/core/rendering/contentPass.d.ts +31 -0
- package/dist/core/rendering/contentPass.js +152 -0
- package/dist/core/rendering/contentPass.js.map +1 -0
- package/dist/core/rendering/htmlRender.d.ts +21 -0
- package/dist/core/rendering/htmlRender.js +56 -0
- package/dist/core/rendering/htmlRender.js.map +1 -0
- package/dist/core/responseProcessingTemplates.d.ts +23 -0
- package/dist/core/responseProcessingTemplates.js +45 -0
- package/dist/core/responseProcessingTemplates.js.map +1 -0
- package/dist/core/rolePolicy.d.ts +5 -0
- package/dist/core/rolePolicy.js +21 -0
- package/dist/core/rolePolicy.js.map +1 -1
- package/dist/core/sanitizer.js +8 -14
- package/dist/core/sanitizer.js.map +1 -1
- package/dist/core/serialization/sessionState.d.ts +56 -0
- package/dist/core/serialization/sessionState.js +139 -0
- package/dist/core/serialization/sessionState.js.map +1 -0
- package/dist/core/serialization/valueForms.d.ts +32 -0
- package/dist/core/serialization/valueForms.js +112 -0
- package/dist/core/serialization/valueForms.js.map +1 -0
- package/dist/document/AssessmentItemDocument.d.ts +27 -1
- package/dist/document/AssessmentItemDocument.js +67 -31
- package/dist/document/AssessmentItemDocument.js.map +1 -1
- package/dist/element-class-BUFpUrJP.js +3792 -0
- package/dist/element-class-BUFpUrJP.js.map +1 -0
- package/dist/element-class.d.ts +34 -1
- package/dist/element-class.js +1 -1
- package/dist/element.js +2 -3
- package/dist/extraction/ExtractionRegistry.js +6 -12
- package/dist/extraction/ExtractionRegistry.js.map +1 -1
- package/dist/extraction/createContext.d.ts +2 -2
- package/dist/extraction/createContext.js.map +1 -1
- package/dist/extraction/index.d.ts +2 -2
- package/dist/extraction/index.js +1 -1
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/interactionCoverage.d.ts +31 -0
- package/dist/extraction/interactionCoverage.js +40 -0
- package/dist/extraction/interactionCoverage.js.map +1 -0
- package/dist/extraction/interactionExtractionPipeline.js +5 -10
- package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
- package/dist/extraction/interactionSecurity.js +1 -28
- package/dist/extraction/interactionSecurity.js.map +1 -1
- package/dist/extraction/mergeDeliveryFields.d.ts +13 -0
- package/dist/extraction/mergeDeliveryFields.js +17 -0
- package/dist/extraction/mergeDeliveryFields.js.map +1 -0
- package/dist/extraction/responseIdentifier.d.ts +19 -0
- package/dist/extraction/responseIdentifier.js +29 -0
- package/dist/extraction/responseIdentifier.js.map +1 -0
- package/dist/extraction/types.d.ts +11 -18
- package/dist/extraction/types.js +0 -12
- package/dist/extraction/types.js.map +1 -1
- package/dist/extraction/utils.d.ts +14 -0
- package/dist/extraction/utils.js +35 -5
- package/dist/extraction/utils.js.map +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/interactions/associate/extractor.d.ts +1 -0
- package/dist/interactions/associate/extractor.js +10 -12
- package/dist/interactions/associate/extractor.js.map +1 -1
- package/dist/interactions/choice/extractor.js +6 -13
- package/dist/interactions/choice/extractor.js.map +1 -1
- package/dist/interactions/drawing/extractor.d.ts +6 -0
- package/dist/interactions/drawing/extractor.js +30 -9
- package/dist/interactions/drawing/extractor.js.map +1 -1
- package/dist/interactions/end-attempt/extractor.js +2 -1
- package/dist/interactions/end-attempt/extractor.js.map +1 -1
- package/dist/interactions/extended-text/extractor.d.ts +6 -1
- package/dist/interactions/extended-text/extractor.js +10 -5
- package/dist/interactions/extended-text/extractor.js.map +1 -1
- package/dist/interactions/extended-text/response.js +18 -18
- package/dist/interactions/extended-text/response.js.map +1 -1
- package/dist/interactions/gap-match/extractor.d.ts +40 -2
- package/dist/interactions/gap-match/extractor.js +197 -39
- package/dist/interactions/gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-associate/extractor.d.ts +11 -0
- package/dist/interactions/graphic-associate/extractor.js +35 -24
- package/dist/interactions/graphic-associate/extractor.js.map +1 -1
- package/dist/interactions/graphic-gap-match/extractor.d.ts +21 -0
- package/dist/interactions/graphic-gap-match/extractor.js +79 -43
- package/dist/interactions/graphic-gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-order/extractor.d.ts +15 -0
- package/dist/interactions/graphic-order/extractor.js +39 -24
- package/dist/interactions/graphic-order/extractor.js.map +1 -1
- package/dist/interactions/hotspot/extractor.d.ts +6 -0
- package/dist/interactions/hotspot/extractor.js +31 -16
- package/dist/interactions/hotspot/extractor.js.map +1 -1
- package/dist/interactions/hottext/extractor.js +2 -12
- package/dist/interactions/hottext/extractor.js.map +1 -1
- package/dist/interactions/inline/accessibleName.d.ts +29 -0
- package/dist/interactions/inline/accessibleName.js +35 -0
- package/dist/interactions/inline/accessibleName.js.map +1 -0
- package/dist/interactions/inline/render-plan.d.ts +5 -14
- package/dist/interactions/inline/render-plan.js +5 -56
- package/dist/interactions/inline/render-plan.js.map +1 -1
- package/dist/interactions/inline-choice/extractor.d.ts +4 -0
- package/dist/interactions/inline-choice/extractor.js +13 -12
- package/dist/interactions/inline-choice/extractor.js.map +1 -1
- package/dist/interactions/match/extractor.d.ts +2 -0
- package/dist/interactions/match/extractor.js +14 -28
- package/dist/interactions/match/extractor.js.map +1 -1
- package/dist/interactions/media/extractor.d.ts +5 -11
- package/dist/interactions/media/extractor.js +100 -36
- package/dist/interactions/media/extractor.js.map +1 -1
- package/dist/interactions/modules.js +8 -2
- package/dist/interactions/modules.js.map +1 -1
- package/dist/interactions/order/extractor.d.ts +2 -0
- package/dist/interactions/order/extractor.js +8 -12
- package/dist/interactions/order/extractor.js.map +1 -1
- package/dist/interactions/order/limits.d.ts +29 -0
- package/dist/interactions/order/limits.js +28 -0
- package/dist/interactions/order/limits.js.map +1 -0
- package/dist/interactions/portable-custom/extractor.js +18 -14
- package/dist/interactions/portable-custom/extractor.js.map +1 -1
- package/dist/interactions/position-object/extractor.d.ts +18 -1
- package/dist/interactions/position-object/extractor.js +81 -22
- package/dist/interactions/position-object/extractor.js.map +1 -1
- package/dist/interactions/select-point/extractor.d.ts +6 -0
- package/dist/interactions/select-point/extractor.js +31 -19
- package/dist/interactions/select-point/extractor.js.map +1 -1
- package/dist/interactions/shared/imageAlt.d.ts +54 -0
- package/dist/interactions/shared/imageAlt.js +84 -0
- package/dist/interactions/shared/imageAlt.js.map +1 -0
- package/dist/interactions/shared/interactionImage.d.ts +32 -0
- package/dist/interactions/shared/interactionImage.js +39 -0
- package/dist/interactions/shared/interactionImage.js.map +1 -0
- package/dist/interactions/shared/specDefaults.d.ts +20 -0
- package/dist/interactions/shared/specDefaults.js +25 -0
- package/dist/interactions/shared/specDefaults.js.map +1 -0
- package/dist/interactions/shared/types.d.ts +212 -40
- package/dist/interactions/shared/types.js.map +1 -1
- package/dist/interactions/text-entry/extractor.d.ts +9 -0
- package/dist/interactions/text-entry/extractor.js +9 -0
- package/dist/interactions/text-entry/extractor.js.map +1 -1
- package/dist/interactions/text-entry/inlineInputStyle.d.ts +10 -0
- package/dist/interactions/text-entry/inlineInputStyle.js +12 -0
- package/dist/interactions/text-entry/inlineInputStyle.js.map +1 -0
- package/dist/interactions/text-entry/inputMode.d.ts +35 -0
- package/dist/interactions/text-entry/inputMode.js +134 -0
- package/dist/interactions/text-entry/inputMode.js.map +1 -0
- package/dist/interactions/text-entry/response.d.ts +15 -0
- package/dist/interactions/text-entry/response.js +25 -0
- package/dist/interactions/text-entry/response.js.map +1 -0
- package/dist/interactions/upload/extractor.js +2 -2
- package/dist/interactions/upload/extractor.js.map +1 -1
- package/dist/pci/PciHost.d.ts +1 -1
- package/dist/pci/PciHost.js +11 -11
- package/dist/pci/PciHost.js.map +1 -1
- package/dist/pci/index.d.ts +1 -0
- package/dist/pci/index.js.map +1 -1
- package/dist/pci/modulePaths.d.ts +16 -0
- package/dist/pci/modulePaths.js +33 -0
- package/dist/pci/modulePaths.js.map +1 -0
- package/dist/pci/pageRealmSession.js +3 -15
- package/dist/pci/pageRealmSession.js.map +1 -1
- package/dist/pci/qtiVariableJson.d.ts +46 -3
- package/dist/pci/qtiVariableJson.js +247 -53
- package/dist/pci/qtiVariableJson.js.map +1 -1
- package/dist/pci/sandbox/SandboxedPciSession.d.ts +3 -0
- package/dist/pci/sandbox/SandboxedPciSession.js +15 -14
- package/dist/pci/sandbox/SandboxedPciSession.js.map +1 -1
- package/dist/pci/sandbox/iframeConnector.d.ts +18 -4
- package/dist/pci/sandbox/iframeConnector.js +35 -6
- package/dist/pci/sandbox/iframeConnector.js.map +1 -1
- package/dist/pci/sandbox/protocol.d.ts +14 -0
- package/dist/pci/sandbox/protocol.js.map +1 -1
- package/dist/pci/sessionHosts.d.ts +47 -0
- package/dist/pci/sessionHosts.js +66 -0
- package/dist/pci/sessionHosts.js.map +1 -0
- package/dist/pci/types.d.ts +9 -3
- package/dist/pci/types.js.map +1 -1
- package/dist/pnp/applyPnp.d.ts +20 -3
- package/dist/pnp/applyPnp.js +84 -9
- package/dist/pnp/applyPnp.js.map +1 -1
- package/dist/pnp/parsePnpXml.js +2 -0
- package/dist/pnp/parsePnpXml.js.map +1 -1
- package/dist/pnp/types.d.ts +16 -8
- package/dist/pnp/types.js.map +1 -1
- package/dist/presentation/feedbackAnnouncement.d.ts +56 -0
- package/dist/presentation/feedbackAnnouncement.js +150 -0
- package/dist/presentation/feedbackAnnouncement.js.map +1 -0
- package/dist/presentation/interactionSlots.d.ts +31 -0
- package/dist/presentation/interactionSlots.js +101 -0
- package/dist/presentation/interactionSlots.js.map +1 -0
- package/dist/presentation/itemPresentationPlan.d.ts +69 -6
- package/dist/presentation/itemPresentationPlan.js +93 -81
- package/dist/presentation/itemPresentationPlan.js.map +1 -1
- package/dist/{components/utils → presentation}/stimulusRender.js +3 -12
- package/dist/presentation/stimulusRender.js.map +1 -0
- package/dist/presentation/stylesheetRender.js.map +1 -0
- package/dist/security/escapeHtml.d.ts +15 -0
- package/dist/security/escapeHtml.js +22 -0
- package/dist/security/escapeHtml.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +1 -0
- package/dist/security/index.js.map +1 -1
- package/dist/server.d.ts +8 -1
- package/dist/server.js.map +1 -1
- package/dist/session-inputs.d.ts +108 -0
- package/dist/session-inputs.js +130 -0
- package/dist/session-inputs.js.map +1 -0
- package/dist/types/index.d.ts +67 -35
- package/dist/types/index.js.map +1 -1
- package/dist/utils/cloneFreeze.d.ts +52 -0
- package/dist/utils/cloneFreeze.js +113 -0
- package/dist/utils/cloneFreeze.js.map +1 -0
- package/dist/utils/htmlAttributes.d.ts +13 -0
- package/dist/utils/htmlAttributes.js +22 -0
- package/dist/utils/htmlAttributes.js.map +1 -0
- package/dist/web-components/QTIInteractionElement.d.ts +0 -29
- package/dist/web-components/QTIInteractionElement.js +0 -32
- package/dist/web-components/QTIInteractionElement.js.map +1 -1
- package/dist/web-components/index.d.ts +1 -2
- package/dist/web-components/index.js +2 -3
- package/dist/web-components/index.js.map +1 -1
- package/package.json +20 -19
- package/dist/components/utils/stimulusRender.js.map +0 -1
- package/dist/components/utils/stylesheetRender.js.map +0 -1
- package/dist/core/constants.d.ts +0 -65
- package/dist/core/constants.js +0 -74
- package/dist/core/constants.js.map +0 -1
- package/dist/element-class-DdpiTalY.js +0 -9226
- package/dist/element-class-DdpiTalY.js.map +0 -1
- package/dist/extensions/MathLiveEditor.d.ts +0 -31
- package/dist/extensions/MathLiveEditor.js +0 -248
- package/dist/extensions/MathLiveEditor.js.map +0 -1
- package/dist/utils/PerformanceMonitor.d.ts +0 -169
- package/dist/utils/PerformanceMonitor.js +0 -243
- package/dist/utils/PerformanceMonitor.js.map +0 -1
- package/dist/utils/responseUtils.d.ts +0 -15
- package/dist/utils/responseUtils.js +0 -46
- package/dist/utils/responseUtils.js.map +0 -1
- package/dist/web-components/QTIInteractionBase.d.ts +0 -119
- package/dist/web-components/QTIInteractionBase.js +0 -244
- package/dist/web-components/QTIInteractionBase.js.map +0 -1
- /package/dist/{components/utils → presentation}/stimulusRender.d.ts +0 -0
- /package/dist/{components/utils → presentation}/stylesheetRender.d.ts +0 -0
- /package/dist/{components/utils → presentation}/stylesheetRender.js +0 -0
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abstract base class for all QTI interaction web components
|
|
3
|
-
*
|
|
4
|
-
* Provides common functionality including:
|
|
5
|
-
* - Reactive property system
|
|
6
|
-
* - Shadow DOM management
|
|
7
|
-
* - Event emission helpers
|
|
8
|
-
* - Update scheduling
|
|
9
|
-
* - Lifecycle management
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* export class QTIChoiceInteraction extends QTIInteractionBase<ChoiceInteractionData> {
|
|
14
|
-
* protected render(): void {
|
|
15
|
-
* this.shadowRoot.innerHTML = `...`;
|
|
16
|
-
* this.attachEventListeners();
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* protected cleanup(): void {
|
|
20
|
-
* // Optional cleanup
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
import { QTIChangeEvent, QTIErrorEvent, QTIReadyEvent, } from './QTIInteractionElement.js';
|
|
26
|
-
export class QTIInteractionBase extends HTMLElement {
|
|
27
|
-
constructor() {
|
|
28
|
-
super();
|
|
29
|
-
this._interaction = null;
|
|
30
|
-
this._response = null;
|
|
31
|
-
this._disabled = false;
|
|
32
|
-
this.updateScheduled = false;
|
|
33
|
-
this.isInitialized = false;
|
|
34
|
-
// attachShadow returns ShadowRoot, and we cast to ensure type compatibility
|
|
35
|
-
this.shadowRoot = this.attachShadow({ mode: 'open' });
|
|
36
|
-
}
|
|
37
|
-
// ========== Property Getters/Setters ==========
|
|
38
|
-
/**
|
|
39
|
-
* The processed interaction data from QTI XML
|
|
40
|
-
* Required property - throws if accessed before being set
|
|
41
|
-
*/
|
|
42
|
-
get interaction() {
|
|
43
|
-
if (!this._interaction) {
|
|
44
|
-
throw new Error(`${this.tagName}: interaction property must be set before use`);
|
|
45
|
-
}
|
|
46
|
-
return this._interaction;
|
|
47
|
-
}
|
|
48
|
-
set interaction(value) {
|
|
49
|
-
if (this._interaction !== value) {
|
|
50
|
-
this._interaction = value;
|
|
51
|
-
this.requestUpdate();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Current response value (type depends on interaction type)
|
|
56
|
-
* May be null if no response has been provided yet
|
|
57
|
-
*/
|
|
58
|
-
get response() {
|
|
59
|
-
return this._response;
|
|
60
|
-
}
|
|
61
|
-
set response(value) {
|
|
62
|
-
if (this._response !== value) {
|
|
63
|
-
this._response = value;
|
|
64
|
-
this.requestUpdate();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Whether the interaction is in read-only/disabled mode
|
|
69
|
-
*/
|
|
70
|
-
get disabled() {
|
|
71
|
-
return this._disabled;
|
|
72
|
-
}
|
|
73
|
-
set disabled(value) {
|
|
74
|
-
const newValue = Boolean(value);
|
|
75
|
-
if (this._disabled !== newValue) {
|
|
76
|
-
this._disabled = newValue;
|
|
77
|
-
this.requestUpdate();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Optional function to apply math typesetting (e.g., KaTeX, MathJax)
|
|
82
|
-
*/
|
|
83
|
-
get typeset() {
|
|
84
|
-
return this._typeset;
|
|
85
|
-
}
|
|
86
|
-
set typeset(value) {
|
|
87
|
-
if (this._typeset !== value) {
|
|
88
|
-
this._typeset = value;
|
|
89
|
-
this.requestUpdate();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// ========== Lifecycle Hooks ==========
|
|
93
|
-
/**
|
|
94
|
-
* Called when the element is connected to the DOM
|
|
95
|
-
*/
|
|
96
|
-
connectedCallback() {
|
|
97
|
-
if (!this.isInitialized) {
|
|
98
|
-
this.isInitialized = true;
|
|
99
|
-
this.init();
|
|
100
|
-
}
|
|
101
|
-
this.requestUpdate();
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Called when the element is disconnected from the DOM
|
|
105
|
-
*/
|
|
106
|
-
disconnectedCallback() {
|
|
107
|
-
this.cleanup();
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Called once when the element is first connected
|
|
111
|
-
* Override this to perform one-time initialization
|
|
112
|
-
*/
|
|
113
|
-
init() {
|
|
114
|
-
// Override in subclasses if needed
|
|
115
|
-
}
|
|
116
|
-
// ========== Reactive Updates ==========
|
|
117
|
-
/**
|
|
118
|
-
* Schedule a re-render on the next microtask
|
|
119
|
-
* Multiple calls within the same tick are batched
|
|
120
|
-
*/
|
|
121
|
-
requestUpdate() {
|
|
122
|
-
if (!this.updateScheduled && this.isConnected) {
|
|
123
|
-
this.updateScheduled = true;
|
|
124
|
-
queueMicrotask(() => {
|
|
125
|
-
this.updateScheduled = false;
|
|
126
|
-
try {
|
|
127
|
-
this.render();
|
|
128
|
-
if (this.isInitialized) {
|
|
129
|
-
this.emitReady();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
this.emitError(error, 'render');
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// ========== Event Helpers ==========
|
|
139
|
-
/**
|
|
140
|
-
* Emit a qti-change event when the user response changes
|
|
141
|
-
* @param value - The new response value
|
|
142
|
-
*/
|
|
143
|
-
emitChange(value) {
|
|
144
|
-
if (!this._interaction) {
|
|
145
|
-
console.warn(`${this.tagName}: Cannot emit change without interaction data`);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const event = new QTIChangeEvent({
|
|
149
|
-
responseId: this._interaction.responseId,
|
|
150
|
-
value,
|
|
151
|
-
timestamp: Date.now(),
|
|
152
|
-
});
|
|
153
|
-
this.dispatchEvent(event);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Emit a qti-ready event when component is initialized
|
|
157
|
-
*/
|
|
158
|
-
emitReady() {
|
|
159
|
-
this.dispatchEvent(new QTIReadyEvent());
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Emit a qti-error event when an error occurs
|
|
163
|
-
*/
|
|
164
|
-
emitError(error, context) {
|
|
165
|
-
const event = new QTIErrorEvent({ error, context });
|
|
166
|
-
this.dispatchEvent(event);
|
|
167
|
-
console.error(`${this.tagName} error in ${context}:`, error);
|
|
168
|
-
}
|
|
169
|
-
// ========== Utility Methods ==========
|
|
170
|
-
/**
|
|
171
|
-
* Apply math typesetting to the shadow root
|
|
172
|
-
* Call this after updating the DOM with math content
|
|
173
|
-
*/
|
|
174
|
-
applyTypesetting() {
|
|
175
|
-
if (this._typeset && this.shadowRoot) {
|
|
176
|
-
try {
|
|
177
|
-
this._typeset(this.shadowRoot);
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
this.emitError(error, 'typesetting');
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Get base styles for all interaction components
|
|
186
|
-
* Override and call super.getStyles() to extend these styles
|
|
187
|
-
*/
|
|
188
|
-
getStyles() {
|
|
189
|
-
return `
|
|
190
|
-
:host {
|
|
191
|
-
display: block;
|
|
192
|
-
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
|
193
|
-
Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
194
|
-
font-size: 16px;
|
|
195
|
-
line-height: 1.5;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
:host([disabled]) {
|
|
199
|
-
opacity: 0.6;
|
|
200
|
-
pointer-events: none;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
* {
|
|
204
|
-
box-sizing: border-box;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
.qti-prompt {
|
|
208
|
-
margin-bottom: 1rem;
|
|
209
|
-
font-weight: 600;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.qti-error {
|
|
213
|
-
color: #dc2626;
|
|
214
|
-
padding: 0.75rem;
|
|
215
|
-
background: #fee2e2;
|
|
216
|
-
border-radius: 0.375rem;
|
|
217
|
-
margin: 0.5rem 0;
|
|
218
|
-
}
|
|
219
|
-
`;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Safely set innerHTML with error handling
|
|
223
|
-
*/
|
|
224
|
-
safeSetInnerHTML(element, html) {
|
|
225
|
-
try {
|
|
226
|
-
element.innerHTML = html;
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
this.emitError(error, 'setInnerHTML');
|
|
230
|
-
element.innerHTML = `<div class="qti-error">Failed to render content</div>`;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Create an element with classes
|
|
235
|
-
*/
|
|
236
|
-
createElement(tagName, classes) {
|
|
237
|
-
const element = document.createElement(tagName);
|
|
238
|
-
if (classes && classes.length > 0) {
|
|
239
|
-
element.className = classes.join(' ');
|
|
240
|
-
}
|
|
241
|
-
return element;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
//# sourceMappingURL=QTIInteractionBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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,CAAC;YACvC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,SAAS,CAAC,KAAc,EAAE,aAAa,CAAC,CAAC;YAC/C,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;OAGG;IACO,SAAS;QAClB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BN,CAAC;IACH,CAAC;IAED;;OAEG;IACO,gBAAgB,CAAC,OAAiC,EAAE,IAAiB;QAC9E,IAAI,CAAC;YACJ,OAAO,CAAC,SAAS,GAAG,IAAW,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,CAAC,KAAc,EAAE,cAAc,CAAC,CAAC;YAC/C,OAAO,CAAC,SAAS,GAAG,uDAAuD,CAAC;QAC7E,CAAC;IACF,CAAC;IAED;;OAEG;IACO,aAAa,CACtB,OAAU,EACV,OAAkB;QAElB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["/**\n * Abstract base class for all QTI interaction web components\n *\n * Provides common functionality including:\n * - Reactive property system\n * - Shadow DOM management\n * - Event emission helpers\n * - Update scheduling\n * - Lifecycle management\n *\n * @example\n * ```typescript\n * export class QTIChoiceInteraction extends QTIInteractionBase<ChoiceInteractionData> {\n * protected render(): void {\n * this.shadowRoot.innerHTML = `...`;\n * this.attachEventListeners();\n * }\n *\n * protected cleanup(): void {\n * // Optional cleanup\n * }\n * }\n * ```\n */\n\nimport type { HtmlContent } from '../types/index.js';\nimport type { BaseInteractionData } from '../interactions/shared/types.js';\nimport {\n\ttype InteractionResponseValue,\n\tQTIChangeEvent,\n\tQTIErrorEvent,\n\ttype QTIInteractionElement,\n\tQTIReadyEvent,\n} from './QTIInteractionElement.js';\n\nexport abstract class QTIInteractionBase<\n\tTData extends BaseInteractionData = BaseInteractionData,\n>\n\textends HTMLElement\n\timplements QTIInteractionElement<TData>\n{\n\tprivate _interaction: TData | null = null;\n\tprivate _response: InteractionResponseValue<TData> | null = null;\n\tprivate _disabled = false;\n\tprivate _typeset?: (element: HTMLElement) => void;\n\n\tdeclare shadowRoot: ShadowRoot; // Override HTMLElement's shadowRoot type\n\tprivate updateScheduled = false;\n\tprivate isInitialized = false;\n\n\tconstructor() {\n\t\tsuper();\n\t\t// attachShadow returns ShadowRoot, and we cast to ensure type compatibility\n\t\t(this as any).shadowRoot = this.attachShadow({ mode: 'open' });\n\t}\n\n\t// ========== Property Getters/Setters ==========\n\n\t/**\n\t * The processed interaction data from QTI XML\n\t * Required property - throws if accessed before being set\n\t */\n\tget interaction(): TData {\n\t\tif (!this._interaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`${this.tagName}: interaction property must be set before use`\n\t\t\t);\n\t\t}\n\t\treturn this._interaction;\n\t}\n\n\tset interaction(value: TData) {\n\t\tif (this._interaction !== value) {\n\t\t\tthis._interaction = value;\n\t\t\tthis.requestUpdate();\n\t\t}\n\t}\n\n\t/**\n\t * Current response value (type depends on interaction type)\n\t * May be null if no response has been provided yet\n\t */\n\tget response(): InteractionResponseValue<TData> | null {\n\t\treturn this._response;\n\t}\n\n\tset response(value: InteractionResponseValue<TData> | null) {\n\t\tif (this._response !== value) {\n\t\t\tthis._response = value;\n\t\t\tthis.requestUpdate();\n\t\t}\n\t}\n\n\t/**\n\t * Whether the interaction is in read-only/disabled mode\n\t */\n\tget disabled(): boolean {\n\t\treturn this._disabled;\n\t}\n\n\tset disabled(value: boolean) {\n\t\tconst newValue = Boolean(value);\n\t\tif (this._disabled !== newValue) {\n\t\t\tthis._disabled = newValue;\n\t\t\tthis.requestUpdate();\n\t\t}\n\t}\n\n\t/**\n\t * Optional function to apply math typesetting (e.g., KaTeX, MathJax)\n\t */\n\tget typeset(): ((element: HTMLElement) => void) | undefined {\n\t\treturn this._typeset;\n\t}\n\n\tset typeset(value: ((element: HTMLElement) => void) | undefined) {\n\t\tif (this._typeset !== value) {\n\t\t\tthis._typeset = value;\n\t\t\tthis.requestUpdate();\n\t\t}\n\t}\n\n\t// ========== Lifecycle Hooks ==========\n\n\t/**\n\t * Called when the element is connected to the DOM\n\t */\n\tconnectedCallback(): void {\n\t\tif (!this.isInitialized) {\n\t\t\tthis.isInitialized = true;\n\t\t\tthis.init();\n\t\t}\n\t\tthis.requestUpdate();\n\t}\n\n\t/**\n\t * Called when the element is disconnected from the DOM\n\t */\n\tdisconnectedCallback(): void {\n\t\tthis.cleanup();\n\t}\n\n\t/**\n\t * Called once when the element is first connected\n\t * Override this to perform one-time initialization\n\t */\n\tprotected init(): void {\n\t\t// Override in subclasses if needed\n\t}\n\n\t// ========== Reactive Updates ==========\n\n\t/**\n\t * Schedule a re-render on the next microtask\n\t * Multiple calls within the same tick are batched\n\t */\n\tprotected requestUpdate(): void {\n\t\tif (!this.updateScheduled && this.isConnected) {\n\t\t\tthis.updateScheduled = true;\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthis.updateScheduled = false;\n\t\t\t\ttry {\n\t\t\t\t\tthis.render();\n\t\t\t\t\tif (this.isInitialized) {\n\t\t\t\t\t\tthis.emitReady();\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.emitError(error as Error, 'render');\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t// ========== Abstract Methods ==========\n\n\t/**\n\t * Render the component's UI\n\t * Called automatically when properties change\n\t * Must be implemented by subclasses\n\t */\n\tprotected abstract render(): void;\n\n\t/**\n\t * Clean up resources when component is removed from DOM\n\t * Override this to remove event listeners, cancel timers, etc.\n\t */\n\tprotected abstract cleanup(): void;\n\n\t// ========== Event Helpers ==========\n\n\t/**\n\t * Emit a qti-change event when the user response changes\n\t * @param value - The new response value\n\t */\n\tprotected emitChange(value: InteractionResponseValue<TData> | null): void {\n\t\tif (!this._interaction) {\n\t\t\tconsole.warn(`${this.tagName}: Cannot emit change without interaction data`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst event = new QTIChangeEvent({\n\t\t\tresponseId: this._interaction.responseId,\n\t\t\tvalue,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\n\t\tthis.dispatchEvent(event);\n\t}\n\n\t/**\n\t * Emit a qti-ready event when component is initialized\n\t */\n\tprivate emitReady(): void {\n\t\tthis.dispatchEvent(new QTIReadyEvent());\n\t}\n\n\t/**\n\t * Emit a qti-error event when an error occurs\n\t */\n\tprotected emitError(error: Error, context: string): void {\n\t\tconst event = new QTIErrorEvent({ error, context });\n\t\tthis.dispatchEvent(event);\n\t\tconsole.error(`${this.tagName} error in ${context}:`, error);\n\t}\n\n\t// ========== Utility Methods ==========\n\n\t/**\n\t * Apply math typesetting to the shadow root\n\t * Call this after updating the DOM with math content\n\t */\n\tprotected applyTypesetting(): void {\n\t\tif (this._typeset && this.shadowRoot) {\n\t\t\ttry {\n\t\t\t\tthis._typeset(this.shadowRoot as any);\n\t\t\t} catch (error) {\n\t\t\t\tthis.emitError(error as Error, 'typesetting');\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get base styles for all interaction components\n\t * Override and call super.getStyles() to extend these styles\n\t */\n\tprotected getStyles(): string {\n\t\treturn `\n\t\t\t:host {\n\t\t\t\tdisplay: block;\n\t\t\t\tfont-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',\n\t\t\t\t\tRoboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n\t\t\t\tfont-size: 16px;\n\t\t\t\tline-height: 1.5;\n\t\t\t}\n\n\t\t\t:host([disabled]) {\n\t\t\t\topacity: 0.6;\n\t\t\t\tpointer-events: none;\n\t\t\t}\n\n\t\t\t* {\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}\n\n\t\t\t.qti-prompt {\n\t\t\t\tmargin-bottom: 1rem;\n\t\t\t\tfont-weight: 600;\n\t\t\t}\n\n\t\t\t.qti-error {\n\t\t\t\tcolor: #dc2626;\n\t\t\t\tpadding: 0.75rem;\n\t\t\t\tbackground: #fee2e2;\n\t\t\t\tborder-radius: 0.375rem;\n\t\t\t\tmargin: 0.5rem 0;\n\t\t\t}\n\t\t`;\n\t}\n\n\t/**\n\t * Safely set innerHTML with error handling\n\t */\n\tprotected safeSetInnerHTML(element: HTMLElement | ShadowRoot, html: HtmlContent): void {\n\t\ttry {\n\t\t\telement.innerHTML = html as any;\n\t\t} catch (error) {\n\t\t\tthis.emitError(error as Error, 'setInnerHTML');\n\t\t\telement.innerHTML = `<div class=\"qti-error\">Failed to render content</div>`;\n\t\t}\n\t}\n\n\t/**\n\t * Create an element with classes\n\t */\n\tprotected createElement<K extends keyof HTMLElementTagNameMap>(\n\t\ttagName: K,\n\t\tclasses?: string[]\n\t): HTMLElementTagNameMap[K] {\n\t\tconst element = document.createElement(tagName);\n\t\tif (classes && classes.length > 0) {\n\t\t\telement.className = classes.join(' ');\n\t\t}\n\t\treturn element;\n\t}\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|