@pie-qti/item-player 0.1.4 → 0.1.5

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.
Files changed (148) hide show
  1. package/README.md +21 -18
  2. package/dist/catalog/applyGlossaryTriggers.d.ts +15 -0
  3. package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -0
  4. package/dist/catalog/applyGlossaryTriggers.js +193 -0
  5. package/dist/catalog/catalogExtractor.d.ts +18 -0
  6. package/dist/catalog/catalogExtractor.d.ts.map +1 -0
  7. package/dist/catalog/catalogExtractor.js +114 -0
  8. package/dist/catalog/catalogLookup.d.ts +18 -0
  9. package/dist/catalog/catalogLookup.d.ts.map +1 -0
  10. package/dist/catalog/catalogLookup.js +44 -0
  11. package/dist/catalog/glossaryAction.d.ts +17 -0
  12. package/dist/catalog/glossaryAction.d.ts.map +1 -0
  13. package/dist/catalog/glossaryAction.js +21 -0
  14. package/dist/catalog/types.d.ts +26 -0
  15. package/dist/catalog/types.d.ts.map +1 -0
  16. package/dist/catalog/types.js +6 -0
  17. package/dist/core/ComponentRegistry.d.ts +9 -0
  18. package/dist/core/ComponentRegistry.d.ts.map +1 -1
  19. package/dist/core/ComponentRegistry.js +14 -0
  20. package/dist/core/ItemRenderer.d.ts.map +1 -1
  21. package/dist/core/ItemRenderer.js +3 -0
  22. package/dist/core/Player.d.ts +52 -0
  23. package/dist/core/Player.d.ts.map +1 -1
  24. package/dist/core/Player.js +158 -4
  25. package/dist/core/rolePolicy.d.ts +16 -0
  26. package/dist/core/rolePolicy.d.ts.map +1 -0
  27. package/dist/core/rolePolicy.js +15 -0
  28. package/dist/core/urlPolicy.d.ts.map +1 -1
  29. package/dist/core/urlPolicy.js +5 -2
  30. package/dist/element.d.ts +22 -0
  31. package/dist/element.js +5327 -0
  32. package/dist/element.js.map +1 -0
  33. package/dist/extraction/ExtractionRegistry.d.ts.map +1 -1
  34. package/dist/extraction/ExtractionRegistry.js +3 -1
  35. package/dist/extraction/extractors/associateExtractor.d.ts +1 -0
  36. package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
  37. package/dist/extraction/extractors/associateExtractor.js +3 -0
  38. package/dist/extraction/extractors/choiceExtractor.d.ts +2 -0
  39. package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
  40. package/dist/extraction/extractors/choiceExtractor.js +10 -0
  41. package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
  42. package/dist/extraction/extractors/extendedTextExtractor.js +6 -0
  43. package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -0
  44. package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
  45. package/dist/extraction/extractors/gapMatchExtractor.js +33 -20
  46. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -0
  47. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
  48. package/dist/extraction/extractors/graphicAssociateExtractor.js +3 -0
  49. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +11 -0
  50. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
  51. package/dist/extraction/extractors/graphicGapMatchExtractor.js +71 -10
  52. package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
  53. package/dist/extraction/extractors/hotspotExtractor.js +27 -8
  54. package/dist/extraction/extractors/hottextExtractor.d.ts +1 -1
  55. package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
  56. package/dist/extraction/extractors/hottextExtractor.js +12 -4
  57. package/dist/extraction/extractors/index.d.ts +1 -0
  58. package/dist/extraction/extractors/index.d.ts.map +1 -1
  59. package/dist/extraction/extractors/index.js +4 -0
  60. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +3 -0
  61. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
  62. package/dist/extraction/extractors/inlineChoiceExtractor.js +17 -4
  63. package/dist/extraction/extractors/matchExtractor.d.ts +5 -0
  64. package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
  65. package/dist/extraction/extractors/matchExtractor.js +26 -0
  66. package/dist/extraction/extractors/orderExtractor.d.ts +2 -0
  67. package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
  68. package/dist/extraction/extractors/orderExtractor.js +4 -0
  69. package/dist/extraction/extractors/portableCustomExtractor.d.ts +14 -0
  70. package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -0
  71. package/dist/extraction/extractors/portableCustomExtractor.js +96 -0
  72. package/dist/extraction/extractors/selectPointExtractor.js +5 -5
  73. package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -0
  74. package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
  75. package/dist/extraction/extractors/textEntryExtractor.js +6 -0
  76. package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
  77. package/dist/extraction/extractors/uploadExtractor.js +9 -2
  78. package/dist/index.d.ts +11 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +8 -1
  81. package/dist/pci/PciHost.d.ts +53 -0
  82. package/dist/pci/PciHost.d.ts.map +1 -0
  83. package/dist/pci/PciHost.js +116 -0
  84. package/dist/pci/types.d.ts +57 -0
  85. package/dist/pci/types.d.ts.map +1 -0
  86. package/dist/pci/types.js +19 -0
  87. package/dist/pnp/applyPnp.d.ts +9 -0
  88. package/dist/pnp/applyPnp.d.ts.map +1 -0
  89. package/dist/pnp/applyPnp.js +19 -0
  90. package/dist/pnp/parsePnpXml.d.ts +9 -0
  91. package/dist/pnp/parsePnpXml.d.ts.map +1 -0
  92. package/dist/pnp/parsePnpXml.js +101 -0
  93. package/dist/pnp/types.d.ts +40 -0
  94. package/dist/pnp/types.d.ts.map +1 -0
  95. package/dist/pnp/types.js +1 -0
  96. package/dist/types/index.d.ts +22 -8
  97. package/dist/types/index.d.ts.map +1 -1
  98. package/dist/types/interactions.d.ts +90 -1
  99. package/dist/types/interactions.d.ts.map +1 -1
  100. package/package.json +19 -9
  101. package/src/__tests__/catalog.test.ts +267 -0
  102. package/src/__tests__/fixtures/pci/echo-pci.js +49 -0
  103. package/src/__tests__/glossaryTriggers.test.ts +411 -0
  104. package/src/__tests__/pci.test.ts +353 -0
  105. package/src/__tests__/pnp.test.ts +250 -0
  106. package/src/__tests__/qti3-extraction.test.ts +5 -5
  107. package/src/catalog/applyGlossaryTriggers.ts +232 -0
  108. package/src/catalog/catalogExtractor.ts +130 -0
  109. package/src/catalog/catalogLookup.ts +53 -0
  110. package/src/catalog/glossaryAction.ts +28 -0
  111. package/src/catalog/types.ts +37 -0
  112. package/src/components/ItemBody.svelte +134 -26
  113. package/src/components/ItemPlayer.svelte +6 -2
  114. package/src/components/index.ts +3 -0
  115. package/src/core/ComponentRegistry.ts +14 -0
  116. package/src/core/ItemRenderer.ts +4 -0
  117. package/src/core/Player.ts +174 -4
  118. package/src/core/rolePolicy.ts +34 -0
  119. package/src/core/urlPolicy.ts +5 -2
  120. package/src/element.ts +128 -0
  121. package/src/extraction/ExtractionRegistry.ts +5 -1
  122. package/src/extraction/extractors/associateExtractor.ts +4 -0
  123. package/src/extraction/extractors/choiceExtractor.ts +12 -1
  124. package/src/extraction/extractors/conformance-qti3-advanced.test.ts +239 -0
  125. package/src/extraction/extractors/conformance-qti3-basic.test.ts +82 -0
  126. package/src/extraction/extractors/conformance.test.ts +208 -0
  127. package/src/extraction/extractors/extendedTextExtractor.ts +6 -0
  128. package/src/extraction/extractors/gapMatchExtractor.ts +36 -21
  129. package/src/extraction/extractors/graphicAssociateExtractor.ts +4 -0
  130. package/src/extraction/extractors/graphicGapMatchExtractor.ts +82 -10
  131. package/src/extraction/extractors/hotspotExtractor.ts +26 -8
  132. package/src/extraction/extractors/hottextExtractor.ts +15 -5
  133. package/src/extraction/extractors/index.ts +4 -0
  134. package/src/extraction/extractors/inlineChoiceExtractor.ts +22 -5
  135. package/src/extraction/extractors/matchExtractor.ts +31 -4
  136. package/src/extraction/extractors/orderExtractor.ts +6 -0
  137. package/src/extraction/extractors/portableCustomExtractor.ts +122 -0
  138. package/src/extraction/extractors/selectPointExtractor.ts +5 -5
  139. package/src/extraction/extractors/textEntryExtractor.ts +7 -0
  140. package/src/extraction/extractors/uploadExtractor.ts +10 -2
  141. package/src/index.ts +17 -1
  142. package/src/pci/PciHost.ts +138 -0
  143. package/src/pci/types.ts +70 -0
  144. package/src/pnp/applyPnp.ts +23 -0
  145. package/src/pnp/parsePnpXml.ts +118 -0
  146. package/src/pnp/types.ts +33 -0
  147. package/src/types/index.ts +22 -8
  148. package/src/types/interactions.ts +81 -6
@@ -1 +1 @@
1
- {"version":3,"file":"ItemRenderer.d.ts","sourceRoot":"","sources":["../../src/core/ItemRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IAEf,oDAAoD;IACpD,SAAS,EAAE,WAAW,CAAC;IAEvB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,yEAAyE;IACzE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAEzC,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5D;AAED;;GAEG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAC,CAAiC;IACjD,OAAO,CAAC,gBAAgB,CAA2C;IAGnE,OAAO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GlossaryTriggers } from '../catalog/applyGlossaryTriggers.js';
9
10
  /**
10
11
  * ItemRenderer class manages the rendering of QTI items using web components
11
12
  */
@@ -47,6 +48,8 @@ export class ItemRenderer {
47
48
  // Process inline interactions in HTML
48
49
  const processedHtml = this.processInlineInteractions(itemBodyHtml, interactions);
49
50
  proseContainer.innerHTML = toTrustedHtml(processedHtml, this.player.getTrustedTypesPolicyName());
51
+ // Inject glossary/keyword-translation trigger buttons for [data-catalog-idref] terms
52
+ applyGlossaryTriggers(proseContainer, this.player);
50
53
  wrapper.appendChild(proseContainer);
51
54
  // Render block interactions as web components
52
55
  for (const interaction of blockInteractions) {
@@ -4,6 +4,9 @@ import type { AdaptiveAttemptResult, CompletionStatus, HtmlContent, ItemSessionS
4
4
  import type { InteractionData } from '../types/interactions.js';
5
5
  import type { ResponseValidationResult } from '../types/responseValidation.js';
6
6
  import type { ComponentRegistry } from './ComponentRegistry.js';
7
+ import type { PnpProfile } from '../pnp/types.js';
8
+ import { PciHost } from '../pci/PciHost.js';
9
+ import type { ExtractedPci } from '../pci/types.js';
7
10
  export declare class Player {
8
11
  private role;
9
12
  private config;
@@ -21,10 +24,59 @@ export declare class Player {
21
24
  private responseProcessingProgram;
22
25
  private templateProcessingProgram;
23
26
  private outcomeProcessingProgram;
27
+ private _pnp;
28
+ private _rootEl;
29
+ private _catalogIndex;
30
+ private _pciHosts;
24
31
  constructor(config: PlayerConfig);
32
+ /**
33
+ * Apply the PNP profile to a player root element.
34
+ * Call this once the root DOM element is available (e.g. after mounting).
35
+ * The player stores the element reference so updatePnp() can re-apply without re-parsing the item.
36
+ */
37
+ applyPnp(rootEl: HTMLElement): void;
38
+ /**
39
+ * Update the PNP profile mid-session without re-parsing the item XML.
40
+ * Deep-merges the partial profile into the current profile and re-applies.
41
+ */
42
+ updatePnp(partial: Partial<PnpProfile>): void;
43
+ /** Return the current resolved PNP profile. */
44
+ getPnp(): PnpProfile | undefined;
45
+ /**
46
+ * Look up a catalog entry by card identifier, usage type, and optional language.
47
+ * Returns the HTML string for the matched entry, or null if not found.
48
+ *
49
+ * Language fallback: exact match → prefix match → no-lang entry → null.
50
+ */
51
+ getCatalogEntry(idref: string, usage: string, lang?: string): string | null;
52
+ /**
53
+ * Create a PciHost for an extracted PCI and register it for response tracking.
54
+ * The caller (typically ItemRenderer) is responsible for calling host.load() and
55
+ * host.initialize(domNode) once the DOM element is available.
56
+ */
57
+ createPciHost(data: ExtractedPci): PciHost;
58
+ /**
59
+ * Push a response value into the PCI identified by responseIdentifier.
60
+ * Called from setResponses() so session restore reaches PCI modules.
61
+ */
62
+ setPciResponse(responseIdentifier: string, value: unknown): void;
63
+ /**
64
+ * Disable/enable all PCI hosts based on role.
65
+ * 'candidate' = enabled; any other role = disabled.
66
+ */
67
+ syncPciDisabledState(): void;
68
+ /**
69
+ * Destroy all PCI hosts. Call on player teardown.
70
+ */
71
+ destroyPciHosts(): void;
25
72
  /** Breaking-change API: returns the typed declaration map */
26
73
  getDeclarations(): DeclarationMap;
27
74
  setResponses(responses: Record<string, unknown>): void;
75
+ /**
76
+ * Destroy all resources owned by this player instance (PCI modules, etc.).
77
+ * Call when unmounting to prevent memory leaks.
78
+ */
79
+ destroy(): void;
28
80
  processResponses(): ScoringResult;
29
81
  getSecurityConfig(): PlayerSecurityConfig | undefined;
30
82
  getTrustedTypesPolicyName(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../../src/core/Player.ts"],"names":[],"mappings":"AAAA,OAAO,EAWN,KAAK,cAAc,EAiBnB,MAAM,yBAAyB,CAAC;AAUjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAI9E,OAAO,KAAK,EACX,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAEhB,YAAY,EACZ,oBAAoB,EAEpB,WAAW,EACX,aAAa,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAc,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IAQzB,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"}
@@ -9,11 +9,17 @@ import { createSeededRng } from './random.js';
9
9
  import { sanitizeHtml } from './sanitizer.js';
10
10
  import { toTrustedHtml } from './trustedTypes.js';
11
11
  import { sanitizeResourceUrl } from './urlPolicy.js';
12
+ import { applyPnpToRoot } from '../pnp/applyPnp.js';
13
+ import { extractCatalogFromItemXml, mergeCatalogs } from '../catalog/catalogExtractor.js';
14
+ import { getCatalogEntry } from '../catalog/catalogLookup.js';
15
+ import { PciHost } from '../pci/PciHost.js';
12
16
  export class Player {
13
17
  constructor(config) {
14
18
  this.responseProcessingProgram = null;
15
19
  this.templateProcessingProgram = null;
16
20
  this.outcomeProcessingProgram = null;
21
+ this._catalogIndex = new Map();
22
+ this._pciHosts = new Map();
17
23
  this.config = config;
18
24
  this.itemXml = config.itemXml ?? '';
19
25
  this.role = config.role ?? 'candidate';
@@ -113,11 +119,102 @@ export class Player {
113
119
  else if (detectedVersion === '2.1') {
114
120
  console.info('[QTI Player] QTI 2.1 detected. Using QTI 2.2 compatibility mode with CC2 template support.');
115
121
  }
122
+ // Store PNP profile for later use (applyPnpToRoot is called once a root element is available).
123
+ this._pnp = config.pnp;
124
+ // Build catalog index from item XML and optional shared catalog.
125
+ const itemCatalog = extractCatalogFromItemXml(this.itemXml);
126
+ if (config.catalogXml) {
127
+ const sharedCatalog = extractCatalogFromItemXml(config.catalogXml);
128
+ // Item-level wins on collision: merge shared first, then override with item entries.
129
+ this._catalogIndex = mergeCatalogs(sharedCatalog, itemCatalog);
130
+ }
131
+ else {
132
+ this._catalogIndex = itemCatalog;
133
+ }
116
134
  // Check strict compliance if enabled
117
135
  if (this.config.strictQtiCompliance?.enabled) {
118
136
  this.validateStrictCompliance();
119
137
  }
120
138
  }
139
+ /**
140
+ * Apply the PNP profile to a player root element.
141
+ * Call this once the root DOM element is available (e.g. after mounting).
142
+ * The player stores the element reference so updatePnp() can re-apply without re-parsing the item.
143
+ */
144
+ applyPnp(rootEl) {
145
+ this._rootEl = rootEl;
146
+ applyPnpToRoot(rootEl, this._pnp);
147
+ }
148
+ /**
149
+ * Update the PNP profile mid-session without re-parsing the item XML.
150
+ * Deep-merges the partial profile into the current profile and re-applies.
151
+ */
152
+ updatePnp(partial) {
153
+ this._pnp = mergePnp(this._pnp, partial);
154
+ if (this._rootEl) {
155
+ applyPnpToRoot(this._rootEl, this._pnp);
156
+ }
157
+ }
158
+ /** Return the current resolved PNP profile. */
159
+ getPnp() {
160
+ return this._pnp;
161
+ }
162
+ /**
163
+ * Look up a catalog entry by card identifier, usage type, and optional language.
164
+ * Returns the HTML string for the matched entry, or null if not found.
165
+ *
166
+ * Language fallback: exact match → prefix match → no-lang entry → null.
167
+ */
168
+ getCatalogEntry(idref, usage, lang) {
169
+ return getCatalogEntry(this._catalogIndex, idref, usage, lang);
170
+ }
171
+ /**
172
+ * Create a PciHost for an extracted PCI and register it for response tracking.
173
+ * The caller (typically ItemRenderer) is responsible for calling host.load() and
174
+ * host.initialize(domNode) once the DOM element is available.
175
+ */
176
+ createPciHost(data) {
177
+ const baseUrl = this.config.pciBaseUrl ?? (typeof document !== 'undefined' ? document.baseURI : '');
178
+ const host = new PciHost(data, baseUrl);
179
+ // Wire response changes back into the player's declaration context
180
+ host.onResponseChange((responseId, value) => {
181
+ const d = this.decls[responseId];
182
+ if (d) {
183
+ d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, value);
184
+ }
185
+ });
186
+ this._pciHosts.set(data.responseIdentifier, host);
187
+ return host;
188
+ }
189
+ /**
190
+ * Push a response value into the PCI identified by responseIdentifier.
191
+ * Called from setResponses() so session restore reaches PCI modules.
192
+ */
193
+ setPciResponse(responseIdentifier, value) {
194
+ this._pciHosts.get(responseIdentifier)?.setResponse(value);
195
+ }
196
+ /**
197
+ * Disable/enable all PCI hosts based on role.
198
+ * 'candidate' = enabled; any other role = disabled.
199
+ */
200
+ syncPciDisabledState() {
201
+ const disabled = this.role !== 'candidate';
202
+ for (const host of this._pciHosts.values()) {
203
+ if (disabled)
204
+ host.disable();
205
+ else
206
+ host.enable();
207
+ }
208
+ }
209
+ /**
210
+ * Destroy all PCI hosts. Call on player teardown.
211
+ */
212
+ destroyPciHosts() {
213
+ for (const host of this._pciHosts.values()) {
214
+ host.destroy();
215
+ }
216
+ this._pciHosts.clear();
217
+ }
121
218
  /** Breaking-change API: returns the typed declaration map */
122
219
  getDeclarations() {
123
220
  return this.decls;
@@ -128,8 +225,17 @@ export class Player {
128
225
  if (!d)
129
226
  continue;
130
227
  d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, raw);
228
+ // Push restored responses into any mounted PCI modules
229
+ this.setPciResponse(id, raw);
131
230
  }
132
231
  }
232
+ /**
233
+ * Destroy all resources owned by this player instance (PCI modules, etc.).
234
+ * Call when unmounting to prevent memory leaks.
235
+ */
236
+ destroy() {
237
+ this.destroyPciHosts();
238
+ }
133
239
  processResponses() {
134
240
  // Spec-aligned behavior: each processing run starts from outcome defaults.
135
241
  // This prevents stale outcomes when response/outcome processing doesn't set every variable.
@@ -382,8 +488,15 @@ export class Player {
382
488
  const res = this.extractionRegistry.extract(el, ctx);
383
489
  if (!res.success)
384
490
  continue;
491
+ // Normalize raw tag to QTI 2.x camelCase for ComponentRegistry compatibility.
492
+ // QTI 3.0 elements use kebab-case with 'qti-' prefix:
493
+ // 'qti-choice-interaction' → 'choiceInteraction'
494
+ const rawTag = el.rawTagName;
495
+ const normalizedType = rawTag.startsWith('qti-')
496
+ ? rawTag.slice(4).replace(/-([a-z])/g, (_, c) => c.toUpperCase())
497
+ : rawTag;
385
498
  interactions.push({
386
- type: el.rawTagName,
499
+ type: normalizedType,
387
500
  responseId,
388
501
  ...res.data,
389
502
  });
@@ -576,10 +689,41 @@ export class Player {
576
689
  complete = Number(value || 0) >= minPlays;
577
690
  }
578
691
  else if (required) {
579
- if (Array.isArray(value))
692
+ if (Array.isArray(value)) {
580
693
  complete = value.length > 0;
581
- else
694
+ // Enforce minChoices / minAssociations where applicable
695
+ const minChoices = Number(i.minChoices || i.minAssociations || 0);
696
+ if (complete && minChoices > 0) {
697
+ complete = value.length >= minChoices;
698
+ }
699
+ // Enforce matchMin per-choice: each pairing entry "id1 id2" in value must
700
+ // appear at least matchMin times for the relevant choice.
701
+ // Collect all choice arrays that can carry matchMin across all pairing interaction types.
702
+ const choices = [
703
+ ...(i.choices ?? []),
704
+ ...(i.gapTexts ?? []),
705
+ ...(i.gapImages ?? []),
706
+ ...(i.sourceSet ?? []),
707
+ ...(i.targetSet ?? []),
708
+ ...(i.associableHotspots ?? []),
709
+ ];
710
+ for (const choice of choices) {
711
+ const min = Number(choice.matchMin || 0);
712
+ if (min > 0) {
713
+ const count = value.filter((p) => {
714
+ const parts = p.split(' ');
715
+ return parts[0] === choice.identifier || parts[1] === choice.identifier;
716
+ }).length;
717
+ if (count < min) {
718
+ complete = false;
719
+ break;
720
+ }
721
+ }
722
+ }
723
+ }
724
+ else {
582
725
  complete = value !== null && value !== undefined && value !== '';
726
+ }
583
727
  }
584
728
  const errors = [];
585
729
  const warnings = [];
@@ -686,7 +830,7 @@ export class Player {
686
830
  }, this.outcomeProcessingProgram);
687
831
  }
688
832
  execResponseProcessingTemplate(templateUrl) {
689
- const name = templateUrl.split('/').pop()?.toLowerCase();
833
+ const name = templateUrl.split('/').pop()?.toLowerCase().replace(/\.xml$/, '');
690
834
  if (!name) {
691
835
  console.warn(`[QTI Player] Could not extract template name from URL: ${templateUrl}`);
692
836
  return;
@@ -1079,3 +1223,13 @@ export class Player {
1079
1223
  return active;
1080
1224
  }
1081
1225
  }
1226
+ // ---------------------------------------------------------------------------
1227
+ // Module-level helpers
1228
+ // ---------------------------------------------------------------------------
1229
+ function mergePnp(base, partial) {
1230
+ return {
1231
+ display: { ...(base?.display ?? {}), ...(partial.display ?? {}) },
1232
+ content: { ...(base?.content ?? {}), ...(partial.content ?? {}) },
1233
+ cognitive: { ...(base?.cognitive ?? {}), ...(partial.cognitive ?? {}) },
1234
+ };
1235
+ }
@@ -0,0 +1,16 @@
1
+ import type { QTIRole } from '../types/index.js';
2
+ /**
3
+ * Product policy layered on top of QTI role/view semantics.
4
+ *
5
+ * QTI defines these roles as audience markers for view-controlled content
6
+ * (for example rubric/outcome visibility). It does not define a universal
7
+ * interaction UI behavior matrix. The player policy below keeps runtime
8
+ * behavior explicit and consistent across integrations.
9
+ */
10
+ export interface RoleCapabilities {
11
+ isCandidate: boolean;
12
+ isReadOnly: boolean;
13
+ canViewCorrectResponses: boolean;
14
+ }
15
+ export declare function getRoleCapabilities(role: QTIRole): RoleCapabilities;
16
+ //# sourceMappingURL=rolePolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rolePolicy.d.ts","sourceRoot":"","sources":["../../src/core/rolePolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,uBAAuB,EAAE,OAAO,CAAC;CACjC;AASD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CASnE"}
@@ -0,0 +1,15 @@
1
+ const ROLES_WITH_CORRECT_RESPONSE_ACCESS = new Set([
2
+ 'scorer',
3
+ 'author',
4
+ 'tutor',
5
+ 'testConstructor',
6
+ ]);
7
+ export function getRoleCapabilities(role) {
8
+ const isCandidate = role === 'candidate';
9
+ const canViewCorrectResponses = ROLES_WITH_CORRECT_RESPONSE_ACCESS.has(role);
10
+ return {
11
+ isCandidate,
12
+ isReadOnly: !isCandidate,
13
+ canViewCorrectResponses,
14
+ };
15
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"urlPolicy.d.ts","sourceRoot":"","sources":["../../src/core/urlPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AA0ClE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,EAAE,IAAI,GAAE,OAAe,GAAG,MAAM,GAAG,IAAI,CA4C/G"}
1
+ {"version":3,"file":"urlPolicy.d.ts","sourceRoot":"","sources":["../../src/core/urlPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AA0ClE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,EAAE,IAAI,GAAE,OAAe,GAAG,MAAM,GAAG,IAAI,CA+C/G"}
@@ -53,7 +53,9 @@ export function sanitizeResourceUrl(raw, policy, kind = 'any') {
53
53
  if (s.startsWith('//'))
54
54
  return p.allowProtocolRelative ? `https:${s}` : null;
55
55
  // Relative/absolute-path URLs: allow and optionally resolve.
56
- if (s.startsWith('/') || s.startsWith('./') || s.startsWith('../')) {
56
+ // Bare relative paths (e.g. "images/foo.png" from IMS CP manifests) are treated
57
+ // the same as "./" paths — they have no scheme and are safe to pass through.
58
+ if (s.startsWith('/') || s.startsWith('./') || s.startsWith('../') || !/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(s)) {
57
59
  if (p.assetBaseUrl) {
58
60
  try {
59
61
  // Strip leading '/' to make URL constructor resolve relative to base path, not origin
@@ -61,7 +63,8 @@ export function sanitizeResourceUrl(raw, policy, kind = 'any') {
61
63
  return new URL(relativePath, p.assetBaseUrl).toString();
62
64
  }
63
65
  catch {
64
- return null;
66
+ // assetBaseUrl resolution failed; return the raw relative path as-is
67
+ return s;
65
68
  }
66
69
  }
67
70
  return s;
@@ -0,0 +1,22 @@
1
+ import { AdaptiveAttemptResult, PlayerSecurityConfig } from './types/index.js';
2
+ import { I18nProvider } from '@pie-qti/i18n';
3
+ declare class PieQtiItemPlayerElement extends HTMLElement {
4
+ #private;
5
+ static observedAttributes: string[];
6
+ get typeset(): ((el: HTMLElement) => void) | undefined;
7
+ set typeset(v: ((el: HTMLElement) => void) | undefined);
8
+ get i18n(): I18nProvider | undefined;
9
+ set i18n(v: I18nProvider | undefined);
10
+ get security(): PlayerSecurityConfig | undefined;
11
+ set security(v: PlayerSecurityConfig | undefined);
12
+ get onResponseChange(): ((id: string, value: unknown) => void) | undefined;
13
+ set onResponseChange(v: ((id: string, value: unknown) => void) | undefined);
14
+ get onSubmit(): ((responses: Record<string, unknown>, result: unknown) => void) | undefined;
15
+ set onSubmit(v: ((responses: Record<string, unknown>, result: unknown) => void) | undefined);
16
+ get onComplete(): ((result: AdaptiveAttemptResult) => void) | undefined;
17
+ set onComplete(v: ((result: AdaptiveAttemptResult) => void) | undefined);
18
+ connectedCallback(): void;
19
+ disconnectedCallback(): void;
20
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
21
+ }
22
+ export { PieQtiItemPlayerElement };