@pie-qti/item-player 0.1.28 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +35 -6
  2. package/dist/catalog/applyGlossaryTriggers.js +8 -2
  3. package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
  4. package/dist/catalog/catalogExtractor.js +44 -7
  5. package/dist/catalog/catalogExtractor.js.map +1 -1
  6. package/dist/catalog/catalogLookup.d.ts +8 -0
  7. package/dist/catalog/catalogLookup.js +17 -0
  8. package/dist/catalog/catalogLookup.js.map +1 -1
  9. package/dist/catalog/types.d.ts +3 -3
  10. package/dist/catalog/types.js.map +1 -1
  11. package/dist/components/utils/feedbackUtils.d.ts +9 -4
  12. package/dist/components/utils/feedbackUtils.js +67 -34
  13. package/dist/components/utils/feedbackUtils.js.map +1 -1
  14. package/dist/core/AssessmentItemDefinition.js +35 -0
  15. package/dist/core/AssessmentItemDefinition.js.map +1 -1
  16. package/dist/core/ItemSession.d.ts +19 -1
  17. package/dist/core/ItemSession.js +12 -2
  18. package/dist/core/ItemSession.js.map +1 -1
  19. package/dist/core/Player.d.ts +41 -1
  20. package/dist/core/Player.js +216 -48
  21. package/dist/core/Player.js.map +1 -1
  22. package/dist/core/sanitizer.js +16 -3
  23. package/dist/core/sanitizer.js.map +1 -1
  24. package/dist/document/AssessmentItemDocument.d.ts +12 -5
  25. package/dist/document/AssessmentItemDocument.js +28 -19
  26. package/dist/document/AssessmentItemDocument.js.map +1 -1
  27. package/dist/document/contentPass.d.ts +17 -0
  28. package/dist/document/contentPass.js +40 -0
  29. package/dist/document/contentPass.js.map +1 -0
  30. package/dist/document/printedVariable.d.ts +35 -0
  31. package/dist/document/printedVariable.js +215 -0
  32. package/dist/document/printedVariable.js.map +1 -0
  33. package/dist/{element-class-BzATCyhV.js → element-class-IVUE-E9w.js} +3288 -2311
  34. package/dist/element-class-IVUE-E9w.js.map +1 -0
  35. package/dist/element-class.js +1 -2
  36. package/dist/element.js +1 -1
  37. package/dist/element.js.map +1 -1
  38. package/dist/extraction/interactionAccessibility.d.ts +14 -0
  39. package/dist/extraction/interactionAccessibility.js +58 -0
  40. package/dist/extraction/interactionAccessibility.js.map +1 -0
  41. package/dist/extraction/interactionExtractionPipeline.d.ts +4 -1
  42. package/dist/extraction/interactionExtractionPipeline.js +7 -2
  43. package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
  44. package/dist/extraction/utils.js +20 -1
  45. package/dist/extraction/utils.js.map +1 -1
  46. package/dist/index.d.ts +9 -3
  47. package/dist/index.js +4 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/interactions/order/extractor.js +2 -0
  50. package/dist/interactions/order/extractor.js.map +1 -1
  51. package/dist/interactions/portable-custom/extractor.js +47 -11
  52. package/dist/interactions/portable-custom/extractor.js.map +1 -1
  53. package/dist/interactions/shared/types.d.ts +16 -0
  54. package/dist/interactions/shared/types.js.map +1 -1
  55. package/dist/pci/PciHost.d.ts +85 -43
  56. package/dist/pci/PciHost.js +229 -148
  57. package/dist/pci/PciHost.js.map +1 -1
  58. package/dist/pci/allowlistResolver.d.ts +10 -1
  59. package/dist/pci/allowlistResolver.js +43 -4
  60. package/dist/pci/allowlistResolver.js.map +1 -1
  61. package/dist/pci/amdLoader.d.ts +23 -0
  62. package/dist/pci/amdLoader.js +190 -0
  63. package/dist/pci/amdLoader.js.map +1 -0
  64. package/dist/pci/index.d.ts +14 -3
  65. package/dist/pci/index.js +8 -1
  66. package/dist/pci/index.js.map +1 -1
  67. package/dist/pci/moduleSession.d.ts +41 -0
  68. package/dist/pci/moduleSession.js +2 -0
  69. package/dist/pci/moduleSession.js.map +1 -0
  70. package/dist/pci/pageRealmSession.d.ts +49 -0
  71. package/dist/pci/pageRealmSession.js +193 -0
  72. package/dist/pci/pageRealmSession.js.map +1 -0
  73. package/dist/pci/qtiVariableJson.d.ts +7 -0
  74. package/dist/pci/qtiVariableJson.js +93 -0
  75. package/dist/pci/qtiVariableJson.js.map +1 -0
  76. package/dist/pci/registry.d.ts +15 -0
  77. package/dist/pci/registry.js +77 -0
  78. package/dist/pci/registry.js.map +1 -0
  79. package/dist/pci/resolutionConfig.d.ts +23 -0
  80. package/dist/pci/resolutionConfig.js +63 -0
  81. package/dist/pci/resolutionConfig.js.map +1 -0
  82. package/dist/pci/sandbox/SandboxedPciSession.d.ts +78 -0
  83. package/dist/pci/sandbox/SandboxedPciSession.js +332 -0
  84. package/dist/pci/sandbox/SandboxedPciSession.js.map +1 -0
  85. package/dist/pci/sandbox/iframeConnector.d.ts +13 -0
  86. package/dist/pci/sandbox/iframeConnector.js +94 -0
  87. package/dist/pci/sandbox/iframeConnector.js.map +1 -0
  88. package/dist/pci/sandbox/protocol.d.ts +117 -0
  89. package/dist/pci/sandbox/protocol.js +49 -0
  90. package/dist/pci/sandbox/protocol.js.map +1 -0
  91. package/dist/pci/types.d.ts +213 -30
  92. package/dist/pci/types.js +8 -1
  93. package/dist/pci/types.js.map +1 -1
  94. package/dist/pnp/applyPnp.d.ts +3 -4
  95. package/dist/pnp/applyPnp.js +54 -8
  96. package/dist/pnp/applyPnp.js.map +1 -1
  97. package/dist/pnp/parsePnpXml.d.ts +2 -2
  98. package/dist/pnp/parsePnpXml.js +146 -4
  99. package/dist/pnp/parsePnpXml.js.map +1 -1
  100. package/dist/pnp/types.d.ts +57 -0
  101. package/dist/pnp/types.js.map +1 -1
  102. package/dist/presentation/itemPresentationPlan.d.ts +12 -1
  103. package/dist/presentation/itemPresentationPlan.js +11 -3
  104. package/dist/presentation/itemPresentationPlan.js.map +1 -1
  105. package/dist/server.d.ts +5 -0
  106. package/dist/server.js.map +1 -1
  107. package/dist/types/index.d.ts +5 -0
  108. package/dist/types/index.js.map +1 -1
  109. package/package.json +8 -8
  110. package/dist/element-class-BzATCyhV.js.map +0 -1
@@ -22,6 +22,15 @@ const CATALOG_SUPPORT_FEATURES = [
22
22
  'tactile',
23
23
  'transcript',
24
24
  ];
25
+ /**
26
+ * AfA features the player routes itself, recorded under the platform preference key
27
+ * (`CatalogSupportPreferences` flag) rather than the AfA feature name, so the granted
28
+ * support reaches the platform routing instead of falling through as host-defined.
29
+ */
30
+ const PLATFORM_CATALOG_FEATURES = {
31
+ braille: 'brailleText',
32
+ 'sign-language': 'signingDefinition',
33
+ };
25
34
  /** The extension SBAC requests its illustrated glossary with. */
26
35
  const ILLUSTRATED_GLOSSARY_EXTENSION = 'sbac-glossary-illustration';
27
36
  /**
@@ -45,6 +54,25 @@ const COLOR_THEMES = {
45
54
  'black-cream': 'blackcream',
46
55
  'cream-black': 'creamblack',
47
56
  };
57
+ /** AfA `generic-font-face` terms onto CSS generic families. */
58
+ const GENERIC_FONT_FACES = {
59
+ serif: 'serif',
60
+ 'sans serif': 'sans-serif',
61
+ monospaced: 'monospace',
62
+ cursive: 'cursive',
63
+ fantasy: 'fantasy',
64
+ };
65
+ /** AfA's speech rate when the profile gives none, in words per minute. */
66
+ const AFA_DEFAULT_SPEECH_RATE = 180;
67
+ /**
68
+ * AfA tool features onto pie-players support ids, the ids its
69
+ * `createPersonalNeedsProfileFromAfa` gives them. `spoken` resolves by reading type.
70
+ */
71
+ const TOOL_FEATURES = {
72
+ 'calculator-on-screen': 'calculator',
73
+ 'line-reader': 'lineReader',
74
+ 'dictionary-on-screen': 'dictionary',
75
+ };
48
76
  /**
49
77
  * Parse an AfA PNP 3.0 document into its record: an `access-for-all-pnp` element, or
50
78
  * the first one inside an `access-for-all-pnp-record`. A bulk records file holds one
@@ -80,8 +108,8 @@ export function parseAfaPnpXml(xml) {
80
108
  /**
81
109
  * The part of an AfA record the item player renders. A feature counts when the record
82
110
  * names it or one of its activation sets lists it, unless `prohibit-set` lists it.
83
- * Features with no `PnpProfile` field stay in the record for the host's tools:
84
- * `fixed-minutes` testing time, `ext:` color themes, and every tool support.
111
+ * Features with no `PnpProfile` field stay in the record for the host: `ext:` color
112
+ * themes, and the tool supports `tools` does not name.
85
113
  */
86
114
  export function pnpProfileFromAfa(record) {
87
115
  const prohibited = new Set(record['prohibit-set'] ?? []);
@@ -105,6 +133,24 @@ export function pnpProfileFromAfa(record) {
105
133
  if (zoom !== undefined && zoom > 0)
106
134
  display.magnification = zoom;
107
135
  }
136
+ if (granted('language-of-interface')) {
137
+ const interfaceLanguage = normalizeLanguageCode(field(record['language-of-interface'], 'language'));
138
+ if (interfaceLanguage)
139
+ display.interfaceLanguage = interfaceLanguage;
140
+ }
141
+ if (granted('invert-display-polarity')) {
142
+ const polarity = record['invert-display-polarity'];
143
+ const foreground = hexColor(field(polarity, 'foreground'));
144
+ const background = hexColor(field(polarity, 'background'));
145
+ display.invertPolarity = { ...(foreground ? { foreground } : {}), ...(background ? { background } : {}) };
146
+ }
147
+ if (granted('layout-single-column'))
148
+ display.singleColumn = true;
149
+ if (granted('text-appearance')) {
150
+ const textAppearance = textAppearanceOf(record['text-appearance']);
151
+ if (textAppearance)
152
+ display.textAppearance = textAppearance;
153
+ }
108
154
  const content = {};
109
155
  if (granted('glossary-on-screen'))
110
156
  content.glossaryOnScreen = true;
@@ -123,19 +169,24 @@ export function pnpProfileFromAfa(record) {
123
169
  const languageCode = normalizeLanguageCode(field(record[feature], 'language'));
124
170
  const preference = languageCode ? { active: true, languageCode } : true;
125
171
  content.catalogSupports ?? (content.catalogSupports = {});
126
- content.catalogSupports[feature] = preference;
172
+ content.catalogSupports[PLATFORM_CATALOG_FEATURES[feature] ?? feature] = preference;
127
173
  }
128
174
  if (granted('additional-testing-time')) {
129
175
  const testingTime = record['additional-testing-time'];
130
176
  const multiplier = isPresent(field(testingTime, 'unlimited'))
131
177
  ? Infinity
132
178
  : finiteNumber(field(testingTime, 'time-multiplier'));
179
+ const fixedMinutes = finiteNumber(field(testingTime, 'fixed-minutes'));
133
180
  if (multiplier !== undefined && multiplier > 0)
134
181
  content.extendedTime = { active: true, multiplier };
182
+ else if (fixedMinutes !== undefined && fixedMinutes > 0) {
183
+ content.extendedTime = { active: true, multiplier: 1, fixedMinutes };
184
+ }
135
185
  }
136
186
  const cognitive = {};
137
187
  if (granted('answer-masking'))
138
- cognitive.eliminationTool = true;
188
+ cognitive.answerMasking = true;
189
+ const tools = toolSupportsOf(record, granted, prohibited);
139
190
  const profile = {};
140
191
  if (Object.keys(display).length > 0)
141
192
  profile.display = display;
@@ -143,8 +194,89 @@ export function pnpProfileFromAfa(record) {
143
194
  profile.content = content;
144
195
  if (Object.keys(cognitive).length > 0)
145
196
  profile.cognitive = cognitive;
197
+ if (tools)
198
+ profile.tools = tools;
146
199
  return profile;
147
200
  }
201
+ /** The tool supports an AfA record grants or withdraws, as pie-players support ids. */
202
+ function toolSupportsOf(record, granted, prohibited) {
203
+ const atInit = new Set(record['activate-at-initialization-set'] ?? []);
204
+ const supports = [];
205
+ const prohibitedSupports = [];
206
+ const activateAtInit = [];
207
+ const toolParameters = {};
208
+ const add = (feature, toolId, parameters) => {
209
+ if (prohibited.has(feature)) {
210
+ prohibitedSupports.push(toolId);
211
+ return;
212
+ }
213
+ if (!granted(feature))
214
+ return;
215
+ supports.push(toolId);
216
+ if (atInit.has(feature))
217
+ activateAtInit.push(toolId);
218
+ if (parameters && Object.keys(parameters).length > 0)
219
+ toolParameters[toolId] = parameters;
220
+ };
221
+ for (const [feature, toolId] of Object.entries(TOOL_FEATURES)) {
222
+ const calculatorType = feature === 'calculator-on-screen' ? field(record[feature], 'calculator-type') : undefined;
223
+ add(feature, toolId, typeof calculatorType === 'string' && ['basic', 'scientific', 'graphing'].includes(calculatorType)
224
+ ? { type: calculatorType }
225
+ : undefined);
226
+ }
227
+ const spoken = record.spoken;
228
+ if (prohibited.has('spoken'))
229
+ prohibitedSupports.push('textToSpeech');
230
+ else if (field(spoken, 'reading-type') === 'computer-read-aloud') {
231
+ const rate = finiteNumber(field(spoken, 'speech-rate'));
232
+ const pitch = finiteNumber(field(spoken, 'pitch'));
233
+ const volume = finiteNumber(field(spoken, 'volume'));
234
+ add('spoken', 'textToSpeech', {
235
+ ...(rate !== undefined && rate > 0 ? { rate: rate / AFA_DEFAULT_SPEECH_RATE } : {}),
236
+ ...(pitch !== undefined ? { pitch: pitch * 2 } : {}),
237
+ ...(volume !== undefined ? { volume } : {}),
238
+ });
239
+ }
240
+ else
241
+ add('spoken', 'screenReader');
242
+ if (supports.length === 0 && prohibitedSupports.length === 0)
243
+ return undefined;
244
+ return {
245
+ ...(supports.length > 0 ? { supports } : {}),
246
+ ...(prohibitedSupports.length > 0 ? { prohibitedSupports } : {}),
247
+ ...(activateAtInit.length > 0 ? { activateAtInit } : {}),
248
+ ...(Object.keys(toolParameters).length > 0 ? { toolParameters } : {}),
249
+ };
250
+ }
251
+ /** AfA `text-appearance` as the player applies it; undefined when it sets nothing. */
252
+ function textAppearanceOf(value) {
253
+ const appearance = {};
254
+ const fontSize = finiteNumber(field(value, 'font-size'));
255
+ if (fontSize !== undefined && fontSize > 0)
256
+ appearance.fontSize = fontSize;
257
+ const fontFace = field(value, 'font-face');
258
+ const names = [field(fontFace, 'font-name')].flat().filter((name) => typeof name === 'string');
259
+ const generic = GENERIC_FONT_FACES[String(field(fontFace, 'generic-font-face') ?? '')];
260
+ const families = [...names.map((name) => JSON.stringify(name.trim())), ...(generic ? [generic] : [])];
261
+ if (families.length > 0)
262
+ appearance.fontFamily = families.join(', ');
263
+ const fontColor = hexColor(field(value, 'font-color'));
264
+ if (fontColor)
265
+ appearance.fontColor = fontColor;
266
+ const backgroundColor = hexColor(field(value, 'background-color'));
267
+ if (backgroundColor)
268
+ appearance.backgroundColor = backgroundColor;
269
+ const lineHeight = finiteNumber(field(value, 'line-height')) ?? finiteNumber(field(value, 'line-spacing'));
270
+ if (lineHeight !== undefined && lineHeight > 0)
271
+ appearance.lineHeight = lineHeight;
272
+ const letterSpacing = finiteNumber(field(value, 'letter-spacing'));
273
+ if (letterSpacing !== undefined)
274
+ appearance.letterSpacing = letterSpacing;
275
+ const wordSpacing = finiteNumber(field(value, 'word-spacing'));
276
+ if (wordSpacing !== undefined)
277
+ appearance.wordSpacing = wordSpacing;
278
+ return Object.keys(appearance).length > 0 ? appearance : undefined;
279
+ }
148
280
  /**
149
281
  * Parse an AfA PNP 3.0 document into the `PnpProfile` the item player renders. Returns
150
282
  * an empty profile when the input holds none. `parseAfaPnpXml` returns the whole record.
@@ -230,6 +362,16 @@ function isPresent(value) {
230
362
  function finiteNumber(value) {
231
363
  return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
232
364
  }
365
+ /**
366
+ * An AfA hex colour (`#fff`, `ffffff`) as CSS; undefined for anything else. An all-digit
367
+ * colour reaches here as the number the record read it as, so it is padded back to six.
368
+ */
369
+ function hexColor(value) {
370
+ if (typeof value !== 'string' && typeof value !== 'number')
371
+ return undefined;
372
+ const hex = typeof value === 'number' ? String(value).padStart(6, '0') : value.trim().replace(/^#/, '');
373
+ return /^(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hex) ? `#${hex.toLowerCase()}` : undefined;
374
+ }
233
375
  function normalizeLanguageCode(value) {
234
376
  if (typeof value !== 'string')
235
377
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"parsePnpXml.js","sourceRoot":"","sources":["../../src/pnp/parsePnpXml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAItD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,wDAAwD,CAAC;AAmB1F,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,gCAAgC,EAAE,wBAAwB,EAAE,cAAc,CAAC,CAAC,CAAC;AAE3G;;;;GAIG;AACH,MAAM,wBAAwB,GAAG;IAChC,uBAAuB;IACvB,mBAAmB;IACnB,SAAS;IACT,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,8BAA8B;IAC9B,QAAQ;IACR,SAAS;IACT,YAAY;CACH,CAAC;AAEX,iEAAiE;AACjE,MAAM,8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AE,OAAO,KAAK,CAAC;IACpC,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,KAAK,CAAC,KAAc,EAAE,GAAW;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1E,CAAC,CAAE,KAAiC,CAAC,GAAG,CAAC;QACzC,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAChC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC;AACjE,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,uCAAuC,CAAC,IAAI,CAAC,YAAY,CAAC;QAAE,OAAO,SAAS,CAAC;IAClF,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["import { parse as parseHtml } from 'node-html-parser';\nimport type { HTMLElement as NhpElement } from 'node-html-parser';\nimport type { CatalogSupportPreference, PnpProfile } from './types.js';\n\n/** QTI 3's profile of Access for All Personal Needs and Preferences 3.0. */\nexport const AFA_PNP_NAMESPACE = 'http://www.imsglobal.org/xsd/qtiv3p0/imsafa3p0pnp_v1p0';\n\n/**\n * An AfA PNP 3.0 profile as JSON keyed by the spec's kebab-case terms, the shape\n * pie-players' `createPersonalNeedsProfileFromAfa` takes.\n *\n * An empty element is `{}`, an element holding only text is that text (a number or\n * boolean when it reads as one), `xml:lang` is `language`, a repeated element is an\n * array, and a feature set is the list of feature names it holds. Elements of another\n * namespace, AfA's extension mechanism, sit under `extensions` by local name.\n */\nexport interface AfaPnpRecord {\n\t'activate-at-initialization-set'?: string[];\n\t'activate-as-option-set'?: string[];\n\t'prohibit-set'?: string[];\n\textensions?: Record<string, unknown>;\n\t[feature: string]: unknown;\n}\n\nconst FEATURE_SETS = new Set(['activate-at-initialization-set', 'activate-as-option-set', 'prohibit-set']);\n\n/**\n * QTI 3's predefined catalog card supports, less `glossary-on-screen` and\n * `keyword-translation`, which have popups of their own. A granted one enables the\n * catalog support of that name.\n */\nconst CATALOG_SUPPORT_FEATURES = [\n\t'additional-directions',\n\t'audio-description',\n\t'braille',\n\t'high-contrast',\n\t'keyboard-directions',\n\t'linguistic-guidance',\n\t'long-description',\n\t'sign-language',\n\t'simplified-graphics',\n\t'simplified-language-portions',\n\t'spoken',\n\t'tactile',\n\t'transcript',\n] as const;\n\n/** The extension SBAC requests its illustrated glossary with. */\nconst ILLUSTRATED_GLOSSARY_EXTENSION = 'sbac-glossary-illustration';\n\ntype ColorScheme = NonNullable<NonNullable<PnpProfile['display']>['colorScheme']>;\n\n/**\n * AfA `color-theme` terms onto the player's scheme names. The spec leaves a theme's\n * exact colors to the delivery system, so `high-contrast` takes black on white and\n * its reverse white on black.\n */\nconst COLOR_THEMES: Readonly<Record<string, ColorScheme>> = {\n\tdefault: 'default',\n\t'default-reverse': 'defaultreverse',\n\t'high-contrast': 'blackwhite',\n\t'high-contrast-reverse': 'whiteblack',\n\t'black-rose': 'blackrose',\n\t'rose-black': 'roseblack',\n\t'yellow-blue': 'yellowblue',\n\t'blue-yellow': 'blueyellow',\n\t'medgray-darkgray': 'mgraydgray',\n\t'darkgray-medgray': 'dgraymgray',\n\t'black-cyan': 'blackcyan',\n\t'cyan-black': 'cyanblack',\n\t'black-cream': 'blackcream',\n\t'cream-black': 'creamblack',\n};\n\n/**\n * Parse an AfA PNP 3.0 document into its record: an `access-for-all-pnp` element, or\n * the first one inside an `access-for-all-pnp-record`. A bulk records file holds one\n * profile per candidate, so pass the candidate's record. Returns `null` when the input\n * holds no profile.\n */\nexport function parseAfaPnpXml(xml: string | Element): AfaPnpRecord | null {\n\tconst source = typeof xml === 'string' ? xml : ((xml as Element).outerHTML ?? '');\n\tconst trimmed = source.replace(/<\\?xml[^>]*\\?>/g, '').trim();\n\tif (!trimmed) return null;\n\n\tconst doc = parseHtml(`<root>${trimmed}</root>`, { lowerCaseTagName: false });\n\tconst root = findProfile(doc);\n\tif (!root) return null;\n\n\tconst afaPrefixes = collectAfaPrefixes(root);\n\tconst record: AfaPnpRecord = {};\n\tfor (const child of elementChildren(root)) {\n\t\tconst { prefix, local } = splitName(child.rawTagName);\n\t\tif (prefix && !afaPrefixes.has(prefix)) {\n\t\t\trecord.extensions ??= {};\n\t\t\taddValue(record.extensions, local, elementValue(child));\n\t\t} else if (FEATURE_SETS.has(local)) {\n\t\t\trecord[local] = elementChildren(child).map((feature) => splitName(feature.rawTagName).local);\n\t\t} else {\n\t\t\taddValue(record, local, elementValue(child));\n\t\t}\n\t}\n\treturn record;\n}\n\n/**\n * The part of an AfA record the item player renders. A feature counts when the record\n * names it or one of its activation sets lists it, unless `prohibit-set` lists it.\n * Features with no `PnpProfile` field stay in the record for the host's tools:\n * `fixed-minutes` testing time, `ext:` color themes, and every tool support.\n */\nexport function pnpProfileFromAfa(record: AfaPnpRecord): PnpProfile {\n\tconst prohibited = new Set(record['prohibit-set'] ?? []);\n\tconst listed = new Set([\n\t\t...(record['activate-at-initialization-set'] ?? []),\n\t\t...(record['activate-as-option-set'] ?? []),\n\t]);\n\tconst granted = (feature: string): boolean =>\n\t\t!prohibited.has(feature) && (isPresent(record[feature]) || listed.has(feature));\n\n\tconst display: NonNullable<PnpProfile['display']> = {};\n\tconst theme = granted('text-appearance')\n\t\t? field(record['text-appearance'], 'color-theme')\n\t\t: granted('color-theme')\n\t\t\t? record['color-theme']\n\t\t\t: undefined;\n\tif (typeof theme === 'string' && COLOR_THEMES[theme]) display.colorScheme = COLOR_THEMES[theme];\n\tif (granted('magnification')) {\n\t\tconst magnification = record.magnification;\n\t\tconst zoom =\n\t\t\tfiniteNumber(field(field(magnification, 'all-content'), 'zoom-amount')) ??\n\t\t\tfiniteNumber(field(field(magnification, 'text'), 'zoom-amount'));\n\t\tif (zoom !== undefined && zoom > 0) display.magnification = zoom;\n\t}\n\n\tconst content: NonNullable<PnpProfile['content']> = {};\n\tif (granted('glossary-on-screen')) content.glossaryOnScreen = true;\n\tif (granted('keyword-translation')) {\n\t\tconst languageCode = normalizeLanguageCode(field(record['keyword-translation'], 'language'));\n\t\tif (languageCode) content.keywordTranslation = { active: true, languageCode };\n\t}\n\tif (\n\t\t!prohibited.has(ILLUSTRATED_GLOSSARY_EXTENSION) &&\n\t\tisPresent(record.extensions?.[ILLUSTRATED_GLOSSARY_EXTENSION])\n\t) {\n\t\tcontent.illustratedGlossary = true;\n\t}\n\tfor (const feature of CATALOG_SUPPORT_FEATURES) {\n\t\tif (!granted(feature)) continue;\n\t\tconst languageCode = normalizeLanguageCode(field(record[feature], 'language'));\n\t\tconst preference: CatalogSupportPreference = languageCode ? { active: true, languageCode } : true;\n\t\tcontent.catalogSupports ??= {};\n\t\tcontent.catalogSupports[feature] = preference;\n\t}\n\tif (granted('additional-testing-time')) {\n\t\tconst testingTime = record['additional-testing-time'];\n\t\tconst multiplier = isPresent(field(testingTime, 'unlimited'))\n\t\t\t? Infinity\n\t\t\t: finiteNumber(field(testingTime, 'time-multiplier'));\n\t\tif (multiplier !== undefined && multiplier > 0) content.extendedTime = { active: true, multiplier };\n\t}\n\n\tconst cognitive: NonNullable<PnpProfile['cognitive']> = {};\n\tif (granted('answer-masking')) cognitive.eliminationTool = true;\n\n\tconst profile: PnpProfile = {};\n\tif (Object.keys(display).length > 0) profile.display = display;\n\tif (Object.keys(content).length > 0) profile.content = content;\n\tif (Object.keys(cognitive).length > 0) profile.cognitive = cognitive;\n\treturn profile;\n}\n\n/**\n * Parse an AfA PNP 3.0 document into the `PnpProfile` the item player renders. Returns\n * an empty profile when the input holds none. `parseAfaPnpXml` returns the whole record.\n */\nexport function parsePnpXml(xml: string | Element): PnpProfile {\n\tconst record = parseAfaPnpXml(xml);\n\treturn record ? pnpProfileFromAfa(record) : {};\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction findProfile(parent: NhpElement): NhpElement | null {\n\tfor (const child of elementChildren(parent)) {\n\t\tif (splitName(child.rawTagName).local === 'access-for-all-pnp') return child;\n\t\tconst nested = findProfile(child);\n\t\tif (nested) return nested;\n\t}\n\treturn null;\n}\n\n/** Prefixes bound to an AfA PNP namespace on the profile or its ancestors. */\nfunction collectAfaPrefixes(root: NhpElement): Set<string> {\n\tconst prefixes = new Set<string>();\n\tfor (let el: NhpElement | null = root; el; el = el.parentNode as NhpElement | null) {\n\t\tfor (const [name, value] of Object.entries(el.rawAttributes ?? {})) {\n\t\t\tif (name.startsWith('xmlns:') && value.includes('imsafa3p0pnp')) prefixes.add(name.slice(6));\n\t\t}\n\t}\n\treturn prefixes;\n}\n\nfunction elementChildren(parent: NhpElement): NhpElement[] {\n\treturn parent.childNodes.filter((child): child is NhpElement => child.nodeType === 1);\n}\n\nfunction splitName(name: string | undefined): { prefix?: string; local: string } {\n\tconst raw = name ?? '';\n\tconst colon = raw.indexOf(':');\n\treturn colon < 0 ? { local: raw } : { prefix: raw.slice(0, colon), local: raw.slice(colon + 1) };\n}\n\nfunction elementValue(el: NhpElement): unknown {\n\tconst value: Record<string, unknown> = {};\n\tfor (const [name, raw] of Object.entries(el.rawAttributes ?? {})) {\n\t\tif (name === 'xmlns' || name.startsWith('xmlns:') || name.startsWith('xsi:')) continue;\n\t\taddValue(value, name === 'xml:lang' ? 'language' : splitName(name).local, scalar(raw));\n\t}\n\tconst children = elementChildren(el);\n\tfor (const child of children) {\n\t\taddValue(value, splitName(child.rawTagName).local, elementValue(child));\n\t}\n\tif (children.length > 0 || Object.keys(value).length > 0) return value;\n\tconst text = el.text.trim();\n\treturn text ? scalar(text) : {};\n}\n\nfunction addValue(target: Record<string, unknown>, key: string, value: unknown): void {\n\tif (!(key in target)) {\n\t\ttarget[key] = value;\n\t\treturn;\n\t}\n\tconst existing = target[key];\n\ttarget[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];\n}\n\nfunction scalar(raw: string): string | number | boolean {\n\tconst value = raw.trim();\n\tif (value === 'true') return true;\n\tif (value === 'false') return false;\n\tif (/^-?\\d+(?:\\.\\d+)?$/.test(value)) return Number(value);\n\treturn value;\n}\n\nfunction field(value: unknown, key: string): unknown {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n\t\t? (value as Record<string, unknown>)[key]\n\t\t: undefined;\n}\n\nfunction isPresent(value: unknown): boolean {\n\treturn value !== undefined && value !== null && value !== false;\n}\n\nfunction finiteNumber(value: unknown): number | undefined {\n\treturn typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\nfunction normalizeLanguageCode(value: unknown): string | undefined {\n\tif (typeof value !== 'string') return undefined;\n\tconst languageCode = value.trim();\n\tif (!/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/.test(languageCode)) return undefined;\n\treturn languageCode;\n}\n"]}
1
+ {"version":3,"file":"parsePnpXml.js","sourceRoot":"","sources":["../../src/pnp/parsePnpXml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAItD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,wDAAwD,CAAC;AAmB1F,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,gCAAgC,EAAE,wBAAwB,EAAE,cAAc,CAAC,CAAC,CAAC;AAE3G;;;;GAIG;AACH,MAAM,wBAAwB,G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ml } from 'node-html-parser';\nimport type { HTMLElement as NhpElement } from 'node-html-parser';\nimport type { CatalogSupportPreference, PnpProfile, PnpTextAppearance, PnpToolSupports } from './types.js';\n\n/** QTI 3's profile of Access for All Personal Needs and Preferences 3.0. */\nexport const AFA_PNP_NAMESPACE = 'http://www.imsglobal.org/xsd/qtiv3p0/imsafa3p0pnp_v1p0';\n\n/**\n * An AfA PNP 3.0 profile as JSON keyed by the spec's kebab-case terms, the shape\n * pie-players' `createPersonalNeedsProfileFromAfa` takes.\n *\n * An empty element is `{}`, an element holding only text is that text (a number or\n * boolean when it reads as one), `xml:lang` is `language`, a repeated element is an\n * array, and a feature set is the list of feature names it holds. Elements of another\n * namespace, AfA's extension mechanism, sit under `extensions` by local name.\n */\nexport interface AfaPnpRecord {\n\t'activate-at-initialization-set'?: string[];\n\t'activate-as-option-set'?: string[];\n\t'prohibit-set'?: string[];\n\textensions?: Record<string, unknown>;\n\t[feature: string]: unknown;\n}\n\nconst FEATURE_SETS = new Set(['activate-at-initialization-set', 'activate-as-option-set', 'prohibit-set']);\n\n/**\n * QTI 3's predefined catalog card supports, less `glossary-on-screen` and\n * `keyword-translation`, which have popups of their own. A granted one enables the\n * catalog support of that name.\n */\nconst CATALOG_SUPPORT_FEATURES = [\n\t'additional-directions',\n\t'audio-description',\n\t'braille',\n\t'high-contrast',\n\t'keyboard-directions',\n\t'linguistic-guidance',\n\t'long-description',\n\t'sign-language',\n\t'simplified-graphics',\n\t'simplified-language-portions',\n\t'spoken',\n\t'tactile',\n\t'transcript',\n] as const;\n\n/**\n * AfA features the player routes itself, recorded under the platform preference key\n * (`CatalogSupportPreferences` flag) rather than the AfA feature name, so the granted\n * support reaches the platform routing instead of falling through as host-defined.\n */\nconst PLATFORM_CATALOG_FEATURES: Readonly<Partial<Record<(typeof CATALOG_SUPPORT_FEATURES)[number], string>>> = {\n\tbraille: 'brailleText',\n\t'sign-language': 'signingDefinition',\n};\n\n/** The extension SBAC requests its illustrated glossary with. */\nconst ILLUSTRATED_GLOSSARY_EXTENSION = 'sbac-glossary-illustration';\n\ntype ColorScheme = NonNullable<NonNullable<PnpProfile['display']>['colorScheme']>;\n\n/**\n * AfA `color-theme` terms onto the player's scheme names. The spec leaves a theme's\n * exact colors to the delivery system, so `high-contrast` takes black on white and\n * its reverse white on black.\n */\nconst COLOR_THEMES: Readonly<Record<string, ColorScheme>> = {\n\tdefault: 'default',\n\t'default-reverse': 'defaultreverse',\n\t'high-contrast': 'blackwhite',\n\t'high-contrast-reverse': 'whiteblack',\n\t'black-rose': 'blackrose',\n\t'rose-black': 'roseblack',\n\t'yellow-blue': 'yellowblue',\n\t'blue-yellow': 'blueyellow',\n\t'medgray-darkgray': 'mgraydgray',\n\t'darkgray-medgray': 'dgraymgray',\n\t'black-cyan': 'blackcyan',\n\t'cyan-black': 'cyanblack',\n\t'black-cream': 'blackcream',\n\t'cream-black': 'creamblack',\n};\n\n/** AfA `generic-font-face` terms onto CSS generic families. */\nconst GENERIC_FONT_FACES: Readonly<Record<string, string>> = {\n\tserif: 'serif',\n\t'sans serif': 'sans-serif',\n\tmonospaced: 'monospace',\n\tcursive: 'cursive',\n\tfantasy: 'fantasy',\n};\n\n/** AfA's speech rate when the profile gives none, in words per minute. */\nconst AFA_DEFAULT_SPEECH_RATE = 180;\n\n/**\n * AfA tool features onto pie-players support ids, the ids its\n * `createPersonalNeedsProfileFromAfa` gives them. `spoken` resolves by reading type.\n */\nconst TOOL_FEATURES: Readonly<Record<string, string>> = {\n\t'calculator-on-screen': 'calculator',\n\t'line-reader': 'lineReader',\n\t'dictionary-on-screen': 'dictionary',\n};\n\n/**\n * Parse an AfA PNP 3.0 document into its record: an `access-for-all-pnp` element, or\n * the first one inside an `access-for-all-pnp-record`. A bulk records file holds one\n * profile per candidate, so pass the candidate's record. Returns `null` when the input\n * holds no profile.\n */\nexport function parseAfaPnpXml(xml: string | Element): AfaPnpRecord | null {\n\tconst source = typeof xml === 'string' ? xml : ((xml as Element).outerHTML ?? '');\n\tconst trimmed = source.replace(/<\\?xml[^>]*\\?>/g, '').trim();\n\tif (!trimmed) return null;\n\n\tconst doc = parseHtml(`<root>${trimmed}</root>`, { lowerCaseTagName: false });\n\tconst root = findProfile(doc);\n\tif (!root) return null;\n\n\tconst afaPrefixes = collectAfaPrefixes(root);\n\tconst record: AfaPnpRecord = {};\n\tfor (const child of elementChildren(root)) {\n\t\tconst { prefix, local } = splitName(child.rawTagName);\n\t\tif (prefix && !afaPrefixes.has(prefix)) {\n\t\t\trecord.extensions ??= {};\n\t\t\taddValue(record.extensions, local, elementValue(child));\n\t\t} else if (FEATURE_SETS.has(local)) {\n\t\t\trecord[local] = elementChildren(child).map((feature) => splitName(feature.rawTagName).local);\n\t\t} else {\n\t\t\taddValue(record, local, elementValue(child));\n\t\t}\n\t}\n\treturn record;\n}\n\n/**\n * The part of an AfA record the item player renders. A feature counts when the record\n * names it or one of its activation sets lists it, unless `prohibit-set` lists it.\n * Features with no `PnpProfile` field stay in the record for the host: `ext:` color\n * themes, and the tool supports `tools` does not name.\n */\nexport function pnpProfileFromAfa(record: AfaPnpRecord): PnpProfile {\n\tconst prohibited = new Set(record['prohibit-set'] ?? []);\n\tconst listed = new Set([\n\t\t...(record['activate-at-initialization-set'] ?? []),\n\t\t...(record['activate-as-option-set'] ?? []),\n\t]);\n\tconst granted = (feature: string): boolean =>\n\t\t!prohibited.has(feature) && (isPresent(record[feature]) || listed.has(feature));\n\n\tconst display: NonNullable<PnpProfile['display']> = {};\n\tconst theme = granted('text-appearance')\n\t\t? field(record['text-appearance'], 'color-theme')\n\t\t: granted('color-theme')\n\t\t\t? record['color-theme']\n\t\t\t: undefined;\n\tif (typeof theme === 'string' && COLOR_THEMES[theme]) display.colorScheme = COLOR_THEMES[theme];\n\tif (granted('magnification')) {\n\t\tconst magnification = record.magnification;\n\t\tconst zoom =\n\t\t\tfiniteNumber(field(field(magnification, 'all-content'), 'zoom-amount')) ??\n\t\t\tfiniteNumber(field(field(magnification, 'text'), 'zoom-amount'));\n\t\tif (zoom !== undefined && zoom > 0) display.magnification = zoom;\n\t}\n\tif (granted('language-of-interface')) {\n\t\tconst interfaceLanguage = normalizeLanguageCode(field(record['language-of-interface'], 'language'));\n\t\tif (interfaceLanguage) display.interfaceLanguage = interfaceLanguage;\n\t}\n\tif (granted('invert-display-polarity')) {\n\t\tconst polarity = record['invert-display-polarity'];\n\t\tconst foreground = hexColor(field(polarity, 'foreground'));\n\t\tconst background = hexColor(field(polarity, 'background'));\n\t\tdisplay.invertPolarity = { ...(foreground ? { foreground } : {}), ...(background ? { background } : {}) };\n\t}\n\tif (granted('layout-single-column')) display.singleColumn = true;\n\tif (granted('text-appearance')) {\n\t\tconst textAppearance = textAppearanceOf(record['text-appearance']);\n\t\tif (textAppearance) display.textAppearance = textAppearance;\n\t}\n\n\tconst content: NonNullable<PnpProfile['content']> = {};\n\tif (granted('glossary-on-screen')) content.glossaryOnScreen = true;\n\tif (granted('keyword-translation')) {\n\t\tconst languageCode = normalizeLanguageCode(field(record['keyword-translation'], 'language'));\n\t\tif (languageCode) content.keywordTranslation = { active: true, languageCode };\n\t}\n\tif (\n\t\t!prohibited.has(ILLUSTRATED_GLOSSARY_EXTENSION) &&\n\t\tisPresent(record.extensions?.[ILLUSTRATED_GLOSSARY_EXTENSION])\n\t) {\n\t\tcontent.illustratedGlossary = true;\n\t}\n\tfor (const feature of CATALOG_SUPPORT_FEATURES) {\n\t\tif (!granted(feature)) continue;\n\t\tconst languageCode = normalizeLanguageCode(field(record[feature], 'language'));\n\t\tconst preference: CatalogSupportPreference = languageCode ? { active: true, languageCode } : true;\n\t\tcontent.catalogSupports ??= {};\n\t\tcontent.catalogSupports[PLATFORM_CATALOG_FEATURES[feature] ?? feature] = preference;\n\t}\n\tif (granted('additional-testing-time')) {\n\t\tconst testingTime = record['additional-testing-time'];\n\t\tconst multiplier = isPresent(field(testingTime, 'unlimited'))\n\t\t\t? Infinity\n\t\t\t: finiteNumber(field(testingTime, 'time-multiplier'));\n\t\tconst fixedMinutes = finiteNumber(field(testingTime, 'fixed-minutes'));\n\t\tif (multiplier !== undefined && multiplier > 0) content.extendedTime = { active: true, multiplier };\n\t\telse if (fixedMinutes !== undefined && fixedMinutes > 0) {\n\t\t\tcontent.extendedTime = { active: true, multiplier: 1, fixedMinutes };\n\t\t}\n\t}\n\n\tconst cognitive: NonNullable<PnpProfile['cognitive']> = {};\n\tif (granted('answer-masking')) cognitive.answerMasking = true;\n\n\tconst tools = toolSupportsOf(record, granted, prohibited);\n\n\tconst profile: PnpProfile = {};\n\tif (Object.keys(display).length > 0) profile.display = display;\n\tif (Object.keys(content).length > 0) profile.content = content;\n\tif (Object.keys(cognitive).length > 0) profile.cognitive = cognitive;\n\tif (tools) profile.tools = tools;\n\treturn profile;\n}\n\n/** The tool supports an AfA record grants or withdraws, as pie-players support ids. */\nfunction toolSupportsOf(\n\trecord: AfaPnpRecord,\n\tgranted: (feature: string) => boolean,\n\tprohibited: ReadonlySet<string>,\n): PnpToolSupports | undefined {\n\tconst atInit = new Set(record['activate-at-initialization-set'] ?? []);\n\tconst supports: string[] = [];\n\tconst prohibitedSupports: string[] = [];\n\tconst activateAtInit: string[] = [];\n\tconst toolParameters: Record<string, Record<string, unknown>> = {};\n\tconst add = (feature: string, toolId: string, parameters?: Record<string, unknown>) => {\n\t\tif (prohibited.has(feature)) {\n\t\t\tprohibitedSupports.push(toolId);\n\t\t\treturn;\n\t\t}\n\t\tif (!granted(feature)) return;\n\t\tsupports.push(toolId);\n\t\tif (atInit.has(feature)) activateAtInit.push(toolId);\n\t\tif (parameters && Object.keys(parameters).length > 0) toolParameters[toolId] = parameters;\n\t};\n\n\tfor (const [feature, toolId] of Object.entries(TOOL_FEATURES)) {\n\t\tconst calculatorType = feature === 'calculator-on-screen' ? field(record[feature], 'calculator-type') : undefined;\n\t\tadd(\n\t\t\tfeature,\n\t\t\ttoolId,\n\t\t\ttypeof calculatorType === 'string' && ['basic', 'scientific', 'graphing'].includes(calculatorType)\n\t\t\t\t? { type: calculatorType }\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\tconst spoken = record.spoken;\n\tif (prohibited.has('spoken')) prohibitedSupports.push('textToSpeech');\n\telse if (field(spoken, 'reading-type') === 'computer-read-aloud') {\n\t\tconst rate = finiteNumber(field(spoken, 'speech-rate'));\n\t\tconst pitch = finiteNumber(field(spoken, 'pitch'));\n\t\tconst volume = finiteNumber(field(spoken, 'volume'));\n\t\tadd('spoken', 'textToSpeech', {\n\t\t\t...(rate !== undefined && rate > 0 ? { rate: rate / AFA_DEFAULT_SPEECH_RATE } : {}),\n\t\t\t...(pitch !== undefined ? { pitch: pitch * 2 } : {}),\n\t\t\t...(volume !== undefined ? { volume } : {}),\n\t\t});\n\t} else add('spoken', 'screenReader');\n\n\tif (supports.length === 0 && prohibitedSupports.length === 0) return undefined;\n\treturn {\n\t\t...(supports.length > 0 ? { supports } : {}),\n\t\t...(prohibitedSupports.length > 0 ? { prohibitedSupports } : {}),\n\t\t...(activateAtInit.length > 0 ? { activateAtInit } : {}),\n\t\t...(Object.keys(toolParameters).length > 0 ? { toolParameters } : {}),\n\t};\n}\n\n/** AfA `text-appearance` as the player applies it; undefined when it sets nothing. */\nfunction textAppearanceOf(value: unknown): PnpTextAppearance | undefined {\n\tconst appearance: PnpTextAppearance = {};\n\tconst fontSize = finiteNumber(field(value, 'font-size'));\n\tif (fontSize !== undefined && fontSize > 0) appearance.fontSize = fontSize;\n\tconst fontFace = field(value, 'font-face');\n\tconst names = [field(fontFace, 'font-name')].flat().filter((name): name is string => typeof name === 'string');\n\tconst generic = GENERIC_FONT_FACES[String(field(fontFace, 'generic-font-face') ?? '')];\n\tconst families = [...names.map((name) => JSON.stringify(name.trim())), ...(generic ? [generic] : [])];\n\tif (families.length > 0) appearance.fontFamily = families.join(', ');\n\tconst fontColor = hexColor(field(value, 'font-color'));\n\tif (fontColor) appearance.fontColor = fontColor;\n\tconst backgroundColor = hexColor(field(value, 'background-color'));\n\tif (backgroundColor) appearance.backgroundColor = backgroundColor;\n\tconst lineHeight = finiteNumber(field(value, 'line-height')) ?? finiteNumber(field(value, 'line-spacing'));\n\tif (lineHeight !== undefined && lineHeight > 0) appearance.lineHeight = lineHeight;\n\tconst letterSpacing = finiteNumber(field(value, 'letter-spacing'));\n\tif (letterSpacing !== undefined) appearance.letterSpacing = letterSpacing;\n\tconst wordSpacing = finiteNumber(field(value, 'word-spacing'));\n\tif (wordSpacing !== undefined) appearance.wordSpacing = wordSpacing;\n\treturn Object.keys(appearance).length > 0 ? appearance : undefined;\n}\n\n/**\n * Parse an AfA PNP 3.0 document into the `PnpProfile` the item player renders. Returns\n * an empty profile when the input holds none. `parseAfaPnpXml` returns the whole record.\n */\nexport function parsePnpXml(xml: string | Element): PnpProfile {\n\tconst record = parseAfaPnpXml(xml);\n\treturn record ? pnpProfileFromAfa(record) : {};\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction findProfile(parent: NhpElement): NhpElement | null {\n\tfor (const child of elementChildren(parent)) {\n\t\tif (splitName(child.rawTagName).local === 'access-for-all-pnp') return child;\n\t\tconst nested = findProfile(child);\n\t\tif (nested) return nested;\n\t}\n\treturn null;\n}\n\n/** Prefixes bound to an AfA PNP namespace on the profile or its ancestors. */\nfunction collectAfaPrefixes(root: NhpElement): Set<string> {\n\tconst prefixes = new Set<string>();\n\tfor (let el: NhpElement | null = root; el; el = el.parentNode as NhpElement | null) {\n\t\tfor (const [name, value] of Object.entries(el.rawAttributes ?? {})) {\n\t\t\tif (name.startsWith('xmlns:') && value.includes('imsafa3p0pnp')) prefixes.add(name.slice(6));\n\t\t}\n\t}\n\treturn prefixes;\n}\n\nfunction elementChildren(parent: NhpElement): NhpElement[] {\n\treturn parent.childNodes.filter((child): child is NhpElement => child.nodeType === 1);\n}\n\nfunction splitName(name: string | undefined): { prefix?: string; local: string } {\n\tconst raw = name ?? '';\n\tconst colon = raw.indexOf(':');\n\treturn colon < 0 ? { local: raw } : { prefix: raw.slice(0, colon), local: raw.slice(colon + 1) };\n}\n\nfunction elementValue(el: NhpElement): unknown {\n\tconst value: Record<string, unknown> = {};\n\tfor (const [name, raw] of Object.entries(el.rawAttributes ?? {})) {\n\t\tif (name === 'xmlns' || name.startsWith('xmlns:') || name.startsWith('xsi:')) continue;\n\t\taddValue(value, name === 'xml:lang' ? 'language' : splitName(name).local, scalar(raw));\n\t}\n\tconst children = elementChildren(el);\n\tfor (const child of children) {\n\t\taddValue(value, splitName(child.rawTagName).local, elementValue(child));\n\t}\n\tif (children.length > 0 || Object.keys(value).length > 0) return value;\n\tconst text = el.text.trim();\n\treturn text ? scalar(text) : {};\n}\n\nfunction addValue(target: Record<string, unknown>, key: string, value: unknown): void {\n\tif (!(key in target)) {\n\t\ttarget[key] = value;\n\t\treturn;\n\t}\n\tconst existing = target[key];\n\ttarget[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];\n}\n\nfunction scalar(raw: string): string | number | boolean {\n\tconst value = raw.trim();\n\tif (value === 'true') return true;\n\tif (value === 'false') return false;\n\tif (/^-?\\d+(?:\\.\\d+)?$/.test(value)) return Number(value);\n\treturn value;\n}\n\nfunction field(value: unknown, key: string): unknown {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n\t\t? (value as Record<string, unknown>)[key]\n\t\t: undefined;\n}\n\nfunction isPresent(value: unknown): boolean {\n\treturn value !== undefined && value !== null && value !== false;\n}\n\nfunction finiteNumber(value: unknown): number | undefined {\n\treturn typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\n/**\n * An AfA hex colour (`#fff`, `ffffff`) as CSS; undefined for anything else. An all-digit\n * colour reaches here as the number the record read it as, so it is padded back to six.\n */\nfunction hexColor(value: unknown): string | undefined {\n\tif (typeof value !== 'string' && typeof value !== 'number') return undefined;\n\tconst hex = typeof value === 'number' ? String(value).padStart(6, '0') : value.trim().replace(/^#/, '');\n\treturn /^(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hex) ? `#${hex.toLowerCase()}` : undefined;\n}\n\nfunction normalizeLanguageCode(value: unknown): string | undefined {\n\tif (typeof value !== 'string') return undefined;\n\tconst languageCode = value.trim();\n\tif (!/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/.test(languageCode)) return undefined;\n\treturn languageCode;\n}\n"]}
@@ -14,6 +14,29 @@ export interface PnpProfile {
14
14
  * Stored here for forward-compatibility but not yet applied by the player.
15
15
  */
16
16
  magnification?: number;
17
+ /** AfA `language-of-interface`: the language the host renders the player's own text in. */
18
+ interfaceLanguage?: string;
19
+ /**
20
+ * AfA `invert-display-polarity`: light content on a dark ground. The colours, when given,
21
+ * replace the inverted ones. Sets `data-qti-invert-polarity` on the player root.
22
+ */
23
+ invertPolarity?: {
24
+ foreground?: string;
25
+ background?: string;
26
+ };
27
+ /** AfA `layout-single-column`: layout grids stack. Sets `data-qti-layout="single-column"`. */
28
+ singleColumn?: boolean;
29
+ /** AfA `text-appearance`, applied as custom properties on the player root. */
30
+ textAppearance?: PnpTextAppearance;
31
+ /**
32
+ * Present each interaction's answer set as a labelled ARIA group for assistive
33
+ * technology: the choice and match interactions wrap their answers in a
34
+ * `role="group"` labelled by the interaction prompt, and the match columns get
35
+ * visible, programmatically associated sub-labels. Neither APIP 1.0 nor AfA PNP
36
+ * 3.0 defines a structured-label term; this is a player extension, so hosts set
37
+ * it in the JSON profile (it has no AfA XML feature).
38
+ */
39
+ structuredLabelSupport?: boolean;
17
40
  };
18
41
  content?: {
19
42
  /** Show glossary trigger buttons on [data-catalog-idref] terms (G-10). */
@@ -34,12 +57,46 @@ export interface PnpProfile {
34
57
  extendedTime?: {
35
58
  active: boolean;
36
59
  multiplier: number;
60
+ /** AfA `fixed-minutes`: minutes added to each time limit, with `multiplier` 1. */
61
+ fixedMinutes?: number;
37
62
  };
38
63
  };
39
64
  cognitive?: {
40
65
  /** Render per-choice elimination toggle buttons in choiceInteraction and orderInteraction. */
41
66
  eliminationTool?: boolean;
67
+ /** AfA `answer-masking`: each choice of a choiceInteraction stays masked until the candidate reveals it. */
68
+ answerMasking?: boolean;
42
69
  };
70
+ /**
71
+ * Tool supports in pie-players' `PersonalNeedsProfile` terms, from AfA `calculator-on-screen`,
72
+ * `spoken`, `line-reader` and `dictionary-on-screen`. The section player enables the tools it
73
+ * offers from them; a host passes them to its own toolkit.
74
+ */
75
+ tools?: PnpToolSupports;
76
+ }
77
+ export interface PnpTextAppearance {
78
+ /** Font size in points. */
79
+ fontSize?: number;
80
+ /** A CSS font-family list: the named fonts, then the generic face. */
81
+ fontFamily?: string;
82
+ fontColor?: string;
83
+ backgroundColor?: string;
84
+ /** Unitless line height, from AfA `line-height`, else `line-spacing`. */
85
+ lineHeight?: number;
86
+ /** Letter spacing in em. */
87
+ letterSpacing?: number;
88
+ /** Word spacing in em. */
89
+ wordSpacing?: number;
90
+ }
91
+ export interface PnpToolSupports {
92
+ /** Tool ids granted to the candidate. */
93
+ supports?: string[];
94
+ /** Tool ids withdrawn from the candidate. */
95
+ prohibitedSupports?: string[];
96
+ /** Granted tool ids turned on at start. */
97
+ activateAtInit?: string[];
98
+ /** The candidate's settings per tool id. */
99
+ toolParameters?: Record<string, Record<string, unknown>>;
43
100
  }
44
101
  export interface CatalogSupportPreferences {
45
102
  ttsPronunciation?: CatalogSupportPreference;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/pnp/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The candidate needs the item player renders, from a per-candidate AfA PNP 3.0\n * profile (`pnpProfileFromAfa`). All fields are optional; absent means \"use platform default\".\n */\nexport interface PnpProfile {\n\tdisplay?: {\n\t\t/**\n\t\t * Named color scheme. Maps to the data-qti-colorscheme attribute on the player root.\n\t\t * 'default' or undefined → attribute removed (browser/host default).\n\t\t */\n\t\tcolorScheme?:\n\t\t\t| 'default'\n\t\t\t| 'defaultreverse'\n\t\t\t| 'blackwhite'\n\t\t\t| 'whiteblack'\n\t\t\t| 'blackrose'\n\t\t\t| 'roseblack'\n\t\t\t| 'yellowblue'\n\t\t\t| 'blueyellow'\n\t\t\t| 'mgraydgray'\n\t\t\t| 'dgraymgray'\n\t\t\t| 'blackcyan'\n\t\t\t| 'cyanblack'\n\t\t\t| 'blackcream'\n\t\t\t| 'creamblack'\n\t\t\t| 'whitenav'\n\t\t\t| 'medgray';\n\t\t/**\n\t\t * CSS zoom factor (1.0 = 100%). Deferred — set by browser zoom or host stylesheet.\n\t\t * Stored here for forward-compatibility but not yet applied by the player.\n\t\t */\n\t\tmagnification?: number;\n\t};\n\tcontent?: {\n\t\t/** Show glossary trigger buttons on [data-catalog-idref] terms (G-10). */\n\t\tglossaryOnScreen?: boolean;\n\t\t/** Show keyword-translation trigger buttons using the given language code. */\n\t\tkeywordTranslation?: { active: boolean; languageCode: string };\n\t\t/** Show illustrated glossary supports when catalog entries provide them. */\n\t\tillustratedGlossary?: boolean;\n\t\t/** Enable user-initiated host-routed catalog supports. */\n\t\tcatalogSupports?: CatalogSupportPreferences;\n\t\t/**\n\t\t * Scale assessment time limits. multiplier: 1.5 means 50% extra time.\n\t\t * multiplier: Infinity removes the time limit entirely.\n\t\t */\n\t\textendedTime?: { active: boolean; multiplier: number };\n\t};\n\tcognitive?: {\n\t\t/** Render per-choice elimination toggle buttons in choiceInteraction and orderInteraction. */\n\t\teliminationTool?: boolean;\n\t};\n}\n\nexport interface CatalogSupportPreferences {\n\tttsPronunciation?: CatalogSupportPreference;\n\tsigningDefinition?: CatalogSupportPreference;\n\tbrailleText?: CatalogSupportPreference;\n\taudioDescription?: CatalogSupportPreference;\n\textendedDescription?: CatalogSupportPreference;\n\t/**\n\t * Host-defined catalog usage names. Use QTI/catalog usage strings such as\n\t * \"custom-audio\" rather than DOM event names or implementation-specific APIs.\n\t */\n\t[usage: string]: CatalogSupportPreference | undefined;\n}\n\nexport type CatalogSupportPreference = boolean | CatalogSupportPreferenceOptions;\n\nexport interface CatalogSupportPreferenceOptions {\n\t/** Defaults to true when omitted. */\n\tactive?: boolean;\n\t/** Preferred catalog entry language for this support, such as \"en-US\" or \"es\". */\n\tlanguageCode?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/pnp/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The candidate needs the item player renders, from a per-candidate AfA PNP 3.0\n * profile (`pnpProfileFromAfa`). All fields are optional; absent means \"use platform default\".\n */\nexport interface PnpProfile {\n\tdisplay?: {\n\t\t/**\n\t\t * Named color scheme. Maps to the data-qti-colorscheme attribute on the player root.\n\t\t * 'default' or undefined → attribute removed (browser/host default).\n\t\t */\n\t\tcolorScheme?:\n\t\t\t| 'default'\n\t\t\t| 'defaultreverse'\n\t\t\t| 'blackwhite'\n\t\t\t| 'whiteblack'\n\t\t\t| 'blackrose'\n\t\t\t| 'roseblack'\n\t\t\t| 'yellowblue'\n\t\t\t| 'blueyellow'\n\t\t\t| 'mgraydgray'\n\t\t\t| 'dgraymgray'\n\t\t\t| 'blackcyan'\n\t\t\t| 'cyanblack'\n\t\t\t| 'blackcream'\n\t\t\t| 'creamblack'\n\t\t\t| 'whitenav'\n\t\t\t| 'medgray';\n\t\t/**\n\t\t * CSS zoom factor (1.0 = 100%). Deferred — set by browser zoom or host stylesheet.\n\t\t * Stored here for forward-compatibility but not yet applied by the player.\n\t\t */\n\t\tmagnification?: number;\n\t\t/** AfA `language-of-interface`: the language the host renders the player's own text in. */\n\t\tinterfaceLanguage?: string;\n\t\t/**\n\t\t * AfA `invert-display-polarity`: light content on a dark ground. The colours, when given,\n\t\t * replace the inverted ones. Sets `data-qti-invert-polarity` on the player root.\n\t\t */\n\t\tinvertPolarity?: { foreground?: string; background?: string };\n\t\t/** AfA `layout-single-column`: layout grids stack. Sets `data-qti-layout=\"single-column\"`. */\n\t\tsingleColumn?: boolean;\n\t\t/** AfA `text-appearance`, applied as custom properties on the player root. */\n\t\ttextAppearance?: PnpTextAppearance;\n\t\t/**\n\t\t * Present each interaction's answer set as a labelled ARIA group for assistive\n\t\t * technology: the choice and match interactions wrap their answers in a\n\t\t * `role=\"group\"` labelled by the interaction prompt, and the match columns get\n\t\t * visible, programmatically associated sub-labels. Neither APIP 1.0 nor AfA PNP\n\t\t * 3.0 defines a structured-label term; this is a player extension, so hosts set\n\t\t * it in the JSON profile (it has no AfA XML feature).\n\t\t */\n\t\tstructuredLabelSupport?: boolean;\n\t};\n\tcontent?: {\n\t\t/** Show glossary trigger buttons on [data-catalog-idref] terms (G-10). */\n\t\tglossaryOnScreen?: boolean;\n\t\t/** Show keyword-translation trigger buttons using the given language code. */\n\t\tkeywordTranslation?: { active: boolean; languageCode: string };\n\t\t/** Show illustrated glossary supports when catalog entries provide them. */\n\t\tillustratedGlossary?: boolean;\n\t\t/** Enable user-initiated host-routed catalog supports. */\n\t\tcatalogSupports?: CatalogSupportPreferences;\n\t\t/**\n\t\t * Scale assessment time limits. multiplier: 1.5 means 50% extra time.\n\t\t * multiplier: Infinity removes the time limit entirely.\n\t\t */\n\t\textendedTime?: {\n\t\t\tactive: boolean;\n\t\t\tmultiplier: number;\n\t\t\t/** AfA `fixed-minutes`: minutes added to each time limit, with `multiplier` 1. */\n\t\t\tfixedMinutes?: number;\n\t\t};\n\t};\n\tcognitive?: {\n\t\t/** Render per-choice elimination toggle buttons in choiceInteraction and orderInteraction. */\n\t\teliminationTool?: boolean;\n\t\t/** AfA `answer-masking`: each choice of a choiceInteraction stays masked until the candidate reveals it. */\n\t\tanswerMasking?: boolean;\n\t};\n\t/**\n\t * Tool supports in pie-players' `PersonalNeedsProfile` terms, from AfA `calculator-on-screen`,\n\t * `spoken`, `line-reader` and `dictionary-on-screen`. The section player enables the tools it\n\t * offers from them; a host passes them to its own toolkit.\n\t */\n\ttools?: PnpToolSupports;\n}\n\nexport interface PnpTextAppearance {\n\t/** Font size in points. */\n\tfontSize?: number;\n\t/** A CSS font-family list: the named fonts, then the generic face. */\n\tfontFamily?: string;\n\tfontColor?: string;\n\tbackgroundColor?: string;\n\t/** Unitless line height, from AfA `line-height`, else `line-spacing`. */\n\tlineHeight?: number;\n\t/** Letter spacing in em. */\n\tletterSpacing?: number;\n\t/** Word spacing in em. */\n\twordSpacing?: number;\n}\n\nexport interface PnpToolSupports {\n\t/** Tool ids granted to the candidate. */\n\tsupports?: string[];\n\t/** Tool ids withdrawn from the candidate. */\n\tprohibitedSupports?: string[];\n\t/** Granted tool ids turned on at start. */\n\tactivateAtInit?: string[];\n\t/** The candidate's settings per tool id. */\n\ttoolParameters?: Record<string, Record<string, unknown>>;\n}\n\nexport interface CatalogSupportPreferences {\n\tttsPronunciation?: CatalogSupportPreference;\n\tsigningDefinition?: CatalogSupportPreference;\n\tbrailleText?: CatalogSupportPreference;\n\taudioDescription?: CatalogSupportPreference;\n\textendedDescription?: CatalogSupportPreference;\n\t/**\n\t * Host-defined catalog usage names. Use QTI/catalog usage strings such as\n\t * \"custom-audio\" rather than DOM event names or implementation-specific APIs.\n\t */\n\t[usage: string]: CatalogSupportPreference | undefined;\n}\n\nexport type CatalogSupportPreference = boolean | CatalogSupportPreferenceOptions;\n\nexport interface CatalogSupportPreferenceOptions {\n\t/** Defaults to true when omitted. */\n\tactive?: boolean;\n\t/** Preferred catalog entry language for this support, such as \"en-US\" or \"es\". */\n\tlanguageCode?: string;\n}\n"]}
@@ -16,6 +16,8 @@ export type ItemPresentationResponseMap = Record<string, ItemPresentationRespons
16
16
  */
17
17
  export interface ItemPresentationSource {
18
18
  itemBodyHtml: HtmlContent;
19
+ /** The content's `xml:lang`, when the item declares one. */
20
+ contentLanguage?: string;
19
21
  interactions: readonly BaseInteractionData[];
20
22
  correctResponses: Record<string, unknown>;
21
23
  componentRegistry: ComponentRegistry;
@@ -34,6 +36,10 @@ export interface CreateItemPresentationOptions {
34
36
  heuristicsConfig?: QtiHeuristicsConfig;
35
37
  itemBodyScopeSelector?: string;
36
38
  renderItemBodyRubrics?: boolean;
39
+ /** False drops every feedbackInline and feedbackBlock, as test-level showFeedback="false" requires. */
40
+ showFeedback?: boolean;
41
+ /** True exposes correct responses whatever the role, as test-level showSolution requires. */
42
+ showSolution?: boolean;
37
43
  onComponentError?: (interaction: BaseInteractionData, error: unknown) => void;
38
44
  }
39
45
  export interface BlockInteractionMount {
@@ -48,6 +54,9 @@ export interface BlockInteractionMount {
48
54
  readonly correctResponse: unknown;
49
55
  readonly pnp: PnpProfile | undefined;
50
56
  readonly eliminationTool: boolean;
57
+ readonly answerMasking: boolean;
58
+ /** Label the interaction's answer set as an ARIA group for assistive technology (G-13). */
59
+ readonly structuredLabelSupport: boolean;
51
60
  readonly disabled: boolean;
52
61
  readonly componentRole: 'scorer' | undefined;
53
62
  }
@@ -76,6 +85,8 @@ export type ItemPresentationFlowNode = {
76
85
  export interface ItemPresentation {
77
86
  readonly capabilities: RoleCapabilities;
78
87
  readonly disabled: boolean;
88
+ /** The language the item body is written in, for its `lang`; undefined when undeclared. */
89
+ readonly contentLanguage?: string;
79
90
  readonly correctResponses: Readonly<Record<string, unknown>>;
80
91
  /** Direct assessmentItem rubrics that remain outside the item-body flow. */
81
92
  readonly directRubrics: readonly RubricBlock[];
@@ -84,6 +95,6 @@ export interface ItemPresentation {
84
95
  /** Policy-checked CSS is kept out of the HTML/Trusted Types pipeline. */
85
96
  readonly scopedCss: string;
86
97
  }
87
- export declare function createItemPresentation({ source, responses, disabled, role, outcomeValues, heuristicsConfig, itemBodyScopeSelector, renderItemBodyRubrics, onComponentError, }: CreateItemPresentationOptions): ItemPresentation;
98
+ export declare function createItemPresentation({ source, responses, disabled, role, outcomeValues, heuristicsConfig, itemBodyScopeSelector, renderItemBodyRubrics, showFeedback, showSolution, onComponentError, }: CreateItemPresentationOptions): ItemPresentation;
88
99
  export declare function interactionKey(interaction: BaseInteractionData): string;
89
100
  export {};
@@ -7,8 +7,11 @@ import { processFeedbackInline } from '../components/utils/feedbackUtils.js';
7
7
  import { buildScopedStylesheetCss } from '../components/utils/stylesheetRender.js';
8
8
  import { buildEffectiveStimulusContent, injectStimulusContent } from '../components/utils/stimulusRender.js';
9
9
  import { createInlineRenderPlan, isInlineInteractionTagName, isInlineInteractionType, } from '../interactions/inline/render-plan.js';
10
- export function createItemPresentation({ source, responses = {}, disabled = false, role = 'candidate', outcomeValues = {}, heuristicsConfig, itemBodyScopeSelector = '[data-qti-item-body-scope]', renderItemBodyRubrics = true, onComponentError, }) {
11
- const roleCapabilities = getRoleCapabilities(role);
10
+ export function createItemPresentation({ source, responses = {}, disabled = false, role = 'candidate', outcomeValues = {}, heuristicsConfig, itemBodyScopeSelector = '[data-qti-item-body-scope]', renderItemBodyRubrics = true, showFeedback = true, showSolution = false, onComponentError, }) {
11
+ const baseCapabilities = getRoleCapabilities(role);
12
+ const roleCapabilities = showSolution
13
+ ? { ...baseCapabilities, canViewCorrectResponses: true }
14
+ : baseCapabilities;
12
15
  const effectiveDisabled = disabled || roleCapabilities.isReadOnly;
13
16
  const correctResponses = roleCapabilities.canViewCorrectResponses ? source.correctResponses : {};
14
17
  const { html, scopedCss } = buildItemBodyPresentation({
@@ -18,6 +21,7 @@ export function createItemPresentation({ source, responses = {}, disabled = fals
18
21
  heuristicsConfig,
19
22
  itemBodyScopeSelector,
20
23
  renderItemBodyRubrics,
24
+ showFeedback,
21
25
  });
22
26
  const inlineFlow = createInlineRenderPlan(html, source.interactions).map((segment) => {
23
27
  if (segment.type === 'html') {
@@ -63,6 +67,7 @@ export function createItemPresentation({ source, responses = {}, disabled = fals
63
67
  return freezePresentation({
64
68
  capabilities: roleCapabilities,
65
69
  disabled: effectiveDisabled,
70
+ ...(source.contentLanguage ? { contentLanguage: source.contentLanguage } : {}),
66
71
  correctResponses,
67
72
  directRubrics: source.directRubrics ?? [],
68
73
  flow: [...inlineFlow, ...blockFlow],
@@ -81,7 +86,7 @@ function freezePresentation(value) {
81
86
  }
82
87
  return value;
83
88
  }
84
- function buildItemBodyPresentation({ source, role, outcomeValues, heuristicsConfig, itemBodyScopeSelector, renderItemBodyRubrics, }) {
89
+ function buildItemBodyPresentation({ source, role, outcomeValues, heuristicsConfig, itemBodyScopeSelector, renderItemBodyRubrics, showFeedback, }) {
85
90
  let html = htmlToString(source.itemBodyHtml);
86
91
  const scopedCss = buildScopedStylesheetCss(source.deliveryContext, itemBodyScopeSelector);
87
92
  const effectiveStimulusContent = buildEffectiveStimulusContent(source.deliveryContext, (content) => sanitizeHtml(content, { security: source.security }));
@@ -92,6 +97,7 @@ function buildItemBodyPresentation({ source, role, outcomeValues, heuristicsConf
92
97
  outcomeValues,
93
98
  applyHeuristics: heuristics.feedbackTextFormatting,
94
99
  wrapWithSpan: false,
100
+ hideAll: !showFeedback,
95
101
  });
96
102
  return { html: hideBlockInteractionMarkup(html), scopedCss };
97
103
  }
@@ -200,6 +206,8 @@ function createBlockInteractionMounts({ interactions, source, responses, correct
200
206
  : null,
201
207
  pnp: source.pnp,
202
208
  eliminationTool: source.pnp?.cognitive?.eliminationTool === true,
209
+ answerMasking: source.pnp?.cognitive?.answerMasking === true,
210
+ structuredLabelSupport: source.pnp?.display?.structuredLabelSupport === true,
203
211
  disabled: effectiveDisabled,
204
212
  componentRole: roleCapabilities.canViewCorrectResponses ? 'scorer' : undefined,
205
213
  };