@pie-qti/ims-cp-core 0.1.0 → 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 +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/qti-heuristics.d.ts +107 -0
- package/dist/qti-heuristics.d.ts.map +1 -0
- package/dist/qti-heuristics.js +144 -0
- package/dist/qti-heuristics.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +2 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/qti-xml.d.ts +104 -0
- package/dist/utils/qti-xml.d.ts.map +1 -0
- package/dist/utils/qti-xml.js +214 -0
- package/dist/utils/qti-xml.js.map +1 -0
- package/package.json +55 -31
- package/.turbo/turbo-build.log +0 -1
- package/src/index.ts +0 -8
- package/src/localized-resources.ts +0 -537
- package/src/manifest-parser.ts +0 -273
- package/src/passage-reusability.ts +0 -221
- package/src/utils/hash.ts +0 -34
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ registry.registerReference('item-1', {
|
|
|
64
64
|
|
|
65
65
|
## API
|
|
66
66
|
|
|
67
|
-
### Breaking Changes from
|
|
67
|
+
### Breaking Changes from to-pie
|
|
68
68
|
|
|
69
69
|
- `generateStablePassageId()` is now **async** (returns `Promise<string>`)
|
|
70
70
|
- `PassageRegistry.detectAndMergeDuplicates()` is now **async**
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,7 @@
|
|
|
5
5
|
export * from './manifest-parser.js';
|
|
6
6
|
export * from './localized-resources.js';
|
|
7
7
|
export * from './passage-reusability.js';
|
|
8
|
+
export * from './qti-heuristics.js';
|
|
9
|
+
export * from './utils/logger.js';
|
|
10
|
+
export * from './utils/qti-xml.js';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
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;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,7 @@
|
|
|
5
5
|
export * from './manifest-parser.js';
|
|
6
6
|
export * from './localized-resources.js';
|
|
7
7
|
export * from './passage-reusability.js';
|
|
8
|
+
export * from './qti-heuristics.js';
|
|
9
|
+
export * from './utils/logger.js';
|
|
10
|
+
export * from './utils/qti-xml.js';
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI Content Heuristics
|
|
3
|
+
*
|
|
4
|
+
* This module contains heuristics for handling non-standard QTI content commonly
|
|
5
|
+
* found in real-world QTI packages from various authoring tools.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ IMPORTANT: These are NOT part of the QTI specification. They are pragmatic
|
|
8
|
+
* workarounds for content that doesn't strictly follow QTI standards but is
|
|
9
|
+
* commonly encountered in production.
|
|
10
|
+
*
|
|
11
|
+
* All heuristics:
|
|
12
|
+
* - Are OPTIONAL and can be disabled
|
|
13
|
+
* - Log when they are applied (in debug mode)
|
|
14
|
+
* - Will NEVER hide real QTI errors
|
|
15
|
+
* - Will NEVER break valid QTI content
|
|
16
|
+
*
|
|
17
|
+
* @see https://www.imsglobal.org/question/ for QTI specifications
|
|
18
|
+
*/
|
|
19
|
+
import type { Logger } from './utils/logger.js';
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for QTI content heuristics
|
|
22
|
+
*/
|
|
23
|
+
export interface QtiHeuristicsConfig {
|
|
24
|
+
/**
|
|
25
|
+
* Enable all heuristics (default: true)
|
|
26
|
+
* Set to false for strict QTI-only processing
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Apply feedback text formatting fixes
|
|
31
|
+
* Some authoring tools add semicolons after "Correct" and "Incorrect" labels
|
|
32
|
+
* (default: true when enabled)
|
|
33
|
+
*/
|
|
34
|
+
feedbackTextFormatting?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Apply lenient image path resolution
|
|
37
|
+
* Try multiple path resolution strategies for images that don't follow
|
|
38
|
+
* strict relative path conventions (default: true when enabled)
|
|
39
|
+
*/
|
|
40
|
+
lenientImagePaths?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Auto-populate FEEDBACK outcome for simple choice interactions
|
|
43
|
+
* Some templates only set SCORE but not FEEDBACK, even though feedbackInline
|
|
44
|
+
* elements reference the FEEDBACK outcome (default: true when enabled)
|
|
45
|
+
*/
|
|
46
|
+
autoPopulateFeedbackOutcome?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Default heuristics configuration
|
|
50
|
+
* Enables common heuristics by default for better real-world compatibility
|
|
51
|
+
*/
|
|
52
|
+
export declare const DEFAULT_HEURISTICS_CONFIG: Required<QtiHeuristicsConfig>;
|
|
53
|
+
/**
|
|
54
|
+
* Strict QTI configuration - disables all heuristics
|
|
55
|
+
*/
|
|
56
|
+
export declare const STRICT_QTI_CONFIG: Required<QtiHeuristicsConfig>;
|
|
57
|
+
/**
|
|
58
|
+
* Merge user config with defaults
|
|
59
|
+
*/
|
|
60
|
+
export declare function normalizeHeuristicsConfig(config?: QtiHeuristicsConfig): Required<QtiHeuristicsConfig>;
|
|
61
|
+
/**
|
|
62
|
+
* Text replacement pattern for vendor-specific formatting
|
|
63
|
+
*/
|
|
64
|
+
export interface TextTransform {
|
|
65
|
+
/** Regular expression to match */
|
|
66
|
+
pattern: RegExp;
|
|
67
|
+
/** Replacement string */
|
|
68
|
+
replacement: string;
|
|
69
|
+
/** Description of what this fixes */
|
|
70
|
+
description: string;
|
|
71
|
+
/** Which vendor/authoring tool produces this pattern (if known) */
|
|
72
|
+
vendor?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Vendor-specific feedback text transforms
|
|
76
|
+
*
|
|
77
|
+
* These fix formatting issues in feedback text from certain authoring tools:
|
|
78
|
+
* - Some tools add semicolons after "Correct" and "Incorrect" labels
|
|
79
|
+
* - This is not required by QTI and looks awkward in display
|
|
80
|
+
*/
|
|
81
|
+
export declare const FEEDBACK_TEXT_TRANSFORMS: TextTransform[];
|
|
82
|
+
/**
|
|
83
|
+
* Apply feedback text formatting heuristics
|
|
84
|
+
*
|
|
85
|
+
* @param content - HTML content to transform
|
|
86
|
+
* @param config - Heuristics configuration
|
|
87
|
+
* @param logger - Optional logger for debug output
|
|
88
|
+
* @returns Transformed content
|
|
89
|
+
*/
|
|
90
|
+
export declare function applyFeedbackTextHeuristics(content: string, config: Required<QtiHeuristicsConfig>, logger?: Logger): string;
|
|
91
|
+
/**
|
|
92
|
+
* Check if lenient image path resolution should be used
|
|
93
|
+
*
|
|
94
|
+
* @param config - Heuristics configuration
|
|
95
|
+
* @param logger - Optional logger
|
|
96
|
+
* @returns True if lenient resolution is enabled
|
|
97
|
+
*/
|
|
98
|
+
export declare function shouldUseLenientImagePaths(config: Required<QtiHeuristicsConfig>, logger?: Logger): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Check if auto-populating FEEDBACK outcome should be used
|
|
101
|
+
*
|
|
102
|
+
* @param config - Heuristics configuration
|
|
103
|
+
* @param logger - Optional logger
|
|
104
|
+
* @returns True if auto-population is enabled
|
|
105
|
+
*/
|
|
106
|
+
export declare function shouldAutoPopulateFeedbackOutcome(config: Required<QtiHeuristicsConfig>, logger?: Logger): boolean;
|
|
107
|
+
//# sourceMappingURL=qti-heuristics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-heuristics.d.ts","sourceRoot":"","sources":["../src/qti-heuristics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,mBAAmB,CAKnE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,mBAAmB,CAK3D,CAAC;AAEF;;GAEG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,CAAC,EAAE,mBAAmB,GAC1B,QAAQ,CAAC,mBAAmB,CAAC,CAe/B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAAa,EAyBnD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACrC,MAAM,CAAC,EAAE,MAAM,GACb,MAAM,CA6BR;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACrC,MAAM,CAAC,EAAE,MAAM,GACb,OAAO,CAWT;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACrC,MAAM,CAAC,EAAE,MAAM,GACb,OAAO,CAWT"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI Content Heuristics
|
|
3
|
+
*
|
|
4
|
+
* This module contains heuristics for handling non-standard QTI content commonly
|
|
5
|
+
* found in real-world QTI packages from various authoring tools.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ IMPORTANT: These are NOT part of the QTI specification. They are pragmatic
|
|
8
|
+
* workarounds for content that doesn't strictly follow QTI standards but is
|
|
9
|
+
* commonly encountered in production.
|
|
10
|
+
*
|
|
11
|
+
* All heuristics:
|
|
12
|
+
* - Are OPTIONAL and can be disabled
|
|
13
|
+
* - Log when they are applied (in debug mode)
|
|
14
|
+
* - Will NEVER hide real QTI errors
|
|
15
|
+
* - Will NEVER break valid QTI content
|
|
16
|
+
*
|
|
17
|
+
* @see https://www.imsglobal.org/question/ for QTI specifications
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Default heuristics configuration
|
|
21
|
+
* Enables common heuristics by default for better real-world compatibility
|
|
22
|
+
*/
|
|
23
|
+
export const DEFAULT_HEURISTICS_CONFIG = {
|
|
24
|
+
enabled: true,
|
|
25
|
+
feedbackTextFormatting: true,
|
|
26
|
+
lenientImagePaths: true,
|
|
27
|
+
autoPopulateFeedbackOutcome: true,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Strict QTI configuration - disables all heuristics
|
|
31
|
+
*/
|
|
32
|
+
export const STRICT_QTI_CONFIG = {
|
|
33
|
+
enabled: false,
|
|
34
|
+
feedbackTextFormatting: false,
|
|
35
|
+
lenientImagePaths: false,
|
|
36
|
+
autoPopulateFeedbackOutcome: false,
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Merge user config with defaults
|
|
40
|
+
*/
|
|
41
|
+
export function normalizeHeuristicsConfig(config) {
|
|
42
|
+
if (config?.enabled === false) {
|
|
43
|
+
return STRICT_QTI_CONFIG;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
enabled: config?.enabled ?? DEFAULT_HEURISTICS_CONFIG.enabled,
|
|
47
|
+
feedbackTextFormatting: config?.feedbackTextFormatting ?? DEFAULT_HEURISTICS_CONFIG.feedbackTextFormatting,
|
|
48
|
+
lenientImagePaths: config?.lenientImagePaths ?? DEFAULT_HEURISTICS_CONFIG.lenientImagePaths,
|
|
49
|
+
autoPopulateFeedbackOutcome: config?.autoPopulateFeedbackOutcome ??
|
|
50
|
+
DEFAULT_HEURISTICS_CONFIG.autoPopulateFeedbackOutcome,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Vendor-specific feedback text transforms
|
|
55
|
+
*
|
|
56
|
+
* These fix formatting issues in feedback text from certain authoring tools:
|
|
57
|
+
* - Some tools add semicolons after "Correct" and "Incorrect" labels
|
|
58
|
+
* - This is not required by QTI and looks awkward in display
|
|
59
|
+
*/
|
|
60
|
+
export const FEEDBACK_TEXT_TRANSFORMS = [
|
|
61
|
+
{
|
|
62
|
+
pattern: /<strong>Incorrect;<\/strong>/gi,
|
|
63
|
+
replacement: '<strong>Incorrect</strong> ',
|
|
64
|
+
description: 'Remove semicolon after "Incorrect" in strong tags',
|
|
65
|
+
vendor: 'Various authoring tools',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
pattern: /Incorrect;/gi,
|
|
69
|
+
replacement: 'Incorrect ',
|
|
70
|
+
description: 'Remove semicolon after "Incorrect"',
|
|
71
|
+
vendor: 'Various authoring tools',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pattern: /<strong>Correct;<\/strong>/gi,
|
|
75
|
+
replacement: '<strong>Correct</strong> ',
|
|
76
|
+
description: 'Remove semicolon after "Correct" in strong tags',
|
|
77
|
+
vendor: 'Various authoring tools',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
pattern: /Correct;/gi,
|
|
81
|
+
replacement: 'Correct ',
|
|
82
|
+
description: 'Remove semicolon after "Correct"',
|
|
83
|
+
vendor: 'Various authoring tools',
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
/**
|
|
87
|
+
* Apply feedback text formatting heuristics
|
|
88
|
+
*
|
|
89
|
+
* @param content - HTML content to transform
|
|
90
|
+
* @param config - Heuristics configuration
|
|
91
|
+
* @param logger - Optional logger for debug output
|
|
92
|
+
* @returns Transformed content
|
|
93
|
+
*/
|
|
94
|
+
export function applyFeedbackTextHeuristics(content, config, logger) {
|
|
95
|
+
if (!config.enabled || !config.feedbackTextFormatting || !content) {
|
|
96
|
+
return content;
|
|
97
|
+
}
|
|
98
|
+
let result = content;
|
|
99
|
+
let appliedCount = 0;
|
|
100
|
+
for (const transform of FEEDBACK_TEXT_TRANSFORMS) {
|
|
101
|
+
const before = result;
|
|
102
|
+
result = result.replace(transform.pattern, transform.replacement);
|
|
103
|
+
if (result !== before) {
|
|
104
|
+
appliedCount++;
|
|
105
|
+
logger?.debug(`[QTI Heuristic] Applied feedback text transform: ${transform.description}`, { vendor: transform.vendor });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (appliedCount > 0) {
|
|
109
|
+
logger?.debug(`[QTI Heuristic] Applied ${appliedCount} feedback text formatting fix(es). ` +
|
|
110
|
+
`This content uses non-standard formatting common in certain authoring tools.`);
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if lenient image path resolution should be used
|
|
116
|
+
*
|
|
117
|
+
* @param config - Heuristics configuration
|
|
118
|
+
* @param logger - Optional logger
|
|
119
|
+
* @returns True if lenient resolution is enabled
|
|
120
|
+
*/
|
|
121
|
+
export function shouldUseLenientImagePaths(config, logger) {
|
|
122
|
+
const enabled = config.enabled && config.lenientImagePaths;
|
|
123
|
+
if (enabled) {
|
|
124
|
+
logger?.debug('[QTI Heuristic] Using lenient image path resolution. ' +
|
|
125
|
+
'Will try multiple path strategies for images that do not follow strict relative path conventions.');
|
|
126
|
+
}
|
|
127
|
+
return enabled;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Check if auto-populating FEEDBACK outcome should be used
|
|
131
|
+
*
|
|
132
|
+
* @param config - Heuristics configuration
|
|
133
|
+
* @param logger - Optional logger
|
|
134
|
+
* @returns True if auto-population is enabled
|
|
135
|
+
*/
|
|
136
|
+
export function shouldAutoPopulateFeedbackOutcome(config, logger) {
|
|
137
|
+
const enabled = config.enabled && config.autoPopulateFeedbackOutcome;
|
|
138
|
+
if (enabled) {
|
|
139
|
+
logger?.debug('[QTI Heuristic] Will auto-populate FEEDBACK outcome if missing. ' +
|
|
140
|
+
'Some QTI templates use feedbackInline but only set SCORE outcome.');
|
|
141
|
+
}
|
|
142
|
+
return enabled;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=qti-heuristics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-heuristics.js","sourceRoot":"","sources":["../src/qti-heuristics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAoCH;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAkC;IACvE,OAAO,EAAE,IAAI;IACb,sBAAsB,EAAE,IAAI;IAC5B,iBAAiB,EAAE,IAAI;IACvB,2BAA2B,EAAE,IAAI;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkC;IAC/D,OAAO,EAAE,KAAK;IACd,sBAAsB,EAAE,KAAK;IAC7B,iBAAiB,EAAE,KAAK;IACxB,2BAA2B,EAAE,KAAK;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACxC,MAA4B;IAE5B,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;QAC/B,OAAO,iBAAiB,CAAC;IAC1B,CAAC;IAED,OAAO;QACN,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,yBAAyB,CAAC,OAAO;QAC7D,sBAAsB,EACrB,MAAM,EAAE,sBAAsB,IAAI,yBAAyB,CAAC,sBAAsB;QACnF,iBAAiB,EAChB,MAAM,EAAE,iBAAiB,IAAI,yBAAyB,CAAC,iBAAiB;QACzE,2BAA2B,EAC1B,MAAM,EAAE,2BAA2B;YACnC,yBAAyB,CAAC,2BAA2B;KACtD,CAAC;AACH,CAAC;AAgBD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACxD;QACC,OAAO,EAAE,gCAAgC;QACzC,WAAW,EAAE,6BAA6B;QAC1C,WAAW,EAAE,mDAAmD;QAChE,MAAM,EAAE,yBAAyB;KACjC;IACD;QACC,OAAO,EAAE,cAAc;QACvB,WAAW,EAAE,YAAY;QACzB,WAAW,EAAE,oC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AAO,IAAI,MAAM,CAAC,iBAAiB,CAAC;IAE3D,IAAI,OAAO,EAAE,CAAC;QACb,MAAM,EAAE,KAAK,CACZ,uDAAuD;YACtD,mGAAmG,CACpG,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAChD,MAAqC,EACrC,MAAe;IAEf,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,2BAA2B,CAAC;IAErE,IAAI,OAAO,EAAE,CAAC;QACb,MAAM,EAAE,KAAK,CACZ,kEAAkE;YACjE,mEAAmE,CACpE,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export Logger interface from @pie-qti/logger for convenience
|
|
3
|
+
* This provides a stable location for the interface in shared code
|
|
4
|
+
*/
|
|
5
|
+
export type { Logger } from '@pie-qti/logger';
|
|
6
|
+
export { noopLogger, consoleLogger } from '@pie-qti/logger';
|
|
7
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI XML utilities for extracting metadata and information from QTI XML content
|
|
3
|
+
*
|
|
4
|
+
* These utilities use regex-based parsing to remain environment-agnostic
|
|
5
|
+
* (works in both browser and Node.js without heavy dependencies).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Comprehensive QTI item metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface QtiItemMetadata {
|
|
11
|
+
/** Item identifier */
|
|
12
|
+
identifier?: string;
|
|
13
|
+
/** Item title */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** Item description */
|
|
16
|
+
description?: string;
|
|
17
|
+
/** Language code (e.g., "en-US") */
|
|
18
|
+
language?: string;
|
|
19
|
+
/** Search metadata for filtering/categorization */
|
|
20
|
+
searchMetadata?: Record<string, any>;
|
|
21
|
+
/** Detected interaction types */
|
|
22
|
+
interactionTypes?: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Extract title from QTI item/test XML content
|
|
26
|
+
*
|
|
27
|
+
* Handles multiple QTI title formats:
|
|
28
|
+
* - Attribute-style: `<assessmentItem title="...">`
|
|
29
|
+
* - Attribute-style: `<assessmentTest title="...">`
|
|
30
|
+
* - Element-style: `<title>...</title>` within assessment elements
|
|
31
|
+
* - Fallback: Any `<title>` element in the document
|
|
32
|
+
*
|
|
33
|
+
* @param xmlContent QTI XML content as string
|
|
34
|
+
* @returns Extracted title or undefined if not found
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const xml = '<assessmentItem identifier="item1" title="Question 1">...</assessmentItem>';
|
|
39
|
+
* const title = extractTitleFromQtiXml(xml); // "Question 1"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractTitleFromQtiXml(xmlContent: string): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Extract identifier from QTI item/test XML content
|
|
45
|
+
*
|
|
46
|
+
* @param xmlContent QTI XML content as string
|
|
47
|
+
* @returns Extracted identifier or undefined if not found
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractIdentifierFromQtiXml(xmlContent: string): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Extract search metadata from QTI item XML content
|
|
52
|
+
*
|
|
53
|
+
* Priority 1: Check for PIE extension with embedded searchMetaData (perfect reconstruction)
|
|
54
|
+
* Priority 2: Parse QTI metadata section with qti-metadata-field elements
|
|
55
|
+
*
|
|
56
|
+
* @param xmlContent QTI XML content as string
|
|
57
|
+
* @returns Extracted search metadata object
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const xml = `
|
|
62
|
+
* <assessmentItem>
|
|
63
|
+
* <qti-metadata>
|
|
64
|
+
* <qti-metadata-field name="domain" value="math" />
|
|
65
|
+
* <qti-metadata-field name="gradeLevel" value="5,6,7" data-type="array" />
|
|
66
|
+
* </qti-metadata>
|
|
67
|
+
* </assessmentItem>
|
|
68
|
+
* `;
|
|
69
|
+
* const metadata = extractSearchMetadataFromQtiXml(xml);
|
|
70
|
+
* // { domain: "math", gradeLevel: ["5", "6", "7"] }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function extractSearchMetadataFromQtiXml(xmlContent: string): Record<string, any>;
|
|
74
|
+
/**
|
|
75
|
+
* Extract interaction types from QTI item XML content
|
|
76
|
+
*
|
|
77
|
+
* Detects all QTI interaction types present in the item.
|
|
78
|
+
*
|
|
79
|
+
* @param xmlContent QTI XML content as string
|
|
80
|
+
* @returns Array of detected interaction type names (e.g., ["choiceInteraction", "textEntryInteraction"])
|
|
81
|
+
*/
|
|
82
|
+
export declare function extractInteractionTypesFromQtiXml(xmlContent: string): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Extract comprehensive metadata from QTI item XML content
|
|
85
|
+
*
|
|
86
|
+
* Combines all metadata extraction functions to provide a complete metadata object.
|
|
87
|
+
*
|
|
88
|
+
* @param xmlContent QTI XML content as string
|
|
89
|
+
* @returns Comprehensive QTI item metadata
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const xml = `<assessmentItem identifier="item1" title="Question 1">...</assessmentItem>`;
|
|
94
|
+
* const metadata = extractQtiItemMetadata(xml);
|
|
95
|
+
* // {
|
|
96
|
+
* // identifier: "item1",
|
|
97
|
+
* // title: "Question 1",
|
|
98
|
+
* // searchMetadata: {...},
|
|
99
|
+
* // interactionTypes: ["choiceInteraction"]
|
|
100
|
+
* // }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function extractQtiItemMetadata(xmlContent: string): QtiItemMetadata;
|
|
104
|
+
//# sourceMappingURL=qti-xml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-xml.d.ts","sourceRoot":"","sources":["../../src/utils/qti-xml.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,iCAAiC;IACjC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA+B7E;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBlF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA0DvF;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAqC9E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAO1E"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI XML utilities for extracting metadata and information from QTI XML content
|
|
3
|
+
*
|
|
4
|
+
* These utilities use regex-based parsing to remain environment-agnostic
|
|
5
|
+
* (works in both browser and Node.js without heavy dependencies).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Extract title from QTI item/test XML content
|
|
9
|
+
*
|
|
10
|
+
* Handles multiple QTI title formats:
|
|
11
|
+
* - Attribute-style: `<assessmentItem title="...">`
|
|
12
|
+
* - Attribute-style: `<assessmentTest title="...">`
|
|
13
|
+
* - Element-style: `<title>...</title>` within assessment elements
|
|
14
|
+
* - Fallback: Any `<title>` element in the document
|
|
15
|
+
*
|
|
16
|
+
* @param xmlContent QTI XML content as string
|
|
17
|
+
* @returns Extracted title or undefined if not found
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const xml = '<assessmentItem identifier="item1" title="Question 1">...</assessmentItem>';
|
|
22
|
+
* const title = extractTitleFromQtiXml(xml); // "Question 1"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function extractTitleFromQtiXml(xmlContent) {
|
|
26
|
+
if (!xmlContent)
|
|
27
|
+
return undefined;
|
|
28
|
+
// Try attribute-style title first: <assessmentItem title="...">
|
|
29
|
+
const attributeMatch = xmlContent.match(/<assessmentItem[^>]*\s+title=["']([^"']+)["']/i);
|
|
30
|
+
if (attributeMatch && attributeMatch[1]) {
|
|
31
|
+
return attributeMatch[1].trim();
|
|
32
|
+
}
|
|
33
|
+
// Try test attribute-style: <assessmentTest title="...">
|
|
34
|
+
const testAttributeMatch = xmlContent.match(/<assessmentTest[^>]*\s+title=["']([^"']+)["']/i);
|
|
35
|
+
if (testAttributeMatch && testAttributeMatch[1]) {
|
|
36
|
+
return testAttributeMatch[1].trim();
|
|
37
|
+
}
|
|
38
|
+
// Try element-style title: <title>...</title>
|
|
39
|
+
// Look for title element that's a direct child of assessmentItem or assessmentTest
|
|
40
|
+
const elementMatch = xmlContent.match(/<(?:assessmentItem|assessmentTest)[^>]*>[\s\S]*?<title[^>]*>([^<]+)<\/title>/i);
|
|
41
|
+
if (elementMatch && elementMatch[1]) {
|
|
42
|
+
return elementMatch[1].trim();
|
|
43
|
+
}
|
|
44
|
+
// Fallback: look for any <title> element (less specific but might catch some cases)
|
|
45
|
+
const fallbackMatch = xmlContent.match(/<title[^>]*>([^<]+)<\/title>/i);
|
|
46
|
+
if (fallbackMatch && fallbackMatch[1]) {
|
|
47
|
+
return fallbackMatch[1].trim();
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Extract identifier from QTI item/test XML content
|
|
53
|
+
*
|
|
54
|
+
* @param xmlContent QTI XML content as string
|
|
55
|
+
* @returns Extracted identifier or undefined if not found
|
|
56
|
+
*/
|
|
57
|
+
export function extractIdentifierFromQtiXml(xmlContent) {
|
|
58
|
+
if (!xmlContent)
|
|
59
|
+
return undefined;
|
|
60
|
+
// Try assessmentItem identifier
|
|
61
|
+
const itemMatch = xmlContent.match(/<assessmentItem[^>]*\s+identifier=["']([^"']+)["']/i);
|
|
62
|
+
if (itemMatch && itemMatch[1]) {
|
|
63
|
+
return itemMatch[1].trim();
|
|
64
|
+
}
|
|
65
|
+
// Try assessmentTest identifier
|
|
66
|
+
const testMatch = xmlContent.match(/<assessmentTest[^>]*\s+identifier=["']([^"']+)["']/i);
|
|
67
|
+
if (testMatch && testMatch[1]) {
|
|
68
|
+
return testMatch[1].trim();
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Extract search metadata from QTI item XML content
|
|
74
|
+
*
|
|
75
|
+
* Priority 1: Check for PIE extension with embedded searchMetaData (perfect reconstruction)
|
|
76
|
+
* Priority 2: Parse QTI metadata section with qti-metadata-field elements
|
|
77
|
+
*
|
|
78
|
+
* @param xmlContent QTI XML content as string
|
|
79
|
+
* @returns Extracted search metadata object
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const xml = `
|
|
84
|
+
* <assessmentItem>
|
|
85
|
+
* <qti-metadata>
|
|
86
|
+
* <qti-metadata-field name="domain" value="math" />
|
|
87
|
+
* <qti-metadata-field name="gradeLevel" value="5,6,7" data-type="array" />
|
|
88
|
+
* </qti-metadata>
|
|
89
|
+
* </assessmentItem>
|
|
90
|
+
* `;
|
|
91
|
+
* const metadata = extractSearchMetadataFromQtiXml(xml);
|
|
92
|
+
* // { domain: "math", gradeLevel: ["5", "6", "7"] }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export function extractSearchMetadataFromQtiXml(xmlContent) {
|
|
96
|
+
if (!xmlContent)
|
|
97
|
+
return {};
|
|
98
|
+
const metadata = {};
|
|
99
|
+
// Priority 1: Try PIE extension first (perfect reconstruction)
|
|
100
|
+
const pieExtensionMatch = xmlContent.match(/<pie:sourceModel[^>]*>([\s\S]*?)<\/pie:sourceModel>/i);
|
|
101
|
+
if (pieExtensionMatch && pieExtensionMatch[1]) {
|
|
102
|
+
try {
|
|
103
|
+
const sourceModel = JSON.parse(pieExtensionMatch[1].trim());
|
|
104
|
+
if (sourceModel.searchMetaData) {
|
|
105
|
+
return sourceModel.searchMetaData;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
// Fall through to QTI metadata parsing
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Priority 2: Parse <qti-metadata> section
|
|
113
|
+
const metadataSection = xmlContent.match(/<qti-metadata[^>]*>([\s\S]*?)<\/qti-metadata>/i);
|
|
114
|
+
if (metadataSection && metadataSection[1]) {
|
|
115
|
+
const fieldsContent = metadataSection[1];
|
|
116
|
+
// Extract all qti-metadata-field elements
|
|
117
|
+
const fieldMatches = fieldsContent.matchAll(/<qti-metadata-field\s+([^>]+)\/?>(?:<\/qti-metadata-field>)?/gi);
|
|
118
|
+
for (const match of fieldMatches) {
|
|
119
|
+
const attributesStr = match[1];
|
|
120
|
+
// Extract name, value, and data-type attributes
|
|
121
|
+
const nameMatch = attributesStr.match(/name=["']([^"']+)["']/i);
|
|
122
|
+
const valueMatch = attributesStr.match(/value=["']([^"']*)["']/i);
|
|
123
|
+
const dataTypeMatch = attributesStr.match(/data-type=["']([^"']+)["']/i);
|
|
124
|
+
const name = nameMatch?.[1];
|
|
125
|
+
const value = valueMatch?.[1];
|
|
126
|
+
const dataType = dataTypeMatch?.[1];
|
|
127
|
+
if (!name || value === undefined)
|
|
128
|
+
continue;
|
|
129
|
+
// Restore original type
|
|
130
|
+
if (dataType === 'array') {
|
|
131
|
+
metadata[name] = value.split(',').map((v) => v.trim());
|
|
132
|
+
}
|
|
133
|
+
else if (dataType === 'number') {
|
|
134
|
+
metadata[name] = parseFloat(value);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
metadata[name] = value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return metadata;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Extract interaction types from QTI item XML content
|
|
145
|
+
*
|
|
146
|
+
* Detects all QTI interaction types present in the item.
|
|
147
|
+
*
|
|
148
|
+
* @param xmlContent QTI XML content as string
|
|
149
|
+
* @returns Array of detected interaction type names (e.g., ["choiceInteraction", "textEntryInteraction"])
|
|
150
|
+
*/
|
|
151
|
+
export function extractInteractionTypesFromQtiXml(xmlContent) {
|
|
152
|
+
if (!xmlContent)
|
|
153
|
+
return [];
|
|
154
|
+
const interactionTypes = new Set();
|
|
155
|
+
// Common QTI interaction types
|
|
156
|
+
const knownInteractions = [
|
|
157
|
+
'choiceInteraction',
|
|
158
|
+
'orderInteraction',
|
|
159
|
+
'associateInteraction',
|
|
160
|
+
'matchInteraction',
|
|
161
|
+
'gapMatchInteraction',
|
|
162
|
+
'inlineChoiceInteraction',
|
|
163
|
+
'textEntryInteraction',
|
|
164
|
+
'extendedTextInteraction',
|
|
165
|
+
'hottextInteraction',
|
|
166
|
+
'hotspotInteraction',
|
|
167
|
+
'selectPointInteraction',
|
|
168
|
+
'graphicOrderInteraction',
|
|
169
|
+
'graphicAssociateInteraction',
|
|
170
|
+
'graphicGapMatchInteraction',
|
|
171
|
+
'positionObjectInteraction',
|
|
172
|
+
'sliderInteraction',
|
|
173
|
+
'drawingInteraction',
|
|
174
|
+
'uploadInteraction',
|
|
175
|
+
'customInteraction',
|
|
176
|
+
'endAttemptInteraction',
|
|
177
|
+
];
|
|
178
|
+
for (const interactionType of knownInteractions) {
|
|
179
|
+
const pattern = new RegExp(`<${interactionType}[^>]*>`, 'i');
|
|
180
|
+
if (pattern.test(xmlContent)) {
|
|
181
|
+
interactionTypes.add(interactionType);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return Array.from(interactionTypes);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Extract comprehensive metadata from QTI item XML content
|
|
188
|
+
*
|
|
189
|
+
* Combines all metadata extraction functions to provide a complete metadata object.
|
|
190
|
+
*
|
|
191
|
+
* @param xmlContent QTI XML content as string
|
|
192
|
+
* @returns Comprehensive QTI item metadata
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* const xml = `<assessmentItem identifier="item1" title="Question 1">...</assessmentItem>`;
|
|
197
|
+
* const metadata = extractQtiItemMetadata(xml);
|
|
198
|
+
* // {
|
|
199
|
+
* // identifier: "item1",
|
|
200
|
+
* // title: "Question 1",
|
|
201
|
+
* // searchMetadata: {...},
|
|
202
|
+
* // interactionTypes: ["choiceInteraction"]
|
|
203
|
+
* // }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export function extractQtiItemMetadata(xmlContent) {
|
|
207
|
+
return {
|
|
208
|
+
identifier: extractIdentifierFromQtiXml(xmlContent),
|
|
209
|
+
title: extractTitleFromQtiXml(xmlContent),
|
|
210
|
+
searchMetadata: extractSearchMetadataFromQtiXml(xmlContent),
|
|
211
|
+
interactionTypes: extractInteractionTypesFromQtiXml(xmlContent),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=qti-xml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-xml.js","sourceRoot":"","sources":["../../src/utils/qti-xml.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAkB;IACxD,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAElC,gEAAgE;IAChE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAC1F,IAAI,cAAc,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,yDAAyD;IACzD,MAAM,kBAAkB,GAAG,UAAU,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAC9F,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAED,8CAA8C;IAC9C,mFAAmF;IACnF,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CACpC,+EAA+E,CAC/E,CAAC;IACF,IAAI,YAAY,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,EAA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