@pie-qti/item-player 0.1.6 → 0.1.8
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/dist/catalog/applyGlossaryTriggers.d.ts +2 -1
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
- package/dist/catalog/applyGlossaryTriggers.js +145 -30
- package/dist/catalog/glossaryAction.d.ts.map +1 -1
- package/dist/catalog/glossaryAction.js +14 -4
- package/dist/components/utils/stimulusRender.d.ts +17 -0
- package/dist/components/utils/stimulusRender.d.ts.map +1 -0
- package/dist/components/utils/stimulusRender.js +70 -0
- package/dist/components/utils/stylesheetRender.d.ts +4 -0
- package/dist/components/utils/stylesheetRender.d.ts.map +1 -0
- package/dist/components/utils/stylesheetRender.js +57 -0
- package/dist/core/Player.d.ts +37 -2
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +320 -48
- package/dist/core/sanitizer.d.ts.map +1 -1
- package/dist/core/sanitizer.js +60 -0
- package/dist/document/AssessmentItemDocument.d.ts +4 -0
- package/dist/document/AssessmentItemDocument.d.ts.map +1 -1
- package/dist/document/AssessmentItemDocument.js +53 -4
- package/dist/element.js +2027 -1532
- package/dist/element.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/interactions/extended-text/extractor.d.ts +1 -0
- package/dist/interactions/extended-text/extractor.d.ts.map +1 -1
- package/dist/interactions/extended-text/extractor.js +2 -0
- package/dist/interactions/shared/types.d.ts +1 -0
- package/dist/interactions/shared/types.d.ts.map +1 -1
- package/dist/pnp/applyPnp.d.ts.map +1 -1
- package/dist/pnp/applyPnp.js +9 -2
- package/dist/pnp/parsePnpXml.d.ts.map +1 -1
- package/dist/pnp/parsePnpXml.js +91 -3
- package/dist/pnp/types.d.ts +24 -1
- package/dist/pnp/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +47 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/catalog/applyGlossaryTriggers.ts +174 -34
- package/src/catalog/glossaryAction.ts +14 -4
- package/src/components/ItemBody.svelte +36 -27
- package/src/components/utils/stimulusRender.ts +93 -0
- package/src/components/utils/stylesheetRender.ts +58 -0
- package/src/core/Player.ts +355 -48
- package/src/core/sanitizer.ts +70 -0
- package/src/document/AssessmentItemDocument.ts +76 -7
- package/src/index.ts +1 -0
- package/src/interactions/extended-text/extractor.ts +3 -0
- package/src/interactions/shared/types.ts +1 -0
- package/src/pnp/applyPnp.ts +8 -2
- package/src/pnp/parsePnpXml.ts +102 -5
- package/src/pnp/types.ts +43 -1
- package/src/types/index.ts +53 -0
- package/src/__tests__/glossaryTriggers.test.ts +0 -411
- package/src/__tests__/pnp.test.ts +0 -250
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AttributeNameMapper, ElementNameMapper } from '@pie-qti/qti-common';
|
|
2
2
|
import {
|
|
3
|
-
childElements,
|
|
4
3
|
findAssessmentItem,
|
|
5
4
|
findDescendants,
|
|
6
5
|
findFirstDescendant,
|
|
@@ -32,6 +31,7 @@ export interface AssessmentItemDocumentInput {
|
|
|
32
31
|
export class AssessmentItemDocument {
|
|
33
32
|
private readonly itemXml: string;
|
|
34
33
|
private readonly security?: PlayerSecurityConfig;
|
|
34
|
+
private readonly mathMlPrefixes: Set<string>;
|
|
35
35
|
readonly elementNameMapper: ElementNameMapper;
|
|
36
36
|
readonly attributeNameMapper: AttributeNameMapper;
|
|
37
37
|
private readonly xmlDocument: Document;
|
|
@@ -47,6 +47,7 @@ export class AssessmentItemDocument {
|
|
|
47
47
|
}: AssessmentItemDocumentInput) {
|
|
48
48
|
this.itemXml = itemXml;
|
|
49
49
|
this.security = security;
|
|
50
|
+
this.mathMlPrefixes = findMathMlPrefixes(itemXml);
|
|
50
51
|
this.elementNameMapper = elementNameMapper;
|
|
51
52
|
this.attributeNameMapper = attributeNameMapper;
|
|
52
53
|
|
|
@@ -70,10 +71,7 @@ export class AssessmentItemDocument {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
serializeItemBodyChildren(): string {
|
|
73
|
-
const itemBody =
|
|
74
|
-
this.assessmentItem,
|
|
75
|
-
this.elementNameMapper.toNative('itembody')
|
|
76
|
-
);
|
|
74
|
+
const itemBody = this.getItemBodyElement();
|
|
77
75
|
if (!itemBody) return '';
|
|
78
76
|
return this.serializeChildren(itemBody);
|
|
79
77
|
}
|
|
@@ -101,7 +99,10 @@ export class AssessmentItemDocument {
|
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
serializeChildren(element: Element): string {
|
|
104
|
-
return
|
|
102
|
+
return normalizeMathMlPrefixes(
|
|
103
|
+
unwrapCdataSections(this.serializeChildNodes(element)),
|
|
104
|
+
this.mathMlPrefixes
|
|
105
|
+
);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
findExtractionElements(elementTypes: Iterable<string>): DiscoveredInteractionElement[] {
|
|
@@ -144,7 +145,7 @@ export class AssessmentItemDocument {
|
|
|
144
145
|
private getExtractionDocument(): QTIElement {
|
|
145
146
|
if (!this.extractionDocument) {
|
|
146
147
|
enforceItemXmlLimits(this.itemXml, this.security);
|
|
147
|
-
this.extractionDocument = parse(this.
|
|
148
|
+
this.extractionDocument = parse(this.serializeItemBodyForExtraction(), {
|
|
148
149
|
lowerCaseTagName: false,
|
|
149
150
|
comment: false,
|
|
150
151
|
}) as unknown as QTIElement;
|
|
@@ -152,6 +153,36 @@ export class AssessmentItemDocument {
|
|
|
152
153
|
return this.extractionDocument;
|
|
153
154
|
}
|
|
154
155
|
|
|
156
|
+
private getItemBodyElement(): Element | null {
|
|
157
|
+
return findFirstDescendant(
|
|
158
|
+
this.assessmentItem,
|
|
159
|
+
this.elementNameMapper.toNative('itembody')
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private serializeItemBodyForExtraction(): string {
|
|
164
|
+
const itemBodyTag = this.elementNameMapper.toNative('itembody');
|
|
165
|
+
const itemBody = this.getItemBodyElement();
|
|
166
|
+
const itemBodyChildren = itemBody ? this.serializeChildren(itemBody) : '';
|
|
167
|
+
|
|
168
|
+
return `<assessmentItem><${itemBodyTag}>${itemBodyChildren}</${itemBodyTag}></assessmentItem>`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private serializeChildNodes(element: Element): string {
|
|
172
|
+
const children = (element as any).childNodes as NodeListOf<Node> | undefined;
|
|
173
|
+
if (!children) return '';
|
|
174
|
+
|
|
175
|
+
const serialized: string[] = [];
|
|
176
|
+
for (let index = 0; index < children.length; index++) {
|
|
177
|
+
const child = children[index];
|
|
178
|
+
if (child) {
|
|
179
|
+
serialized.push(serializeXml(child));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return serialized.join('');
|
|
184
|
+
}
|
|
185
|
+
|
|
155
186
|
private walkExtractionChildren(root: QTIElement, visit: (element: QTIElement) => void): void {
|
|
156
187
|
for (const child of root.childNodes ?? []) {
|
|
157
188
|
const element = child as QTIElement;
|
|
@@ -176,3 +207,41 @@ export class AssessmentItemDocument {
|
|
|
176
207
|
export function parseAssessmentItemDocument(input: AssessmentItemDocumentInput): AssessmentItemDocument {
|
|
177
208
|
return new AssessmentItemDocument(input);
|
|
178
209
|
}
|
|
210
|
+
|
|
211
|
+
function unwrapCdataSections(xml: string): string {
|
|
212
|
+
return xml.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, (_match, content: string) => content);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function findMathMlPrefixes(xml: string): Set<string> {
|
|
216
|
+
const prefixes = new Set<string>();
|
|
217
|
+
for (const match of xml.matchAll(
|
|
218
|
+
/\sxmlns:([A-Za-z_][\w.-]*)=(["'])http:\/\/www\.w3\.org\/1998\/Math\/MathML\2/g
|
|
219
|
+
)) {
|
|
220
|
+
const prefix = match[1];
|
|
221
|
+
if (prefix) {
|
|
222
|
+
prefixes.add(prefix);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return prefixes;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function normalizeMathMlPrefixes(xml: string, prefixes: Set<string>): string {
|
|
229
|
+
let normalized = xml;
|
|
230
|
+
for (const prefix of prefixes) {
|
|
231
|
+
const escapedPrefix = escapeRegExp(prefix);
|
|
232
|
+
normalized = normalized
|
|
233
|
+
.replace(new RegExp(`(<\\/?)${escapedPrefix}:([A-Za-z][\\w.-]*)(?=[\\s>/])`, 'g'), '$1$2')
|
|
234
|
+
.replace(
|
|
235
|
+
new RegExp(
|
|
236
|
+
`\\sxmlns:${escapedPrefix}=(["'])http:\\/\\/www\\.w3\\.org\\/1998\\/Math\\/MathML\\1`,
|
|
237
|
+
'g'
|
|
238
|
+
),
|
|
239
|
+
''
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return normalized;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function escapeRegExp(value: string): string {
|
|
246
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
247
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -69,6 +69,7 @@ export { parsePnpXml } from './pnp/parsePnpXml.js';
|
|
|
69
69
|
export type { CatalogIndex, CatalogCard, CatalogEntry } from './catalog/types.js';
|
|
70
70
|
export { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';
|
|
71
71
|
export { getCatalogEntry } from './catalog/catalogLookup.js';
|
|
72
|
+
export type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';
|
|
72
73
|
|
|
73
74
|
// PCI — Portable Custom Interaction (QTI 3.0 §6.1)
|
|
74
75
|
export type { PciModule, PciBoundTo, ExtractedPci } from './pci/types.js';
|
|
@@ -12,6 +12,7 @@ import type { ElementExtractor } from '../../extraction/types.js';
|
|
|
12
12
|
export interface ExtendedTextData {
|
|
13
13
|
expectedLines: number;
|
|
14
14
|
expectedLength: number;
|
|
15
|
+
prompt: string | null;
|
|
15
16
|
placeholderText: string;
|
|
16
17
|
format: string;
|
|
17
18
|
}
|
|
@@ -46,10 +47,12 @@ export const standardExtendedTextExtractor: ElementExtractor<ExtendedTextData> =
|
|
|
46
47
|
const patternMask = utils.getAttribute(element, 'patternMask', '') || null;
|
|
47
48
|
const patternMaskMessage = utils.getAttribute(element, 'patternMaskMessage', '') || null;
|
|
48
49
|
const interactionClasses = utils.getClasses(element);
|
|
50
|
+
const prompt = utils.getPrompt(element);
|
|
49
51
|
|
|
50
52
|
return {
|
|
51
53
|
expectedLines,
|
|
52
54
|
expectedLength,
|
|
55
|
+
prompt,
|
|
53
56
|
placeholderText,
|
|
54
57
|
format,
|
|
55
58
|
...(patternMask ? { patternMask } : {}),
|
|
@@ -50,6 +50,7 @@ export interface ExtendedTextInteractionData extends BaseInteractionData {
|
|
|
50
50
|
type: 'extendedTextInteraction';
|
|
51
51
|
expectedLines: number;
|
|
52
52
|
expectedLength: number;
|
|
53
|
+
prompt: string | null;
|
|
53
54
|
placeholderText: string;
|
|
54
55
|
format: string;
|
|
55
56
|
patternMask?: string | null;
|
package/src/pnp/applyPnp.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PnpProfile } from './types.js';
|
|
2
2
|
|
|
3
3
|
const ATTR = 'data-qti-colorscheme';
|
|
4
|
+
const MAGNIFICATION_ATTR = 'data-qti-magnification';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Apply a PNP profile to the player root element.
|
|
@@ -17,7 +18,12 @@ export function applyPnpToRoot(rootEl: HTMLElement, pnp: PnpProfile | undefined)
|
|
|
17
18
|
rootEl.setAttribute(ATTR, scheme);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const magnification = pnp?.display?.magnification;
|
|
22
|
+
if (magnification !== undefined && Number.isFinite(magnification) && magnification > 0) {
|
|
23
|
+
rootEl.setAttribute(MAGNIFICATION_ATTR, String(magnification));
|
|
24
|
+
rootEl.style?.setProperty?.('--qti-magnification', String(magnification));
|
|
25
|
+
} else {
|
|
26
|
+
rootEl.removeAttribute(MAGNIFICATION_ATTR);
|
|
27
|
+
rootEl.style?.removeProperty?.('--qti-magnification');
|
|
22
28
|
}
|
|
23
29
|
}
|
package/src/pnp/parsePnpXml.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parse as parseHtml } from 'node-html-parser';
|
|
2
2
|
import type { HTMLElement as NhpElement } from 'node-html-parser';
|
|
3
|
-
import type { PnpProfile } from './types.js';
|
|
3
|
+
import type { CatalogSupportPreference, PnpProfile } from './types.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Parse a QTI 3.0 <personalNeedsProfile> element (or legacy <pnp> element) into a PnpProfile.
|
|
@@ -63,6 +63,43 @@ function extractProfile(root: NhpElement): PnpProfile {
|
|
|
63
63
|
if (languageCode) profile.content.keywordTranslation = { active, languageCode };
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
const illustratedEl = findChild(contentEl, [
|
|
67
|
+
'illustratedglossary',
|
|
68
|
+
'illustrated-glossary',
|
|
69
|
+
'ext:sbacglossaryillustration',
|
|
70
|
+
'ext:sbac-glossary-illustration',
|
|
71
|
+
]);
|
|
72
|
+
if (illustratedEl) {
|
|
73
|
+
profile.content.illustratedGlossary = parseBool(
|
|
74
|
+
illustratedEl.getAttribute('enabled') ?? illustratedEl.getAttribute('active') ?? illustratedEl.text ?? 'true'
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const catalogSupportMap = [
|
|
79
|
+
['ttsPronunciation', ['ttspronunciation', 'tts-pronunciation']],
|
|
80
|
+
['signingDefinition', ['signingdefinition', 'signing-definition']],
|
|
81
|
+
['brailleText', ['brailletext', 'braille-text']],
|
|
82
|
+
['audioDescription', ['audiodescription', 'audio-description']],
|
|
83
|
+
['extendedDescription', ['extendeddescription', 'extended-description']],
|
|
84
|
+
] as const;
|
|
85
|
+
for (const [key, names] of catalogSupportMap) {
|
|
86
|
+
const el = findChild(contentEl, names);
|
|
87
|
+
if (el) {
|
|
88
|
+
profile.content.catalogSupports ??= {};
|
|
89
|
+
profile.content.catalogSupports[key] = parseCatalogSupportPreference(el);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const el of findChildren(contentEl, ['catalogsupport', 'catalog-support', 'qti-catalog-support'])) {
|
|
94
|
+
const usage = normalizeCatalogUsage(
|
|
95
|
+
el.getAttribute('usage') ?? el.getAttribute('support') ?? el.getAttribute('name') ?? ''
|
|
96
|
+
);
|
|
97
|
+
if (!usage) continue;
|
|
98
|
+
const key = catalogSupportPreferenceKey(usage);
|
|
99
|
+
profile.content.catalogSupports ??= {};
|
|
100
|
+
profile.content.catalogSupports[key] = parseCatalogSupportPreference(el);
|
|
101
|
+
}
|
|
102
|
+
|
|
66
103
|
const etEl = findChild(contentEl, ['extendedtime', 'extended-time']);
|
|
67
104
|
if (etEl) {
|
|
68
105
|
const active = parseBool(etEl.getAttribute('active') ?? 'true');
|
|
@@ -96,14 +133,19 @@ function extractProfile(root: NhpElement): PnpProfile {
|
|
|
96
133
|
// Helpers
|
|
97
134
|
// ---------------------------------------------------------------------------
|
|
98
135
|
|
|
99
|
-
function findChild(parent: NhpElement, names: string[]): NhpElement | null {
|
|
136
|
+
function findChild(parent: NhpElement, names: readonly string[]): NhpElement | null {
|
|
137
|
+
return findChildren(parent, names)[0] ?? null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function findChildren(parent: NhpElement, names: readonly string[]): NhpElement[] {
|
|
141
|
+
const matches: NhpElement[] = [];
|
|
100
142
|
for (const child of parent.childNodes) {
|
|
101
143
|
if (child.nodeType !== 1) continue; // element nodes only
|
|
102
144
|
const el = child as NhpElement;
|
|
103
145
|
const tag = (el.rawTagName ?? '').toLowerCase();
|
|
104
|
-
if (names.includes(tag))
|
|
146
|
+
if (names.includes(tag)) matches.push(el);
|
|
105
147
|
}
|
|
106
|
-
return
|
|
148
|
+
return matches;
|
|
107
149
|
}
|
|
108
150
|
|
|
109
151
|
function parseBool(value: string): boolean {
|
|
@@ -111,8 +153,63 @@ function parseBool(value: string): boolean {
|
|
|
111
153
|
return v !== 'false' && v !== '0' && v !== 'no';
|
|
112
154
|
}
|
|
113
155
|
|
|
156
|
+
function parseCatalogSupportPreference(el: NhpElement): CatalogSupportPreference {
|
|
157
|
+
const active = parseBool(el.getAttribute('enabled') ?? el.getAttribute('active') ?? el.text ?? 'true');
|
|
158
|
+
const languageCode = normalizeLanguageCode(
|
|
159
|
+
el.getAttribute('languagecode') ?? el.getAttribute('language-code') ?? el.getAttribute('lang') ?? ''
|
|
160
|
+
);
|
|
161
|
+
return languageCode ? { active, languageCode } : active;
|
|
162
|
+
}
|
|
163
|
+
|
|
114
164
|
type ColorScheme = PnpProfile['display'] extends { colorScheme?: infer C } ? Exclude<C, undefined> : never;
|
|
115
|
-
const COLOR_SCHEMES = new Set<string>([
|
|
165
|
+
const COLOR_SCHEMES = new Set<string>([
|
|
166
|
+
'default',
|
|
167
|
+
'defaultreverse',
|
|
168
|
+
'blackwhite',
|
|
169
|
+
'whiteblack',
|
|
170
|
+
'blackrose',
|
|
171
|
+
'roseblack',
|
|
172
|
+
'yellowblue',
|
|
173
|
+
'blueyellow',
|
|
174
|
+
'mgraydgray',
|
|
175
|
+
'dgraymgray',
|
|
176
|
+
'blackcyan',
|
|
177
|
+
'cyanblack',
|
|
178
|
+
'blackcream',
|
|
179
|
+
'creamblack',
|
|
180
|
+
'whitenav',
|
|
181
|
+
'medgray',
|
|
182
|
+
]);
|
|
116
183
|
function isColorScheme(v: string): v is ColorScheme {
|
|
117
184
|
return COLOR_SCHEMES.has(v);
|
|
118
185
|
}
|
|
186
|
+
|
|
187
|
+
function normalizeCatalogUsage(value: string): string | null {
|
|
188
|
+
const usage = value.trim().toLowerCase();
|
|
189
|
+
if (!/^[a-z][a-z0-9._-]*$/.test(usage)) return null;
|
|
190
|
+
return usage;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function normalizeLanguageCode(value: string): string | undefined {
|
|
194
|
+
const languageCode = value.trim();
|
|
195
|
+
if (!languageCode) return undefined;
|
|
196
|
+
if (!/^[a-zA-Z]{2,8}(?:-[a-zA-Z0-9]{1,8})*$/.test(languageCode)) return undefined;
|
|
197
|
+
return languageCode;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function catalogSupportPreferenceKey(usage: string): string {
|
|
201
|
+
switch (usage) {
|
|
202
|
+
case 'tts-pronunciation':
|
|
203
|
+
return 'ttsPronunciation';
|
|
204
|
+
case 'signing-definition':
|
|
205
|
+
return 'signingDefinition';
|
|
206
|
+
case 'braille-text':
|
|
207
|
+
return 'brailleText';
|
|
208
|
+
case 'audio-description':
|
|
209
|
+
return 'audioDescription';
|
|
210
|
+
case 'extended-description':
|
|
211
|
+
return 'extendedDescription';
|
|
212
|
+
default:
|
|
213
|
+
return usage;
|
|
214
|
+
}
|
|
215
|
+
}
|
package/src/pnp/types.ts
CHANGED
|
@@ -8,7 +8,23 @@ export interface PnpProfile {
|
|
|
8
8
|
* Named color scheme. Maps to the data-qti-colorscheme attribute on the player root.
|
|
9
9
|
* 'default' or undefined → attribute removed (browser/host default).
|
|
10
10
|
*/
|
|
11
|
-
colorScheme?:
|
|
11
|
+
colorScheme?:
|
|
12
|
+
| 'default'
|
|
13
|
+
| 'defaultreverse'
|
|
14
|
+
| 'blackwhite'
|
|
15
|
+
| 'whiteblack'
|
|
16
|
+
| 'blackrose'
|
|
17
|
+
| 'roseblack'
|
|
18
|
+
| 'yellowblue'
|
|
19
|
+
| 'blueyellow'
|
|
20
|
+
| 'mgraydgray'
|
|
21
|
+
| 'dgraymgray'
|
|
22
|
+
| 'blackcyan'
|
|
23
|
+
| 'cyanblack'
|
|
24
|
+
| 'blackcream'
|
|
25
|
+
| 'creamblack'
|
|
26
|
+
| 'whitenav'
|
|
27
|
+
| 'medgray';
|
|
12
28
|
/**
|
|
13
29
|
* CSS zoom factor (1.0 = 100%). Deferred — set by browser zoom or host stylesheet.
|
|
14
30
|
* Stored here for forward-compatibility but not yet applied by the player.
|
|
@@ -20,6 +36,10 @@ export interface PnpProfile {
|
|
|
20
36
|
glossaryOnScreen?: boolean;
|
|
21
37
|
/** Show keyword-translation trigger buttons using the given language code. */
|
|
22
38
|
keywordTranslation?: { active: boolean; languageCode: string };
|
|
39
|
+
/** Show illustrated glossary supports when catalog entries provide them. */
|
|
40
|
+
illustratedGlossary?: boolean;
|
|
41
|
+
/** Enable user-initiated host-routed catalog supports. */
|
|
42
|
+
catalogSupports?: CatalogSupportPreferences;
|
|
23
43
|
/**
|
|
24
44
|
* Scale assessment time limits. multiplier: 1.5 means 50% extra time.
|
|
25
45
|
* multiplier: Infinity removes the time limit entirely.
|
|
@@ -31,3 +51,25 @@ export interface PnpProfile {
|
|
|
31
51
|
eliminationTool?: boolean;
|
|
32
52
|
};
|
|
33
53
|
}
|
|
54
|
+
|
|
55
|
+
export interface CatalogSupportPreferences {
|
|
56
|
+
ttsPronunciation?: CatalogSupportPreference;
|
|
57
|
+
signingDefinition?: CatalogSupportPreference;
|
|
58
|
+
brailleText?: CatalogSupportPreference;
|
|
59
|
+
audioDescription?: CatalogSupportPreference;
|
|
60
|
+
extendedDescription?: CatalogSupportPreference;
|
|
61
|
+
/**
|
|
62
|
+
* Host-defined catalog usage names. Use QTI/catalog usage strings such as
|
|
63
|
+
* "custom-audio" rather than DOM event names or implementation-specific APIs.
|
|
64
|
+
*/
|
|
65
|
+
[usage: string]: CatalogSupportPreference | undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type CatalogSupportPreference = boolean | CatalogSupportPreferenceOptions;
|
|
69
|
+
|
|
70
|
+
export interface CatalogSupportPreferenceOptions {
|
|
71
|
+
/** Defaults to true when omitted. */
|
|
72
|
+
active?: boolean;
|
|
73
|
+
/** Preferred catalog entry language for this support, such as "en-US" or "es". */
|
|
74
|
+
languageCode?: string;
|
|
75
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -7,6 +7,8 @@ import type {
|
|
|
7
7
|
Cardinality as ProcessingCardinality,
|
|
8
8
|
QtiValue,
|
|
9
9
|
} from '@pie-qti/qti-processing';
|
|
10
|
+
import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';
|
|
11
|
+
import type { ResponseValidationResult } from './responseValidation.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* QTI base type identifier
|
|
@@ -78,6 +80,51 @@ export interface ItemSessionState {
|
|
|
78
80
|
[variableId: string]: any;
|
|
79
81
|
}
|
|
80
82
|
|
|
83
|
+
export type ItemLifecycleStatus = 'initial' | 'interacting' | 'suspended' | 'closed' | 'review' | 'solution' | 'answer';
|
|
84
|
+
|
|
85
|
+
export type SerializedVariableKind = 'response' | 'outcome' | 'template' | 'context';
|
|
86
|
+
|
|
87
|
+
export interface SerializedItemSessionVariable {
|
|
88
|
+
identifier: string;
|
|
89
|
+
kind: SerializedVariableKind;
|
|
90
|
+
baseType: VariableBaseType;
|
|
91
|
+
cardinality: VariableCardinality;
|
|
92
|
+
value: any;
|
|
93
|
+
defaultValue?: any;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface SerializedItemSessionState {
|
|
97
|
+
itemIdentifier?: string;
|
|
98
|
+
sessionGuid: string;
|
|
99
|
+
lifecycleStatus: ItemLifecycleStatus;
|
|
100
|
+
completionStatus: CompletionStatus;
|
|
101
|
+
numAttempts: number;
|
|
102
|
+
/**
|
|
103
|
+
* Time-on-task in milliseconds, stored as the QTI built-in duration variable value.
|
|
104
|
+
*/
|
|
105
|
+
duration: number;
|
|
106
|
+
responseVariables: Record<string, SerializedItemSessionVariable>;
|
|
107
|
+
outcomeVariables: Record<string, SerializedItemSessionVariable>;
|
|
108
|
+
templateVariables: Record<string, SerializedItemSessionVariable>;
|
|
109
|
+
contextVariables: Record<string, SerializedItemSessionVariable>;
|
|
110
|
+
validationMessages: ResponseValidationResult['issues'];
|
|
111
|
+
savedAt: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type ItemSessionAction = 'suspendAttempt' | 'endAttempt' | 'scoreAttempt' | 'newTemplate';
|
|
115
|
+
|
|
116
|
+
export interface ItemSessionActionResult {
|
|
117
|
+
action: ItemSessionAction;
|
|
118
|
+
lifecycleStatus: ItemLifecycleStatus;
|
|
119
|
+
completionStatus: CompletionStatus;
|
|
120
|
+
numAttempts: number;
|
|
121
|
+
duration: number;
|
|
122
|
+
completed: boolean;
|
|
123
|
+
sessionState: SerializedItemSessionState;
|
|
124
|
+
validation?: ResponseValidationResult;
|
|
125
|
+
scoring?: ScoringResult;
|
|
126
|
+
}
|
|
127
|
+
|
|
81
128
|
export interface InteractionResponse {
|
|
82
129
|
[responseId: string]: any;
|
|
83
130
|
}
|
|
@@ -190,6 +237,12 @@ export interface PlayerConfig {
|
|
|
190
237
|
* Deferred: external catalog files from IMS manifest (G-15) are not yet supported.
|
|
191
238
|
*/
|
|
192
239
|
catalogXml?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Optional resolved delivery context produced by IMS package/assessment layers.
|
|
242
|
+
* This is additive to catalogXml: shared catalog sources are merged first, then
|
|
243
|
+
* catalogXml, then item-embedded catalog entries so item-local entries win.
|
|
244
|
+
*/
|
|
245
|
+
deliveryContext?: ResolvedItemDeliveryContext;
|
|
193
246
|
sessionState?: ItemSessionState;
|
|
194
247
|
responses?: InteractionResponse;
|
|
195
248
|
role?: QTIRole;
|