@pie-qti/item-player 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -18
- package/dist/catalog/applyGlossaryTriggers.d.ts +15 -0
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -0
- package/dist/catalog/applyGlossaryTriggers.js +193 -0
- package/dist/catalog/catalogExtractor.d.ts +18 -0
- package/dist/catalog/catalogExtractor.d.ts.map +1 -0
- package/dist/catalog/catalogExtractor.js +114 -0
- package/dist/catalog/catalogLookup.d.ts +18 -0
- package/dist/catalog/catalogLookup.d.ts.map +1 -0
- package/dist/catalog/catalogLookup.js +44 -0
- package/dist/catalog/glossaryAction.d.ts +17 -0
- package/dist/catalog/glossaryAction.d.ts.map +1 -0
- package/dist/catalog/glossaryAction.js +21 -0
- package/dist/catalog/types.d.ts +26 -0
- package/dist/catalog/types.d.ts.map +1 -0
- package/dist/catalog/types.js +6 -0
- package/dist/core/ComponentRegistry.d.ts +9 -0
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +14 -0
- package/dist/core/ItemRenderer.d.ts.map +1 -1
- package/dist/core/ItemRenderer.js +3 -0
- package/dist/core/Player.d.ts +52 -0
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +158 -4
- package/dist/core/rolePolicy.d.ts +16 -0
- package/dist/core/rolePolicy.d.ts.map +1 -0
- package/dist/core/rolePolicy.js +15 -0
- package/dist/core/urlPolicy.d.ts.map +1 -1
- package/dist/core/urlPolicy.js +5 -2
- package/dist/element.d.ts +22 -0
- package/dist/element.js +5327 -0
- package/dist/element.js.map +1 -0
- package/dist/extraction/ExtractionRegistry.d.ts.map +1 -1
- package/dist/extraction/ExtractionRegistry.js +3 -1
- package/dist/extraction/extractors/associateExtractor.d.ts +1 -0
- package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/associateExtractor.js +3 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts +2 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/choiceExtractor.js +10 -0
- package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/extendedTextExtractor.js +6 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/gapMatchExtractor.js +33 -20
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicAssociateExtractor.js +3 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +11 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicGapMatchExtractor.js +71 -10
- package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/hotspotExtractor.js +27 -8
- package/dist/extraction/extractors/hottextExtractor.d.ts +1 -1
- package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/hottextExtractor.js +12 -4
- package/dist/extraction/extractors/index.d.ts +1 -0
- package/dist/extraction/extractors/index.d.ts.map +1 -1
- package/dist/extraction/extractors/index.js +4 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +3 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/inlineChoiceExtractor.js +17 -4
- package/dist/extraction/extractors/matchExtractor.d.ts +5 -0
- package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/matchExtractor.js +26 -0
- package/dist/extraction/extractors/orderExtractor.d.ts +2 -0
- package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/orderExtractor.js +4 -0
- package/dist/extraction/extractors/portableCustomExtractor.d.ts +14 -0
- package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/portableCustomExtractor.js +96 -0
- package/dist/extraction/extractors/selectPointExtractor.js +5 -5
- package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -0
- package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/textEntryExtractor.js +6 -0
- package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/uploadExtractor.js +9 -2
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/pci/PciHost.d.ts +53 -0
- package/dist/pci/PciHost.d.ts.map +1 -0
- package/dist/pci/PciHost.js +116 -0
- package/dist/pci/types.d.ts +57 -0
- package/dist/pci/types.d.ts.map +1 -0
- package/dist/pci/types.js +19 -0
- package/dist/pnp/applyPnp.d.ts +9 -0
- package/dist/pnp/applyPnp.d.ts.map +1 -0
- package/dist/pnp/applyPnp.js +19 -0
- package/dist/pnp/parsePnpXml.d.ts +9 -0
- package/dist/pnp/parsePnpXml.d.ts.map +1 -0
- package/dist/pnp/parsePnpXml.js +101 -0
- package/dist/pnp/types.d.ts +40 -0
- package/dist/pnp/types.d.ts.map +1 -0
- package/dist/pnp/types.js +1 -0
- package/dist/types/index.d.ts +22 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interactions.d.ts +90 -1
- package/dist/types/interactions.d.ts.map +1 -1
- package/package.json +19 -9
- package/src/__tests__/catalog.test.ts +267 -0
- package/src/__tests__/fixtures/pci/echo-pci.js +49 -0
- package/src/__tests__/glossaryTriggers.test.ts +411 -0
- package/src/__tests__/pci.test.ts +353 -0
- package/src/__tests__/pnp.test.ts +250 -0
- package/src/__tests__/qti3-extraction.test.ts +5 -5
- package/src/catalog/applyGlossaryTriggers.ts +232 -0
- package/src/catalog/catalogExtractor.ts +130 -0
- package/src/catalog/catalogLookup.ts +53 -0
- package/src/catalog/glossaryAction.ts +28 -0
- package/src/catalog/types.ts +37 -0
- package/src/components/ItemBody.svelte +134 -26
- package/src/components/ItemPlayer.svelte +6 -2
- package/src/components/index.ts +3 -0
- package/src/core/ComponentRegistry.ts +14 -0
- package/src/core/ItemRenderer.ts +4 -0
- package/src/core/Player.ts +174 -4
- package/src/core/rolePolicy.ts +34 -0
- package/src/core/urlPolicy.ts +5 -2
- package/src/element.ts +128 -0
- package/src/extraction/ExtractionRegistry.ts +5 -1
- package/src/extraction/extractors/associateExtractor.ts +4 -0
- package/src/extraction/extractors/choiceExtractor.ts +12 -1
- package/src/extraction/extractors/conformance-qti3-advanced.test.ts +239 -0
- package/src/extraction/extractors/conformance-qti3-basic.test.ts +82 -0
- package/src/extraction/extractors/conformance.test.ts +208 -0
- package/src/extraction/extractors/extendedTextExtractor.ts +6 -0
- package/src/extraction/extractors/gapMatchExtractor.ts +36 -21
- package/src/extraction/extractors/graphicAssociateExtractor.ts +4 -0
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +82 -10
- package/src/extraction/extractors/hotspotExtractor.ts +26 -8
- package/src/extraction/extractors/hottextExtractor.ts +15 -5
- package/src/extraction/extractors/index.ts +4 -0
- package/src/extraction/extractors/inlineChoiceExtractor.ts +22 -5
- package/src/extraction/extractors/matchExtractor.ts +31 -4
- package/src/extraction/extractors/orderExtractor.ts +6 -0
- package/src/extraction/extractors/portableCustomExtractor.ts +122 -0
- package/src/extraction/extractors/selectPointExtractor.ts +5 -5
- package/src/extraction/extractors/textEntryExtractor.ts +7 -0
- package/src/extraction/extractors/uploadExtractor.ts +10 -2
- package/src/index.ts +17 -1
- package/src/pci/PciHost.ts +138 -0
- package/src/pci/types.ts +70 -0
- package/src/pnp/applyPnp.ts +23 -0
- package/src/pnp/parsePnpXml.ts +118 -0
- package/src/pnp/types.ts +33 -0
- package/src/types/index.ts +22 -8
- package/src/types/interactions.ts +81 -6
|
@@ -11,8 +11,11 @@ export interface InlineChoiceData {
|
|
|
11
11
|
choices: Array<{
|
|
12
12
|
identifier: string;
|
|
13
13
|
text: string;
|
|
14
|
+
fixed?: boolean;
|
|
14
15
|
}>;
|
|
15
16
|
shuffle: boolean;
|
|
17
|
+
/** Text from the QTI <label> child element; used as the placeholder "Select…" option */
|
|
18
|
+
label: string | null;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
21
|
* Standard QTI inline choice interaction extractor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineChoiceExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/inlineChoiceExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"inlineChoiceExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/inlineChoiceExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,wFAAwF;IACxF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,gBAAgB,CAAC,gBAAgB,CAkF5E,CAAC"}
|
|
@@ -21,15 +21,28 @@ export const standardInlineChoiceExtractor = {
|
|
|
21
21
|
const { utils } = context;
|
|
22
22
|
// Extract choices (inlineChoice children)
|
|
23
23
|
const inlineChoices = utils.getChildrenByTag(element, 'inlineChoice');
|
|
24
|
-
const choices = inlineChoices.map((choice) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const choices = inlineChoices.map((choice) => {
|
|
25
|
+
const fixed = utils.getBooleanAttribute(choice, 'fixed');
|
|
26
|
+
return {
|
|
27
|
+
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
28
|
+
text: utils.getTextContent(choice),
|
|
29
|
+
...(fixed ? { fixed } : {}),
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
// Extract <label> child — used as placeholder text in the dropdown
|
|
33
|
+
const labelElements = utils.getChildrenByTag(element, 'label');
|
|
34
|
+
const label = labelElements.length > 0 ? utils.getTextContent(labelElements[0]) : null;
|
|
35
|
+
// data-prompt: alternative placeholder for the dropdown default option
|
|
36
|
+
const dataPrompt = utils.getAttribute(element, 'data-prompt', '') || null;
|
|
28
37
|
// Extract attributes
|
|
29
38
|
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
39
|
+
const interactionClasses = utils.getClasses(element);
|
|
30
40
|
return {
|
|
31
41
|
choices,
|
|
32
42
|
shuffle,
|
|
43
|
+
label,
|
|
44
|
+
...(dataPrompt ? { dataPrompt } : {}),
|
|
45
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
33
46
|
};
|
|
34
47
|
},
|
|
35
48
|
validate(data) {
|
|
@@ -12,16 +12,21 @@ export interface MatchData {
|
|
|
12
12
|
identifier: string;
|
|
13
13
|
text: string;
|
|
14
14
|
matchMax: number;
|
|
15
|
+
matchMin?: number;
|
|
16
|
+
matchGroup?: string[];
|
|
15
17
|
classes?: string[];
|
|
16
18
|
}>;
|
|
17
19
|
targetSet: Array<{
|
|
18
20
|
identifier: string;
|
|
19
21
|
text: string;
|
|
20
22
|
matchMax: number;
|
|
23
|
+
matchMin?: number;
|
|
24
|
+
matchGroup?: string[];
|
|
21
25
|
classes?: string[];
|
|
22
26
|
}>;
|
|
23
27
|
shuffle: boolean;
|
|
24
28
|
maxAssociations: number;
|
|
29
|
+
minAssociations?: number;
|
|
25
30
|
prompt: string | null;
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/matchExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,SAAS,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"matchExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/matchExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,SAAS,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACvI,SAAS,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACvI,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,CAAC,SAAS,CAkK9D,CAAC"}
|
|
@@ -33,10 +33,15 @@ export const standardMatchExtractor = {
|
|
|
33
33
|
sourceSet = sourceElements.map((choice) => {
|
|
34
34
|
const classes = utils.getClasses(choice);
|
|
35
35
|
const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
|
|
36
|
+
const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
|
|
37
|
+
const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
|
|
38
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
36
39
|
return {
|
|
37
40
|
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
38
41
|
text: utils.getHtmlContent(choice),
|
|
39
42
|
matchMax,
|
|
43
|
+
...(matchMin > 0 ? { matchMin } : {}),
|
|
44
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
40
45
|
...(classes.length > 0 ? { classes } : {}),
|
|
41
46
|
};
|
|
42
47
|
});
|
|
@@ -46,10 +51,15 @@ export const standardMatchExtractor = {
|
|
|
46
51
|
targetSet = targetElements.map((choice) => {
|
|
47
52
|
const classes = utils.getClasses(choice);
|
|
48
53
|
const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
|
|
54
|
+
const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
|
|
55
|
+
const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
|
|
56
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
49
57
|
return {
|
|
50
58
|
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
51
59
|
text: utils.getHtmlContent(choice),
|
|
52
60
|
matchMax,
|
|
61
|
+
...(matchMin > 0 ? { matchMin } : {}),
|
|
62
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
53
63
|
...(classes.length > 0 ? { classes } : {}),
|
|
54
64
|
};
|
|
55
65
|
});
|
|
@@ -59,10 +69,15 @@ export const standardMatchExtractor = {
|
|
|
59
69
|
const extractedChoices = allChoices.map((choice) => {
|
|
60
70
|
const classes = utils.getClasses(choice);
|
|
61
71
|
const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
|
|
72
|
+
const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
|
|
73
|
+
const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
|
|
74
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
62
75
|
return {
|
|
63
76
|
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
64
77
|
text: utils.getHtmlContent(choice),
|
|
65
78
|
matchMax,
|
|
79
|
+
...(matchMin > 0 ? { matchMin } : {}),
|
|
80
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
66
81
|
...(classes.length > 0 ? { classes } : {}),
|
|
67
82
|
};
|
|
68
83
|
});
|
|
@@ -72,6 +87,12 @@ export const standardMatchExtractor = {
|
|
|
72
87
|
// Extract attributes
|
|
73
88
|
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
74
89
|
const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 1);
|
|
90
|
+
const minAssociationsRaw = utils.getNumberAttribute(element, 'minAssociations', 0);
|
|
91
|
+
const minAssociations = minAssociationsRaw > 0 ? minAssociationsRaw : undefined;
|
|
92
|
+
const interactionClasses = utils.getClasses(element);
|
|
93
|
+
const maxSelectionsMessage = utils.getAttribute(element, 'data-qti-max-selections-message', '') || null;
|
|
94
|
+
const minSelectionsMessage = utils.getAttribute(element, 'data-qti-min-selections-message', '') || null;
|
|
95
|
+
const firstColumnHeader = utils.getAttribute(element, 'data-qti-first-column-header', '') || null;
|
|
75
96
|
// Extract prompt (optional)
|
|
76
97
|
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
77
98
|
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
@@ -80,7 +101,12 @@ export const standardMatchExtractor = {
|
|
|
80
101
|
targetSet,
|
|
81
102
|
shuffle,
|
|
82
103
|
maxAssociations,
|
|
104
|
+
...(minAssociations !== undefined ? { minAssociations } : {}),
|
|
83
105
|
prompt,
|
|
106
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
107
|
+
...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
|
|
108
|
+
...(minSelectionsMessage ? { minSelectionsMessage } : {}),
|
|
109
|
+
...(firstColumnHeader ? { firstColumnHeader } : {}),
|
|
84
110
|
};
|
|
85
111
|
},
|
|
86
112
|
validate(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/orderExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,OAAO,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC1F,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"orderExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/orderExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,OAAO,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC1F,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,CAAC,SAAS,CA+F9D,CAAC"}
|
|
@@ -37,10 +37,14 @@ export const standardOrderExtractor = {
|
|
|
37
37
|
// Extract attributes
|
|
38
38
|
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
39
39
|
const orientation = utils.getAttribute(element, 'orientation', 'vertical');
|
|
40
|
+
const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
|
|
41
|
+
const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 0);
|
|
40
42
|
return {
|
|
41
43
|
choices,
|
|
42
44
|
shuffle,
|
|
43
45
|
orientation,
|
|
46
|
+
minChoices,
|
|
47
|
+
maxChoices,
|
|
44
48
|
prompt,
|
|
45
49
|
};
|
|
46
50
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ElementExtractor } from '../types.js';
|
|
2
|
+
import type { ExtractedPci } from '../../pci/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extractor for <qti-portable-custom-interaction> (QTI 3.0) and
|
|
5
|
+
* <portableCustomInteraction> (QTI 2.x vendor extension).
|
|
6
|
+
*
|
|
7
|
+
* Extracts the module paths, markup, and config properties needed by PciHost
|
|
8
|
+
* to load and initialize the PCI JavaScript module.
|
|
9
|
+
*
|
|
10
|
+
* Priority 20 > standardCustomExtractor priority 10, so this runs first when
|
|
11
|
+
* both would match the same element.
|
|
12
|
+
*/
|
|
13
|
+
export declare const portableCustomExtractor: ElementExtractor<ExtractedPci>;
|
|
14
|
+
//# sourceMappingURL=portableCustomExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portableCustomExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/portableCustomExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,CAAC,YAAY,CA4GlE,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extractor for <qti-portable-custom-interaction> (QTI 3.0) and
|
|
3
|
+
* <portableCustomInteraction> (QTI 2.x vendor extension).
|
|
4
|
+
*
|
|
5
|
+
* Extracts the module paths, markup, and config properties needed by PciHost
|
|
6
|
+
* to load and initialize the PCI JavaScript module.
|
|
7
|
+
*
|
|
8
|
+
* Priority 20 > standardCustomExtractor priority 10, so this runs first when
|
|
9
|
+
* both would match the same element.
|
|
10
|
+
*/
|
|
11
|
+
export const portableCustomExtractor = {
|
|
12
|
+
id: 'qti:portable-custom-interaction',
|
|
13
|
+
name: 'QTI Portable Custom Interaction',
|
|
14
|
+
priority: 20,
|
|
15
|
+
elementTypes: [
|
|
16
|
+
'portableCustomInteraction',
|
|
17
|
+
'qti-portable-custom-interaction',
|
|
18
|
+
],
|
|
19
|
+
description: 'Extracts QTI 3.0 portable custom interaction module paths, markup, and config',
|
|
20
|
+
canHandle(element, _context) {
|
|
21
|
+
const tag = element.rawTagName?.toLowerCase() ?? '';
|
|
22
|
+
return (tag === 'qti-portable-custom-interaction' ||
|
|
23
|
+
tag === 'portablecustominteraction');
|
|
24
|
+
},
|
|
25
|
+
extract(element, context) {
|
|
26
|
+
const { utils } = context;
|
|
27
|
+
const responseIdentifier = utils.getAttribute(element, 'responseIdentifier') ||
|
|
28
|
+
utils.getAttribute(element, 'response-identifier') || '';
|
|
29
|
+
const customInteractionTypeIdentifier = utils.getAttribute(element, 'customInteractionTypeIdentifier') ||
|
|
30
|
+
utils.getAttribute(element, 'custom-interaction-type-identifier') || '';
|
|
31
|
+
// --- Module paths from <qti-interaction-modules>/<qti-interaction-module> ---
|
|
32
|
+
// These element names ARE in the standard QTI 3.0 element mapper so utils.querySelector works.
|
|
33
|
+
let primaryPath = '';
|
|
34
|
+
let fallbackPath;
|
|
35
|
+
const modulesEl = utils.querySelector(element, 'qti-interaction-modules') ??
|
|
36
|
+
utils.querySelector(element, 'interactionmodules');
|
|
37
|
+
if (modulesEl) {
|
|
38
|
+
const moduleEl = utils.querySelector(modulesEl, 'qti-interaction-module') ??
|
|
39
|
+
utils.querySelector(modulesEl, 'interactionmodule');
|
|
40
|
+
if (moduleEl) {
|
|
41
|
+
primaryPath =
|
|
42
|
+
utils.getAttribute(moduleEl, 'primaryPath') ||
|
|
43
|
+
utils.getAttribute(moduleEl, 'primary-path') || '';
|
|
44
|
+
const fb = utils.getAttribute(moduleEl, 'fallbackPath') ||
|
|
45
|
+
utils.getAttribute(moduleEl, 'fallback-path') || '';
|
|
46
|
+
if (fb)
|
|
47
|
+
fallbackPath = fb;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// --- Markup from <qti-interaction-markup> ---
|
|
51
|
+
const markupEl = utils.querySelector(element, 'qti-interaction-markup') ??
|
|
52
|
+
utils.querySelector(element, 'interactionmarkup');
|
|
53
|
+
const markup = markupEl ? utils.getHtmlContent(markupEl) : '';
|
|
54
|
+
// --- Config from <qti-pci-properties>/<qti-pci-property> ---
|
|
55
|
+
// qti-pci-properties is NOT in the standard QTI 3.0 element mapper, so we use the
|
|
56
|
+
// native node-html-parser querySelector (available as element.querySelector on the raw element).
|
|
57
|
+
const config = {};
|
|
58
|
+
const rawEl = element;
|
|
59
|
+
const propsEl = rawEl.querySelector?.('qti-pci-properties') ??
|
|
60
|
+
rawEl.querySelector?.('pciproperties');
|
|
61
|
+
if (propsEl) {
|
|
62
|
+
const propEls = [
|
|
63
|
+
...(propsEl.querySelectorAll?.('qti-pci-property') ?? []),
|
|
64
|
+
...(propsEl.querySelectorAll?.('pciproperty') ?? []),
|
|
65
|
+
];
|
|
66
|
+
for (const propEl of propEls) {
|
|
67
|
+
const key = propEl.getAttribute?.('key') || propEl.getAttribute?.('name') || '';
|
|
68
|
+
const value = propEl.getAttribute?.('value') || (propEl.textContent ?? '').trim() || '';
|
|
69
|
+
if (key)
|
|
70
|
+
config[key] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
responseIdentifier,
|
|
75
|
+
customInteractionTypeIdentifier,
|
|
76
|
+
primaryPath,
|
|
77
|
+
fallbackPath,
|
|
78
|
+
markup,
|
|
79
|
+
config,
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
validate(data) {
|
|
83
|
+
const errors = [];
|
|
84
|
+
const warnings = [];
|
|
85
|
+
if (!data.responseIdentifier) {
|
|
86
|
+
errors.push('portableCustomInteraction is missing responseIdentifier');
|
|
87
|
+
}
|
|
88
|
+
if (!data.customInteractionTypeIdentifier) {
|
|
89
|
+
warnings.push('portableCustomInteraction is missing customInteractionTypeIdentifier');
|
|
90
|
+
}
|
|
91
|
+
if (!data.primaryPath) {
|
|
92
|
+
errors.push('portableCustomInteraction has no primaryPath in qti-interaction-modules');
|
|
93
|
+
}
|
|
94
|
+
return { valid: errors.length === 0, errors: errors.length ? errors : undefined, warnings: warnings.length ? warnings : undefined };
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -88,16 +88,16 @@ export const standardSelectPointExtractor = {
|
|
|
88
88
|
else if (data.imageData.type === 'svg' && !data.imageData.content) {
|
|
89
89
|
errors.push('selectPointInteraction must have SVG content');
|
|
90
90
|
}
|
|
91
|
-
// Validate maxChoices
|
|
92
|
-
if (data.maxChoices
|
|
93
|
-
errors.push('maxChoices must be
|
|
91
|
+
// Validate maxChoices — 0 means unlimited per QTI spec
|
|
92
|
+
if (data.maxChoices < 0) {
|
|
93
|
+
errors.push('maxChoices must be non-negative');
|
|
94
94
|
}
|
|
95
95
|
// Validate minChoices
|
|
96
96
|
if (data.minChoices < 0) {
|
|
97
97
|
errors.push('minChoices must be non-negative');
|
|
98
98
|
}
|
|
99
|
-
// Validate minChoices <= maxChoices
|
|
100
|
-
if (data.minChoices > data.maxChoices) {
|
|
99
|
+
// Validate minChoices <= maxChoices (skip when maxChoices=0, meaning unlimited)
|
|
100
|
+
if (data.maxChoices > 0 && data.minChoices > data.maxChoices) {
|
|
101
101
|
errors.push(`minChoices (${data.minChoices}) must be less than or equal to maxChoices (${data.maxChoices})`);
|
|
102
102
|
}
|
|
103
103
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textEntryExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/textEntryExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"textEntryExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/textEntryExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,CAAC,aAAa,CAwDtE,CAAC"}
|
|
@@ -23,10 +23,16 @@ export const standardTextEntryExtractor = {
|
|
|
23
23
|
const expectedLength = utils.getNumberAttribute(element, 'expectedLength', 20);
|
|
24
24
|
const patternMask = utils.getAttribute(element, 'patternMask', '');
|
|
25
25
|
const placeholderText = utils.getAttribute(element, 'placeholderText', '');
|
|
26
|
+
const format = utils.getAttribute(element, 'format', '');
|
|
27
|
+
const interactionClasses = utils.getClasses(element);
|
|
28
|
+
const patternMaskMessage = utils.getAttribute(element, 'data-patternmask-message', '') || null;
|
|
26
29
|
return {
|
|
27
30
|
expectedLength,
|
|
28
31
|
patternMask: patternMask || null,
|
|
29
32
|
placeholderText,
|
|
33
|
+
...(format ? { format } : {}),
|
|
34
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
35
|
+
...(patternMaskMessage ? { patternMaskMessage } : {}),
|
|
30
36
|
};
|
|
31
37
|
},
|
|
32
38
|
validate(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/uploadExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"uploadExtractor.d.ts","sourceRoot":"","sources":["../../../src/extraction/extractors/uploadExtractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,CAAC,UAAU,CA2DhE,CAAC"}
|
|
@@ -19,9 +19,16 @@ export const standardUploadExtractor = {
|
|
|
19
19
|
},
|
|
20
20
|
extract(element, context) {
|
|
21
21
|
const { utils } = context;
|
|
22
|
-
// Extract fileType child elements
|
|
22
|
+
// Extract fileType child elements (vendor / QTI 3.0 style)
|
|
23
23
|
const fileTypeElements = utils.getChildrenByTag(element, 'fileType');
|
|
24
|
-
|
|
24
|
+
let fileTypes = fileTypeElements.map((el) => utils.getTextContent(el));
|
|
25
|
+
// Fall back to QTI 2.x `type` attribute when no <fileType> children are present
|
|
26
|
+
if (fileTypes.length === 0) {
|
|
27
|
+
const typeAttr = utils.getAttribute(element, 'type', '');
|
|
28
|
+
if (typeAttr) {
|
|
29
|
+
fileTypes = typeAttr.split(/\s+/).filter(Boolean);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
25
32
|
// Extract all attributes
|
|
26
33
|
const rawAttributes = {};
|
|
27
34
|
if (element.attributes) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @pie-qti/item-player
|
|
3
|
-
* Modern QTI 2.2
|
|
3
|
+
* Modern QTI player (2.2/3.0) - Framework-agnostic with web components
|
|
4
4
|
*/
|
|
5
5
|
export { type ComponentConfig, type ComponentPlugin, ComponentRegistry, createComponentRegistry, } from './core/ComponentRegistry.js';
|
|
6
6
|
export * from './core/constants.js';
|
|
@@ -8,6 +8,7 @@ export * from './core/declarations.js';
|
|
|
8
8
|
export * from './utils/drawingUtils.js';
|
|
9
9
|
export { createItemRenderer, ItemRenderer, type ItemRendererConfig, } from './core/ItemRenderer.js';
|
|
10
10
|
export { Player } from './core/Player.js';
|
|
11
|
+
export { getRoleCapabilities, type RoleCapabilities } from './core/rolePolicy.js';
|
|
11
12
|
export { type PluginContext, type PluginLifecycle, type QTIPlugin, type RenderContext, } from './core/Plugin.js';
|
|
12
13
|
export { PluginManager } from './core/PluginManager.js';
|
|
13
14
|
export type { ElementExtractor, ExtractionContext, ExtractionResult, ExtractionUtils, ValidationResult, VariableDeclaration, } from './extraction/index.js';
|
|
@@ -15,6 +16,15 @@ export { createExtractionContext, createExtractionRegistry, createExtractionUtil
|
|
|
15
16
|
export * from './types/index.js';
|
|
16
17
|
export { globalPerformanceMonitor, type PerformanceEntry, PerformanceMonitor, type PerformanceMonitorConfig, type PerformanceReport, } from './utils/PerformanceMonitor.js';
|
|
17
18
|
export { isResponseEmpty } from './utils/responseUtils.js';
|
|
19
|
+
export type { PnpProfile } from './pnp/types.js';
|
|
20
|
+
export { applyPnpToRoot } from './pnp/applyPnp.js';
|
|
21
|
+
export { parsePnpXml } from './pnp/parsePnpXml.js';
|
|
22
|
+
export type { CatalogIndex, CatalogCard, CatalogEntry } from './catalog/types.js';
|
|
23
|
+
export { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';
|
|
24
|
+
export { getCatalogEntry } from './catalog/catalogLookup.js';
|
|
25
|
+
export type { PciModule, PciBoundTo, ExtractedPci } from './pci/types.js';
|
|
26
|
+
export { PciLoadError } from './pci/types.js';
|
|
27
|
+
export { PciHost } from './pci/PciHost.js';
|
|
18
28
|
export { normalizeHeuristicsConfig, applyFeedbackTextHeuristics, shouldUseLenientImagePaths, shouldAutoPopulateFeedbackOutcome, DEFAULT_HEURISTICS_CONFIG, STRICT_QTI_CONFIG, FEEDBACK_TEXT_TRANSFORMS, type QtiHeuristicsConfig, type TextTransform, } from '@pie-qti/ims-cp-core';
|
|
19
29
|
/**
|
|
20
30
|
* NOTE (SSR safety):
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,6BAA6B,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACN,kBAAkB,EAClB,YAAY,EACZ,KAAK,kBAAkB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,6BAA6B,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACN,kBAAkB,EAClB,YAAY,EACZ,KAAK,kBAAkB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAElF,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,aAAa,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,YAAY,EACX,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,eAAe,GACf,MAAM,uBAAuB,CAAC;AAK/B,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EACN,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,GACtB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,OAAO,EACN,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,iCAAiC,EACjC,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,KAAK,aAAa,GAClB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;GAQG"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @pie-qti/item-player
|
|
3
|
-
* Modern QTI 2.2
|
|
3
|
+
* Modern QTI player (2.2/3.0) - Framework-agnostic with web components
|
|
4
4
|
*/
|
|
5
5
|
// Export web component registry for pluggable UI components
|
|
6
6
|
export { ComponentRegistry, createComponentRegistry, } from './core/ComponentRegistry.js';
|
|
@@ -11,6 +11,7 @@ export * from './utils/drawingUtils.js';
|
|
|
11
11
|
// Export ItemRenderer for framework-agnostic rendering
|
|
12
12
|
export { createItemRenderer, ItemRenderer, } from './core/ItemRenderer.js';
|
|
13
13
|
export { Player } from './core/Player.js';
|
|
14
|
+
export { getRoleCapabilities } from './core/rolePolicy.js';
|
|
14
15
|
export { PluginManager } from './core/PluginManager.js';
|
|
15
16
|
export { createExtractionContext, createExtractionRegistry, createExtractionUtils, ExtractionError, ExtractionRegistry, isErrorResult, isSuccessResult, } from './extraction/index.js';
|
|
16
17
|
// NOTE:
|
|
@@ -21,6 +22,12 @@ export * from './types/index.js';
|
|
|
21
22
|
// Export utilities
|
|
22
23
|
export { globalPerformanceMonitor, PerformanceMonitor, } from './utils/PerformanceMonitor.js';
|
|
23
24
|
export { isResponseEmpty } from './utils/responseUtils.js';
|
|
25
|
+
export { applyPnpToRoot } from './pnp/applyPnp.js';
|
|
26
|
+
export { parsePnpXml } from './pnp/parsePnpXml.js';
|
|
27
|
+
export { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';
|
|
28
|
+
export { getCatalogEntry } from './catalog/catalogLookup.js';
|
|
29
|
+
export { PciLoadError } from './pci/types.js';
|
|
30
|
+
export { PciHost } from './pci/PciHost.js';
|
|
24
31
|
// Re-export QTI heuristics from @pie-qti/ims-cp-core for convenience
|
|
25
32
|
// (heuristics are now in the shared ingestion layer)
|
|
26
33
|
export { normalizeHeuristicsConfig, applyFeedbackTextHeuristics, shouldUseLenientImagePaths, shouldAutoPopulateFeedbackOutcome, DEFAULT_HEURISTICS_CONFIG, STRICT_QTI_CONFIG, FEEDBACK_TEXT_TRANSFORMS, } from '@pie-qti/ims-cp-core';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ExtractedPci } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Loads, initializes, and manages the lifecycle of a single PCI module.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const host = new PciHost(extractedData, baseUrl);
|
|
7
|
+
* await host.load();
|
|
8
|
+
* host.initialize(domNode);
|
|
9
|
+
* host.getResponse(); // returns current response
|
|
10
|
+
* host.destroy(); // cleanup on player teardown
|
|
11
|
+
*/
|
|
12
|
+
export declare class PciHost {
|
|
13
|
+
private readonly data;
|
|
14
|
+
private readonly baseUrl;
|
|
15
|
+
private module;
|
|
16
|
+
private _response;
|
|
17
|
+
private _onResponseChange;
|
|
18
|
+
constructor(data: ExtractedPci, baseUrl: string);
|
|
19
|
+
/**
|
|
20
|
+
* Register a callback to fire when the PCI's response changes.
|
|
21
|
+
* The player calls this to wire the PCI into its internal response map.
|
|
22
|
+
*/
|
|
23
|
+
onResponseChange(callback: (responseId: string, value: unknown) => void): void;
|
|
24
|
+
/**
|
|
25
|
+
* Load the PCI module from primaryPath, falling back to fallbackPath.
|
|
26
|
+
* Throws PciLoadError if both fail.
|
|
27
|
+
*/
|
|
28
|
+
load(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the PCI inside the given DOM element.
|
|
31
|
+
* Must be called after load() resolves.
|
|
32
|
+
*/
|
|
33
|
+
initialize(dom: HTMLElement): void;
|
|
34
|
+
/** Return the current response value from the PCI module. */
|
|
35
|
+
getResponse(): unknown;
|
|
36
|
+
/** Restore a response value into the PCI module (e.g. from session state). */
|
|
37
|
+
setResponse(value: unknown): void;
|
|
38
|
+
/** Disable the PCI (e.g. when role is not candidate, or after final submission). */
|
|
39
|
+
disable(): void;
|
|
40
|
+
/** Re-enable the PCI. */
|
|
41
|
+
enable(): void;
|
|
42
|
+
/** Tear down the PCI and release all resources. */
|
|
43
|
+
destroy(): void;
|
|
44
|
+
/** Thin wrapper around dynamic import — overridable in tests. */
|
|
45
|
+
protected dynamicImport(url: string): Promise<any>;
|
|
46
|
+
private resolveUrl;
|
|
47
|
+
/**
|
|
48
|
+
* Extract a PciModule from a dynamic import result.
|
|
49
|
+
* Supports: default export, named `getInstance` export, or the module itself.
|
|
50
|
+
*/
|
|
51
|
+
private extractPciInterface;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=PciHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PciHost.d.ts","sourceRoot":"","sources":["../../src/pci/PciHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAyB,MAAM,YAAY,CAAC;AAGtE;;;;;;;;;GASG;AACH,qBAAa,OAAO;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAe;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,iBAAiB,CAA+D;gBAE5E,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM;IAK/C;;;OAGG;IACI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAIrF;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBlC;;;OAGG;IACI,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAczC,6DAA6D;IACtD,WAAW,IAAI,OAAO;IAI7B,8EAA8E;IACvE,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKxC,oFAAoF;IAC7E,OAAO,IAAI,IAAI;IAItB,yBAAyB;IAClB,MAAM,IAAI,IAAI;IAIrB,mDAAmD;IAC5C,OAAO,IAAI,IAAI;IAStB,iEAAiE;IACjE,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIlD,OAAO,CAAC,UAAU;IAOlB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAU3B"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { PciLoadError } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Loads, initializes, and manages the lifecycle of a single PCI module.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const host = new PciHost(extractedData, baseUrl);
|
|
7
|
+
* await host.load();
|
|
8
|
+
* host.initialize(domNode);
|
|
9
|
+
* host.getResponse(); // returns current response
|
|
10
|
+
* host.destroy(); // cleanup on player teardown
|
|
11
|
+
*/
|
|
12
|
+
export class PciHost {
|
|
13
|
+
constructor(data, baseUrl) {
|
|
14
|
+
this.module = null;
|
|
15
|
+
this._response = null;
|
|
16
|
+
this._onResponseChange = null;
|
|
17
|
+
this.data = data;
|
|
18
|
+
this.baseUrl = baseUrl;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Register a callback to fire when the PCI's response changes.
|
|
22
|
+
* The player calls this to wire the PCI into its internal response map.
|
|
23
|
+
*/
|
|
24
|
+
onResponseChange(callback) {
|
|
25
|
+
this._onResponseChange = callback;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load the PCI module from primaryPath, falling back to fallbackPath.
|
|
29
|
+
* Throws PciLoadError if both fail.
|
|
30
|
+
*/
|
|
31
|
+
async load() {
|
|
32
|
+
const primary = this.resolveUrl(this.data.primaryPath);
|
|
33
|
+
try {
|
|
34
|
+
const mod = await this.dynamicImport(primary);
|
|
35
|
+
this.module = this.extractPciInterface(mod);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
catch (primaryErr) {
|
|
39
|
+
if (!this.data.fallbackPath) {
|
|
40
|
+
throw new PciLoadError(this.data.primaryPath, undefined, primaryErr);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const fallback = this.resolveUrl(this.data.fallbackPath);
|
|
44
|
+
try {
|
|
45
|
+
const mod = await this.dynamicImport(fallback);
|
|
46
|
+
this.module = this.extractPciInterface(mod);
|
|
47
|
+
}
|
|
48
|
+
catch (fallbackErr) {
|
|
49
|
+
throw new PciLoadError(this.data.primaryPath, this.data.fallbackPath, fallbackErr);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Initialize the PCI inside the given DOM element.
|
|
54
|
+
* Must be called after load() resolves.
|
|
55
|
+
*/
|
|
56
|
+
initialize(dom) {
|
|
57
|
+
if (!this.module)
|
|
58
|
+
return;
|
|
59
|
+
const boundTo = {
|
|
60
|
+
onReady: () => { },
|
|
61
|
+
onResponseChange: (value) => {
|
|
62
|
+
this._response = value;
|
|
63
|
+
this._onResponseChange?.(this.data.responseIdentifier, value);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
this.module.initialize(dom, this.data.config, boundTo);
|
|
67
|
+
}
|
|
68
|
+
/** Return the current response value from the PCI module. */
|
|
69
|
+
getResponse() {
|
|
70
|
+
return this.module ? this.module.getResponse() : this._response;
|
|
71
|
+
}
|
|
72
|
+
/** Restore a response value into the PCI module (e.g. from session state). */
|
|
73
|
+
setResponse(value) {
|
|
74
|
+
this._response = value;
|
|
75
|
+
this.module?.setResponse(value);
|
|
76
|
+
}
|
|
77
|
+
/** Disable the PCI (e.g. when role is not candidate, or after final submission). */
|
|
78
|
+
disable() {
|
|
79
|
+
this.module?.disable();
|
|
80
|
+
}
|
|
81
|
+
/** Re-enable the PCI. */
|
|
82
|
+
enable() {
|
|
83
|
+
this.module?.enable();
|
|
84
|
+
}
|
|
85
|
+
/** Tear down the PCI and release all resources. */
|
|
86
|
+
destroy() {
|
|
87
|
+
this.module?.destroy();
|
|
88
|
+
this.module = null;
|
|
89
|
+
}
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Private helpers
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
/** Thin wrapper around dynamic import — overridable in tests. */
|
|
94
|
+
dynamicImport(url) {
|
|
95
|
+
return import(/* @vite-ignore */ url);
|
|
96
|
+
}
|
|
97
|
+
resolveUrl(path) {
|
|
98
|
+
if (/^https?:\/\//.test(path) || path.startsWith('/'))
|
|
99
|
+
return path;
|
|
100
|
+
// Relative path: resolve against baseUrl
|
|
101
|
+
const base = this.baseUrl.endsWith('/') ? this.baseUrl : this.baseUrl + '/';
|
|
102
|
+
return base + path;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Extract a PciModule from a dynamic import result.
|
|
106
|
+
* Supports: default export, named `getInstance` export, or the module itself.
|
|
107
|
+
*/
|
|
108
|
+
extractPciInterface(mod) {
|
|
109
|
+
const candidate = mod?.default ?? mod?.getInstance?.() ?? mod;
|
|
110
|
+
if (typeof candidate?.initialize !== 'function') {
|
|
111
|
+
throw new Error(`PCI module at '${this.data.primaryPath}' does not export a valid PciModule interface ` +
|
|
112
|
+
'(expected .initialize, .getResponse, .setResponse, .disable, .enable, .destroy)');
|
|
113
|
+
}
|
|
114
|
+
return candidate;
|
|
115
|
+
}
|
|
116
|
+
}
|