@pie-qti/item-player 0.1.9 → 0.1.10
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 +17 -0
- package/dist/catalog/applyGlossaryTriggers.d.ts +13 -2
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
- package/dist/catalog/glossaryAction.d.ts +4 -2
- package/dist/catalog/glossaryAction.d.ts.map +1 -1
- package/dist/components/utils/index.d.ts +1 -2
- package/dist/components/utils/index.d.ts.map +1 -1
- package/dist/components/utils/index.js +1 -2
- package/dist/core/ComponentRegistry.d.ts +10 -1
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +42 -1
- package/dist/core/Player.d.ts +10 -2
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +54 -46
- package/dist/document/AssessmentItemDocument.d.ts +1 -1
- package/dist/element.d.ts +15 -0
- package/dist/element.js +1817 -1625
- package/dist/element.js.map +1 -1
- package/dist/extraction/ExtractionRegistry.d.ts +1 -1
- package/dist/extraction/createContext.d.ts +1 -1
- package/dist/extraction/index.d.ts +2 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +1 -1
- package/dist/extraction/interactionExtractionPipeline.d.ts +1 -1
- package/dist/extraction/interactionSecurity.d.ts +1 -1
- package/dist/extraction/types.d.ts +1 -1
- package/dist/presentation/itemPresentationPlan.d.ts +54 -0
- package/dist/presentation/itemPresentationPlan.d.ts.map +1 -0
- package/dist/presentation/itemPresentationPlan.js +98 -0
- package/dist/types/index.d.ts +17 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -3
- package/dist/web-components/QTIInteractionBase.d.ts +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +1 -1
- package/package.json +7 -14
- package/src/__tests__/catalog.test.ts +0 -267
- package/src/__tests__/fixtures/pci/echo-pci.js +0 -49
- package/src/__tests__/pci.test.ts +0 -353
- package/src/__tests__/qti3-attribute-extraction.test.ts +0 -174
- package/src/__tests__/qti3-debug.test.ts +0 -140
- package/src/__tests__/qti3-extraction.test.ts +0 -309
- package/src/catalog/applyGlossaryTriggers.ts +0 -372
- package/src/catalog/catalogExtractor.ts +0 -130
- package/src/catalog/catalogLookup.ts +0 -53
- package/src/catalog/glossaryAction.ts +0 -38
- package/src/catalog/types.ts +0 -37
- package/src/components/ItemBody.svelte +0 -363
- package/src/components/ItemPlayer.svelte +0 -163
- package/src/components/ModalFeedbackDisplay.svelte +0 -97
- package/src/components/actions/typesetAction.ts +0 -74
- package/src/components/index.ts +0 -22
- package/src/components/utils/assignProps.ts +0 -2
- package/src/components/utils/feedbackUtils.ts +0 -140
- package/src/components/utils/index.ts +0 -13
- package/src/components/utils/stimulusRender.ts +0 -93
- package/src/components/utils/stylesheetRender.ts +0 -58
- package/src/core/ComponentRegistry.ts +0 -248
- package/src/core/Player.ts +0 -1618
- package/src/core/Plugin.ts +0 -123
- package/src/core/PluginManager.ts +0 -182
- package/src/core/constants.ts +0 -117
- package/src/core/declarations.ts +0 -171
- package/src/core/parsingLimits.ts +0 -62
- package/src/core/random.ts +0 -24
- package/src/core/rolePolicy.ts +0 -34
- package/src/core/sanitizer.ts +0 -305
- package/src/core/trustedTypes.ts +0 -63
- package/src/core/urlPolicy.ts +0 -98
- package/src/document/AssessmentItemDocument.ts +0 -247
- package/src/element.ts +0 -128
- package/src/extensions/MathLiveEditor.ts +0 -313
- package/src/extraction/ExtractionRegistry.ts +0 -335
- package/src/extraction/createContext.ts +0 -52
- package/src/extraction/extractors/associateExtractor.ts +0 -1
- package/src/extraction/extractors/choiceExtractor.ts +0 -1
- package/src/extraction/extractors/conformance-qti3-advanced.test.ts +0 -239
- package/src/extraction/extractors/conformance-qti3-basic.test.ts +0 -82
- package/src/extraction/extractors/conformance.test.ts +0 -208
- package/src/extraction/extractors/customExtractor.ts +0 -1
- package/src/extraction/extractors/drawingExtractor.ts +0 -1
- package/src/extraction/extractors/endAttemptExtractor.ts +0 -1
- package/src/extraction/extractors/extendedTextExtractor.ts +0 -1
- package/src/extraction/extractors/gapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicAssociateExtractor.ts +0 -1
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicOrderExtractor.ts +0 -1
- package/src/extraction/extractors/hotspotExtractor.ts +0 -1
- package/src/extraction/extractors/hottextExtractor.ts +0 -1
- package/src/extraction/extractors/index.ts +0 -9
- package/src/extraction/extractors/inlineChoiceExtractor.ts +0 -1
- package/src/extraction/extractors/matchExtractor.ts +0 -1
- package/src/extraction/extractors/mediaExtractor.ts +0 -1
- package/src/extraction/extractors/orderExtractor.ts +0 -1
- package/src/extraction/extractors/portableCustomExtractor.ts +0 -1
- package/src/extraction/extractors/positionObjectExtractor.ts +0 -1
- package/src/extraction/extractors/selectPointExtractor.ts +0 -1
- package/src/extraction/extractors/sliderExtractor.ts +0 -1
- package/src/extraction/extractors/textEntryExtractor.ts +0 -1
- package/src/extraction/extractors/uploadExtractor.ts +0 -1
- package/src/extraction/index.ts +0 -108
- package/src/extraction/interactionExtractionPipeline.ts +0 -70
- package/src/extraction/interactionSecurity.ts +0 -60
- package/src/extraction/types.ts +0 -246
- package/src/extraction/utils.ts +0 -243
- package/src/iframe/IFramePlayerHost.ts +0 -265
- package/src/iframe/index.ts +0 -11
- package/src/iframe/protocol.ts +0 -137
- package/src/index.ts +0 -101
- package/src/interactions/associate/extractor.ts +0 -133
- package/src/interactions/associate/index.ts +0 -2
- package/src/interactions/associate/types.ts +0 -1
- package/src/interactions/choice/extractor.ts +0 -121
- package/src/interactions/choice/index.ts +0 -2
- package/src/interactions/choice/types.ts +0 -1
- package/src/interactions/custom/extractor.ts +0 -72
- package/src/interactions/custom/index.ts +0 -2
- package/src/interactions/custom/types.ts +0 -1
- package/src/interactions/drawing/extractor.ts +0 -113
- package/src/interactions/drawing/index.ts +0 -2
- package/src/interactions/drawing/types.ts +0 -1
- package/src/interactions/end-attempt/extractor.ts +0 -74
- package/src/interactions/end-attempt/index.ts +0 -2
- package/src/interactions/end-attempt/types.ts +0 -1
- package/src/interactions/extended-text/extractor.ts +0 -92
- package/src/interactions/extended-text/index.ts +0 -2
- package/src/interactions/extended-text/types.ts +0 -1
- package/src/interactions/gap-match/extractor.ts +0 -193
- package/src/interactions/gap-match/index.ts +0 -2
- package/src/interactions/gap-match/types.ts +0 -1
- package/src/interactions/graphic-associate/extractor.ts +0 -192
- package/src/interactions/graphic-associate/index.ts +0 -2
- package/src/interactions/graphic-associate/types.ts +0 -1
- package/src/interactions/graphic-gap-match/extractor.ts +0 -257
- package/src/interactions/graphic-gap-match/index.ts +0 -2
- package/src/interactions/graphic-gap-match/types.ts +0 -1
- package/src/interactions/graphic-order/extractor.ts +0 -162
- package/src/interactions/graphic-order/index.ts +0 -2
- package/src/interactions/graphic-order/types.ts +0 -1
- package/src/interactions/hotspot/extractor.ts +0 -208
- package/src/interactions/hotspot/index.ts +0 -2
- package/src/interactions/hotspot/types.ts +0 -1
- package/src/interactions/hottext/extractor.ts +0 -163
- package/src/interactions/hottext/index.ts +0 -2
- package/src/interactions/hottext/types.ts +0 -1
- package/src/interactions/index.ts +0 -52
- package/src/interactions/inline/index.ts +0 -1
- package/src/interactions/inline/render-plan.ts +0 -105
- package/src/interactions/inline-choice/InlineChoice.svelte +0 -57
- package/src/interactions/inline-choice/extractor.ts +0 -105
- package/src/interactions/inline-choice/index.ts +0 -2
- package/src/interactions/inline-choice/types.ts +0 -1
- package/src/interactions/match/extractor.ts +0 -187
- package/src/interactions/match/index.ts +0 -2
- package/src/interactions/match/types.ts +0 -1
- package/src/interactions/media/extractor.ts +0 -168
- package/src/interactions/media/index.ts +0 -2
- package/src/interactions/media/types.ts +0 -1
- package/src/interactions/modules.ts +0 -111
- package/src/interactions/order/extractor.ts +0 -120
- package/src/interactions/order/index.ts +0 -2
- package/src/interactions/order/types.ts +0 -1
- package/src/interactions/portable-custom/extractor.ts +0 -122
- package/src/interactions/portable-custom/index.ts +0 -2
- package/src/interactions/portable-custom/types.ts +0 -1
- package/src/interactions/position-object/extractor.ts +0 -243
- package/src/interactions/position-object/index.ts +0 -2
- package/src/interactions/position-object/types.ts +0 -1
- package/src/interactions/select-point/extractor.ts +0 -143
- package/src/interactions/select-point/index.ts +0 -2
- package/src/interactions/select-point/types.ts +0 -1
- package/src/interactions/shared/index.ts +0 -1
- package/src/interactions/shared/types.ts +0 -430
- package/src/interactions/slider/extractor.ts +0 -102
- package/src/interactions/slider/index.ts +0 -2
- package/src/interactions/slider/types.ts +0 -1
- package/src/interactions/text-entry/InlineTextEntry.svelte +0 -75
- package/src/interactions/text-entry/extractor.ts +0 -79
- package/src/interactions/text-entry/index.ts +0 -2
- package/src/interactions/text-entry/types.ts +0 -1
- package/src/interactions/upload/extractor.ts +0 -81
- package/src/interactions/upload/index.ts +0 -2
- package/src/interactions/upload/types.ts +0 -1
- package/src/pci/PciHost.ts +0 -138
- package/src/pci/types.ts +0 -70
- package/src/pnp/applyPnp.ts +0 -29
- package/src/pnp/parsePnpXml.ts +0 -215
- package/src/pnp/types.ts +0 -75
- package/src/server.ts +0 -14
- package/src/types/index.ts +0 -388
- package/src/types/interactions.ts +0 -8
- package/src/types/responseValidation.ts +0 -29
- package/src/types/xmldom.d.ts +0 -12
- package/src/utils/PerformanceMonitor.ts +0 -335
- package/src/utils/drawingUtils.ts +0 -73
- package/src/utils/responseUtils.ts +0 -51
- package/src/utils/touchDragHelper.ts +0 -1
- package/src/web-components/QTIInteractionBase.ts +0 -303
- package/src/web-components/QTIInteractionElement.ts +0 -125
- package/src/web-components/index.ts +0 -22
package/README.md
CHANGED
|
@@ -28,6 +28,23 @@ npm install @pie-qti/item-player
|
|
|
28
28
|
|
|
29
29
|
## Quick Start
|
|
30
30
|
|
|
31
|
+
### Web Component Host Integration
|
|
32
|
+
|
|
33
|
+
For browser applications, the public rendering boundary is the custom element:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import '@pie-qti/default-components/plugins';
|
|
37
|
+
import '@pie-qti/item-player/element';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<pie-qti-item-player item-xml="<assessmentItem ...></assessmentItem>" role="author"></pie-qti-item-player>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The package does not require hosts to import Svelte components. Internal Svelte
|
|
45
|
+
components are compiled into the custom element bundle and are not part of the
|
|
46
|
+
public package contract.
|
|
47
|
+
|
|
31
48
|
### Core Player (Framework-Agnostic)
|
|
32
49
|
|
|
33
50
|
```typescript
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PnpProfile } from '../pnp/types.js';
|
|
2
|
+
interface CatalogComponentRegistry {
|
|
3
|
+
getTagNameForType(type: string): string | null;
|
|
4
|
+
}
|
|
5
|
+
export interface GlossaryPlayer {
|
|
6
|
+
getPnp(): PnpProfile | undefined;
|
|
7
|
+
getCatalogEntry(idref: string, usage: string, lang?: string, options?: {
|
|
8
|
+
stimulusIdentifier?: string;
|
|
9
|
+
}): string | null;
|
|
10
|
+
getComponentRegistry(): CatalogComponentRegistry;
|
|
11
|
+
}
|
|
2
12
|
/**
|
|
3
13
|
* Inject glossary/keyword-translation trigger buttons into a rendered item container.
|
|
4
14
|
*
|
|
@@ -11,6 +21,7 @@ import type { Player } from '../core/Player.js';
|
|
|
11
21
|
* audio-description) the player fires a `qti-catalog-lookup` CustomEvent instead of
|
|
12
22
|
* mounting a popup — the host application handles those usages.
|
|
13
23
|
*/
|
|
14
|
-
export declare function applyGlossaryTriggers(container: HTMLElement, player:
|
|
24
|
+
export declare function applyGlossaryTriggers(container: HTMLElement, player: GlossaryPlayer): () => void;
|
|
15
25
|
export declare function cleanupGlossaryTriggers(container: HTMLElement): void;
|
|
26
|
+
export {};
|
|
16
27
|
//# sourceMappingURL=applyGlossaryTriggers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyGlossaryTriggers.d.ts","sourceRoot":"","sources":["../../src/catalog/applyGlossaryTriggers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"applyGlossaryTriggers.d.ts","sourceRoot":"","sources":["../../src/catalog/applyGlossaryTriggers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA0BlD,UAAU,wBAAwB;IACjC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,IAAI,UAAU,GAAG,SAAS,CAAC;IACjC,eAAe,CACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;KAAE,GACvC,MAAM,GAAG,IAAI,CAAC;IACjB,oBAAoB,IAAI,wBAAwB,CAAC;CACjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,CA8GhG;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAUpE"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type GlossaryPlayer } from './applyGlossaryTriggers.js';
|
|
2
2
|
export interface GlossaryActionParams {
|
|
3
|
-
player:
|
|
3
|
+
player: GlossaryPlayer & {
|
|
4
|
+
onPnpChange?: (listener: () => void) => () => void;
|
|
5
|
+
};
|
|
4
6
|
}
|
|
5
7
|
/**
|
|
6
8
|
* Svelte action that reactively applies glossary trigger buttons to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glossaryAction.d.ts","sourceRoot":"","sources":["../../src/catalog/glossaryAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"glossaryAction.d.ts","sourceRoot":"","sources":["../../src/catalog/glossaryAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAExF,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,cAAc,GAAG;QACxB,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;KACnD,CAAC;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB;sBAQ1D,oBAAoB;;EAcvC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utilities for QTI item component rendering
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export { cleanFeedbackText, processFeedbackInline, DEFAULT_FEEDBACK_OUTCOME_ID, DEFAULT_FEEDBACK_TRANSFORMS, type FeedbackTransform, type ProcessFeedbackInlineOptions, } from './feedbackUtils';
|
|
4
|
+
export { cleanFeedbackText, processFeedbackInline, DEFAULT_FEEDBACK_OUTCOME_ID, DEFAULT_FEEDBACK_TRANSFORMS, type FeedbackTransform, type ProcessFeedbackInlineOptions, } from './feedbackUtils.js';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,GACjC,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utilities for QTI item component rendering
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export { cleanFeedbackText, processFeedbackInline, DEFAULT_FEEDBACK_OUTCOME_ID, DEFAULT_FEEDBACK_TRANSFORMS, } from './feedbackUtils';
|
|
4
|
+
export { cleanFeedbackText, processFeedbackInline, DEFAULT_FEEDBACK_OUTCOME_ID, DEFAULT_FEEDBACK_TRANSFORMS, } from './feedbackUtils.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* different QTI interaction types. Uses priority-based dispatch similar to the
|
|
6
6
|
* ExtractionRegistry, but for framework-agnostic web components.
|
|
7
7
|
*/
|
|
8
|
-
import type { InteractionData } from '../
|
|
8
|
+
import type { InteractionData } from '../interactions/index.js';
|
|
9
9
|
/**
|
|
10
10
|
* Configuration for registering a web component renderer
|
|
11
11
|
*/
|
|
@@ -110,6 +110,15 @@ export declare class ComponentRegistry {
|
|
|
110
110
|
* Create a new component registry
|
|
111
111
|
*/
|
|
112
112
|
export declare function createComponentRegistry(): ComponentRegistry;
|
|
113
|
+
/**
|
|
114
|
+
* Register the default QTI interaction tag names without importing their implementations.
|
|
115
|
+
*
|
|
116
|
+
* Hosts still choose the implementation bundle, typically by importing
|
|
117
|
+
* `@pie-qti/default-components/plugins` in the browser. Keeping only tag metadata here lets
|
|
118
|
+
* the item-player custom element remain the public rendering boundary without depending on
|
|
119
|
+
* Svelte-authored default components.
|
|
120
|
+
*/
|
|
121
|
+
export declare function registerDefaultComponentTags(registry: ComponentRegistry): void;
|
|
113
122
|
/**
|
|
114
123
|
* Plugin interface for registering web components
|
|
115
124
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../src/core/ComponentRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE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QAAQ,CAAC,KAAK,SAAS,eAAe,EACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,GAC5B,IAAI;IA+BP,OAAO,CAAC,yBAAyB;IAYjC;;;;;;;OAOG;IACH,UAAU,CAAC,KAAK,SAAS,eAAe,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM;IAwC9D;;;OAGG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAInC;;;;;;;OAOG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAK9C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAI3D;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAQ9E;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAEhB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC5C"}
|
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
* different QTI interaction types. Uses priority-based dispatch similar to the
|
|
6
6
|
* ExtractionRegistry, but for framework-agnostic web components.
|
|
7
7
|
*/
|
|
8
|
+
const DEFAULT_COMPONENT_TAGS_BY_TYPE = {
|
|
9
|
+
choiceInteraction: { name: 'default-choice', tagName: 'pie-qti-choice' },
|
|
10
|
+
sliderInteraction: { name: 'default-slider', tagName: 'pie-qti-slider' },
|
|
11
|
+
orderInteraction: { name: 'default-order', tagName: 'pie-qti-order' },
|
|
12
|
+
matchInteraction: { name: 'default-match', tagName: 'pie-qti-match' },
|
|
13
|
+
associateInteraction: { name: 'default-associate', tagName: 'pie-qti-associate' },
|
|
14
|
+
gapMatchInteraction: { name: 'default-gap-match', tagName: 'pie-qti-gap-match' },
|
|
15
|
+
hotspotInteraction: { name: 'default-hotspot', tagName: 'pie-qti-hotspot' },
|
|
16
|
+
hottextInteraction: { name: 'default-hottext', tagName: 'pie-qti-hottext' },
|
|
17
|
+
mediaInteraction: { name: 'default-media', tagName: 'pie-qti-media' },
|
|
18
|
+
customInteraction: { name: 'default-custom', tagName: 'pie-qti-custom' },
|
|
19
|
+
endAttemptInteraction: { name: 'default-end-attempt', tagName: 'pie-qti-end-attempt' },
|
|
20
|
+
positionObjectInteraction: { name: 'default-position-object', tagName: 'pie-qti-position-object' },
|
|
21
|
+
graphicGapMatchInteraction: { name: 'default-graphic-gap-match', tagName: 'pie-qti-graphic-gap-match' },
|
|
22
|
+
graphicOrderInteraction: { name: 'default-graphic-order', tagName: 'pie-qti-graphic-order' },
|
|
23
|
+
graphicAssociateInteraction: { name: 'default-graphic-associate', tagName: 'pie-qti-graphic-associate' },
|
|
24
|
+
selectPointInteraction: { name: 'default-select-point', tagName: 'pie-qti-select-point' },
|
|
25
|
+
extendedTextInteraction: { name: 'default-extended-text', tagName: 'pie-qti-extended-text' },
|
|
26
|
+
uploadInteraction: { name: 'default-upload', tagName: 'pie-qti-upload' },
|
|
27
|
+
drawingInteraction: { name: 'default-drawing', tagName: 'pie-qti-drawing' },
|
|
28
|
+
catalogPopup: { name: 'default-catalog-popup', tagName: 'pie-qti-catalog-popup' },
|
|
29
|
+
};
|
|
8
30
|
/**
|
|
9
31
|
* Registry for web components that render QTI interactions
|
|
10
32
|
*/
|
|
@@ -140,5 +162,24 @@ export class ComponentRegistry {
|
|
|
140
162
|
* Create a new component registry
|
|
141
163
|
*/
|
|
142
164
|
export function createComponentRegistry() {
|
|
143
|
-
|
|
165
|
+
const registry = new ComponentRegistry();
|
|
166
|
+
registerDefaultComponentTags(registry);
|
|
167
|
+
return registry;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Register the default QTI interaction tag names without importing their implementations.
|
|
171
|
+
*
|
|
172
|
+
* Hosts still choose the implementation bundle, typically by importing
|
|
173
|
+
* `@pie-qti/default-components/plugins` in the browser. Keeping only tag metadata here lets
|
|
174
|
+
* the item-player custom element remain the public rendering boundary without depending on
|
|
175
|
+
* Svelte-authored default components.
|
|
176
|
+
*/
|
|
177
|
+
export function registerDefaultComponentTags(registry) {
|
|
178
|
+
for (const [type, component] of Object.entries(DEFAULT_COMPONENT_TAGS_BY_TYPE)) {
|
|
179
|
+
registry.register(type, {
|
|
180
|
+
...component,
|
|
181
|
+
description: `Default web component tag for ${type}`,
|
|
182
|
+
priority: -100,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
144
185
|
}
|
package/dist/core/Player.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type DeclarationMap } from '@pie-qti/qti-processing';
|
|
2
2
|
import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';
|
|
3
3
|
import type { ExtractionRegistry } from '../extraction/ExtractionRegistry.js';
|
|
4
|
-
import type { AdaptiveAttemptResult, CompletionStatus, HtmlContent, ItemSessionActionResult, ItemSessionState, PlayerConfig, PlayerSecurityConfig, RubricBlock, ScoringResult, SerializedItemSessionState } from '../types/index.js';
|
|
5
|
-
import type { InteractionData } from '../
|
|
4
|
+
import type { AdaptiveAttemptResult, CompletionStatus, HtmlContent, ItemSessionActionCommand, ItemSessionActionResult, ItemSessionState, PlayerConfig, PlayerSecurityConfig, RubricBlock, ScoringResult, SerializedItemSessionState } from '../types/index.js';
|
|
5
|
+
import type { InteractionData } from '../interactions/index.js';
|
|
6
6
|
import type { ResponseValidationResult } from '../types/responseValidation.js';
|
|
7
7
|
import type { ComponentRegistry } from './ComponentRegistry.js';
|
|
8
8
|
import type { PnpProfile } from '../pnp/types.js';
|
|
@@ -103,6 +103,13 @@ export declare class Player {
|
|
|
103
103
|
newTemplate(options?: {
|
|
104
104
|
resetResponses?: boolean;
|
|
105
105
|
}): ItemSessionActionResult;
|
|
106
|
+
runItemSessionAction(command: ItemSessionActionCommand): ItemSessionActionResult;
|
|
107
|
+
private runSuspendAttemptAction;
|
|
108
|
+
private runEndAttemptAction;
|
|
109
|
+
private runScoreAttemptAction;
|
|
110
|
+
private runNewTemplateAction;
|
|
111
|
+
private runSubmitAttemptAction;
|
|
112
|
+
private createItemSessionActionResult;
|
|
106
113
|
getSecurityConfig(): PlayerSecurityConfig | undefined;
|
|
107
114
|
getTrustedTypesPolicyName(): string | undefined;
|
|
108
115
|
/**
|
|
@@ -175,6 +182,7 @@ export declare class Player {
|
|
|
175
182
|
getCompletionStatus(): CompletionStatus;
|
|
176
183
|
isCompleted(): boolean;
|
|
177
184
|
submitAttempt(countAttempt?: boolean): AdaptiveAttemptResult;
|
|
185
|
+
private runAdaptiveSubmitAttempt;
|
|
178
186
|
getResponses(): Record<string, any>;
|
|
179
187
|
/**
|
|
180
188
|
* Get correct response for a specific response identifier
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../../src/core/Player.ts"],"names":[],"mappings":"AAAA,OAAO,EAWN,KAAK,cAAc,EAcnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAUxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAI9E,OAAO,KAAK,EACX,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EAEX,uBAAuB,EACvB,gBAAgB,EAEhB,YAAY,EACZ,oBAAoB,EAEpB,WAAW,EACX,aAAa,EACb,0BAA0B,EAE1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,E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IACI,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;IAqB3D,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,6BAA6B;IAarC,OAAO,CAAC,4BAA4B;IAapC,OAAO,CAAC,8BAA8B;IAsFtC,OAAO,CAAC,iBAAiB;IA6DzB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,yBAAyB;IAkEjC,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,wBAAwB;IAWhC,OAAO,CAAC,oBAAoB;IAqC5B,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,YAAY;IA4CpB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,wBAAwB;IAsChC,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,gBAAgB;CAsBxB"}
|
package/dist/core/Player.js
CHANGED
|
@@ -302,71 +302,64 @@ export class Player {
|
|
|
302
302
|
this.updateDuration();
|
|
303
303
|
}
|
|
304
304
|
suspendAttempt() {
|
|
305
|
+
return this.runItemSessionAction({ action: 'suspendAttempt' });
|
|
306
|
+
}
|
|
307
|
+
endAttempt(options = {}) {
|
|
308
|
+
return this.runItemSessionAction({ action: 'endAttempt', ...options });
|
|
309
|
+
}
|
|
310
|
+
scoreAttempt() {
|
|
311
|
+
return this.runItemSessionAction({ action: 'scoreAttempt' });
|
|
312
|
+
}
|
|
313
|
+
newTemplate(options = {}) {
|
|
314
|
+
return this.runItemSessionAction({ action: 'newTemplate', ...options });
|
|
315
|
+
}
|
|
316
|
+
runItemSessionAction(command) {
|
|
317
|
+
switch (command.action) {
|
|
318
|
+
case 'suspendAttempt':
|
|
319
|
+
return this.runSuspendAttemptAction();
|
|
320
|
+
case 'endAttempt':
|
|
321
|
+
return this.runEndAttemptAction(command);
|
|
322
|
+
case 'scoreAttempt':
|
|
323
|
+
return this.runScoreAttemptAction();
|
|
324
|
+
case 'newTemplate':
|
|
325
|
+
return this.runNewTemplateAction(command);
|
|
326
|
+
case 'submitAttempt':
|
|
327
|
+
return this.runSubmitAttemptAction(command.countAttempt ?? true);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
runSuspendAttemptAction() {
|
|
305
331
|
const validation = this.validateResponses(this.getResponses());
|
|
306
332
|
this.lifecycleStatus = 'suspended';
|
|
307
333
|
const sessionState = this.saveItemSession();
|
|
308
|
-
return {
|
|
309
|
-
action: 'suspendAttempt',
|
|
310
|
-
lifecycleStatus: this.lifecycleStatus,
|
|
311
|
-
completionStatus: this.getCompletionStatus(),
|
|
312
|
-
numAttempts: this.getNumAttempts(),
|
|
313
|
-
duration: sessionState.duration,
|
|
314
|
-
completed: this.isCompleted(),
|
|
315
|
-
sessionState,
|
|
316
|
-
validation,
|
|
317
|
-
};
|
|
334
|
+
return this.createItemSessionActionResult('suspendAttempt', sessionState, { validation });
|
|
318
335
|
}
|
|
319
|
-
|
|
336
|
+
runEndAttemptAction(options) {
|
|
320
337
|
const validate = options.validateResponses ?? false;
|
|
321
338
|
const validation = validate ? this.validateResponses(this.getResponses()) : undefined;
|
|
322
339
|
if (validation && !validation.valid) {
|
|
323
|
-
|
|
324
|
-
return {
|
|
325
|
-
action: 'endAttempt',
|
|
326
|
-
lifecycleStatus: this.lifecycleStatus,
|
|
327
|
-
completionStatus: this.getCompletionStatus(),
|
|
328
|
-
numAttempts: this.getNumAttempts(),
|
|
329
|
-
duration: sessionState.duration,
|
|
330
|
-
completed: this.isCompleted(),
|
|
331
|
-
sessionState,
|
|
332
|
-
validation,
|
|
333
|
-
};
|
|
340
|
+
return this.createItemSessionActionResult('endAttempt', this.saveItemSession(), { validation });
|
|
334
341
|
}
|
|
335
342
|
const scoring = this.isAdaptive()
|
|
336
|
-
? this.
|
|
343
|
+
? this.runAdaptiveSubmitAttempt(options.countAttempt ?? true)
|
|
337
344
|
: this.runResponseProcessing({
|
|
338
345
|
finalizeNonAdaptiveAttempt: true,
|
|
339
346
|
countAttempt: options.countAttempt ?? true,
|
|
340
347
|
});
|
|
341
348
|
this.lifecycleStatus = scoring.completed ? 'closed' : 'interacting';
|
|
342
|
-
|
|
343
|
-
return {
|
|
344
|
-
action: 'endAttempt',
|
|
345
|
-
lifecycleStatus: this.lifecycleStatus,
|
|
346
|
-
completionStatus: this.getCompletionStatus(),
|
|
347
|
-
numAttempts: this.getNumAttempts(),
|
|
348
|
-
duration: sessionState.duration,
|
|
349
|
+
return this.createItemSessionActionResult('endAttempt', this.saveItemSession(), {
|
|
349
350
|
completed: scoring.completed,
|
|
350
|
-
sessionState,
|
|
351
351
|
validation,
|
|
352
352
|
scoring,
|
|
353
|
-
};
|
|
353
|
+
});
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
runScoreAttemptAction() {
|
|
356
356
|
const scoring = this.runResponseProcessing({ finalizeNonAdaptiveAttempt: false });
|
|
357
|
-
|
|
358
|
-
return {
|
|
359
|
-
action: 'scoreAttempt',
|
|
360
|
-
lifecycleStatus: this.lifecycleStatus,
|
|
361
|
-
completionStatus: this.getCompletionStatus(),
|
|
362
|
-
numAttempts: this.getNumAttempts(),
|
|
363
|
-
duration: sessionState.duration,
|
|
357
|
+
return this.createItemSessionActionResult('scoreAttempt', this.saveItemSession(), {
|
|
364
358
|
completed: scoring.completed,
|
|
365
|
-
sessionState,
|
|
366
359
|
scoring,
|
|
367
|
-
};
|
|
360
|
+
});
|
|
368
361
|
}
|
|
369
|
-
|
|
362
|
+
runNewTemplateAction(options) {
|
|
370
363
|
this.resetOutcomesToDefault();
|
|
371
364
|
if (options.resetResponses ?? true) {
|
|
372
365
|
this.resetResponsesToDefault();
|
|
@@ -379,15 +372,26 @@ export class Player {
|
|
|
379
372
|
this.accumulatedDurationMs = 0;
|
|
380
373
|
this.sessionStartedAt = Date.now();
|
|
381
374
|
this.updateDuration();
|
|
382
|
-
|
|
375
|
+
return this.createItemSessionActionResult('newTemplate', this.serializeItemSession());
|
|
376
|
+
}
|
|
377
|
+
runSubmitAttemptAction(countAttempt) {
|
|
378
|
+
const scoring = this.runAdaptiveSubmitAttempt(countAttempt);
|
|
379
|
+
return this.createItemSessionActionResult('submitAttempt', this.saveItemSession(), {
|
|
380
|
+
completed: scoring.completed,
|
|
381
|
+
scoring,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
createItemSessionActionResult(action, sessionState, options = {}) {
|
|
383
385
|
return {
|
|
384
|
-
action
|
|
386
|
+
action,
|
|
385
387
|
lifecycleStatus: this.lifecycleStatus,
|
|
386
388
|
completionStatus: this.getCompletionStatus(),
|
|
387
389
|
numAttempts: this.getNumAttempts(),
|
|
388
390
|
duration: sessionState.duration,
|
|
389
|
-
completed: this.isCompleted(),
|
|
391
|
+
completed: options.completed ?? this.isCompleted(),
|
|
390
392
|
sessionState,
|
|
393
|
+
validation: options.validation,
|
|
394
|
+
scoring: options.scoring,
|
|
391
395
|
};
|
|
392
396
|
}
|
|
393
397
|
getSecurityConfig() {
|
|
@@ -646,6 +650,10 @@ export class Player {
|
|
|
646
650
|
return this.getCompletionStatus() === 'completed';
|
|
647
651
|
}
|
|
648
652
|
submitAttempt(countAttempt = true) {
|
|
653
|
+
const result = this.runItemSessionAction({ action: 'submitAttempt', countAttempt });
|
|
654
|
+
return result.scoring;
|
|
655
|
+
}
|
|
656
|
+
runAdaptiveSubmitAttempt(countAttempt = true) {
|
|
649
657
|
if (this.isCompleted()) {
|
|
650
658
|
throw new Error('Cannot submit: item is already completed');
|
|
651
659
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AttributeNameMapper, ElementNameMapper } from '@pie-qti/qti-common';
|
|
2
2
|
import type { PlayerSecurityConfig } from '../types/index.js';
|
|
3
|
-
import type { QTIElement } from '../
|
|
3
|
+
import type { QTIElement } from '../interactions/index.js';
|
|
4
4
|
export type ProcessingKind = 'template' | 'response' | 'outcome';
|
|
5
5
|
export interface DiscoveredInteractionElement {
|
|
6
6
|
element: QTIElement;
|
package/dist/element.d.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
|
+
import { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';
|
|
1
2
|
import { AdaptiveAttemptResult, PlayerSecurityConfig } from './types/index.js';
|
|
2
3
|
import { I18nProvider } from '@pie-qti/i18n';
|
|
4
|
+
import { PnpProfile } from './pnp/types.js';
|
|
5
|
+
type ItemResponseMap = Record<string, unknown>;
|
|
3
6
|
declare class PieQtiItemPlayerElement extends HTMLElement {
|
|
4
7
|
#private;
|
|
5
8
|
static observedAttributes: string[];
|
|
9
|
+
get itemXml(): string | undefined;
|
|
10
|
+
set itemXml(v: string | undefined);
|
|
11
|
+
get role(): string | null;
|
|
12
|
+
set role(v: string | null);
|
|
13
|
+
get disabled(): boolean | undefined;
|
|
14
|
+
set disabled(v: boolean | undefined);
|
|
6
15
|
get typeset(): ((el: HTMLElement) => void) | undefined;
|
|
7
16
|
set typeset(v: ((el: HTMLElement) => void) | undefined);
|
|
8
17
|
get i18n(): I18nProvider | undefined;
|
|
9
18
|
set i18n(v: I18nProvider | undefined);
|
|
10
19
|
get security(): PlayerSecurityConfig | undefined;
|
|
11
20
|
set security(v: PlayerSecurityConfig | undefined);
|
|
21
|
+
get pnp(): PnpProfile | undefined;
|
|
22
|
+
set pnp(v: PnpProfile | undefined);
|
|
23
|
+
get deliveryContext(): ResolvedItemDeliveryContext | undefined;
|
|
24
|
+
set deliveryContext(v: ResolvedItemDeliveryContext | undefined);
|
|
25
|
+
get responses(): ItemResponseMap | undefined;
|
|
26
|
+
set responses(v: ItemResponseMap | undefined);
|
|
12
27
|
get onResponseChange(): ((id: string, value: unknown) => void) | undefined;
|
|
13
28
|
set onResponseChange(v: ((id: string, value: unknown) => void) | undefined);
|
|
14
29
|
get onSubmit(): ((responses: Record<string, unknown>, result: unknown) => void) | undefined;
|