@pie-qti/item-player 0.1.18 → 0.1.20
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 +137 -427
- package/dist/catalog/applyGlossaryTriggers.d.ts +2 -1
- package/dist/catalog/applyGlossaryTriggers.js +4 -2
- package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
- package/dist/components/utils/stimulusRender.d.ts +1 -2
- package/dist/components/utils/stimulusRender.js +2 -5
- package/dist/components/utils/stimulusRender.js.map +1 -1
- package/dist/core/AssessmentItemDefinition.d.ts +69 -0
- package/dist/core/AssessmentItemDefinition.js +149 -0
- package/dist/core/AssessmentItemDefinition.js.map +1 -0
- package/dist/core/ComponentRegistry.d.ts +11 -5
- package/dist/core/ComponentRegistry.js +44 -17
- package/dist/core/ComponentRegistry.js.map +1 -1
- package/dist/core/ItemSession.d.ts +58 -0
- package/dist/core/ItemSession.js +286 -0
- package/dist/core/ItemSession.js.map +1 -0
- package/dist/core/Player.d.ts +9 -8
- package/dist/core/Player.js +182 -163
- package/dist/core/Player.js.map +1 -1
- package/dist/core/sanitizer.js +33 -10
- package/dist/core/sanitizer.js.map +1 -1
- package/dist/document/AssessmentItemDocument.d.ts +32 -10
- package/dist/document/AssessmentItemDocument.js +80 -23
- package/dist/document/AssessmentItemDocument.js.map +1 -1
- package/dist/{element-class-C8OTgYHE.js → element-class-CILJ4Ls7.js} +3583 -2779
- package/dist/element-class-CILJ4Ls7.js.map +1 -0
- package/dist/element-class.d.ts +17 -13
- package/dist/element-class.js +1 -1
- package/dist/element.js +1 -1
- package/dist/extraction/ExtractionRegistry.d.ts +34 -11
- package/dist/extraction/ExtractionRegistry.js +122 -19
- package/dist/extraction/ExtractionRegistry.js.map +1 -1
- package/dist/extraction/createContext.d.ts +5 -6
- package/dist/extraction/createContext.js +2 -2
- package/dist/extraction/createContext.js.map +1 -1
- package/dist/extraction/deliveryTypes.d.ts +26 -0
- package/dist/extraction/deliveryTypes.js +7 -0
- package/dist/extraction/deliveryTypes.js.map +1 -0
- package/dist/extraction/index.d.ts +3 -3
- package/dist/extraction/index.js +1 -2
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/interactionExtractionPipeline.d.ts +4 -4
- package/dist/extraction/interactionExtractionPipeline.js +27 -10
- package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
- package/dist/extraction/interactionSecurity.d.ts +11 -2
- package/dist/extraction/interactionSecurity.js +105 -40
- package/dist/extraction/interactionSecurity.js.map +1 -1
- package/dist/extraction/types.d.ts +44 -7
- package/dist/extraction/types.js.map +1 -1
- package/dist/extraction/utils.js +4 -16
- package/dist/extraction/utils.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/interactions/associate/extractor.js +1 -1
- package/dist/interactions/associate/extractor.js.map +1 -1
- package/dist/interactions/drawing/extractor.js +5 -4
- package/dist/interactions/drawing/extractor.js.map +1 -1
- package/dist/interactions/end-attempt/extractor.js +2 -2
- package/dist/interactions/end-attempt/extractor.js.map +1 -1
- package/dist/interactions/gap-match/extractor.js +4 -3
- package/dist/interactions/gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-associate/extractor.js +5 -4
- package/dist/interactions/graphic-associate/extractor.js.map +1 -1
- package/dist/interactions/graphic-gap-match/extractor.js +20 -17
- package/dist/interactions/graphic-gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-order/extractor.js +5 -4
- package/dist/interactions/graphic-order/extractor.js.map +1 -1
- package/dist/interactions/hotspot/extractor.js +11 -10
- package/dist/interactions/hotspot/extractor.js.map +1 -1
- package/dist/interactions/inline/render-plan.d.ts +3 -5
- package/dist/interactions/inline/render-plan.js.map +1 -1
- package/dist/interactions/media/extractor.js +2 -2
- package/dist/interactions/media/extractor.js.map +1 -1
- package/dist/interactions/modules.d.ts +11 -91
- package/dist/interactions/modules.js +185 -45
- package/dist/interactions/modules.js.map +1 -1
- package/dist/interactions/portable-custom/extractor.d.ts +1 -1
- package/dist/interactions/portable-custom/extractor.js +1 -1
- package/dist/interactions/portable-custom/extractor.js.map +1 -1
- package/dist/interactions/position-object/extractor.js +3 -2
- package/dist/interactions/position-object/extractor.js.map +1 -1
- package/dist/interactions/select-point/extractor.js +7 -6
- package/dist/interactions/select-point/extractor.js.map +1 -1
- package/dist/interactions/shared/types.d.ts +59 -70
- package/dist/interactions/shared/types.js.map +1 -1
- package/dist/interactions/slider/extractor.js +2 -2
- package/dist/interactions/slider/extractor.js.map +1 -1
- package/dist/interactions/upload/extractor.js +2 -2
- package/dist/interactions/upload/extractor.js.map +1 -1
- package/dist/pci/types.d.ts +2 -3
- package/dist/pci/types.js.map +1 -1
- package/dist/presentation/itemPresentationPlan.d.ts +71 -38
- package/dist/presentation/itemPresentationPlan.js +78 -34
- package/dist/presentation/itemPresentationPlan.js.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/styleValues.d.ts +20 -0
- package/dist/security/styleValues.js +49 -0
- package/dist/security/styleValues.js.map +1 -0
- package/dist/server.d.ts +188 -9
- package/dist/server.js +32 -7
- package/dist/server.js.map +1 -1
- package/dist/types/index.d.ts +1 -110
- package/dist/types/index.js.map +1 -1
- package/dist/web-components/QTIInteractionBase.d.ts +2 -2
- package/dist/web-components/QTIInteractionBase.js.map +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +3 -3
- package/dist/web-components/QTIInteractionElement.js.map +1 -1
- package/package.json +11 -11
- package/dist/core/Plugin.d.ts +0 -104
- package/dist/core/Plugin.js +0 -8
- package/dist/core/Plugin.js.map +0 -1
- package/dist/core/PluginManager.d.ts +0 -55
- package/dist/core/PluginManager.js +0 -148
- package/dist/core/PluginManager.js.map +0 -1
- package/dist/element-class-C8OTgYHE.js.map +0 -1
- package/dist/interactions/associate/index.d.ts +0 -2
- package/dist/interactions/associate/index.js +0 -2
- package/dist/interactions/associate/index.js.map +0 -1
- package/dist/interactions/associate/types.d.ts +0 -1
- package/dist/interactions/associate/types.js +0 -2
- package/dist/interactions/associate/types.js.map +0 -1
- package/dist/interactions/choice/index.d.ts +0 -2
- package/dist/interactions/choice/index.js +0 -2
- package/dist/interactions/choice/index.js.map +0 -1
- package/dist/interactions/choice/types.d.ts +0 -1
- package/dist/interactions/choice/types.js +0 -2
- package/dist/interactions/choice/types.js.map +0 -1
- package/dist/interactions/custom/index.d.ts +0 -2
- package/dist/interactions/custom/index.js +0 -2
- package/dist/interactions/custom/index.js.map +0 -1
- package/dist/interactions/custom/types.d.ts +0 -1
- package/dist/interactions/custom/types.js +0 -2
- package/dist/interactions/custom/types.js.map +0 -1
- package/dist/interactions/drawing/index.d.ts +0 -2
- package/dist/interactions/drawing/index.js +0 -2
- package/dist/interactions/drawing/index.js.map +0 -1
- package/dist/interactions/drawing/types.d.ts +0 -1
- package/dist/interactions/drawing/types.js +0 -2
- package/dist/interactions/drawing/types.js.map +0 -1
- package/dist/interactions/end-attempt/index.d.ts +0 -2
- package/dist/interactions/end-attempt/index.js +0 -2
- package/dist/interactions/end-attempt/index.js.map +0 -1
- package/dist/interactions/end-attempt/types.d.ts +0 -1
- package/dist/interactions/end-attempt/types.js +0 -2
- package/dist/interactions/end-attempt/types.js.map +0 -1
- package/dist/interactions/extended-text/index.d.ts +0 -3
- package/dist/interactions/extended-text/index.js +0 -3
- package/dist/interactions/extended-text/index.js.map +0 -1
- package/dist/interactions/extended-text/types.d.ts +0 -1
- package/dist/interactions/extended-text/types.js +0 -2
- package/dist/interactions/extended-text/types.js.map +0 -1
- package/dist/interactions/gap-match/index.d.ts +0 -2
- package/dist/interactions/gap-match/index.js +0 -2
- package/dist/interactions/gap-match/index.js.map +0 -1
- package/dist/interactions/gap-match/types.d.ts +0 -1
- package/dist/interactions/gap-match/types.js +0 -2
- package/dist/interactions/gap-match/types.js.map +0 -1
- package/dist/interactions/graphic-associate/index.d.ts +0 -2
- package/dist/interactions/graphic-associate/index.js +0 -2
- package/dist/interactions/graphic-associate/index.js.map +0 -1
- package/dist/interactions/graphic-associate/types.d.ts +0 -1
- package/dist/interactions/graphic-associate/types.js +0 -2
- package/dist/interactions/graphic-associate/types.js.map +0 -1
- package/dist/interactions/graphic-gap-match/index.d.ts +0 -2
- package/dist/interactions/graphic-gap-match/index.js +0 -2
- package/dist/interactions/graphic-gap-match/index.js.map +0 -1
- package/dist/interactions/graphic-gap-match/types.d.ts +0 -1
- package/dist/interactions/graphic-gap-match/types.js +0 -2
- package/dist/interactions/graphic-gap-match/types.js.map +0 -1
- package/dist/interactions/graphic-order/index.d.ts +0 -2
- package/dist/interactions/graphic-order/index.js +0 -2
- package/dist/interactions/graphic-order/index.js.map +0 -1
- package/dist/interactions/graphic-order/types.d.ts +0 -1
- package/dist/interactions/graphic-order/types.js +0 -2
- package/dist/interactions/graphic-order/types.js.map +0 -1
- package/dist/interactions/hotspot/index.d.ts +0 -2
- package/dist/interactions/hotspot/index.js +0 -2
- package/dist/interactions/hotspot/index.js.map +0 -1
- package/dist/interactions/hotspot/types.d.ts +0 -1
- package/dist/interactions/hotspot/types.js +0 -2
- package/dist/interactions/hotspot/types.js.map +0 -1
- package/dist/interactions/hottext/index.d.ts +0 -2
- package/dist/interactions/hottext/index.js +0 -2
- package/dist/interactions/hottext/index.js.map +0 -1
- package/dist/interactions/hottext/types.d.ts +0 -1
- package/dist/interactions/hottext/types.js +0 -2
- package/dist/interactions/hottext/types.js.map +0 -1
- package/dist/interactions/index.d.ts +0 -32
- package/dist/interactions/index.js +0 -31
- package/dist/interactions/index.js.map +0 -1
- package/dist/interactions/inline/index.d.ts +0 -1
- package/dist/interactions/inline/index.js +0 -2
- package/dist/interactions/inline/index.js.map +0 -1
- package/dist/interactions/inline-choice/index.d.ts +0 -2
- package/dist/interactions/inline-choice/index.js +0 -2
- package/dist/interactions/inline-choice/index.js.map +0 -1
- package/dist/interactions/inline-choice/types.d.ts +0 -1
- package/dist/interactions/inline-choice/types.js +0 -2
- package/dist/interactions/inline-choice/types.js.map +0 -1
- package/dist/interactions/match/index.d.ts +0 -2
- package/dist/interactions/match/index.js +0 -2
- package/dist/interactions/match/index.js.map +0 -1
- package/dist/interactions/match/types.d.ts +0 -1
- package/dist/interactions/match/types.js +0 -2
- package/dist/interactions/match/types.js.map +0 -1
- package/dist/interactions/media/index.d.ts +0 -2
- package/dist/interactions/media/index.js +0 -2
- package/dist/interactions/media/index.js.map +0 -1
- package/dist/interactions/media/types.d.ts +0 -1
- package/dist/interactions/media/types.js +0 -2
- package/dist/interactions/media/types.js.map +0 -1
- package/dist/interactions/order/index.d.ts +0 -2
- package/dist/interactions/order/index.js +0 -2
- package/dist/interactions/order/index.js.map +0 -1
- package/dist/interactions/order/types.d.ts +0 -1
- package/dist/interactions/order/types.js +0 -2
- package/dist/interactions/order/types.js.map +0 -1
- package/dist/interactions/portable-custom/index.d.ts +0 -2
- package/dist/interactions/portable-custom/index.js +0 -2
- package/dist/interactions/portable-custom/index.js.map +0 -1
- package/dist/interactions/portable-custom/types.d.ts +0 -1
- package/dist/interactions/portable-custom/types.js +0 -2
- package/dist/interactions/portable-custom/types.js.map +0 -1
- package/dist/interactions/position-object/index.d.ts +0 -2
- package/dist/interactions/position-object/index.js +0 -2
- package/dist/interactions/position-object/index.js.map +0 -1
- package/dist/interactions/position-object/types.d.ts +0 -1
- package/dist/interactions/position-object/types.js +0 -2
- package/dist/interactions/position-object/types.js.map +0 -1
- package/dist/interactions/select-point/index.d.ts +0 -2
- package/dist/interactions/select-point/index.js +0 -2
- package/dist/interactions/select-point/index.js.map +0 -1
- package/dist/interactions/select-point/types.d.ts +0 -1
- package/dist/interactions/select-point/types.js +0 -2
- package/dist/interactions/select-point/types.js.map +0 -1
- package/dist/interactions/shared/index.d.ts +0 -1
- package/dist/interactions/shared/index.js +0 -2
- package/dist/interactions/shared/index.js.map +0 -1
- package/dist/interactions/slider/index.d.ts +0 -2
- package/dist/interactions/slider/index.js +0 -2
- package/dist/interactions/slider/index.js.map +0 -1
- package/dist/interactions/slider/types.d.ts +0 -1
- package/dist/interactions/slider/types.js +0 -2
- package/dist/interactions/slider/types.js.map +0 -1
- package/dist/interactions/text-entry/index.d.ts +0 -2
- package/dist/interactions/text-entry/index.js +0 -2
- package/dist/interactions/text-entry/index.js.map +0 -1
- package/dist/interactions/text-entry/types.d.ts +0 -1
- package/dist/interactions/text-entry/types.js +0 -2
- package/dist/interactions/text-entry/types.js.map +0 -1
- package/dist/interactions/upload/index.d.ts +0 -2
- package/dist/interactions/upload/index.js +0 -2
- package/dist/interactions/upload/index.js.map +0 -1
- package/dist/interactions/upload/types.d.ts +0 -1
- package/dist/interactions/upload/types.js +0 -2
- package/dist/interactions/upload/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,498 +1,208 @@
|
|
|
1
1
|
# @pie-qti/item-player
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-neutral QTI 2.2/3.0 item compilation, live session state, response processing, and
|
|
4
|
+
render-neutral presentation data.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
The primary API has two lifetimes:
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- ✅ **Adaptive Items** - Multi-attempt workflow with progressive feedback
|
|
10
|
-
- ✅ **Full Keyboard Accessibility** (follows WCAG 2.2 Level AA guidelines)
|
|
11
|
-
- ✅ **Client-Side Response Processing** with 45/45 QTI operators
|
|
12
|
-
- ✅ **Framework-Agnostic Core** with a **Web Component interaction layer** (default implementations authored in Svelte)
|
|
13
|
-
- ✅ **TypeScript** with full type definitions
|
|
14
|
-
- **No Svelte dependency for consumers of the framework-agnostic core**
|
|
15
|
-
- ✅ **Iframe mode (reference)** - Optional host helper + postMessage protocol for iframe-isolated deployments
|
|
8
|
+
1. `AssessmentItemDefinition` compiles immutable item XML, security policy, mappings, and plugins.
|
|
9
|
+
2. `ItemSession` owns one mutable attempt, its variables, lifecycle, responses, and presentation.
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> The item custom element enables parsing limits by default. Sanitization is not a JavaScript
|
|
20
|
-
> sandbox: for content that is not trusted to run in the host origin, prefer a cross-origin
|
|
21
|
-
> sandboxed iframe. See `docs/prds/architecture/security.md` in the repository.
|
|
11
|
+
The implementation engine is private. Browser, assessment, standalone, and server deployments all
|
|
12
|
+
use the definition/session interface.
|
|
22
13
|
|
|
23
|
-
##
|
|
14
|
+
## Install
|
|
24
15
|
|
|
25
16
|
```bash
|
|
26
17
|
bun add @pie-qti/item-player
|
|
27
18
|
```
|
|
28
19
|
|
|
29
|
-
|
|
20
|
+
For the complete browser runtime, prefer `@pie-qti/player-elements`:
|
|
30
21
|
|
|
31
22
|
```bash
|
|
32
|
-
|
|
23
|
+
bun add @pie-qti/player-elements
|
|
33
24
|
```
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### Web Component Host Integration
|
|
38
|
-
|
|
39
|
-
For browser applications, the public rendering boundary is the custom element. The default
|
|
40
|
-
interaction implementations are a separate package, so install both packages:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npm install @pie-qti/item-player @pie-qti/default-components
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import '@pie-qti/default-components/plugins';
|
|
48
|
-
import '@pie-qti/item-player/element';
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
```html
|
|
52
|
-
<pie-qti-item-player item-xml="<assessmentItem ...></assessmentItem>" role="author"></pie-qti-item-player>
|
|
26
|
+
```ts
|
|
27
|
+
import '@pie-qti/player-elements/register';
|
|
53
28
|
```
|
|
54
29
|
|
|
55
|
-
|
|
56
|
-
components are compiled into the custom element bundle. Importing
|
|
57
|
-
`@pie-qti/default-components/plugins` is currently required; `@pie-qti/default-components` is not a
|
|
58
|
-
dependency of this package.
|
|
59
|
-
|
|
60
|
-
### Core Player (Framework-Agnostic)
|
|
30
|
+
## Compile a definition and open a session
|
|
61
31
|
|
|
62
|
-
```
|
|
63
|
-
import {
|
|
32
|
+
```ts
|
|
33
|
+
import { createAssessmentItemDefinition } from '@pie-qti/item-player';
|
|
64
34
|
|
|
65
|
-
|
|
66
|
-
const qtiXml = `<assessmentItem ...>...</assessmentItem>`;
|
|
67
|
-
const player = new Player({
|
|
35
|
+
const definition = createAssessmentItemDefinition({
|
|
68
36
|
itemXml: qtiXml,
|
|
69
|
-
role: 'candidate'
|
|
37
|
+
role: 'candidate',
|
|
38
|
+
security: {
|
|
39
|
+
parsingLimits: { enabled: true, rejectDoctype: true },
|
|
40
|
+
trustedTypesPolicyName: 'qti-content'
|
|
41
|
+
},
|
|
42
|
+
plugins
|
|
70
43
|
});
|
|
71
44
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// [{ type: 'choiceInteraction', responseIdentifier: 'RESPONSE', element: ... }]
|
|
75
|
-
|
|
76
|
-
// Set response
|
|
77
|
-
player.setResponse('RESPONSE', 'A');
|
|
78
|
-
|
|
79
|
-
// Score the item
|
|
80
|
-
const result = player.score();
|
|
81
|
-
console.log(result.score); // 0.0 to 1.0
|
|
82
|
-
console.log(result.outcomes); // { SCORE: 1.0, ... }
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Iframe mode (optional, reference)
|
|
86
|
-
|
|
87
|
-
For deployments that need stronger isolation for **untrusted** QTI, you can run the player inside an iframe and communicate via a versioned `postMessage` protocol.
|
|
88
|
-
|
|
89
|
-
- Docs: `docs/iframe-mode.md`
|
|
90
|
-
- Import: `@pie-qti/item-player/iframe` (browser-only)
|
|
91
|
-
|
|
92
|
-
## QTI Role/View Actors
|
|
93
|
-
|
|
94
|
-
QTI roles are primarily audience markers for `view`-controlled content (for example rubric visibility).
|
|
95
|
-
This player applies the following runtime behavior policy on top of that:
|
|
96
|
-
|
|
97
|
-
| Role | Behavior |
|
|
98
|
-
|------|----------|
|
|
99
|
-
| `candidate` | Test-taker - inputs editable, no correct answers shown |
|
|
100
|
-
| `scorer` | Grader/reviewer - inputs readonly, correct answers shown |
|
|
101
|
-
| `author` | Content authoring review - inputs readonly, correct answers shown |
|
|
102
|
-
| `tutor` | Instructional review - inputs readonly, correct answers shown |
|
|
103
|
-
| `proctor` | Test administration view - inputs readonly, no correct answers shown |
|
|
104
|
-
| `testConstructor` | Test construction review - inputs readonly, correct answers shown |
|
|
105
|
-
|
|
106
|
-
### Role-Based Rendering
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
// For test-takers (editable inputs)
|
|
110
|
-
const player = new Player({
|
|
111
|
-
itemXml: qtiXml,
|
|
112
|
-
role: 'candidate'
|
|
45
|
+
const session = definition.openSession({
|
|
46
|
+
responses: { RESPONSE: 'A' }
|
|
113
47
|
});
|
|
114
48
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
itemXml: qtiXml,
|
|
118
|
-
role: 'scorer'
|
|
49
|
+
const unsubscribe = session.subscribe(({ command, current }) => {
|
|
50
|
+
console.log(command.action, current.revision, current.responses);
|
|
119
51
|
});
|
|
120
52
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
53
|
+
session.dispatch({
|
|
54
|
+
action: 'setResponse',
|
|
55
|
+
responseIdentifier: 'RESPONSE',
|
|
56
|
+
value: 'B'
|
|
125
57
|
});
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Supported Interaction Types
|
|
129
|
-
|
|
130
|
-
| QTI Type | Component | Description |
|
|
131
|
-
|----------|-----------|-------------|
|
|
132
|
-
| `choiceInteraction` | Built-in | Single/multiple choice |
|
|
133
|
-
| `textEntryInteraction` | Built-in | Short text input |
|
|
134
|
-
| `extendedTextInteraction` | Built-in | Long-form text (essay) |
|
|
135
|
-
| `inlineChoiceInteraction` | `InlineInteractionRenderer` | Dropdown in text |
|
|
136
|
-
| `orderInteraction` | `SortableList` | Drag to reorder items |
|
|
137
|
-
| `matchInteraction` | `MatchDragDrop` | Match items between sets |
|
|
138
|
-
| `associateInteraction` | - | Create associations |
|
|
139
|
-
| `gapMatchInteraction` | - | Drag items into text gaps |
|
|
140
|
-
| `graphicGapMatchInteraction` | `GraphicGapMatch` | Drag labels onto image hotspots |
|
|
141
|
-
| `sliderInteraction` | Built-in | Slider input |
|
|
142
|
-
| `hotspotInteraction` | - | Click regions on image |
|
|
143
|
-
| `uploadInteraction` | `FileUpload` | Upload a file response |
|
|
144
|
-
| `drawingInteraction` | `DrawingCanvas` | Draw/annotate on a canvas |
|
|
145
|
-
| `customInteraction` | `CustomInteractionFallback` | Fallback display + optional manual response |
|
|
146
|
-
|
|
147
|
-
## QTI Version Support
|
|
148
|
-
|
|
149
|
-
The player supports **QTI 3.0** and **QTI 2.2**, with compatibility support for QTI 2.0/2.1 content:
|
|
150
|
-
|
|
151
|
-
- **QTI 3.0**: Supported (kebab-case `qti-` element/attribute forms)
|
|
152
|
-
- **QTI 2.2**: Full support (recommended baseline for legacy 2.x ecosystems)
|
|
153
|
-
- **QTI 2.1**: Supported with CC2 template aliases (`cc2_match`, `cc2_map_response`, etc.)
|
|
154
|
-
- **QTI 2.0**: Limited support - core interactions work, but some features may be unsupported
|
|
155
|
-
|
|
156
|
-
### Version Detection
|
|
157
|
-
|
|
158
|
-
The player automatically detects QTI version from:
|
|
159
|
-
|
|
160
|
-
1. Namespace URI (`xmlns="http://www.imsglobal.org/xsd/imsqti_v2pX"`)
|
|
161
|
-
2. Version attribute (`<assessmentItem version="2.X">`)
|
|
162
|
-
|
|
163
|
-
Warnings are logged for legacy versions or when version cannot be detected.
|
|
164
|
-
|
|
165
|
-
### Template Processing
|
|
166
|
-
|
|
167
|
-
Response processing templates are namespace-agnostic. The player supports:
|
|
168
|
-
|
|
169
|
-
- Standard templates: `match_correct`, `map_response`, etc.
|
|
170
|
-
- QTI 2.1 CC2 aliases: `cc2_match`, `cc2_map_response`, etc.
|
|
171
|
-
|
|
172
|
-
### Strict Compliance Mode
|
|
173
|
-
|
|
174
|
-
For strict QTI 2.2 validation (legacy interoperability mode), enable strict compliance:
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
const player = new Player({
|
|
178
|
-
itemXml: qtiXml,
|
|
179
|
-
strictQtiCompliance: {
|
|
180
|
-
enabled: true, // Enable strict QTI 2.2 validation mode
|
|
181
|
-
rejectUnknownExtensions: true, // Throw errors on non-2.2 versions
|
|
182
|
-
logDeviations: true // Log warnings for spec deviations
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
See [QTI Compliance Documentation](./docs/QTI-COMPLIANCE.md) for details.
|
|
188
|
-
|
|
189
|
-
## Architecture
|
|
190
58
|
|
|
191
|
-
|
|
59
|
+
const presentation = session.present();
|
|
60
|
+
const result = session.dispatch({ action: 'scoreAttempt' }).result?.scoring;
|
|
61
|
+
const saved = session.serialize();
|
|
192
62
|
|
|
63
|
+
unsubscribe();
|
|
64
|
+
session.dispose();
|
|
193
65
|
```
|
|
194
|
-
┌─────────────────────────────────────────┐
|
|
195
|
-
│ Interaction UI (Web Components) │
|
|
196
|
-
│ - default implementations authored in │
|
|
197
|
-
│ Svelte (`@pie-qti/default-components`) │
|
|
198
|
-
└─────────────────────────────────────────┘
|
|
199
|
-
↓
|
|
200
|
-
┌─────────────────────────────────────────┐
|
|
201
|
-
│ Extraction │
|
|
202
|
-
│ - Player.getInteractionData() │
|
|
203
|
-
│ - ExtractionRegistry + extractors │
|
|
204
|
-
└─────────────────────────────────────────┘
|
|
205
|
-
↓
|
|
206
|
-
┌─────────────────────────────────────────┐
|
|
207
|
-
│ Core Player (Framework-Agnostic) │
|
|
208
|
-
│ - XML parsing │
|
|
209
|
-
│ - Response processing │
|
|
210
|
-
│ - Scoring engine │
|
|
211
|
-
│ - Role-based behavior │
|
|
212
|
-
└─────────────────────────────────────────┘
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## API Reference
|
|
216
|
-
|
|
217
|
-
### Player Class
|
|
218
|
-
|
|
219
|
-
```typescript
|
|
220
|
-
interface PlayerConfig {
|
|
221
|
-
itemXml: string;
|
|
222
|
-
role?: QTIRole; // 'candidate' | 'scorer' | 'author' | 'tutor' | 'proctor' | 'testConstructor'
|
|
223
|
-
componentRegistry?: ComponentRegistry; // Custom web component registry
|
|
224
|
-
extractionRegistry?: ExtractionRegistry; // Custom extractors
|
|
225
|
-
plugins?: QTIPlugin[]; // Plugin-based extension point
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
class Player {
|
|
229
|
-
constructor(config: PlayerConfig)
|
|
230
66
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
responseIdentifier: string;
|
|
235
|
-
element: HTMLElement;
|
|
236
|
-
}>
|
|
67
|
+
`openSession()` accepts an optional serialized `restore` snapshot, response overrides, and
|
|
68
|
+
`activate: true` to resume a suspended handoff as an active session. Response identifiers are
|
|
69
|
+
validated against the compiled declarations.
|
|
237
70
|
|
|
238
|
-
|
|
239
|
-
|
|
71
|
+
The definition's role is fixed for every session it opens and is visible as `session.state().role`.
|
|
72
|
+
`present()` intentionally does not accept a role override.
|
|
240
73
|
|
|
241
|
-
|
|
242
|
-
setResponse(identifier: string, value: any): void
|
|
74
|
+
## Session commands
|
|
243
75
|
|
|
244
|
-
|
|
245
|
-
getResponse(identifier: string): any
|
|
76
|
+
`ItemSession.dispatch()` is the single mutation boundary:
|
|
246
77
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
// Get item body HTML
|
|
255
|
-
getItemBodyHtml(): string
|
|
256
|
-
|
|
257
|
-
// Get rubric blocks for current role
|
|
258
|
-
getRubricBlocks(): RubricBlock[]
|
|
259
|
-
}
|
|
260
|
-
```
|
|
78
|
+
- `setResponse` and `setResponses` update declared response variables.
|
|
79
|
+
- `updatePnp` applies a partial PNP update.
|
|
80
|
+
- `suspendAttempt` serializes a handoff state.
|
|
81
|
+
- `endAttempt` optionally validates responses and counts an attempt.
|
|
82
|
+
- `scoreAttempt` runs response processing without the adaptive submit guard.
|
|
83
|
+
- `submitAttempt` applies the adaptive attempt workflow.
|
|
84
|
+
- `newTemplate` reruns template processing for a new template instance.
|
|
261
85
|
|
|
262
|
-
|
|
86
|
+
Every successful dispatch increments `state().revision` and notifies subscribers with immutable
|
|
87
|
+
previous/current views. Response writes are rejected when the lifecycle is not writable. `dispose()`
|
|
88
|
+
is idempotent. The final `state()` view remains readable with `disposed: true`; later dispatch,
|
|
89
|
+
present, subscribe, and serialize calls are rejected.
|
|
263
90
|
|
|
264
|
-
|
|
91
|
+
## Presentation contract
|
|
265
92
|
|
|
266
|
-
|
|
267
|
-
interface Props {
|
|
268
|
-
items: Array<{ id: string; text: string }>;
|
|
269
|
-
orderedIds: string[];
|
|
270
|
-
orientation?: 'vertical' | 'horizontal';
|
|
271
|
-
disabled?: boolean;
|
|
272
|
-
onReorder: (newOrder: string[]) => void;
|
|
273
|
-
}
|
|
274
|
-
```
|
|
93
|
+
`session.present()` returns an immutable `ItemPresentation` instead of a `Player` adapter:
|
|
275
94
|
|
|
276
|
-
|
|
95
|
+
```ts
|
|
96
|
+
const presentation = session.present({
|
|
97
|
+
disabled: false,
|
|
98
|
+
renderItemBodyRubrics: true
|
|
99
|
+
});
|
|
277
100
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
targetSet: Array<{ identifier: string; text: string }>;
|
|
282
|
-
pairs: string[]; // "sourceId targetId"
|
|
283
|
-
disabled?: boolean;
|
|
284
|
-
onPairsChange: (newPairs: string[]) => void;
|
|
101
|
+
for (const node of presentation.flow) {
|
|
102
|
+
if (node.kind === 'html') renderFinalHtml(node.html);
|
|
103
|
+
else mountInteraction(node.mount);
|
|
285
104
|
}
|
|
286
|
-
```
|
|
287
105
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
```typescript
|
|
291
|
-
interface Props {
|
|
292
|
-
gapTexts: Array<{ identifier: string; text: string; matchMax: number }>;
|
|
293
|
-
hotspots: Array<{ identifier: string; shape: string; coords: string; matchMax: number }>;
|
|
294
|
-
pairs: string[]; // "gapTextId hotspotId"
|
|
295
|
-
imageData: { type: 'svg' | 'image'; content?: string; src?: string; width: string; height: string };
|
|
296
|
-
disabled?: boolean;
|
|
297
|
-
onPairsChange: (newPairs: string[]) => void;
|
|
298
|
-
}
|
|
106
|
+
renderRubrics(presentation.directRubrics);
|
|
299
107
|
```
|
|
300
108
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
109
|
+
The presentation contains role capabilities, disabled state, role-filtered correct responses,
|
|
110
|
+
policy-checked scoped CSS, ordered body flow, and direct `assessmentItem` rubric blocks. HTML values
|
|
111
|
+
use `HtmlContent` (`string | TrustedHTML` when available); `FinalItemBodyHtml` marks content that has
|
|
112
|
+
completed the body transform and delivery pipeline.
|
|
304
113
|
|
|
305
|
-
|
|
114
|
+
Section/test-part shared rubrics are not duplicated into item presentation. Assessment and section
|
|
115
|
+
hosts place those through section composition.
|
|
306
116
|
|
|
307
|
-
|
|
117
|
+
## Browser element
|
|
308
118
|
|
|
309
|
-
|
|
119
|
+
The all-in-one browser package registers `pie-qti-item-player`:
|
|
310
120
|
|
|
311
|
-
|
|
121
|
+
```ts
|
|
122
|
+
import '@pie-qti/player-elements/register';
|
|
312
123
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
itemXml: qtiXml, // With adaptive="true"
|
|
320
|
-
role: 'candidate'
|
|
124
|
+
const element = document.createElement('pie-qti-item-player');
|
|
125
|
+
element.itemXml = qtiXml;
|
|
126
|
+
element.role = 'candidate';
|
|
127
|
+
element.plugins = plugins;
|
|
128
|
+
element.addEventListener('response-change', (event) => {
|
|
129
|
+
console.log(event.detail.responses);
|
|
321
130
|
});
|
|
322
|
-
|
|
323
|
-
// Check if item is adaptive
|
|
324
|
-
if (player.isAdaptive()) {
|
|
325
|
-
// Submit first attempt
|
|
326
|
-
player.setResponses({ RESPONSE: 'A' });
|
|
327
|
-
const result = player.submitAttempt();
|
|
328
|
-
|
|
329
|
-
console.log(result.numAttempts); // 1
|
|
330
|
-
console.log(result.completionStatus); // 'unknown' or 'completed'
|
|
331
|
-
console.log(result.canContinue); // true (if not completed)
|
|
332
|
-
console.log(result.modalFeedback); // Progressive feedback/hints
|
|
333
|
-
|
|
334
|
-
// Continue submitting until completed
|
|
335
|
-
while (!player.isCompleted()) {
|
|
336
|
-
player.setResponses({ RESPONSE: nextGuess });
|
|
337
|
-
const nextResult = player.submitAttempt();
|
|
338
|
-
// Show feedback, allow retry
|
|
339
|
-
}
|
|
340
|
-
}
|
|
131
|
+
document.body.append(element);
|
|
341
132
|
```
|
|
342
133
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
Adaptive items can have hint buttons that don't increment the attempt counter:
|
|
134
|
+
An orchestrator may inject its exact live session instead of asking the element to create one:
|
|
346
135
|
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
title="Request Hint"
|
|
350
|
-
countAttempt="false"/>
|
|
136
|
+
```ts
|
|
137
|
+
element.session = session;
|
|
351
138
|
```
|
|
352
139
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
player.
|
|
356
|
-
const hint = player.submitAttempt(false); // Pass false for countAttempt
|
|
357
|
-
console.log(hint.numAttempts); // Unchanged
|
|
358
|
-
console.log(hint.modalFeedback); // Hint content
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
### Progressive Feedback Example
|
|
362
|
-
|
|
363
|
-
```xml
|
|
364
|
-
<assessmentItem identifier="adaptive-item" adaptive="true">
|
|
365
|
-
<!-- ... interactions ... -->
|
|
366
|
-
|
|
367
|
-
<responseProcessing>
|
|
368
|
-
<responseCondition>
|
|
369
|
-
<responseIf>
|
|
370
|
-
<!-- First attempt: encourage -->
|
|
371
|
-
<lt>
|
|
372
|
-
<variable identifier="numAttempts"/>
|
|
373
|
-
<baseValue baseType="integer">2</baseValue>
|
|
374
|
-
</lt>
|
|
375
|
-
<setOutcomeValue identifier="FEEDBACK">
|
|
376
|
-
<baseValue baseType="identifier">tryagain</baseValue>
|
|
377
|
-
</setOutcomeValue>
|
|
378
|
-
</responseIf>
|
|
379
|
-
<responseElse>
|
|
380
|
-
<!-- Second+ attempt: show answer -->
|
|
381
|
-
<setOutcomeValue identifier="FEEDBACK">
|
|
382
|
-
<baseValue baseType="identifier">answer</baseValue>
|
|
383
|
-
</setOutcomeValue>
|
|
384
|
-
<setOutcomeValue identifier="completionStatus">
|
|
385
|
-
<baseValue baseType="identifier">completed</baseValue>
|
|
386
|
-
</setOutcomeValue>
|
|
387
|
-
</responseElse>
|
|
388
|
-
</responseCondition>
|
|
389
|
-
</responseProcessing>
|
|
390
|
-
|
|
391
|
-
<modalFeedback outcomeIdentifier="FEEDBACK" identifier="tryagain" showHide="show">
|
|
392
|
-
<p>Try again! You have one more attempt.</p>
|
|
393
|
-
</modalFeedback>
|
|
394
|
-
|
|
395
|
-
<modalFeedback outcomeIdentifier="FEEDBACK" identifier="answer" showHide="show">
|
|
396
|
-
<p>The correct answer is C. Here's why...</p>
|
|
397
|
-
</modalFeedback>
|
|
398
|
-
</assessmentItem>
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
### API Methods
|
|
402
|
-
|
|
403
|
-
| Method | Description |
|
|
404
|
-
| ---------------------------------------------------------------- | ----------------------------------------- |
|
|
405
|
-
| `isAdaptive(): boolean` | Check if item has `adaptive="true"` |
|
|
406
|
-
| `isCompleted(): boolean` | Check if `completionStatus="completed"` |
|
|
407
|
-
| `getNumAttempts(): number` | Get current attempt count |
|
|
408
|
-
| `submitAttempt(countAttempt?: boolean): AdaptiveAttemptResult` | Submit attempt with optional counting |
|
|
409
|
-
|
|
410
|
-
For complete documentation, see [ADAPTIVE-ITEMS-DESIGN.md](ADAPTIVE-ITEMS-DESIGN.md).
|
|
411
|
-
|
|
412
|
-
## Accessibility
|
|
413
|
-
|
|
414
|
-
All components follow WCAG 2.2 Level AA guidelines:
|
|
415
|
-
|
|
416
|
-
- ✅ **Full keyboard navigation** (Tab, Space, Enter, Arrow keys, Escape)
|
|
417
|
-
- ✅ **Screen reader support** with ARIA labels and live regions
|
|
418
|
-
- ✅ **Focus management** with visible indicators
|
|
419
|
-
- ✅ **Alternative to drag-and-drop** for all interactions
|
|
420
|
-
|
|
421
|
-
### Keyboard Shortcuts
|
|
422
|
-
|
|
423
|
-
| Component | Keys | Action |
|
|
424
|
-
|-----------|------|--------|
|
|
425
|
-
| SortableList | Space/Enter | Grab/drop item |
|
|
426
|
-
| | Arrow keys | Move grabbed item |
|
|
427
|
-
| | Escape | Cancel |
|
|
428
|
-
| MatchDragDrop | Space/Enter | Select source |
|
|
429
|
-
| | Tab → Space/Enter | Match to target |
|
|
430
|
-
| GraphicGapMatch | Space/Enter | Select label |
|
|
431
|
-
| | Tab → Space/Enter | Place on hotspot |
|
|
432
|
-
|
|
433
|
-
For detailed accessibility analysis, see [WCAG-2.2-COMPLIANCE.md](docs/WCAG-2.2-COMPLIANCE.md).
|
|
140
|
+
`session`, `plugins`, security, PNP, PCI, i18n, processing-fragment resolvers, and response maps are
|
|
141
|
+
JavaScript properties rather than HTML attributes. See
|
|
142
|
+
[`@pie-qti/player-elements`](../player-elements/README.md) for the full element contract.
|
|
434
143
|
|
|
435
|
-
|
|
144
|
+
The older standalone registration entry remains available when a host intentionally composes the
|
|
145
|
+
interaction implementations itself:
|
|
436
146
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
// Check if backend scoring is available
|
|
441
|
-
if (player.getItemAttribute('adaptive') === 'true') {
|
|
442
|
-
// Send to backend for scoring
|
|
443
|
-
const response = await fetch('/api/score', {
|
|
444
|
-
method: 'POST',
|
|
445
|
-
body: JSON.stringify({
|
|
446
|
-
itemId: 'item-123',
|
|
447
|
-
responses: player.getAllResponses()
|
|
448
|
-
})
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
const result = await response.json();
|
|
452
|
-
// Apply backend scores
|
|
453
|
-
player.applyOutcomes(result.outcomes);
|
|
454
|
-
}
|
|
147
|
+
```ts
|
|
148
|
+
import '@pie-qti/default-components/plugins';
|
|
149
|
+
import '@pie-qti/item-player/element';
|
|
455
150
|
```
|
|
456
151
|
|
|
457
|
-
|
|
152
|
+
## Definition plugins
|
|
458
153
|
|
|
459
|
-
|
|
154
|
+
`AssessmentItemDefinitionPlugin` is the primary synchronous extension contract:
|
|
460
155
|
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
bun install
|
|
156
|
+
```ts
|
|
157
|
+
import type { AssessmentItemDefinitionPlugin } from '@pie-qti/item-player';
|
|
464
158
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
159
|
+
export const plugin: AssessmentItemDefinitionPlugin = {
|
|
160
|
+
kind: 'assessment-item-definition-plugin',
|
|
161
|
+
name: '@vendor/interactions',
|
|
162
|
+
version: '1.0.0',
|
|
163
|
+
registerExtractors(registry) {
|
|
164
|
+
registry.register(vendorExtractor);
|
|
165
|
+
},
|
|
166
|
+
registerComponents(registry) {
|
|
167
|
+
registry.register('vendorInteraction', {
|
|
168
|
+
name: 'vendor-interaction',
|
|
169
|
+
tagName: 'vendor-qti-interaction'
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
476
173
|
```
|
|
477
174
|
|
|
478
|
-
|
|
175
|
+
Definition creation registers standard modules and plugins, then seals the registries before a
|
|
176
|
+
session opens. Plugin extractors declare renderer identity with `outputType` and declare all HTML and
|
|
177
|
+
resource URL fields with a `delivery` schema. See
|
|
178
|
+
[Custom extractors](./docs/custom-extractors.md).
|
|
179
|
+
|
|
180
|
+
## Security boundary
|
|
479
181
|
|
|
480
|
-
|
|
182
|
+
The player applies configured HTML sanitation, URL policy, parsing limits, and optional Trusted
|
|
183
|
+
Types finalization to declared delivery fields. Plugins are trusted executable application code and
|
|
184
|
+
are not sandboxed. Sanitized same-DOM content is still not equivalent to isolating untrusted
|
|
185
|
+
JavaScript; use a suitably sandboxed cross-origin iframe when content is not trusted to run in the
|
|
186
|
+
host origin.
|
|
481
187
|
|
|
482
|
-
|
|
188
|
+
Portable Custom Interaction execution is disabled unless the host supplies a trusted
|
|
189
|
+
`pci.moduleResolver`. Authored module paths are never imported directly by default.
|
|
483
190
|
|
|
484
|
-
|
|
485
|
-
- [@pie-qti/player-elements](../player-elements) - Web components
|
|
486
|
-
- [@pie-qti/app-demo](../../apps/demo) - Demo application
|
|
487
|
-
- [@pie-qti/to-pie](../to-pie) - QTI to PIE transformer
|
|
191
|
+
## Server scoring
|
|
488
192
|
|
|
489
|
-
|
|
193
|
+
`@pie-qti/item-player/server` exports a DOM-free definition/session interface with the same ownership
|
|
194
|
+
model. It omits presentation, PNP DOM, PCI, catalogs, and browser component types. See the
|
|
195
|
+
[server scoring guide](./docs/server-api.md).
|
|
490
196
|
|
|
491
|
-
|
|
197
|
+
## Public entries
|
|
492
198
|
|
|
493
|
-
|
|
199
|
+
- `@pie-qti/item-player`: definitions, sessions, presentation/extraction/plugin contracts, security
|
|
200
|
+
types, PNP/catalog/PCI helpers.
|
|
201
|
+
- `@pie-qti/item-player/server`: DOM-free definitions, sessions, scoring commands, and persistence.
|
|
202
|
+
- `@pie-qti/item-player/web-components`: interaction element base contracts.
|
|
203
|
+
- `@pie-qti/item-player/element` and `/element-class`: standalone browser element compatibility.
|
|
204
|
+
- `@pie-qti/item-player/iframe`: optional iframe host/protocol helpers.
|
|
205
|
+
- `@pie-qti/item-player/security`: security utilities.
|
|
494
206
|
|
|
495
|
-
|
|
496
|
-
- [
|
|
497
|
-
- [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
|
|
498
|
-
- [PIE Framework](https://github.com/pie-framework)
|
|
207
|
+
Additional detail: [QTI compliance](./docs/QTI-COMPLIANCE.md),
|
|
208
|
+
[server scoring](./docs/server-api.md), and [iframe mode](./docs/iframe-mode.md).
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PnpProfile } from '../pnp/types.js';
|
|
2
|
+
import type { HtmlContent } from '../types/index.js';
|
|
2
3
|
interface CatalogComponentRegistry {
|
|
3
4
|
getTagNameForType(type: string): string | null;
|
|
4
5
|
}
|
|
@@ -6,7 +7,7 @@ export interface GlossaryPlayer {
|
|
|
6
7
|
getPnp(): PnpProfile | undefined;
|
|
7
8
|
getCatalogEntry(idref: string, usage: string, lang?: string, options?: {
|
|
8
9
|
stimulusIdentifier?: string;
|
|
9
|
-
}):
|
|
10
|
+
}): HtmlContent | null;
|
|
10
11
|
getComponentRegistry(): CatalogComponentRegistry;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { htmlToString } from '../core/trustedTypes.js';
|
|
1
2
|
const PLATFORM_USAGES = [
|
|
2
3
|
{ usage: 'tts-pronunciation', flag: 'ttsPronunciation', label: 'Request pronunciation', text: 'P' },
|
|
3
4
|
{ usage: 'signing-definition', flag: 'signingDefinition', label: 'Request signing definition', text: 'S' },
|
|
@@ -261,10 +262,11 @@ function buildFallbackPopup(label, html, close) {
|
|
|
261
262
|
header.appendChild(closeBtn);
|
|
262
263
|
const body = document.createElement('div');
|
|
263
264
|
body.className = 'card-body p-3';
|
|
264
|
-
const
|
|
265
|
+
const htmlString = htmlToString(html);
|
|
266
|
+
const isUrl = /^(https?:\/\/|\/)/i.test(htmlString.trim());
|
|
265
267
|
if (isUrl) {
|
|
266
268
|
const img = document.createElement('img');
|
|
267
|
-
img.src =
|
|
269
|
+
img.src = htmlString.trim();
|
|
268
270
|
img.alt = label;
|
|
269
271
|
img.className = 'max-w-full h-auto block mx-auto';
|
|
270
272
|
body.appendChild(img);
|