@pie-qti/item-player 1.0.0-beta.4 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -6
- package/dist/catalog/applyGlossaryTriggers.js +14 -2
- package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
- package/dist/catalog/catalogExtractor.js +2 -4
- package/dist/catalog/catalogExtractor.js.map +1 -1
- package/dist/catalog/sessionCatalog.d.ts +46 -0
- package/dist/catalog/sessionCatalog.js +87 -0
- package/dist/catalog/sessionCatalog.js.map +1 -0
- package/dist/components/utils/endAttempt.d.ts +16 -0
- package/dist/components/utils/endAttempt.js +28 -0
- package/dist/components/utils/endAttempt.js.map +1 -0
- package/dist/components/utils/focus.d.ts +19 -0
- package/dist/components/utils/focus.js +67 -0
- package/dist/components/utils/focus.js.map +1 -0
- package/dist/components/utils/itemBodyRenderer.d.ts +44 -0
- package/dist/components/utils/itemBodyRenderer.js +177 -0
- package/dist/components/utils/itemBodyRenderer.js.map +1 -0
- package/dist/components/utils/sentenceContext.d.ts +6 -0
- package/dist/components/utils/sentenceContext.js +16 -0
- package/dist/components/utils/sentenceContext.js.map +1 -0
- package/dist/core/AssessmentItemDefinition.d.ts +20 -1
- package/dist/core/AssessmentItemDefinition.js +12 -31
- package/dist/core/AssessmentItemDefinition.js.map +1 -1
- package/dist/core/ComponentRegistry.d.ts +92 -0
- package/dist/core/ComponentRegistry.js +7 -1
- package/dist/core/ComponentRegistry.js.map +1 -1
- package/dist/core/ItemSession.d.ts +18 -1
- package/dist/core/ItemSession.js +79 -41
- package/dist/core/ItemSession.js.map +1 -1
- package/dist/core/Player.d.ts +118 -141
- package/dist/core/Player.js +390 -1233
- package/dist/core/Player.js.map +1 -1
- package/dist/core/compliance.d.ts +72 -0
- package/dist/core/compliance.js +147 -0
- package/dist/core/compliance.js.map +1 -0
- package/dist/core/declarations/declarationBuilder.d.ts +29 -0
- package/dist/core/declarations/declarationBuilder.js +284 -0
- package/dist/core/declarations/declarationBuilder.js.map +1 -0
- package/dist/core/declarations/declarationValues.d.ts +11 -0
- package/dist/core/declarations/declarationValues.js +168 -0
- package/dist/core/declarations/declarationValues.js.map +1 -0
- package/dist/core/matchGroups.d.ts +36 -0
- package/dist/core/matchGroups.js +100 -0
- package/dist/core/matchGroups.js.map +1 -0
- package/dist/core/nameMappers.d.ts +35 -0
- package/dist/core/nameMappers.js +47 -0
- package/dist/core/nameMappers.js.map +1 -0
- package/dist/core/parsingLimits.d.ts +4 -0
- package/dist/core/parsingLimits.js +5 -2
- package/dist/core/parsingLimits.js.map +1 -1
- package/dist/core/processing/responseProcessing.d.ts +88 -0
- package/dist/core/processing/responseProcessing.js +317 -0
- package/dist/core/processing/responseProcessing.js.map +1 -0
- package/dist/core/processing/responseValidation.d.ts +55 -0
- package/dist/core/processing/responseValidation.js +335 -0
- package/dist/core/processing/responseValidation.js.map +1 -0
- package/dist/core/rendering/contentPass.d.ts +31 -0
- package/dist/core/rendering/contentPass.js +152 -0
- package/dist/core/rendering/contentPass.js.map +1 -0
- package/dist/core/rendering/htmlRender.d.ts +21 -0
- package/dist/core/rendering/htmlRender.js +56 -0
- package/dist/core/rendering/htmlRender.js.map +1 -0
- package/dist/core/responseProcessingTemplates.d.ts +23 -0
- package/dist/core/responseProcessingTemplates.js +45 -0
- package/dist/core/responseProcessingTemplates.js.map +1 -0
- package/dist/core/rolePolicy.d.ts +5 -0
- package/dist/core/rolePolicy.js +21 -0
- package/dist/core/rolePolicy.js.map +1 -1
- package/dist/core/sanitizer.js +8 -14
- package/dist/core/sanitizer.js.map +1 -1
- package/dist/core/serialization/sessionState.d.ts +56 -0
- package/dist/core/serialization/sessionState.js +139 -0
- package/dist/core/serialization/sessionState.js.map +1 -0
- package/dist/core/serialization/valueForms.d.ts +32 -0
- package/dist/core/serialization/valueForms.js +112 -0
- package/dist/core/serialization/valueForms.js.map +1 -0
- package/dist/document/AssessmentItemDocument.d.ts +27 -1
- package/dist/document/AssessmentItemDocument.js +67 -31
- package/dist/document/AssessmentItemDocument.js.map +1 -1
- package/dist/element-class-BUFpUrJP.js +3792 -0
- package/dist/element-class-BUFpUrJP.js.map +1 -0
- package/dist/element-class.d.ts +34 -1
- package/dist/element-class.js +1 -1
- package/dist/element.js +2 -3
- package/dist/extraction/ExtractionRegistry.js +6 -12
- package/dist/extraction/ExtractionRegistry.js.map +1 -1
- package/dist/extraction/createContext.d.ts +2 -2
- package/dist/extraction/createContext.js.map +1 -1
- package/dist/extraction/index.d.ts +2 -2
- package/dist/extraction/index.js +1 -1
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/interactionCoverage.d.ts +31 -0
- package/dist/extraction/interactionCoverage.js +40 -0
- package/dist/extraction/interactionCoverage.js.map +1 -0
- package/dist/extraction/interactionExtractionPipeline.js +5 -10
- package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
- package/dist/extraction/interactionSecurity.js +1 -28
- package/dist/extraction/interactionSecurity.js.map +1 -1
- package/dist/extraction/mergeDeliveryFields.d.ts +13 -0
- package/dist/extraction/mergeDeliveryFields.js +17 -0
- package/dist/extraction/mergeDeliveryFields.js.map +1 -0
- package/dist/extraction/responseIdentifier.d.ts +19 -0
- package/dist/extraction/responseIdentifier.js +29 -0
- package/dist/extraction/responseIdentifier.js.map +1 -0
- package/dist/extraction/types.d.ts +11 -18
- package/dist/extraction/types.js +0 -12
- package/dist/extraction/types.js.map +1 -1
- package/dist/extraction/utils.d.ts +14 -0
- package/dist/extraction/utils.js +35 -5
- package/dist/extraction/utils.js.map +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/interactions/associate/extractor.d.ts +1 -0
- package/dist/interactions/associate/extractor.js +10 -12
- package/dist/interactions/associate/extractor.js.map +1 -1
- package/dist/interactions/choice/extractor.js +6 -13
- package/dist/interactions/choice/extractor.js.map +1 -1
- package/dist/interactions/drawing/extractor.d.ts +6 -0
- package/dist/interactions/drawing/extractor.js +30 -9
- package/dist/interactions/drawing/extractor.js.map +1 -1
- package/dist/interactions/end-attempt/extractor.js +2 -1
- package/dist/interactions/end-attempt/extractor.js.map +1 -1
- package/dist/interactions/extended-text/extractor.d.ts +6 -1
- package/dist/interactions/extended-text/extractor.js +10 -5
- package/dist/interactions/extended-text/extractor.js.map +1 -1
- package/dist/interactions/extended-text/response.js +18 -18
- package/dist/interactions/extended-text/response.js.map +1 -1
- package/dist/interactions/gap-match/extractor.d.ts +40 -2
- package/dist/interactions/gap-match/extractor.js +197 -39
- package/dist/interactions/gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-associate/extractor.d.ts +11 -0
- package/dist/interactions/graphic-associate/extractor.js +35 -24
- package/dist/interactions/graphic-associate/extractor.js.map +1 -1
- package/dist/interactions/graphic-gap-match/extractor.d.ts +21 -0
- package/dist/interactions/graphic-gap-match/extractor.js +79 -43
- package/dist/interactions/graphic-gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-order/extractor.d.ts +15 -0
- package/dist/interactions/graphic-order/extractor.js +39 -24
- package/dist/interactions/graphic-order/extractor.js.map +1 -1
- package/dist/interactions/hotspot/extractor.d.ts +6 -0
- package/dist/interactions/hotspot/extractor.js +31 -16
- package/dist/interactions/hotspot/extractor.js.map +1 -1
- package/dist/interactions/hottext/extractor.js +2 -12
- package/dist/interactions/hottext/extractor.js.map +1 -1
- package/dist/interactions/inline/accessibleName.d.ts +29 -0
- package/dist/interactions/inline/accessibleName.js +35 -0
- package/dist/interactions/inline/accessibleName.js.map +1 -0
- package/dist/interactions/inline/render-plan.d.ts +5 -14
- package/dist/interactions/inline/render-plan.js +5 -56
- package/dist/interactions/inline/render-plan.js.map +1 -1
- package/dist/interactions/inline-choice/extractor.d.ts +4 -0
- package/dist/interactions/inline-choice/extractor.js +13 -12
- package/dist/interactions/inline-choice/extractor.js.map +1 -1
- package/dist/interactions/match/extractor.d.ts +2 -0
- package/dist/interactions/match/extractor.js +14 -28
- package/dist/interactions/match/extractor.js.map +1 -1
- package/dist/interactions/media/extractor.d.ts +5 -11
- package/dist/interactions/media/extractor.js +100 -36
- package/dist/interactions/media/extractor.js.map +1 -1
- package/dist/interactions/modules.js +8 -2
- package/dist/interactions/modules.js.map +1 -1
- package/dist/interactions/order/extractor.d.ts +2 -0
- package/dist/interactions/order/extractor.js +8 -12
- package/dist/interactions/order/extractor.js.map +1 -1
- package/dist/interactions/order/limits.d.ts +29 -0
- package/dist/interactions/order/limits.js +28 -0
- package/dist/interactions/order/limits.js.map +1 -0
- package/dist/interactions/portable-custom/extractor.js +18 -14
- package/dist/interactions/portable-custom/extractor.js.map +1 -1
- package/dist/interactions/position-object/extractor.d.ts +18 -1
- package/dist/interactions/position-object/extractor.js +81 -22
- package/dist/interactions/position-object/extractor.js.map +1 -1
- package/dist/interactions/select-point/extractor.d.ts +6 -0
- package/dist/interactions/select-point/extractor.js +31 -19
- package/dist/interactions/select-point/extractor.js.map +1 -1
- package/dist/interactions/shared/imageAlt.d.ts +54 -0
- package/dist/interactions/shared/imageAlt.js +84 -0
- package/dist/interactions/shared/imageAlt.js.map +1 -0
- package/dist/interactions/shared/interactionImage.d.ts +32 -0
- package/dist/interactions/shared/interactionImage.js +39 -0
- package/dist/interactions/shared/interactionImage.js.map +1 -0
- package/dist/interactions/shared/specDefaults.d.ts +20 -0
- package/dist/interactions/shared/specDefaults.js +25 -0
- package/dist/interactions/shared/specDefaults.js.map +1 -0
- package/dist/interactions/shared/types.d.ts +212 -40
- package/dist/interactions/shared/types.js.map +1 -1
- package/dist/interactions/text-entry/extractor.d.ts +9 -0
- package/dist/interactions/text-entry/extractor.js +9 -0
- package/dist/interactions/text-entry/extractor.js.map +1 -1
- package/dist/interactions/text-entry/inlineInputStyle.d.ts +10 -0
- package/dist/interactions/text-entry/inlineInputStyle.js +12 -0
- package/dist/interactions/text-entry/inlineInputStyle.js.map +1 -0
- package/dist/interactions/text-entry/inputMode.d.ts +35 -0
- package/dist/interactions/text-entry/inputMode.js +134 -0
- package/dist/interactions/text-entry/inputMode.js.map +1 -0
- package/dist/interactions/text-entry/response.d.ts +15 -0
- package/dist/interactions/text-entry/response.js +25 -0
- package/dist/interactions/text-entry/response.js.map +1 -0
- package/dist/interactions/upload/extractor.js +2 -2
- package/dist/interactions/upload/extractor.js.map +1 -1
- package/dist/pci/PciHost.d.ts +1 -1
- package/dist/pci/PciHost.js +11 -11
- package/dist/pci/PciHost.js.map +1 -1
- package/dist/pci/index.d.ts +1 -0
- package/dist/pci/index.js.map +1 -1
- package/dist/pci/modulePaths.d.ts +16 -0
- package/dist/pci/modulePaths.js +33 -0
- package/dist/pci/modulePaths.js.map +1 -0
- package/dist/pci/pageRealmSession.js +3 -15
- package/dist/pci/pageRealmSession.js.map +1 -1
- package/dist/pci/qtiVariableJson.d.ts +46 -3
- package/dist/pci/qtiVariableJson.js +247 -53
- package/dist/pci/qtiVariableJson.js.map +1 -1
- package/dist/pci/sandbox/SandboxedPciSession.d.ts +3 -0
- package/dist/pci/sandbox/SandboxedPciSession.js +15 -14
- package/dist/pci/sandbox/SandboxedPciSession.js.map +1 -1
- package/dist/pci/sandbox/iframeConnector.d.ts +18 -4
- package/dist/pci/sandbox/iframeConnector.js +35 -6
- package/dist/pci/sandbox/iframeConnector.js.map +1 -1
- package/dist/pci/sandbox/protocol.d.ts +14 -0
- package/dist/pci/sandbox/protocol.js.map +1 -1
- package/dist/pci/sessionHosts.d.ts +47 -0
- package/dist/pci/sessionHosts.js +66 -0
- package/dist/pci/sessionHosts.js.map +1 -0
- package/dist/pci/types.d.ts +9 -3
- package/dist/pci/types.js.map +1 -1
- package/dist/pnp/applyPnp.d.ts +20 -3
- package/dist/pnp/applyPnp.js +84 -9
- package/dist/pnp/applyPnp.js.map +1 -1
- package/dist/pnp/parsePnpXml.js +2 -0
- package/dist/pnp/parsePnpXml.js.map +1 -1
- package/dist/pnp/types.d.ts +16 -8
- package/dist/pnp/types.js.map +1 -1
- package/dist/presentation/feedbackAnnouncement.d.ts +56 -0
- package/dist/presentation/feedbackAnnouncement.js +150 -0
- package/dist/presentation/feedbackAnnouncement.js.map +1 -0
- package/dist/presentation/interactionSlots.d.ts +31 -0
- package/dist/presentation/interactionSlots.js +101 -0
- package/dist/presentation/interactionSlots.js.map +1 -0
- package/dist/presentation/itemPresentationPlan.d.ts +69 -6
- package/dist/presentation/itemPresentationPlan.js +93 -81
- package/dist/presentation/itemPresentationPlan.js.map +1 -1
- package/dist/{components/utils → presentation}/stimulusRender.js +3 -12
- package/dist/presentation/stimulusRender.js.map +1 -0
- package/dist/presentation/stylesheetRender.js.map +1 -0
- package/dist/security/escapeHtml.d.ts +15 -0
- package/dist/security/escapeHtml.js +22 -0
- package/dist/security/escapeHtml.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +1 -0
- package/dist/security/index.js.map +1 -1
- package/dist/server.d.ts +8 -1
- package/dist/server.js.map +1 -1
- package/dist/session-inputs.d.ts +108 -0
- package/dist/session-inputs.js +130 -0
- package/dist/session-inputs.js.map +1 -0
- package/dist/types/index.d.ts +67 -35
- package/dist/types/index.js.map +1 -1
- package/dist/utils/cloneFreeze.d.ts +52 -0
- package/dist/utils/cloneFreeze.js +113 -0
- package/dist/utils/cloneFreeze.js.map +1 -0
- package/dist/utils/htmlAttributes.d.ts +13 -0
- package/dist/utils/htmlAttributes.js +22 -0
- package/dist/utils/htmlAttributes.js.map +1 -0
- package/dist/web-components/QTIInteractionElement.d.ts +0 -29
- package/dist/web-components/QTIInteractionElement.js +0 -32
- package/dist/web-components/QTIInteractionElement.js.map +1 -1
- package/dist/web-components/index.d.ts +1 -2
- package/dist/web-components/index.js +2 -3
- package/dist/web-components/index.js.map +1 -1
- package/package.json +20 -19
- package/dist/components/utils/stimulusRender.js.map +0 -1
- package/dist/components/utils/stylesheetRender.js.map +0 -1
- package/dist/core/constants.d.ts +0 -65
- package/dist/core/constants.js +0 -74
- package/dist/core/constants.js.map +0 -1
- package/dist/element-class-DdpiTalY.js +0 -9226
- package/dist/element-class-DdpiTalY.js.map +0 -1
- package/dist/extensions/MathLiveEditor.d.ts +0 -31
- package/dist/extensions/MathLiveEditor.js +0 -248
- package/dist/extensions/MathLiveEditor.js.map +0 -1
- package/dist/utils/PerformanceMonitor.d.ts +0 -169
- package/dist/utils/PerformanceMonitor.js +0 -243
- package/dist/utils/PerformanceMonitor.js.map +0 -1
- package/dist/utils/responseUtils.d.ts +0 -15
- package/dist/utils/responseUtils.js +0 -46
- package/dist/utils/responseUtils.js.map +0 -1
- package/dist/web-components/QTIInteractionBase.d.ts +0 -119
- package/dist/web-components/QTIInteractionBase.js +0 -244
- package/dist/web-components/QTIInteractionBase.js.map +0 -1
- /package/dist/{components/utils → presentation}/stimulusRender.d.ts +0 -0
- /package/dist/{components/utils → presentation}/stylesheetRender.d.ts +0 -0
- /package/dist/{components/utils → presentation}/stylesheetRender.js +0 -0
|
@@ -3,10 +3,16 @@ import { parse } from 'node-html-parser';
|
|
|
3
3
|
import { sanitizeHtml } from '../core/sanitizer.js';
|
|
4
4
|
import { htmlToString, toTrustedHtml } from '../core/trustedTypes.js';
|
|
5
5
|
import { getRoleCapabilities } from '../core/rolePolicy.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { escapeHtmlAttribute } from '../security/escapeHtml.js';
|
|
7
|
+
import { deepFreezeInPlace } from '../utils/cloneFreeze.js';
|
|
8
|
+
import { cleanFeedbackText, processFeedbackInline } from '@pie-qti/qti-common';
|
|
9
|
+
import { extractShownFeedback } from './feedbackAnnouncement.js';
|
|
10
|
+
import { buildScopedStylesheetCss } from './stylesheetRender.js';
|
|
11
|
+
import { buildEffectiveStimulusContent, injectStimulusContent } from './stimulusRender.js';
|
|
12
|
+
import { isInlineInteractionType } from '../interactions/inline/render-plan.js';
|
|
13
|
+
import { textEntryStringIdentifier } from '../interactions/text-entry/response.js';
|
|
14
|
+
import { hasInteractionSlot, placeInteractionSlots } from './interactionSlots.js';
|
|
15
|
+
export { INTERACTION_SLOT_ATTRIBUTE } from './interactionSlots.js';
|
|
10
16
|
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
17
|
const baseCapabilities = getRoleCapabilities(role);
|
|
12
18
|
const roleCapabilities = showSolution
|
|
@@ -14,7 +20,7 @@ export function createItemPresentation({ source, responses = {}, disabled = fals
|
|
|
14
20
|
: baseCapabilities;
|
|
15
21
|
const effectiveDisabled = disabled || roleCapabilities.isReadOnly;
|
|
16
22
|
const correctResponses = roleCapabilities.canViewCorrectResponses ? source.correctResponses : {};
|
|
17
|
-
const { html, scopedCss } = buildItemBodyPresentation({
|
|
23
|
+
const { html, scopedCss, shownFeedback } = buildItemBodyPresentation({
|
|
18
24
|
source,
|
|
19
25
|
role,
|
|
20
26
|
outcomeValues,
|
|
@@ -23,69 +29,36 @@ export function createItemPresentation({ source, responses = {}, disabled = fals
|
|
|
23
29
|
renderItemBodyRubrics,
|
|
24
30
|
showFeedback,
|
|
25
31
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
kind: 'html',
|
|
33
|
-
html: finalizeItemBodyHtml(sanitized, source.security),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (segment.type === 'textEntry') {
|
|
37
|
-
return {
|
|
38
|
-
kind: 'interaction',
|
|
39
|
-
mount: {
|
|
40
|
-
placement: 'inline',
|
|
41
|
-
renderer: 'text-entry',
|
|
42
|
-
interaction: segment.interaction,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
kind: 'interaction',
|
|
48
|
-
mount: {
|
|
49
|
-
placement: 'inline',
|
|
50
|
-
renderer: 'inline-choice',
|
|
51
|
-
interaction: segment.interaction,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
const blockFlow = createBlockInteractionMounts({
|
|
32
|
+
const placed = placeInteractionSlots(html, source.interactions, (interaction) => isInlineInteractionType(interaction.type) ? 'inline' : 'block');
|
|
33
|
+
// Slot placement is the last string transform of the body, so sanitation runs once over the
|
|
34
|
+
// composed body, immediately before Trusted Types finalization.
|
|
35
|
+
const sanitized = sanitizeHtml(placed.html, { security: source.security });
|
|
36
|
+
const slots = new Map([...placed.slots].filter(([, slot]) => hasInteractionSlot(sanitized, slot)));
|
|
37
|
+
const { mounts, failedInteractions } = createInteractionMounts({
|
|
56
38
|
interactions: source.interactions,
|
|
39
|
+
slots,
|
|
57
40
|
source,
|
|
58
41
|
responses,
|
|
59
42
|
correctResponses,
|
|
60
43
|
roleCapabilities,
|
|
61
44
|
effectiveDisabled,
|
|
62
45
|
onComponentError,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
mount,
|
|
66
|
-
}));
|
|
67
|
-
return freezePresentation({
|
|
46
|
+
});
|
|
47
|
+
return deepFreezeInPlace({
|
|
68
48
|
capabilities: roleCapabilities,
|
|
69
49
|
disabled: effectiveDisabled,
|
|
70
50
|
...(source.contentLanguage ? { contentLanguage: source.contentLanguage } : {}),
|
|
71
51
|
correctResponses,
|
|
72
52
|
directRubrics: source.directRubrics ?? [],
|
|
73
|
-
flow: [
|
|
53
|
+
flow: [
|
|
54
|
+
{ kind: 'html', html: finalizeItemBodyHtml(sanitized, source.security) },
|
|
55
|
+
...mounts.map((mount) => ({ kind: 'interaction', mount })),
|
|
56
|
+
],
|
|
57
|
+
failedInteractions,
|
|
74
58
|
scopedCss,
|
|
59
|
+
shownFeedback,
|
|
75
60
|
});
|
|
76
61
|
}
|
|
77
|
-
function freezePresentation(value) {
|
|
78
|
-
if (!value || typeof value !== 'object' || Object.isFrozen(value))
|
|
79
|
-
return value;
|
|
80
|
-
const prototype = Object.getPrototypeOf(value);
|
|
81
|
-
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null)
|
|
82
|
-
return value;
|
|
83
|
-
Object.freeze(value);
|
|
84
|
-
for (const child of Object.values(value)) {
|
|
85
|
-
freezePresentation(child);
|
|
86
|
-
}
|
|
87
|
-
return value;
|
|
88
|
-
}
|
|
89
62
|
function buildItemBodyPresentation({ source, role, outcomeValues, heuristicsConfig, itemBodyScopeSelector, renderItemBodyRubrics, showFeedback, }) {
|
|
90
63
|
let html = htmlToString(source.itemBodyHtml);
|
|
91
64
|
const scopedCss = buildScopedStylesheetCss(source.deliveryContext, itemBodyScopeSelector);
|
|
@@ -93,13 +66,20 @@ function buildItemBodyPresentation({ source, role, outcomeValues, heuristicsConf
|
|
|
93
66
|
html = injectStimulusContent(html, effectiveStimulusContent);
|
|
94
67
|
html = renderRubricBlocksForRole(html, role, { renderRubrics: renderItemBodyRubrics });
|
|
95
68
|
const heuristics = normalizeHeuristicsConfig(heuristicsConfig);
|
|
69
|
+
// While every feedback element is still in the HTML, read which of them the outcomes show and
|
|
70
|
+
// what they say, with the same text heuristics, so the body can announce it (WCAG 4.1.3) once
|
|
71
|
+
// this presentation renders it.
|
|
72
|
+
const shownFeedback = extractShownFeedback(html, outcomeValues, {
|
|
73
|
+
hideAll: !showFeedback,
|
|
74
|
+
transform: heuristics.feedbackTextFormatting ? (content) => cleanFeedbackText(content) : undefined,
|
|
75
|
+
});
|
|
96
76
|
html = processFeedbackInline(html, {
|
|
97
77
|
outcomeValues,
|
|
98
78
|
applyHeuristics: heuristics.feedbackTextFormatting,
|
|
99
79
|
wrapWithSpan: false,
|
|
100
80
|
hideAll: !showFeedback,
|
|
101
81
|
});
|
|
102
|
-
return { html
|
|
82
|
+
return { html, scopedCss, shownFeedback };
|
|
103
83
|
}
|
|
104
84
|
function finalizeItemBodyHtml(html, security) {
|
|
105
85
|
return toTrustedHtml(html, security?.trustedTypesPolicyName);
|
|
@@ -165,28 +145,57 @@ function serializeHtmlChildren(element) {
|
|
|
165
145
|
.map((child) => child.toString())
|
|
166
146
|
.join('');
|
|
167
147
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
148
|
+
/**
|
|
149
|
+
* One mount per interaction that resolves, in document order: slotted interactions in slot
|
|
150
|
+
* order, then any whose element is not in the body, in extraction order. An interaction whose
|
|
151
|
+
* component the registry cannot resolve gets no mount — the host hears the failure once
|
|
152
|
+
* through `onComponentError` — and is returned in `failedInteractions` with the slot it
|
|
153
|
+
* owned, so the presenter can stand the render-failed placeholder where it was authored.
|
|
154
|
+
*/
|
|
155
|
+
function createInteractionMounts({ interactions, slots, source, responses, correctResponses, roleCapabilities, effectiveDisabled, onComponentError, }) {
|
|
156
|
+
const slotRank = (index) => {
|
|
157
|
+
const slot = slots.get(index);
|
|
158
|
+
return slot === undefined ? Number.POSITIVE_INFINITY : Number(slot);
|
|
159
|
+
};
|
|
160
|
+
const order = interactions.map((_, index) => index).sort((a, b) => slotRank(a) - slotRank(b));
|
|
161
|
+
const inlineCount = interactions.filter((interaction) => isInlineInteractionType(interaction.type)).length;
|
|
162
|
+
const usedKeys = new Map();
|
|
163
|
+
const uniqueKey = (interaction) => {
|
|
164
|
+
const key = interactionKey(interaction);
|
|
165
|
+
const seen = usedKeys.get(key) ?? 0;
|
|
166
|
+
usedKeys.set(key, seen + 1);
|
|
167
|
+
// Keyed rendering needs distinct keys even for (invalid) duplicate interactions.
|
|
168
|
+
return seen === 0 ? key : `${key}#${seen}`;
|
|
169
|
+
};
|
|
170
|
+
const mounts = [];
|
|
171
|
+
const failedInteractions = [];
|
|
172
|
+
let inlineIndex = 0;
|
|
173
|
+
for (const index of order) {
|
|
174
|
+
const interaction = interactions[index];
|
|
175
|
+
const slot = slots.get(index) ?? null;
|
|
176
|
+
if (isInlineInteractionType(interaction.type)) {
|
|
177
|
+
inlineIndex += 1;
|
|
178
|
+
const inline = {
|
|
179
|
+
placement: 'inline',
|
|
180
|
+
key: uniqueKey(interaction),
|
|
181
|
+
slot,
|
|
182
|
+
position: { index: inlineIndex, count: inlineCount },
|
|
183
|
+
};
|
|
184
|
+
if (interaction.type === 'textEntryInteraction') {
|
|
185
|
+
const textEntry = interaction;
|
|
186
|
+
const stringIdentifier = textEntryStringIdentifier(textEntry);
|
|
187
|
+
mounts.push({
|
|
188
|
+
...inline,
|
|
189
|
+
renderer: 'text-entry',
|
|
190
|
+
interaction: textEntry,
|
|
191
|
+
...(stringIdentifier ? { stringResponse: responses[stringIdentifier] ?? null } : {}),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
mounts.push({ ...inline, renderer: 'inline-choice', interaction: interaction });
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
190
199
|
try {
|
|
191
200
|
const stringIdentifier = 'stringIdentifier' in interaction && typeof interaction.stringIdentifier === 'string'
|
|
192
201
|
? interaction.stringIdentifier
|
|
@@ -196,7 +205,8 @@ function createBlockInteractionMounts({ interactions, source, responses, correct
|
|
|
196
205
|
renderer: 'web-component',
|
|
197
206
|
interaction,
|
|
198
207
|
tagName: source.componentRegistry.getTagName(interaction),
|
|
199
|
-
key:
|
|
208
|
+
key: uniqueKey(interaction),
|
|
209
|
+
slot,
|
|
200
210
|
response: responses[interaction.responseId] ?? null,
|
|
201
211
|
...(stringIdentifier
|
|
202
212
|
? { stringResponse: responses[stringIdentifier] ?? null }
|
|
@@ -211,14 +221,16 @@ function createBlockInteractionMounts({ interactions, source, responses, correct
|
|
|
211
221
|
disabled: effectiveDisabled,
|
|
212
222
|
componentRole: roleCapabilities.canViewCorrectResponses ? 'scorer' : undefined,
|
|
213
223
|
};
|
|
214
|
-
|
|
224
|
+
mounts.push(block);
|
|
215
225
|
}
|
|
216
226
|
catch (error) {
|
|
227
|
+
// No component renders the type: the interaction has no mount, the body keeps
|
|
228
|
+
// rendering around it, and the slot it owned stays reserved for the placeholder.
|
|
217
229
|
onComponentError?.(interaction, error);
|
|
218
|
-
|
|
230
|
+
failedInteractions.push({ key: uniqueKey(interaction), slot, interaction });
|
|
219
231
|
}
|
|
220
|
-
}
|
|
221
|
-
|
|
232
|
+
}
|
|
233
|
+
return { mounts, failedInteractions };
|
|
222
234
|
}
|
|
223
235
|
export function interactionKey(interaction) {
|
|
224
236
|
const anyInteraction = interaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemPresentationPlan.js","sourceRoot":"","sources":["../../src/presentation/itemPresentationPlan.ts"],"names":[],"mappings":"AACA,OAAO,EACN,yBAAyB,GAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAyB,MAAM,uBAAuB,CAAC;AAOnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC7G,OAAO,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,GACvB,MAAM,uCAAuC,CAAC;AAyG/C,MAAM,UAAU,sBAAsB,CAAC,EACtC,MAAM,EACN,SAAS,GAAG,EAAE,EACd,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,WAAW,EAClB,aAAa,GAAG,EAAE,EAClB,gBAAgB,EAChB,qBAAqB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,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,WAAgC;IAC9D,MAAM,cAAc,GAAG,WAAkB,CAAC;IAC1C,MAAM,GAAG,GACR,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAC1E,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3F,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,MAAM,GAAG,OAAO,cAAc,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACvF,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,UAAU,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;AACzE,CAAC","sourcesContent":["import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport {\n\tnormalizeHeuristicsConfig,\n\ttype QtiHeuristicsConfig,\n} from '@pie-qti/ims-cp-core';\nimport { parse } from 'node-html-parser';\nimport type { HTMLElement as ParsedHtmlElement } from 'node-html-parser';\nimport type { ComponentRegistry } from '../core/ComponentRegistry.js';\nimport { sanitizeHtml } from '../core/sanitizer.js';\nimport { htmlToString, toTrustedHtml } from '../core/trustedTypes.js';\nimport type { PnpProfile } from '../pnp/types.js';\nimport { getRoleCapabilities, type RoleCapabilities } from '../core/rolePolicy.js';\nimport type {\n\tHtmlContent,\n\tPlayerSecurityConfig,\n\tQTIRole,\n\tRubricBlock,\n} from '../types/index.js';\nimport { processFeedbackInline } from '@pie-qti/qti-common';\nimport { buildScopedStylesheetCss } from '../components/utils/stylesheetRender.js';\nimport { buildEffectiveStimulusContent, injectStimulusContent } from '../components/utils/stimulusRender.js';\nimport {\n\tcreateInlineRenderPlan,\n\tisInlineInteractionTagName,\n\tisInlineInteractionType,\n} from '../interactions/inline/render-plan.js';\nimport type {\n\tBaseInteractionData,\n\tInlineChoiceInteractionData,\n\tTextEntryInteractionData,\n} from '../interactions/shared/types.js';\n\nexport type ItemPresentationResponseValue = unknown;\nexport type ItemPresentationResponseMap = Record<string, ItemPresentationResponseValue>;\n\n/**\n * Immutable inputs captured from the live item session for one presentation pass.\n *\n * This deliberately contains data rather than a Player-shaped adapter. Presentation\n * cannot reach back into the session midway through a render, and its only live seam\n * is the real component registry used to resolve plugin renderers.\n */\nexport interface ItemPresentationSource {\n\titemBodyHtml: HtmlContent;\n\t/** The content's `xml:lang`, when the item declares one. */\n\tcontentLanguage?: string;\n\tinteractions: readonly BaseInteractionData[];\n\tcorrectResponses: Record<string, unknown>;\n\tcomponentRegistry: ComponentRegistry;\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\tpnp?: PnpProfile;\n\tsecurity?: PlayerSecurityConfig;\n\t/** Role-filtered, finalized direct rubrics for host placement. */\n\tdirectRubrics?: readonly RubricBlock[];\n}\n\nexport interface CreateItemPresentationOptions {\n\tsource: ItemPresentationSource;\n\tresponses?: ItemPresentationResponseMap;\n\tdisabled?: boolean;\n\trole?: QTIRole;\n\toutcomeValues?: Record<string, unknown>;\n\theuristicsConfig?: QtiHeuristicsConfig;\n\titemBodyScopeSelector?: string;\n\trenderItemBodyRubrics?: boolean;\n\t/** False drops every feedbackInline and feedbackBlock, as test-level showFeedback=\"false\" requires. */\n\tshowFeedback?: boolean;\n\t/** True exposes correct responses whatever the role, as test-level showSolution requires. */\n\tshowSolution?: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}\n\nexport interface BlockInteractionMount {\n\treadonly placement: 'block';\n\treadonly renderer: 'web-component';\n\treadonly interaction: BaseInteractionData;\n\treadonly tagName: string;\n\treadonly key: string;\n\treadonly response: ItemPresentationResponseValue | null;\n\t/** Lexical companion value used by extendedTextInteraction stringIdentifier. */\n\treadonly stringResponse?: ItemPresentationResponseValue | null;\n\treadonly correctResponse: unknown;\n\treadonly pnp: PnpProfile | undefined;\n\treadonly eliminationTool: boolean;\n\treadonly answerMasking: boolean;\n\t/** Label the interaction's answer set as an ARIA group for assistive technology (G-13). */\n\treadonly structuredLabelSupport: boolean;\n\treadonly disabled: boolean;\n\treadonly componentRole: 'scorer' | undefined;\n}\n\nexport type InlineInteractionMount =\n\t| {\n\t\t\treadonly placement: 'inline';\n\t\t\treadonly renderer: 'text-entry';\n\t\t\treadonly interaction: TextEntryInteractionData;\n\t }\n\t| {\n\t\t\treadonly placement: 'inline';\n\t\t\treadonly renderer: 'inline-choice';\n\t\t\treadonly interaction: InlineChoiceInteractionData;\n\t };\n\nexport type ItemInteractionMount = InlineInteractionMount | BlockInteractionMount;\n\ndeclare const finalItemBodyHtmlBrand: unique symbol;\n\n/** HTML that has completed every body transform, sanitation, and Trusted Types finalization. */\nexport type FinalItemBodyHtml = HtmlContent & {\n\treadonly [finalItemBodyHtmlBrand]: true;\n};\n\nexport type ItemPresentationFlowNode =\n\t| { readonly kind: 'html'; readonly html: FinalItemBodyHtml }\n\t| { readonly kind: 'interaction'; readonly mount: ItemInteractionMount };\n\nexport interface ItemPresentation {\n\treadonly capabilities: RoleCapabilities;\n\treadonly disabled: boolean;\n\t/** The language the item body is written in, for its `lang`; undefined when undeclared. */\n\treadonly contentLanguage?: string;\n\treadonly correctResponses: Readonly<Record<string, unknown>>;\n\t/** Direct assessmentItem rubrics that remain outside the item-body flow. */\n\treadonly directRubrics: readonly RubricBlock[];\n\t/** Ordered, render-neutral body flow. Block mounts follow the authored body HTML. */\n\treadonly flow: readonly ItemPresentationFlowNode[];\n\t/** Policy-checked CSS is kept out of the HTML/Trusted Types pipeline. */\n\treadonly scopedCss: string;\n}\n\nexport function createItemPresentation({\n\tsource,\n\tresponses = {},\n\tdisabled = false,\n\trole = 'candidate',\n\toutcomeValues = {},\n\theuristicsConfig,\n\titemBodyScopeSelector = '[data-qti-item-body-scope]',\n\trenderItemBodyRubrics = true,\n\tshowFeedback = true,\n\tshowSolution = false,\n\tonComponentError,\n}: CreateItemPresentationOptions): ItemPresentation {\n\tconst baseCapabilities = getRoleCapabilities(role);\n\tconst roleCapabilities = showSolution\n\t\t? { ...baseCapabilities, canViewCorrectResponses: true }\n\t\t: baseCapabilities;\n\tconst effectiveDisabled = disabled || roleCapabilities.isReadOnly;\n\tconst correctResponses = roleCapabilities.canViewCorrectResponses ? source.correctResponses : {};\n\tconst { html, scopedCss } = buildItemBodyPresentation({\n\t\tsource,\n\t\trole,\n\t\toutcomeValues,\n\t\theuristicsConfig,\n\t\titemBodyScopeSelector,\n\t\trenderItemBodyRubrics,\n\t\tshowFeedback,\n\t});\n\tconst inlineFlow = createInlineRenderPlan(html, source.interactions).map(\n\t\t(segment): ItemPresentationFlowNode => {\n\t\t\tif (segment.type === 'html') {\n\t\t\t\t// Inline planning parses and reserializes the composed body, so sanitation\n\t\t\t\t// belongs after that final string transform and immediately before TT.\n\t\t\t\tconst sanitized = sanitizeHtml(segment.content, { security: source.security });\n\t\t\t\treturn {\n\t\t\t\t\tkind: 'html',\n\t\t\t\t\thtml: finalizeItemBodyHtml(sanitized, source.security),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (segment.type === 'textEntry') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: 'interaction',\n\t\t\t\t\tmount: {\n\t\t\t\t\t\tplacement: 'inline',\n\t\t\t\t\t\trenderer: 'text-entry',\n\t\t\t\t\t\tinteraction: segment.interaction,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: 'interaction',\n\t\t\t\tmount: {\n\t\t\t\t\tplacement: 'inline',\n\t\t\t\t\trenderer: 'inline-choice',\n\t\t\t\t\tinteraction: segment.interaction,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t);\n\tconst blockFlow = createBlockInteractionMounts({\n\t\tinteractions: source.interactions,\n\t\tsource,\n\t\tresponses,\n\t\tcorrectResponses,\n\t\troleCapabilities,\n\t\teffectiveDisabled,\n\t\tonComponentError,\n\t}).map(\n\t\t(mount): ItemPresentationFlowNode => ({\n\t\t\tkind: 'interaction',\n\t\t\tmount,\n\t\t})\n\t);\n\n\treturn freezePresentation({\n\t\tcapabilities: roleCapabilities,\n\t\tdisabled: effectiveDisabled,\n\t\t...(source.contentLanguage ? { contentLanguage: source.contentLanguage } : {}),\n\t\tcorrectResponses,\n\t\tdirectRubrics: source.directRubrics ?? [],\n\t\tflow: [...inlineFlow, ...blockFlow],\n\t\tscopedCss,\n\t});\n}\n\nfunction freezePresentation<T>(value: T): T {\n\tif (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return value;\n\tObject.freeze(value);\n\tfor (const child of Object.values(value as Record<string, unknown>)) {\n\t\tfreezePresentation(child);\n\t}\n\treturn value;\n}\n\nfunction buildItemBodyPresentation({\n\tsource,\n\trole,\n\toutcomeValues,\n\theuristicsConfig,\n\titemBodyScopeSelector,\n\trenderItemBodyRubrics,\n\tshowFeedback,\n}: {\n\tsource: ItemPresentationSource;\n\trole: QTIRole;\n\toutcomeValues: Record<string, unknown>;\n\theuristicsConfig: QtiHeuristicsConfig | undefined;\n\titemBodyScopeSelector: string;\n\trenderItemBodyRubrics: boolean;\n\tshowFeedback: boolean;\n}): { html: string; scopedCss: string } {\n\tlet html = htmlToString(source.itemBodyHtml);\n\tconst scopedCss = buildScopedStylesheetCss(source.deliveryContext, itemBodyScopeSelector);\n\tconst effectiveStimulusContent = buildEffectiveStimulusContent(\n\t\tsource.deliveryContext,\n\t\t(content) => sanitizeHtml(content, { security: source.security })\n\t);\n\n\thtml = injectStimulusContent(html, effectiveStimulusContent);\n\thtml = renderRubricBlocksForRole(html, role, { renderRubrics: renderItemBodyRubrics });\n\n\tconst heuristics = normalizeHeuristicsConfig(heuristicsConfig);\n\thtml = processFeedbackInline(html, {\n\t\toutcomeValues,\n\t\tapplyHeuristics: heuristics.feedbackTextFormatting,\n\t\twrapWithSpan: false,\n\t\thideAll: !showFeedback,\n\t});\n\n\treturn { html: hideBlockInteractionMarkup(html), scopedCss };\n}\n\nfunction finalizeItemBodyHtml(\n\thtml: string,\n\tsecurity: PlayerSecurityConfig | undefined\n): FinalItemBodyHtml {\n\treturn toTrustedHtml(html, security?.trustedTypesPolicyName) as FinalItemBodyHtml;\n}\n\nfunction renderRubricBlocksForRole(\n\thtml: string,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): string {\n\tif (!html || !/rubric-?block/i.test(html)) {\n\t\treturn html;\n\t}\n\n\ttry {\n\t\tconst root = parse(html, { lowerCaseTagName: false, comment: false });\n\t\trenderRubricBlockChildren(root as unknown as ParsedHtmlElement, role, { renderRubrics });\n\t\treturn root.toString();\n\t} catch {\n\t\treturn html;\n\t}\n}\n\nfunction renderRubricBlockChildren(\n\telement: ParsedHtmlElement,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): void {\n\tconst children = [...element.childNodes] as unknown as ParsedHtmlElement[];\n\tfor (const child of children) {\n\t\tconst tagName = child.rawTagName?.toLowerCase();\n\t\tif (\n\t\t\ttagName &&\n\t\t\tisRubricBlockTag(tagName) &&\n\t\t\t(!renderRubrics || !rubricBlockVisibleToRole(child, role))\n\t\t) {\n\t\t\tchild.remove();\n\t\t\tcontinue;\n\t\t}\n\t\tif (child.childNodes?.length) {\n\t\t\trenderRubricBlockChildren(child, role, { renderRubrics });\n\t\t}\n\t\tif (tagName && isRubricBlockTag(tagName)) {\n\t\t\tchild.replaceWith(renderRubricBlockWrapper(child));\n\t\t}\n\t}\n}\n\nfunction isRubricBlockTag(tagName: string): boolean {\n\treturn tagName === 'rubricblock' || tagName === 'qti-rubric-block';\n}\n\nfunction rubricBlockVisibleToRole(element: ParsedHtmlElement, role: QTIRole): boolean {\n\tconst view = element.getAttribute('view')?.trim();\n\tif (!view) {\n\t\treturn true;\n\t}\n\treturn splitRubricView(view).includes(role);\n}\n\nfunction renderRubricBlockWrapper(element: ParsedHtmlElement): string {\n\tconst view = element.getAttribute('view')?.trim();\n\tconst use = element.getAttribute('use')?.trim();\n\tconst attrs = [\n\t\t'class=\"qti-rubric-block\"',\n\t\tview ? `data-qti-rubric-view=\"${escapeHtmlAttribute(view)}\"` : '',\n\t\tuse ? `data-qti-rubric-use=\"${escapeHtmlAttribute(use)}\"` : '',\n\t]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n\treturn `<div ${attrs}>${serializeHtmlChildren(element)}</div>`;\n}\n\nfunction splitRubricView(view: string): string[] {\n\treturn view.split(/[\\s,]+/).filter(Boolean);\n}\n\nfunction serializeHtmlChildren(element: ParsedHtmlElement): string {\n\treturn ([...element.childNodes] as unknown as ParsedHtmlElement[])\n\t\t.map((child) => child.toString())\n\t\t.join('');\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '&')\n\t\t.replace(/\"/g, '"')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>');\n}\n\nfunction hideBlockInteractionMarkup(html: string): string {\n\t// positionObjectStage is hidden as a unit: it owns the background object and wraps its\n\t// interactions, all of which the component renders. Matching only the interaction inside it\n\t// would leave the stage's background image visible in the item body as well.\n\treturn html.replace(\n\t\t/<(\\w+Interaction|qti-[\\w-]+-interaction|positionObjectStage|qti-position-object-stage)(\\s[^>]*)?>[\\s\\S]*?<\\/\\1>/gi,\n\t\t(match, tagName) => {\n\t\t\tconst lower = tagName.toLowerCase();\n\t\t\tif (isInlineInteractionTagName(lower)) return match;\n\t\t\treturn `<span class=\"qti-hidden-interaction\">${match}</span>`;\n\t\t}\n\t);\n}\n\nfunction createBlockInteractionMounts({\n\tinteractions,\n\tsource,\n\tresponses,\n\tcorrectResponses,\n\troleCapabilities,\n\teffectiveDisabled,\n\tonComponentError,\n}: {\n\tinteractions: readonly BaseInteractionData[];\n\tsource: ItemPresentationSource;\n\tresponses: ItemPresentationResponseMap;\n\tcorrectResponses: Record<string, unknown>;\n\troleCapabilities: RoleCapabilities;\n\teffectiveDisabled: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}): BlockInteractionMount[] {\n\treturn interactions\n\t\t.filter((interaction) => !isInlineInteractionType(interaction.type))\n\t\t.map((interaction) => {\n\t\t\ttry {\n\t\t\t\tconst stringIdentifier =\n\t\t\t\t\t'stringIdentifier' in interaction && typeof interaction.stringIdentifier === 'string'\n\t\t\t\t\t\t? interaction.stringIdentifier\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst block: BlockInteractionMount = {\n\t\t\t\t\tplacement: 'block',\n\t\t\t\t\trenderer: 'web-component',\n\t\t\t\t\tinteraction,\n\t\t\t\t\ttagName: source.componentRegistry.getTagName(interaction),\n\t\t\t\t\tkey: interactionKey(interaction),\n\t\t\t\t\tresponse: responses[interaction.responseId] ?? null,\n\t\t\t\t\t...(stringIdentifier\n\t\t\t\t\t\t? { stringResponse: responses[stringIdentifier] ?? null }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tcorrectResponse: roleCapabilities.canViewCorrectResponses\n\t\t\t\t\t\t? (correctResponses[interaction.responseId] ?? null)\n\t\t\t\t\t\t: null,\n\t\t\t\t\tpnp: source.pnp,\n\t\t\t\t\teliminationTool: source.pnp?.cognitive?.eliminationTool === true,\n\t\t\t\t\tanswerMasking: source.pnp?.cognitive?.answerMasking === true,\n\t\t\t\t\tstructuredLabelSupport: source.pnp?.display?.structuredLabelSupport === true,\n\t\t\t\t\tdisabled: effectiveDisabled,\n\t\t\t\t\tcomponentRole: roleCapabilities.canViewCorrectResponses ? 'scorer' : undefined,\n\t\t\t\t};\n\t\t\t\treturn block;\n\t\t\t} catch (error) {\n\t\t\t\tonComponentError?.(interaction, error);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t})\n\t\t.filter((item): item is BlockInteractionMount => item !== null);\n}\n\nexport function interactionKey(interaction: BaseInteractionData): string {\n\tconst anyInteraction = interaction as any;\n\tconst ids =\n\t\tArray.isArray(anyInteraction?.choices) && anyInteraction.choices.length > 0\n\t\t\t? anyInteraction.choices.map((choice: any) => choice?.identifier).filter(Boolean).join(',')\n\t\t\t: '';\n\tconst prompt = typeof anyInteraction?.prompt === 'string' ? anyInteraction.prompt : '';\n\treturn `${interaction.type}|${interaction.responseId}|${ids}|${prompt}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"itemPresentationPlan.js","sourceRoot":"","sources":["../../src/presentation/itemPresentationPlan.ts"],"names":[],"mappings":"AACA,OAAO,EACN,yBAAyB,GAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAyB,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAO5D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAsB,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAMnF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,u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A8E;YAC9E,iFAAiF;YACjF,gBAAgB,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;YACvC,kBAAkB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QAC7E,CAAC;IACF,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,WAAgC;IAC9D,MAAM,cAAc,GAAG,WAAkB,CAAC;IAC1C,MAAM,GAAG,GACR,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAC1E,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3F,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,MAAM,GAAG,OAAO,cAAc,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACvF,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,UAAU,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;AACzE,CAAC","sourcesContent":["import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport {\n\tnormalizeHeuristicsConfig,\n\ttype QtiHeuristicsConfig,\n} from '@pie-qti/ims-cp-core';\nimport { parse } from 'node-html-parser';\nimport type { HTMLElement as ParsedHtmlElement } from 'node-html-parser';\nimport type { ComponentRegistry } from '../core/ComponentRegistry.js';\nimport { sanitizeHtml } from '../core/sanitizer.js';\nimport { htmlToString, toTrustedHtml } from '../core/trustedTypes.js';\nimport type { PnpProfile } from '../pnp/types.js';\nimport { getRoleCapabilities, type RoleCapabilities } from '../core/rolePolicy.js';\nimport { escapeHtmlAttribute } from '../security/escapeHtml.js';\nimport { deepFreezeInPlace } from '../utils/cloneFreeze.js';\nimport type {\n\tHtmlContent,\n\tPlayerSecurityConfig,\n\tQTIRole,\n\tRubricBlock,\n} from '../types/index.js';\nimport { cleanFeedbackText, processFeedbackInline } from '@pie-qti/qti-common';\nimport { extractShownFeedback, type ShownFeedback } from './feedbackAnnouncement.js';\nimport { buildScopedStylesheetCss } from './stylesheetRender.js';\nimport { buildEffectiveStimulusContent, injectStimulusContent } from './stimulusRender.js';\nimport { isInlineInteractionType } from '../interactions/inline/render-plan.js';\nimport { textEntryStringIdentifier } from '../interactions/text-entry/response.js';\nimport type {\n\tBaseInteractionData,\n\tInlineChoiceInteractionData,\n\tTextEntryInteractionData,\n} from '../interactions/shared/types.js';\nimport { hasInteractionSlot, placeInteractionSlots } from './interactionSlots.js';\n\nexport { INTERACTION_SLOT_ATTRIBUTE } from './interactionSlots.js';\n\nexport type ItemPresentationResponseValue = unknown;\nexport type ItemPresentationResponseMap = Record<string, ItemPresentationResponseValue>;\n\n/**\n * Immutable inputs captured from the live item session for one presentation pass.\n *\n * This deliberately contains data rather than a Player-shaped adapter. Presentation\n * cannot reach back into the session midway through a render, and its only live seam\n * is the real component registry used to resolve plugin renderers.\n */\nexport interface ItemPresentationSource {\n\titemBodyHtml: HtmlContent;\n\t/** The content's `xml:lang`, when the item declares one. */\n\tcontentLanguage?: string;\n\tinteractions: readonly BaseInteractionData[];\n\tcorrectResponses: Record<string, unknown>;\n\tcomponentRegistry: ComponentRegistry;\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n\tpnp?: PnpProfile;\n\tsecurity?: PlayerSecurityConfig;\n\t/** Role-filtered, finalized direct rubrics for host placement. */\n\tdirectRubrics?: readonly RubricBlock[];\n}\n\nexport interface CreateItemPresentationOptions {\n\tsource: ItemPresentationSource;\n\tresponses?: ItemPresentationResponseMap;\n\tdisabled?: boolean;\n\trole?: QTIRole;\n\toutcomeValues?: Record<string, unknown>;\n\theuristicsConfig?: QtiHeuristicsConfig;\n\titemBodyScopeSelector?: string;\n\trenderItemBodyRubrics?: boolean;\n\t/** False drops every feedbackInline and feedbackBlock, as test-level showFeedback=\"false\" requires. */\n\tshowFeedback?: boolean;\n\t/** True exposes correct responses whatever the role, as test-level showSolution requires. */\n\tshowSolution?: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}\n\nexport interface BlockInteractionMount {\n\treadonly placement: 'block';\n\treadonly renderer: 'web-component';\n\treadonly interaction: BaseInteractionData;\n\treadonly tagName: string;\n\treadonly key: string;\n\t/**\n\t * The slot this interaction mounts into: the `data-qti-interaction-slot` value of the empty\n\t * placeholder at its authored position in the body HTML. Null when the interaction's element\n\t * is not in the body; the interaction then renders after the body.\n\t */\n\treadonly slot: string | null;\n\treadonly response: ItemPresentationResponseValue | null;\n\t/** Lexical companion value used by extendedTextInteraction stringIdentifier. */\n\treadonly stringResponse?: ItemPresentationResponseValue | null;\n\treadonly correctResponse: unknown;\n\treadonly pnp: PnpProfile | undefined;\n\treadonly eliminationTool: boolean;\n\treadonly answerMasking: boolean;\n\t/** Label the interaction's answer set as an ARIA group for assistive technology (G-13). */\n\treadonly structuredLabelSupport: boolean;\n\treadonly disabled: boolean;\n\treadonly componentRole: 'scorer' | undefined;\n}\n\n/** Where an inline interaction sits among the item's inline interactions, in document order. */\nexport interface InlineInteractionPosition {\n\t/** 1-based. */\n\treadonly index: number;\n\treadonly count: number;\n}\n\ninterface InlineInteractionMountBase {\n\treadonly placement: 'inline';\n\treadonly key: string;\n\t/** As for {@link BlockInteractionMount.slot}; the slot stays in its sentence. */\n\treadonly slot: string | null;\n\t/**\n\t * Its position among the item's inline interactions, which names it for assistive\n\t * technology (\"Blank 2 of 4\") when no label is authored. The response identifier never\n\t * does: it is author data and can hint at the answer.\n\t */\n\treadonly position: InlineInteractionPosition;\n}\n\nexport type InlineInteractionMount =\n\t| (InlineInteractionMountBase & {\n\t\t\treadonly renderer: 'text-entry';\n\t\t\treadonly interaction: TextEntryInteractionData;\n\t\t\t/**\n\t\t\t * The text the candidate entered, held by the response the interaction's\n\t\t\t * stringIdentifier names: the field shows it while it is present, so \"3.50\" is restored\n\t\t\t * as typed rather than as the numeric response's 3.5.\n\t\t\t */\n\t\t\treadonly stringResponse?: ItemPresentationResponseValue | null;\n\t })\n\t| (InlineInteractionMountBase & {\n\t\t\treadonly renderer: 'inline-choice';\n\t\t\treadonly interaction: InlineChoiceInteractionData;\n\t });\n\nexport type ItemInteractionMount = InlineInteractionMount | BlockInteractionMount;\n\n/**\n * An interaction whose web component the registry could not resolve: it has no mount in\n * `flow`, the body keeps rendering around it, and it still owns its slot. The presenter\n * stands the render-failed `role=\"alert\"` placeholder — the same one a mount that throws\n * gets — in that slot.\n */\nexport interface FailedInteractionMount {\n\t/** Unique key, drawn from the same keying the mounts use. */\n\treadonly key: string;\n\t/** As for {@link BlockInteractionMount.slot}. */\n\treadonly slot: string | null;\n\treadonly interaction: BaseInteractionData;\n}\n\ndeclare const finalItemBodyHtmlBrand: unique symbol;\n\n/** HTML that has completed every body transform, sanitation, and Trusted Types finalization. */\nexport type FinalItemBodyHtml = HtmlContent & {\n\treadonly [finalItemBodyHtmlBrand]: true;\n};\n\nexport type ItemPresentationFlowNode =\n\t| { readonly kind: 'html'; readonly html: FinalItemBodyHtml }\n\t| { readonly kind: 'interaction'; readonly mount: ItemInteractionMount };\n\nexport interface ItemPresentation {\n\treadonly capabilities: RoleCapabilities;\n\treadonly disabled: boolean;\n\t/** The language the item body is written in, for its `lang`; undefined when undeclared. */\n\treadonly contentLanguage?: string;\n\treadonly correctResponses: Readonly<Record<string, unknown>>;\n\t/** Direct assessmentItem rubrics that remain outside the item-body flow. */\n\treadonly directRubrics: readonly RubricBlock[];\n\t/**\n\t * Ordered, render-neutral body flow: one `html` node holding the whole item body, then every\n\t * interaction mount in document order. The body keeps each interaction's authored position as\n\t * an empty slot element (`[data-qti-interaction-slot]`); render the body once and mount each\n\t * interaction into the slot its `slot` names, which keeps block interactions between the\n\t * paragraphs, layout columns and table cells they were authored in and inline interactions in\n\t * their sentence. A mount whose `slot` is null renders after the body.\n\t */\n\treadonly flow: readonly ItemPresentationFlowNode[];\n\t/**\n\t * Interactions whose component the registry failed to resolve (no component renders the\n\t * type), with the slot each authored. The host heard each failure once through\n\t * `onComponentError`; the presenter keeps the candidate-facing half of that contract —\n\t * the visible placeholder — in place while the failure stands.\n\t */\n\treadonly failedInteractions: readonly FailedInteractionMount[];\n\t/** Policy-checked CSS is kept out of the HTML/Trusted Types pipeline. */\n\treadonly scopedCss: string;\n\t/**\n\t * The feedbackInline and feedbackBlock this body shows, read as accessible text in document\n\t * order. The plan splices shown feedback into the body and leaves no marker behind, so this is\n\t * the one place the shown feedback survives as data — the item body announces it while the\n\t * candidate can still hear it (WCAG 4.1.3 Status Messages).\n\t */\n\treadonly shownFeedback: ShownFeedback;\n}\n\nexport function createItemPresentation({\n\tsource,\n\tresponses = {},\n\tdisabled = false,\n\trole = 'candidate',\n\toutcomeValues = {},\n\theuristicsConfig,\n\titemBodyScopeSelector = '[data-qti-item-body-scope]',\n\trenderItemBodyRubrics = true,\n\tshowFeedback = true,\n\tshowSolution = false,\n\tonComponentError,\n}: CreateItemPresentationOptions): ItemPresentation {\n\tconst baseCapabilities = getRoleCapabilities(role);\n\tconst roleCapabilities = showSolution\n\t\t? { ...baseCapabilities, canViewCorrectResponses: true }\n\t\t: baseCapabilities;\n\tconst effectiveDisabled = disabled || roleCapabilities.isReadOnly;\n\tconst correctResponses = roleCapabilities.canViewCorrectResponses ? source.correctResponses : {};\n\tconst { html, scopedCss, shownFeedback } = buildItemBodyPresentation({\n\t\tsource,\n\t\trole,\n\t\toutcomeValues,\n\t\theuristicsConfig,\n\t\titemBodyScopeSelector,\n\t\trenderItemBodyRubrics,\n\t\tshowFeedback,\n\t});\n\tconst placed = placeInteractionSlots(html, source.interactions, (interaction) =>\n\t\tisInlineInteractionType(interaction.type) ? 'inline' : 'block'\n\t);\n\t// Slot placement is the last string transform of the body, so sanitation runs once over the\n\t// composed body, immediately before Trusted Types finalization.\n\tconst sanitized = sanitizeHtml(placed.html, { security: source.security });\n\tconst slots = new Map(\n\t\t[...placed.slots].filter(([, slot]) => hasInteractionSlot(sanitized, slot))\n\t);\n\tconst { mounts, failedInteractions } = createInteractionMounts({\n\t\tinteractions: source.interactions,\n\t\tslots,\n\t\tsource,\n\t\tresponses,\n\t\tcorrectResponses,\n\t\troleCapabilities,\n\t\teffectiveDisabled,\n\t\tonComponentError,\n\t});\n\n\treturn deepFreezeInPlace({\n\t\tcapabilities: roleCapabilities,\n\t\tdisabled: effectiveDisabled,\n\t\t...(source.contentLanguage ? { contentLanguage: source.contentLanguage } : {}),\n\t\tcorrectResponses,\n\t\tdirectRubrics: source.directRubrics ?? [],\n\t\tflow: [\n\t\t\t{ kind: 'html', html: finalizeItemBodyHtml(sanitized, source.security) },\n\t\t\t...mounts.map((mount): ItemPresentationFlowNode => ({ kind: 'interaction', mount })),\n\t\t],\n\t\tfailedInteractions,\n\t\tscopedCss,\n\t\tshownFeedback,\n\t});\n}\n\nfunction buildItemBodyPresentation({\n\tsource,\n\trole,\n\toutcomeValues,\n\theuristicsConfig,\n\titemBodyScopeSelector,\n\trenderItemBodyRubrics,\n\tshowFeedback,\n}: {\n\tsource: ItemPresentationSource;\n\trole: QTIRole;\n\toutcomeValues: Record<string, unknown>;\n\theuristicsConfig: QtiHeuristicsConfig | undefined;\n\titemBodyScopeSelector: string;\n\trenderItemBodyRubrics: boolean;\n\tshowFeedback: boolean;\n}): { html: string; scopedCss: string; shownFeedback: ShownFeedback } {\n\tlet html = htmlToString(source.itemBodyHtml);\n\tconst scopedCss = buildScopedStylesheetCss(source.deliveryContext, itemBodyScopeSelector);\n\tconst effectiveStimulusContent = buildEffectiveStimulusContent(\n\t\tsource.deliveryContext,\n\t\t(content) => sanitizeHtml(content, { security: source.security })\n\t);\n\n\thtml = injectStimulusContent(html, effectiveStimulusContent);\n\thtml = renderRubricBlocksForRole(html, role, { renderRubrics: renderItemBodyRubrics });\n\n\tconst heuristics = normalizeHeuristicsConfig(heuristicsConfig);\n\t// While every feedback element is still in the HTML, read which of them the outcomes show and\n\t// what they say, with the same text heuristics, so the body can announce it (WCAG 4.1.3) once\n\t// this presentation renders it.\n\tconst shownFeedback = extractShownFeedback(html, outcomeValues, {\n\t\thideAll: !showFeedback,\n\t\ttransform: heuristics.feedbackTextFormatting ? (content) => cleanFeedbackText(content) : undefined,\n\t});\n\thtml = processFeedbackInline(html, {\n\t\toutcomeValues,\n\t\tapplyHeuristics: heuristics.feedbackTextFormatting,\n\t\twrapWithSpan: false,\n\t\thideAll: !showFeedback,\n\t});\n\n\treturn { html, scopedCss, shownFeedback };\n}\n\nfunction finalizeItemBodyHtml(\n\thtml: string,\n\tsecurity: PlayerSecurityConfig | undefined\n): FinalItemBodyHtml {\n\treturn toTrustedHtml(html, security?.trustedTypesPolicyName) as FinalItemBodyHtml;\n}\n\nfunction renderRubricBlocksForRole(\n\thtml: string,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): string {\n\tif (!html || !/rubric-?block/i.test(html)) {\n\t\treturn html;\n\t}\n\n\ttry {\n\t\tconst root = parse(html, { lowerCaseTagName: false, comment: false });\n\t\trenderRubricBlockChildren(root as unknown as ParsedHtmlElement, role, { renderRubrics });\n\t\treturn root.toString();\n\t} catch {\n\t\treturn html;\n\t}\n}\n\nfunction renderRubricBlockChildren(\n\telement: ParsedHtmlElement,\n\trole: QTIRole,\n\t{ renderRubrics }: { renderRubrics: boolean }\n): void {\n\tconst children = [...element.childNodes] as unknown as ParsedHtmlElement[];\n\tfor (const child of children) {\n\t\tconst tagName = child.rawTagName?.toLowerCase();\n\t\tif (\n\t\t\ttagName &&\n\t\t\tisRubricBlockTag(tagName) &&\n\t\t\t(!renderRubrics || !rubricBlockVisibleToRole(child, role))\n\t\t) {\n\t\t\tchild.remove();\n\t\t\tcontinue;\n\t\t}\n\t\tif (child.childNodes?.length) {\n\t\t\trenderRubricBlockChildren(child, role, { renderRubrics });\n\t\t}\n\t\tif (tagName && isRubricBlockTag(tagName)) {\n\t\t\tchild.replaceWith(renderRubricBlockWrapper(child));\n\t\t}\n\t}\n}\n\nfunction isRubricBlockTag(tagName: string): boolean {\n\treturn tagName === 'rubricblock' || tagName === 'qti-rubric-block';\n}\n\nfunction rubricBlockVisibleToRole(element: ParsedHtmlElement, role: QTIRole): boolean {\n\tconst view = element.getAttribute('view')?.trim();\n\tif (!view) {\n\t\treturn true;\n\t}\n\treturn splitRubricView(view).includes(role);\n}\n\nfunction renderRubricBlockWrapper(element: ParsedHtmlElement): string {\n\tconst view = element.getAttribute('view')?.trim();\n\tconst use = element.getAttribute('use')?.trim();\n\tconst attrs = [\n\t\t'class=\"qti-rubric-block\"',\n\t\tview ? `data-qti-rubric-view=\"${escapeHtmlAttribute(view)}\"` : '',\n\t\tuse ? `data-qti-rubric-use=\"${escapeHtmlAttribute(use)}\"` : '',\n\t]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n\treturn `<div ${attrs}>${serializeHtmlChildren(element)}</div>`;\n}\n\nfunction splitRubricView(view: string): string[] {\n\treturn view.split(/[\\s,]+/).filter(Boolean);\n}\n\nfunction serializeHtmlChildren(element: ParsedHtmlElement): string {\n\treturn ([...element.childNodes] as unknown as ParsedHtmlElement[])\n\t\t.map((child) => child.toString())\n\t\t.join('');\n}\n\n/**\n * One mount per interaction that resolves, in document order: slotted interactions in slot\n * order, then any whose element is not in the body, in extraction order. An interaction whose\n * component the registry cannot resolve gets no mount — the host hears the failure once\n * through `onComponentError` — and is returned in `failedInteractions` with the slot it\n * owned, so the presenter can stand the render-failed placeholder where it was authored.\n */\nfunction createInteractionMounts({\n\tinteractions,\n\tslots,\n\tsource,\n\tresponses,\n\tcorrectResponses,\n\troleCapabilities,\n\teffectiveDisabled,\n\tonComponentError,\n}: {\n\tinteractions: readonly BaseInteractionData[];\n\tslots: ReadonlyMap<number, string>;\n\tsource: ItemPresentationSource;\n\tresponses: ItemPresentationResponseMap;\n\tcorrectResponses: Record<string, unknown>;\n\troleCapabilities: RoleCapabilities;\n\teffectiveDisabled: boolean;\n\tonComponentError?: (interaction: BaseInteractionData, error: unknown) => void;\n}): { mounts: ItemInteractionMount[]; failedInteractions: FailedInteractionMount[] } {\n\tconst slotRank = (index: number) => {\n\t\tconst slot = slots.get(index);\n\t\treturn slot === undefined ? Number.POSITIVE_INFINITY : Number(slot);\n\t};\n\tconst order = interactions.map((_, index) => index).sort((a, b) => slotRank(a) - slotRank(b));\n\tconst inlineCount = interactions.filter((interaction) => isInlineInteractionType(interaction.type)).length;\n\tconst usedKeys = new Map<string, number>();\n\tconst uniqueKey = (interaction: BaseInteractionData) => {\n\t\tconst key = interactionKey(interaction);\n\t\tconst seen = usedKeys.get(key) ?? 0;\n\t\tusedKeys.set(key, seen + 1);\n\t\t// Keyed rendering needs distinct keys even for (invalid) duplicate interactions.\n\t\treturn seen === 0 ? key : `${key}#${seen}`;\n\t};\n\n\tconst mounts: ItemInteractionMount[] = [];\n\tconst failedInteractions: FailedInteractionMount[] = [];\n\tlet inlineIndex = 0;\n\tfor (const index of order) {\n\t\tconst interaction = interactions[index];\n\t\tconst slot = slots.get(index) ?? null;\n\t\tif (isInlineInteractionType(interaction.type)) {\n\t\t\tinlineIndex += 1;\n\t\t\tconst inline = {\n\t\t\t\tplacement: 'inline' as const,\n\t\t\t\tkey: uniqueKey(interaction),\n\t\t\t\tslot,\n\t\t\t\tposition: { index: inlineIndex, count: inlineCount },\n\t\t\t};\n\t\t\tif (interaction.type === 'textEntryInteraction') {\n\t\t\t\tconst textEntry = interaction as TextEntryInteractionData;\n\t\t\t\tconst stringIdentifier = textEntryStringIdentifier(textEntry);\n\t\t\t\tmounts.push({\n\t\t\t\t\t...inline,\n\t\t\t\t\trenderer: 'text-entry',\n\t\t\t\t\tinteraction: textEntry,\n\t\t\t\t\t...(stringIdentifier ? { stringResponse: responses[stringIdentifier] ?? null } : {}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tmounts.push({ ...inline, renderer: 'inline-choice', interaction: interaction as InlineChoiceInteractionData });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst stringIdentifier =\n\t\t\t\t'stringIdentifier' in interaction && typeof interaction.stringIdentifier === 'string'\n\t\t\t\t\t? interaction.stringIdentifier\n\t\t\t\t\t: undefined;\n\t\t\tconst block: BlockInteractionMount = {\n\t\t\t\tplacement: 'block',\n\t\t\t\trenderer: 'web-component',\n\t\t\t\tinteraction,\n\t\t\t\ttagName: source.componentRegistry.getTagName(interaction),\n\t\t\t\tkey: uniqueKey(interaction),\n\t\t\t\tslot,\n\t\t\t\tresponse: responses[interaction.responseId] ?? null,\n\t\t\t\t...(stringIdentifier\n\t\t\t\t\t? { stringResponse: responses[stringIdentifier] ?? null }\n\t\t\t\t\t: {}),\n\t\t\t\tcorrectResponse: roleCapabilities.canViewCorrectResponses\n\t\t\t\t\t? (correctResponses[interaction.responseId] ?? null)\n\t\t\t\t\t: null,\n\t\t\t\tpnp: source.pnp,\n\t\t\t\teliminationTool: source.pnp?.cognitive?.eliminationTool === true,\n\t\t\t\tanswerMasking: source.pnp?.cognitive?.answerMasking === true,\n\t\t\t\tstructuredLabelSupport: source.pnp?.display?.structuredLabelSupport === true,\n\t\t\t\tdisabled: effectiveDisabled,\n\t\t\t\tcomponentRole: roleCapabilities.canViewCorrectResponses ? 'scorer' : undefined,\n\t\t\t};\n\t\t\tmounts.push(block);\n\t\t} catch (error) {\n\t\t\t// No component renders the type: the interaction has no mount, the body keeps\n\t\t\t// rendering around it, and the slot it owned stays reserved for the placeholder.\n\t\t\tonComponentError?.(interaction, error);\n\t\t\tfailedInteractions.push({ key: uniqueKey(interaction), slot, interaction });\n\t\t}\n\t}\n\treturn { mounts, failedInteractions };\n}\n\nexport function interactionKey(interaction: BaseInteractionData): string {\n\tconst anyInteraction = interaction as any;\n\tconst ids =\n\t\tArray.isArray(anyInteraction?.choices) && anyInteraction.choices.length > 0\n\t\t\t? anyInteraction.choices.map((choice: any) => choice?.identifier).filter(Boolean).join(',')\n\t\t\t: '';\n\tconst prompt = typeof anyInteraction?.prompt === 'string' ? anyInteraction.prompt : '';\n\treturn `${interaction.type}|${interaction.responseId}|${ids}|${prompt}`;\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { escapeHtmlAttribute } from '../security/escapeHtml.js';
|
|
2
|
+
import { readHtmlAttribute } from '../utils/htmlAttributes.js';
|
|
1
3
|
/**
|
|
2
4
|
* Build the effective stimulus content map for an item render.
|
|
3
5
|
*
|
|
@@ -27,7 +29,7 @@ export function injectStimulusContent(itemBodyHtml, stimulusContent) {
|
|
|
27
29
|
return `<${tagName}${mergeClassAttribute(attrs, 'qti-stimulus-dock')}>${content}</${tagName}>`;
|
|
28
30
|
});
|
|
29
31
|
html = html.replace(/<qti-assessment-stimulus-ref\b([^>]*)\/?>\s*(?:<\/qti-assessment-stimulus-ref>)?/gi, (match, attrs) => {
|
|
30
|
-
const identifier =
|
|
32
|
+
const identifier = readHtmlAttribute(attrs, 'identifier');
|
|
31
33
|
if (!identifier)
|
|
32
34
|
return match;
|
|
33
35
|
if (docked.has(identifier))
|
|
@@ -44,10 +46,6 @@ export function injectStimulusContent(itemBodyHtml, stimulusContent) {
|
|
|
44
46
|
.join('');
|
|
45
47
|
return undocked ? undocked + html : html;
|
|
46
48
|
}
|
|
47
|
-
function extractAttribute(attrs, name) {
|
|
48
|
-
const match = attrs.match(new RegExp(`\\b${name}\\s*=\\s*["']([^"']+)["']`, 'i'));
|
|
49
|
-
return match?.[1] ?? null;
|
|
50
|
-
}
|
|
51
49
|
function mergeClassAttribute(attrs, className) {
|
|
52
50
|
const classMatch = attrs.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
|
|
53
51
|
if (!classMatch)
|
|
@@ -58,11 +56,4 @@ function mergeClassAttribute(attrs, className) {
|
|
|
58
56
|
classes.add(className);
|
|
59
57
|
return attrs.replace(classMatch[0], `class=${quote}${Array.from(classes).join(' ')}${quote}`);
|
|
60
58
|
}
|
|
61
|
-
function escapeHtmlAttribute(value) {
|
|
62
|
-
return value
|
|
63
|
-
.replace(/&/g, '&')
|
|
64
|
-
.replace(/"/g, '"')
|
|
65
|
-
.replace(/</g, '<')
|
|
66
|
-
.replace(/>/g, '>');
|
|
67
|
-
}
|
|
68
59
|
//# sourceMappingURL=stimulusRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stimulusRender.js","sourceRoot":"","sources":["../../src/presentation/stimulusRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAI/D;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC5C,eAAwD,EACxD,QAA2B;IAE3B,OAAO,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;QAC9E,UAAU;QACV,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;KAC3B,CAAC,CACF,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB,EAAE,eAAuC;IAClG,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,YAAY,CAAC;IAEnE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,IAAI,IAAI,GAAG,YAAY,CAAC,OAAO,CAC9B,+EAA+E,EAC/E,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAA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AC,CAAC,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa,EAAE,SAAiB;IAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAClE,IAAI,CAAC,UAAU;QAAE,OAAO,GAAG,KAAK,WAAW,SAAS,GAAG,CAAC;IACxD,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';\nimport { escapeHtmlAttribute } from '../security/escapeHtml.js';\nimport { readHtmlAttribute } from '../utils/htmlAttributes.js';\n\nexport type StimulusSanitizer = (html: string) => string;\n\n/**\n * Build the effective stimulus content map for an item render.\n *\n * Resolved delivery-context content is the package/assessment source of truth.\n */\nexport function buildEffectiveStimulusContent(\n\tdeliveryContext: ResolvedItemDeliveryContext | undefined,\n\tsanitize: StimulusSanitizer\n): Record<string, string> {\n\treturn Object.fromEntries(\n\t\tObject.entries(deliveryContext?.stimuli ?? {}).map(([identifier, stimulus]) => [\n\t\t\tidentifier,\n\t\t\tsanitize(stimulus.bodyHtml),\n\t\t])\n\t);\n}\n\n/**\n * Inject shared stimulus bodies at QTI refs or host-authored docking points.\n *\n * Any resolved stimulus that has no matching docking point is prepended in\n * delivery-context order so undocked package content is still visible.\n */\nexport function injectStimulusContent(itemBodyHtml: string, stimulusContent: Record<string, string>): string {\n\tif (Object.keys(stimulusContent).length === 0) return itemBodyHtml;\n\n\tconst docked = new Set<string>();\n\tlet html = itemBodyHtml.replace(\n\t\t/<([a-z][\\w:-]*)([^>]*\\bdata-stimulus-idref=([\"'])([^\"']+)\\3[^>]*)>\\s*<\\/\\1>/gi,\n\t\t(match, tagName, attrs, _quote, identifier) => {\n\t\t\tconst content = stimulusContent[identifier];\n\t\t\tif (!content) return match;\n\t\t\tdocked.add(identifier);\n\t\t\treturn `<${tagName}${mergeClassAttribute(attrs, 'qti-stimulus-dock')}>${content}</${tagName}>`;\n\t\t}\n\t);\n\n\thtml = html.replace(\n\t\t/<qti-assessment-stimulus-ref\\b([^>]*)\\/?>\\s*(?:<\\/qti-assessment-stimulus-ref>)?/gi,\n\t\t(match, attrs) => {\n\t\t\tconst identifier = readHtmlAttribute(attrs, 'identifier');\n\t\t\tif (!identifier) return match;\n\t\t\tif (docked.has(identifier)) return '';\n\t\t\tconst content = stimulusContent[identifier];\n\t\t\tif (!content) return match;\n\t\t\tdocked.add(identifier);\n\t\t\treturn `<div data-stimulus-idref=\"${escapeHtmlAttribute(identifier)}\" class=\"qti-stimulus-dock\">${content}</div>`;\n\t\t}\n\t);\n\n\tconst undocked = Object.entries(stimulusContent)\n\t\t.filter(([identifier]) => !docked.has(identifier))\n\t\t.map(\n\t\t\t([identifier, content]) =>\n\t\t\t\t`<div data-stimulus-idref=\"${escapeHtmlAttribute(identifier)}\" class=\"qti-stimulus-block\">${content}</div>`\n\t\t)\n\t\t.join('');\n\n\treturn undocked ? undocked + html : html;\n}\n\nfunction mergeClassAttribute(attrs: string, className: string): string {\n\tconst classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\tif (!classMatch) return `${attrs} class=\"${className}\"`;\n\tconst quote = classMatch[1]!;\n\tconst existing = classMatch[2] ?? '';\n\tconst classes = new Set(existing.split(/\\s+/).filter(Boolean));\n\tclasses.add(className);\n\treturn attrs.replace(classMatch[0], `class=${quote}${Array.from(classes).join(' ')}${quote}`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesheetRender.js","sourceRoot":"","sources":["../../src/presentation/stylesheetRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,UAAU,wBAAwB,CACvC,eAAwD,EACxD,aAAa,GAAG,4BAA4B;IAE5C,IAAI,CAAC,eAAe;QAAE,OAAO,EAAE,CAAC;IAChC,OAAO,eAAe,CAAC,WAAW;SAChC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,qBAAqB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;SACrE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAoC,EAAE,aAAqB;IACzF,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACnD,MAAM,eAAe,GAAG,0BAA0B,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAE3F,wFAAwF;AACxF,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAE7D,kFAAkF;A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sourcesContent":["import type { ResolvedItemDeliveryContext, ResolvedQtiStylesheetRef } from '@pie-qti/ims-cp-core';\nimport { isBlockedStylesheetCss } from '@pie-qti/ims-cp-core';\n\nexport function buildScopedStylesheetCss(\n\tdeliveryContext: ResolvedItemDeliveryContext | undefined,\n\tscopeSelector = '[data-qti-item-body-scope]'\n): string {\n\tif (!deliveryContext) return '';\n\treturn deliveryContext.stylesheets\n\t\t.map((stylesheet) => stylesheetToScopedCss(stylesheet, scopeSelector))\n\t\t.filter(Boolean)\n\t\t.join('\\n');\n}\n\nfunction stylesheetToScopedCss(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {\n\tconst css = stylesheet.cssText?.trim();\n\tif (!css || isBlockedStylesheetCss(css)) return '';\n\tconst stylesheetScope = getStylesheetScopeSelector(stylesheet, scopeSelector);\n\tconst scoped = scopeCssRules(css, stylesheetScope);\n\tif (!scoped) return '';\n\treturn scoped;\n}\n\n/**\n * At-rules whose block contains nested *rules*, so scoping recurses into the\n * block while the prelude is preserved verbatim.\n *\n * Anything not listed here is passed through untouched. That is the safe\n * default both ways: at-rules whose block holds declarations rather than rules\n * (`@font-face`, `@page`, `@property`, `@counter-style`) or non-selector keys\n * (`@keyframes` percentages) must not be scoped, and an at-rule this list has\n * never heard of is more safely left alone than guessed at.\n */\nconst NESTED_RULE_AT_RULES = new Set(['media', 'supports', 'container', 'layer', 'scope']);\n\n/** Matches a leading `:root`, `html` or `body` not followed by more name characters. */\nconst DOCUMENT_ROOT_PREFIX = /^(?::root|html|body)(?![\\w-])/;\n\n/** Matches an at-rule name, with any vendor prefix, at the start of a prelude. */\nconst AT_RULE_NAME = /^@(?:-[a-z]+-)?([\\w-]+)/i;\n\ntype StyleNode =\n\t/** A `;`-terminated at-rule with no block, such as `@layer a;`. */\n\t| { kind: 'statement'; text: string; end: number }\n\t/** A prelude plus a `{ ... }` block: a style rule or a block at-rule. */\n\t| { kind: 'rule'; prelude: string; block: string; end: number }\n\t/** Trailing text with no rule in it, kept so nothing is silently dropped. */\n\t| { kind: 'trailing'; text: string; end: number };\n\n/**\n * Confine every selector in `css` to `scopeSelector`.\n *\n * This walks the stylesheet brace-by-brace. It used to be a single regex over\n * `([^{}@]+)\\{([^{}]*)\\}`, which handled flat selector rules and silently\n * destroyed at-rules. Because `@` was excluded from the selector pattern rather\n * than *understood*, an `@media` block never matched as a unit, so the inner\n * rules matched on their own and were emitted **without the condition** — the\n * media query was dropped and its rules applied unconditionally, so a\n * print-only or narrow-viewport rule took effect everywhere. `@keyframes`\n * degraded the same way, with its percentage selectors scoped into\n * `[scope] 0%` and the animation name discarded, and `@font-face` became\n * `[scope] font-face`.\n *\n * A CSS parser would be the textbook answer and is deliberately not added:\n * scoping needs rule boundaries only, not property grammar, and this runs in\n * the delivery path.\n *\n * Note that `isBlockedStylesheetCss` rejects any stylesheet containing `url(`\n * or `@import` before this is reached, so `@font-face` with a real `src` never\n * arrives here in practice. `@media`, `@supports` and `@keyframes` do.\n */\nexport function scopeCssRules(css: string, scopeSelector = '[data-qti-item-body-scope]'): string {\n\tif (!css) return '';\n\tconst scope = scopeSelector?.trim();\n\tif (!scope) return css;\n\treturn scopeRuleList(stripComments(css), scope).trim();\n}\n\nfunction scopeRuleList(css: string, scope: string): string {\n\tlet out = '';\n\tlet index = 0;\n\twhile (index < css.length) {\n\t\tconst node = readNode(css, index);\n\t\tif (node.end <= index) break;\n\t\tout += renderNode(node, scope);\n\t\tindex = node.end;\n\t}\n\treturn out;\n}\n\nfunction renderNode(node: StyleNode, scope: string): string {\n\tif (node.kind === 'statement') {\n\t\tconst text = node.text.trim();\n\t\treturn text === ';' ? '' : `${text}\\n`;\n\t}\n\tif (node.kind === 'trailing') {\n\t\treturn node.text.trim() ? `${node.text.trim()}\\n` : '';\n\t}\n\tconst prelude = node.prelude.trim();\n\tif (!prelude) return '';\n\tif (prelude.startsWith('@')) {\n\t\tconst name = AT_RULE_NAME.exec(prelude)?.[1]?.toLowerCase();\n\t\tif (name && NESTED_RULE_AT_RULES.has(name)) {\n\t\t\tconst inner = scopeRuleList(node.block, scope);\n\t\t\tif (!inner.trim()) return '';\n\t\t\treturn `${prelude} {\\n${inner}}\\n`;\n\t\t}\n\t\treturn `${prelude} {${node.block}}\\n`;\n\t}\n\t// Rules with no declarations are dropped, as they were before.\n\tconst declarations = node.block.trim();\n\tif (!declarations) return '';\n\tconst selectors = splitTopLevel(prelude, ',')\n\t\t.map((selector) => scopeSelectorText(selector.trim(), scope))\n\t\t.filter(Boolean);\n\tif (selectors.length === 0) return '';\n\treturn `${selectors.join(', ')} { ${declarations} }\\n`;\n}\n\nfunction getStylesheetScopeSelector(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {\n\tif (stylesheet.source !== 'stimulus' || !stylesheet.stimulusIdentifier) return scopeSelector;\n\treturn `${scopeSelector} [data-stimulus-idref=\"${escapeCssString(stylesheet.stimulusIdentifier)}\"]`;\n}\n\nfunction scopeSelectorText(selector: string, scopeSelector: string): string {\n\tif (!selector) return '';\n\tif (selector === scopeSelector || selector.startsWith(`${scopeSelector} `)) return selector;\n\t// `:root`/`html`/`body` are replaced rather than prefixed: `[scope] :root`\n\t// cannot match, because `:root` is the document element and is not a\n\t// descendant of the item body. Whatever followed is preserved, so\n\t// `html.dark .a` becomes `[scope].dark .a`.\n\tconst rootPrefix = DOCUMENT_ROOT_PREFIX.exec(selector);\n\tif (rootPrefix) return `${scopeSelector}${selector.slice(rootPrefix[0].length)}`;\n\t// Everything else becomes a descendant, including a leading pseudo. This\n\t// used to attach — `[scope]:is(.a, .b)` — which is a different selector: an\n\t// authored `:is(.a, .b) .c` means \"some element matching .a or .b\", so\n\t// attaching demands that the item body itself carry the authored class, and\n\t// it does not. The same holds for `:hover` and `::selection`.\n\treturn `${scopeSelector} ${selector}`;\n}\n\n/**\n * Read one node starting at `start`, tracking strings and parentheses so a `{`\n * inside `content: \"{\"` or a `,` inside `:is(a, b)` is not mistaken for\n * structure.\n */\nfunction readNode(css: string, start: number): StyleNode {\n\tlet index = start;\n\tlet quote: string | null = null;\n\tlet parenDepth = 0;\n\twhile (index < css.length) {\n\t\tconst char = css[index];\n\t\tif (quote) {\n\t\t\tif (char === '\\\\') index += 1;\n\t\t\telse if (char === quote) quote = null;\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t} else if (char === '(') {\n\t\t\tparenDepth += 1;\n\t\t} else if (char === ')') {\n\t\t\tif (parenDepth > 0) parenDepth -= 1;\n\t\t} else if (parenDepth === 0 && char === ';') {\n\t\t\treturn { kind: 'statement', text: css.slice(start, index + 1), end: index + 1 };\n\t\t} else if (parenDepth === 0 && char === '{') {\n\t\t\tconst blockEnd = findBlockEnd(css, index);\n\t\t\treturn {\n\t\t\t\tkind: 'rule',\n\t\t\t\tprelude: css.slice(start, index),\n\t\t\t\tblock: css.slice(index + 1, blockEnd.contentEnd),\n\t\t\t\tend: blockEnd.end,\n\t\t\t};\n\t\t}\n\t\tindex += 1;\n\t}\n\treturn { kind: 'trailing', text: css.slice(start), end: css.length };\n}\n\n/**\n * Find the `}` matching the `{` at `openIndex`. Unbalanced input — a truncated\n * stylesheet — is treated as running to the end rather than throwing.\n */\nfunction findBlockEnd(css: string, openIndex: number): { contentEnd: number; end: number } {\n\tlet depth = 0;\n\tlet quote: string | null = null;\n\tfor (let index = openIndex; index < css.length; index += 1) {\n\t\tconst char = css[index];\n\t\tif (quote) {\n\t\t\tif (char === '\\\\') index += 1;\n\t\t\telse if (char === quote) quote = null;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '{') depth += 1;\n\t\telse if (char === '}') {\n\t\t\tdepth -= 1;\n\t\t\tif (depth === 0) return { contentEnd: index, end: index + 1 };\n\t\t}\n\t}\n\treturn { contentEnd: css.length, end: css.length };\n}\n\n/** Split on `separator` at paren depth zero and outside strings. */\nfunction splitTopLevel(value: string, separator: string): string[] {\n\tconst parts: string[] = [];\n\tlet current = '';\n\tlet quote: string | null = null;\n\tlet parenDepth = 0;\n\tfor (let index = 0; index < value.length; index += 1) {\n\t\tconst char = value[index] as string;\n\t\tif (quote) {\n\t\t\tcurrent += char;\n\t\t\tif (char === '\\\\' && index + 1 < value.length) {\n\t\t\t\tcurrent += value[index + 1];\n\t\t\t\tindex += 1;\n\t\t\t} else if (char === quote) {\n\t\t\t\tquote = null;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '(') parenDepth += 1;\n\t\telse if (char === ')' && parenDepth > 0) parenDepth -= 1;\n\t\tif (char === separator && parenDepth === 0) {\n\t\t\tparts.push(current);\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tcurrent += char;\n\t}\n\tparts.push(current);\n\treturn parts;\n}\n\n/**\n * Remove comments before walking, so a comment between two rules is not\n * absorbed into the next rule's selector list. String-aware, so a literal\n * `content: \"/*\"` survives — the previous regex strip was not.\n */\nfunction stripComments(css: string): string {\n\tlet out = '';\n\tlet quote: string | null = null;\n\tlet index = 0;\n\twhile (index < css.length) {\n\t\tconst char = css[index] as string;\n\t\tif (quote) {\n\t\t\tout += char;\n\t\t\tif (char === '\\\\' && index + 1 < css.length) {\n\t\t\t\tout += css[index + 1];\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === quote) quote = null;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tout += char;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '/' && css[index + 1] === '*') {\n\t\t\tconst close = css.indexOf('*/', index + 2);\n\t\t\tindex = close === -1 ? css.length : close + 2;\n\t\t\t// Keep a space so `a/**/b` does not become the single token `ab`.\n\t\t\tout += ' ';\n\t\t\tcontinue;\n\t\t}\n\t\tout += char;\n\t\tindex += 1;\n\t}\n\treturn out;\n}\n\nfunction escapeCssString(value: string): string {\n\treturn value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\n|\\r|\\f/g, ' ');\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape plain text for a double-quoted HTML attribute value.
|
|
3
|
+
*
|
|
4
|
+
* Every copy of this escape in the player (presentation plans, the sanitizer's
|
|
5
|
+
* attribute rebuilds, catalog file hrefs, read-aloud attributes) writes the
|
|
6
|
+
* result into a double-quoted attribute, so `"`, `&`, `<` and `>` are exactly
|
|
7
|
+
* the characters that need escaping; `'` cannot break such a value and is left
|
|
8
|
+
* as authored.
|
|
9
|
+
*
|
|
10
|
+
* Attributes read with node-html-parser arrive decoded, so a decoded value is
|
|
11
|
+
* escaped exactly once here; callers that read raw source text with a regex
|
|
12
|
+
* (stimulus docking) keep the value's authored entities and re-escape them,
|
|
13
|
+
* which stays byte-identical to the previous per-file copies.
|
|
14
|
+
*/
|
|
15
|
+
export declare function escapeHtmlAttribute(value: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape plain text for a double-quoted HTML attribute value.
|
|
3
|
+
*
|
|
4
|
+
* Every copy of this escape in the player (presentation plans, the sanitizer's
|
|
5
|
+
* attribute rebuilds, catalog file hrefs, read-aloud attributes) writes the
|
|
6
|
+
* result into a double-quoted attribute, so `"`, `&`, `<` and `>` are exactly
|
|
7
|
+
* the characters that need escaping; `'` cannot break such a value and is left
|
|
8
|
+
* as authored.
|
|
9
|
+
*
|
|
10
|
+
* Attributes read with node-html-parser arrive decoded, so a decoded value is
|
|
11
|
+
* escaped exactly once here; callers that read raw source text with a regex
|
|
12
|
+
* (stimulus docking) keep the value's authored entities and re-escape them,
|
|
13
|
+
* which stays byte-identical to the previous per-file copies.
|
|
14
|
+
*/
|
|
15
|
+
export function escapeHtmlAttribute(value) {
|
|
16
|
+
return value
|
|
17
|
+
.replace(/&/g, '&')
|
|
18
|
+
.replace(/"/g, '"')
|
|
19
|
+
.replace(/</g, '<')
|
|
20
|
+
.replace(/>/g, '>');
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=escapeHtml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escapeHtml.js","sourceRoot":"","sources":["../../src/security/escapeHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAChD,OAAO,KAAK;SACV,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Escape plain text for a double-quoted HTML attribute value.\n *\n * Every copy of this escape in the player (presentation plans, the sanitizer's\n * attribute rebuilds, catalog file hrefs, read-aloud attributes) writes the\n * result into a double-quoted attribute, so `\"`, `&`, `<` and `>` are exactly\n * the characters that need escaping; `'` cannot break such a value and is left\n * as authored.\n *\n * Attributes read with node-html-parser arrive decoded, so a decoded value is\n * escaped exactly once here; callers that read raw source text with a regex\n * (stimulus docking) keep the value's authored entities and re-escape them,\n * which stays byte-identical to the previous per-file copies.\n */\nexport function escapeHtmlAttribute(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '&')\n\t\t.replace(/\"/g, '"')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>');\n}\n"]}
|
package/dist/security/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { sanitizeHtml, sanitizeTextContent, type SanitizeHtmlOptions };
|
|
|
6
6
|
export { sanitizeResourceUrl, type UrlKind };
|
|
7
7
|
export { enforceItemXmlLimits, normalizeParsingLimits, type NormalizedParsingLimits, } from '../core/parsingLimits.js';
|
|
8
8
|
export { toTrustedHtml, htmlToString };
|
|
9
|
+
export { escapeHtmlAttribute } from './escapeHtml.js';
|
|
9
10
|
export { normalizeCssPixelLength, normalizePixelDimension, type CssPixelLength, } from './styleValues.js';
|
|
10
11
|
export type { HtmlContent, ParsingLimitsConfig, PlayerSecurityConfig, TrustedTypesHtml, UrlPolicyConfig, } from '../types/index.js';
|
|
11
12
|
export interface SanitizeSharedHtmlOptions {
|
package/dist/security/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { sanitizeHtml, sanitizeTextContent };
|
|
|
5
5
|
export { sanitizeResourceUrl };
|
|
6
6
|
export { enforceItemXmlLimits, normalizeParsingLimits, } from '../core/parsingLimits.js';
|
|
7
7
|
export { toTrustedHtml, htmlToString };
|
|
8
|
+
export { escapeHtmlAttribute } from './escapeHtml.js';
|
|
8
9
|
export { normalizeCssPixelLength, normalizePixelDimension, } from './styleValues.js';
|
|
9
10
|
export function sanitizeSharedHtml(html, security, options) {
|
|
10
11
|
const sanitized = sanitizeHtml(html, { security, sanitizeUrl: options?.sanitizeUrl });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA4B,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAgB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA4B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAgB,CAAC;AAC7C,OAAO,EACN,oBAAoB,EACpB,sBAAsB,GAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AACvC,OAAO,EACN,uBAAuB,EACvB,uBAAuB,GAEvB,MAAM,kBAAkB,CAAC;AAa1B,MAAM,UAAU,kBAAkB,CACjC,IAAY,EACZ,QAA+B,EAC/B,OAAmC;IAEnC,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IACtF,OAAO,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,sBAAsB,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { sanitizeHtml, sanitizeTextContent, type SanitizeHtmlOptions } from '../core/sanitizer.js';\nimport { sanitizeResourceUrl, type UrlKind } from '../core/urlPolicy.js';\nimport { toTrustedHtml, htmlToString } from '../core/trustedTypes.js';\nimport type { HtmlContent, PlayerSecurityConfig } from '../types/index.js';\n\nexport { sanitizeHtml, sanitizeTextContent, type SanitizeHtmlOptions };\nexport { sanitizeResourceUrl, type UrlKind };\nexport {\n\tenforceItemXmlLimits,\n\tnormalizeParsingLimits,\n\ttype NormalizedParsingLimits,\n} from '../core/parsingLimits.js';\nexport { toTrustedHtml, htmlToString };\nexport {\n\tnormalizeCssPixelLength,\n\tnormalizePixelDimension,\n\ttype CssPixelLength,\n} from './styleValues.js';\nexport type {\n\tHtmlContent,\n\tParsingLimitsConfig,\n\tPlayerSecurityConfig,\n\tTrustedTypesHtml,\n\tUrlPolicyConfig,\n} from '../types/index.js';\n\nexport interface SanitizeSharedHtmlOptions {\n\tsanitizeUrl?: SanitizeHtmlOptions['sanitizeUrl'];\n}\n\nexport function sanitizeSharedHtml(\n\thtml: string,\n\tsecurity?: PlayerSecurityConfig,\n\toptions?: SanitizeSharedHtmlOptions\n): HtmlContent {\n\tconst sanitized = sanitizeHtml(html, { security, sanitizeUrl: options?.sanitizeUrl });\n\treturn toTrustedHtml(sanitized, security?.trustedTypesPolicyName);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA4B,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAgB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA4B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAgB,CAAC;AAC7C,OAAO,EACN,oBAAoB,EACpB,sBAAsB,GAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACN,uBAAuB,EACvB,uBAAuB,GAEvB,MAAM,kBAAkB,CAAC;AAa1B,MAAM,UAAU,kBAAkB,CACjC,IAAY,EACZ,QAA+B,EAC/B,OAAmC;IAEnC,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IACtF,OAAO,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,sBAAsB,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { sanitizeHtml, sanitizeTextContent, type SanitizeHtmlOptions } from '../core/sanitizer.js';\nimport { sanitizeResourceUrl, type UrlKind } from '../core/urlPolicy.js';\nimport { toTrustedHtml, htmlToString } from '../core/trustedTypes.js';\nimport type { HtmlContent, PlayerSecurityConfig } from '../types/index.js';\n\nexport { sanitizeHtml, sanitizeTextContent, type SanitizeHtmlOptions };\nexport { sanitizeResourceUrl, type UrlKind };\nexport {\n\tenforceItemXmlLimits,\n\tnormalizeParsingLimits,\n\ttype NormalizedParsingLimits,\n} from '../core/parsingLimits.js';\nexport { toTrustedHtml, htmlToString };\nexport { escapeHtmlAttribute } from './escapeHtml.js';\nexport {\n\tnormalizeCssPixelLength,\n\tnormalizePixelDimension,\n\ttype CssPixelLength,\n} from './styleValues.js';\nexport type {\n\tHtmlContent,\n\tParsingLimitsConfig,\n\tPlayerSecurityConfig,\n\tTrustedTypesHtml,\n\tUrlPolicyConfig,\n} from '../types/index.js';\n\nexport interface SanitizeSharedHtmlOptions {\n\tsanitizeUrl?: SanitizeHtmlOptions['sanitizeUrl'];\n}\n\nexport function sanitizeSharedHtml(\n\thtml: string,\n\tsecurity?: PlayerSecurityConfig,\n\toptions?: SanitizeSharedHtmlOptions\n): HtmlContent {\n\tconst sanitized = sanitizeHtml(html, { security, sanitizeUrl: options?.sanitizeUrl });\n\treturn toTrustedHtml(sanitized, security?.trustedTypesPolicyName);\n}\n"]}
|
package/dist/server.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export interface ServerSerializedVariable {
|
|
|
22
22
|
baseType?: string;
|
|
23
23
|
cardinality: string;
|
|
24
24
|
value: unknown;
|
|
25
|
-
defaultValue
|
|
25
|
+
defaultValue: unknown;
|
|
26
|
+
/** Present only on response variables that have or had a correct response; null when it is NULL. */
|
|
27
|
+
correctResponse?: unknown;
|
|
26
28
|
}
|
|
27
29
|
export interface ServerResponseValidationIssue {
|
|
28
30
|
responseId: string;
|
|
@@ -168,6 +170,11 @@ export interface ServerAssessmentItemDefinitionConfig {
|
|
|
168
170
|
class?: string;
|
|
169
171
|
definition?: string;
|
|
170
172
|
}) => ServerQtiValue>>;
|
|
173
|
+
/** String comparison folds beyond QTI's equality; see `AssessmentItemDefinitionConfig.stringComparison`. */
|
|
174
|
+
readonly stringComparison?: Readonly<{
|
|
175
|
+
foldScriptInput?: boolean;
|
|
176
|
+
foldLetterVariants?: boolean;
|
|
177
|
+
}>;
|
|
171
178
|
readonly resolveProcessingFragment?: (request: ServerProcessingFragmentRequest) => string | null | undefined;
|
|
172
179
|
readonly processingFragmentLimits?: Readonly<{
|
|
173
180
|
maxDepth?: number;
|