@pie-qti/qti-common 0.1.28 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +31 -86
  2. package/package.json +2 -3
  3. package/dist/accessibility/apip.d.ts +0 -66
  4. package/dist/accessibility/apip.js +0 -576
  5. package/dist/accessibility/apip.js.map +0 -1
  6. package/dist/accessibility/catalog-info.d.ts +0 -17
  7. package/dist/accessibility/catalog-info.js +0 -60
  8. package/dist/accessibility/catalog-info.js.map +0 -1
  9. package/dist/accessibility/catalog.d.ts +0 -53
  10. package/dist/accessibility/catalog.js +0 -68
  11. package/dist/accessibility/catalog.js.map +0 -1
  12. package/dist/accessibility/index.d.ts +0 -3
  13. package/dist/accessibility/index.js +0 -4
  14. package/dist/accessibility/index.js.map +0 -1
  15. package/dist/dom/assignProps.d.ts +0 -4
  16. package/dist/dom/assignProps.js +0 -9
  17. package/dist/dom/assignProps.js.map +0 -1
  18. package/dist/dom/svelteMountController.d.ts +0 -25
  19. package/dist/dom/svelteMountController.js +0 -131
  20. package/dist/dom/svelteMountController.js.map +0 -1
  21. package/dist/dom/touchDrag.d.ts +0 -10
  22. package/dist/dom/touchDrag.js +0 -141
  23. package/dist/dom/touchDrag.js.map +0 -1
  24. package/dist/element-mapper/AttributeNameMapper.d.ts +0 -66
  25. package/dist/element-mapper/AttributeNameMapper.js +0 -2
  26. package/dist/element-mapper/AttributeNameMapper.js.map +0 -1
  27. package/dist/element-mapper/ElementNameMapper.d.ts +0 -66
  28. package/dist/element-mapper/ElementNameMapper.js +0 -2
  29. package/dist/element-mapper/ElementNameMapper.js.map +0 -1
  30. package/dist/element-mapper/Qti2xAttributeNameMapper.d.ts +0 -27
  31. package/dist/element-mapper/Qti2xAttributeNameMapper.js +0 -38
  32. package/dist/element-mapper/Qti2xAttributeNameMapper.js.map +0 -1
  33. package/dist/element-mapper/Qti2xElementNameMapper.d.ts +0 -37
  34. package/dist/element-mapper/Qti2xElementNameMapper.js +0 -47
  35. package/dist/element-mapper/Qti2xElementNameMapper.js.map +0 -1
  36. package/dist/element-mapper/Qti3AttributeNameMapper.d.ts +0 -40
  37. package/dist/element-mapper/Qti3AttributeNameMapper.js +0 -87
  38. package/dist/element-mapper/Qti3AttributeNameMapper.js.map +0 -1
  39. package/dist/element-mapper/Qti3ElementNameMapper.d.ts +0 -14
  40. package/dist/element-mapper/Qti3ElementNameMapper.js +0 -39
  41. package/dist/element-mapper/Qti3ElementNameMapper.js.map +0 -1
  42. package/dist/element-mapper/index.d.ts +0 -8
  43. package/dist/element-mapper/index.js +0 -7
  44. package/dist/element-mapper/index.js.map +0 -1
  45. package/dist/element-mapper/qti2-to-qti3.d.ts +0 -36
  46. package/dist/element-mapper/qti2-to-qti3.js +0 -228
  47. package/dist/element-mapper/qti2-to-qti3.js.map +0 -1
  48. package/dist/element-mapper/qti3-attribute-map.d.ts +0 -8
  49. package/dist/element-mapper/qti3-attribute-map.js +0 -115
  50. package/dist/element-mapper/qti3-attribute-map.js.map +0 -1
  51. package/dist/element-mapper/qti3-element-mappings.d.ts +0 -538
  52. package/dist/element-mapper/qti3-element-mappings.js +0 -381
  53. package/dist/element-mapper/qti3-element-mappings.js.map +0 -1
  54. package/dist/index.d.ts +0 -15
  55. package/dist/index.js +0 -17
  56. package/dist/index.js.map +0 -1
  57. package/dist/parser-factory.d.ts +0 -137
  58. package/dist/parser-factory.js +0 -146
  59. package/dist/parser-factory.js.map +0 -1
  60. package/dist/version-detection/detectQtiVersion.d.ts +0 -23
  61. package/dist/version-detection/detectQtiVersion.js +0 -129
  62. package/dist/version-detection/detectQtiVersion.js.map +0 -1
  63. package/dist/version-detection/index.d.ts +0 -2
  64. package/dist/version-detection/index.js +0 -2
  65. package/dist/version-detection/index.js.map +0 -1
  66. package/dist/xml/attributes.d.ts +0 -77
  67. package/dist/xml/attributes.js +0 -120
  68. package/dist/xml/attributes.js.map +0 -1
@@ -1,39 +0,0 @@
1
- import { getCanonicalName, QTI3_ELEMENT_MAPPINGS } from './qti3-element-mappings.js';
2
- const QTI3_NATIVE_BY_CANONICAL = new Map(Object.entries(QTI3_ELEMENT_MAPPINGS).map(([native, canonical]) => [canonical, native]));
3
- /**
4
- * Element name mapper for QTI 3.0.
5
- *
6
- * QTI-defined elements use kebab-case with a `qti-` prefix. HTML, MathML,
7
- * SVG, and extension vocabularies retain their native names.
8
- */
9
- export class Qti3ElementNameMapper {
10
- version = '3.0';
11
- PREFIX = 'qti-';
12
- toCanonical(elementName) {
13
- const knownQtiName = getCanonicalName(elementName);
14
- if (knownQtiName)
15
- return knownQtiName;
16
- const canonicalName = elementName.toLowerCase();
17
- if (QTI3_NATIVE_BY_CANONICAL.has(canonicalName))
18
- return canonicalName;
19
- if (elementName.startsWith(this.PREFIX)) {
20
- return elementName.slice(this.PREFIX.length).replace(/-/g, '').toLowerCase();
21
- }
22
- return elementName;
23
- }
24
- toNative(canonicalName) {
25
- return QTI3_NATIVE_BY_CANONICAL.get(canonicalName.toLowerCase()) ?? canonicalName;
26
- }
27
- isValidElementName(elementName) {
28
- if (!elementName.startsWith(this.PREFIX))
29
- return false;
30
- if (elementName === this.PREFIX)
31
- return false;
32
- if (elementName.includes('--'))
33
- return false;
34
- if (elementName.endsWith('-'))
35
- return false;
36
- return /^qti-[a-z][a-z0-9-]*$/.test(elementName);
37
- }
38
- }
39
- //# sourceMappingURL=Qti3ElementNameMapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Qti3ElementNameMapper.js","sourceRoot":"","sources":["../../src/element-mapper/Qti3ElementNameMapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAErF,MAAM,wBAAwB,GAAG,IAAI,GAAG,CACvC,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CA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';\nimport { getCanonicalName, QTI3_ELEMENT_MAPPINGS } from './qti3-element-mappings.js';\n\nconst QTI3_NATIVE_BY_CANONICAL = new Map<string, string>(\n\tObject.entries(QTI3_ELEMENT_MAPPINGS).map(([native, canonical]) => [canonical, native]),\n);\n\n/**\n * Element name mapper for QTI 3.0.\n *\n * QTI-defined elements use kebab-case with a `qti-` prefix. HTML, MathML,\n * SVG, and extension vocabularies retain their native names.\n */\nexport class Qti3ElementNameMapper implements ElementNameMapper {\n\treadonly version = '3.0';\n\tprivate readonly PREFIX = 'qti-';\n\n\ttoCanonical(elementName: string): string {\n\t\tconst knownQtiName = getCanonicalName(elementName);\n\t\tif (knownQtiName) return knownQtiName;\n\t\tconst canonicalName = elementName.toLowerCase();\n\t\tif (QTI3_NATIVE_BY_CANONICAL.has(canonicalName)) return canonicalName;\n\n\t\tif (elementName.startsWith(this.PREFIX)) {\n\t\t\treturn elementName.slice(this.PREFIX.length).replace(/-/g, '').toLowerCase();\n\t\t}\n\n\t\treturn elementName;\n\t}\n\n\ttoNative(canonicalName: string): string {\n\t\treturn QTI3_NATIVE_BY_CANONICAL.get(canonicalName.toLowerCase()) ?? canonicalName;\n\t}\n\n\tisValidElementName(elementName: string): boolean {\n\t\tif (!elementName.startsWith(this.PREFIX)) return false;\n\t\tif (elementName === this.PREFIX) return false;\n\t\tif (elementName.includes('--')) return false;\n\t\tif (elementName.endsWith('-')) return false;\n\t\treturn /^qti-[a-z][a-z0-9-]*$/.test(elementName);\n\t}\n}\n"]}
@@ -1,8 +0,0 @@
1
- export type { ElementNameMapper } from './ElementNameMapper.js';
2
- export { Qti2xElementNameMapper } from './Qti2xElementNameMapper.js';
3
- export { Qti3ElementNameMapper } from './Qti3ElementNameMapper.js';
4
- export type { AttributeNameMapper } from './AttributeNameMapper.js';
5
- export { Qti2xAttributeNameMapper } from './Qti2xAttributeNameMapper.js';
6
- export { Qti3AttributeNameMapper } from './Qti3AttributeNameMapper.js';
7
- export { QTI2_PROMPT_BEARING_INTERACTIONS, QTI3_ATTRIBUTE_TO_QTI2 } from './qti3-attribute-map.js';
8
- export { convertQti2ToQti3, QTI3_ASI_SCHEMA_LOCATION, QTI3_HTML_ELEMENTS, QTI3_NAMESPACE, QTI3_RPTEMPLATE_BASE, qti3AttributeName, qti3ElementName, qti3TemplateUri, } from './qti2-to-qti3.js';
@@ -1,7 +0,0 @@
1
- export { Qti2xElementNameMapper } from './Qti2xElementNameMapper.js';
2
- export { Qti3ElementNameMapper } from './Qti3ElementNameMapper.js';
3
- export { Qti2xAttributeNameMapper } from './Qti2xAttributeNameMapper.js';
4
- export { Qti3AttributeNameMapper } from './Qti3AttributeNameMapper.js';
5
- export { QTI2_PROMPT_BEARING_INTERACTIONS, QTI3_ATTRIBUTE_TO_QTI2 } from './qti3-attribute-map.js';
6
- export { convertQti2ToQti3, QTI3_ASI_SCHEMA_LOCATION, QTI3_HTML_ELEMENTS, QTI3_NAMESPACE, QTI3_RPTEMPLATE_BASE, qti3AttributeName, qti3ElementName, qti3TemplateUri, } from './qti2-to-qti3.js';
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/element-mapper/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACnG,OAAO,EACN,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,eAAe,GACf,MAAM,mBAAmB,CAAC","sourcesContent":["export type { ElementNameMapper } from './ElementNameMapper.js';\nexport { Qti2xElementNameMapper } from './Qti2xElementNameMapper.js';\nexport { Qti3ElementNameMapper } from './Qti3ElementNameMapper.js';\n\nexport type { AttributeNameMapper } from './AttributeNameMapper.js';\nexport { Qti2xAttributeNameMapper } from './Qti2xAttributeNameMapper.js';\nexport { Qti3AttributeNameMapper } from './Qti3AttributeNameMapper.js';\nexport { QTI2_PROMPT_BEARING_INTERACTIONS, QTI3_ATTRIBUTE_TO_QTI2 } from './qti3-attribute-map.js';\nexport {\n\tconvertQti2ToQti3,\n\tQTI3_ASI_SCHEMA_LOCATION,\n\tQTI3_HTML_ELEMENTS,\n\tQTI3_NAMESPACE,\n\tQTI3_RPTEMPLATE_BASE,\n\tqti3AttributeName,\n\tqti3ElementName,\n\tqti3TemplateUri,\n} from './qti2-to-qti3.js';\n"]}
@@ -1,36 +0,0 @@
1
- /**
2
- * QTI 2.x → QTI 3.0 rename
3
- *
4
- * QTI 3.0 is QTI 2.2's information model under new names: `qti-` prefixed kebab-case elements,
5
- * kebab-case attributes, the `imsqtiasi_v3p0` namespace. `convertQti2ToQti3` applies that rename
6
- * to a QTI 2.x item, test or stimulus document, plus the three structural changes 3.0 makes to
7
- * what the generators emit:
8
- *
9
- * - `rubricBlock` content goes inside `qti-content-body`, after any `qti-stylesheet`, and the
10
- * now-required `use` defaults to `scoring` for a scorer view, else `instructions`.
11
- * - Response-processing template URIs take their 3.0 form; the item player and other 3.0
12
- * processors resolve them by file name.
13
- * - `xsi:schemaLocation` names the 3.0 ASI schema for the QTI namespace.
14
- *
15
- * The document is rewritten as a token stream, so markup, entities and whitespace outside tag
16
- * names and attribute names are kept byte for byte. HTML elements keep their names, as QTI 3
17
- * does. Foreign subtrees — MathML, SVG, any prefixed element and any element declaring another
18
- * default namespace — pass through untouched: Content MathML's `and`, `max` or `sum` would
19
- * otherwise collide with QTI expressions.
20
- *
21
- * Elements 3.0 has no counterpart for (`infoControl`) and APIP are not converted; the input is
22
- * expected to carry neither, and they come out unchanged.
23
- */
24
- export declare const QTI3_NAMESPACE = "http://www.imsglobal.org/xsd/imsqtiasi_v3p0";
25
- export declare const QTI3_ASI_SCHEMA_LOCATION = "https://purl.imsglobal.org/spec/qti/v3p0/schema/xsd/imsqti_asiv3p0_v1p0.xsd";
26
- export declare const QTI3_RPTEMPLATE_BASE = "https://purl.imsglobal.org/spec/qti/v3p0/rptemplates/";
27
- /** The HTML elements the QTI 3.0 ASI schema declares; they keep their names. */
28
- export declare const QTI3_HTML_ELEMENTS: ReadonlySet<string>;
29
- /** The QTI 3.0 name of a QTI 2.x element; HTML and unknown names are kept. */
30
- export declare function qti3ElementName(qti2Name: string): string;
31
- /** The QTI 3.0 name of a QTI 2.x attribute: kebab-case for a QTI camelCase name, else unchanged. */
32
- export declare function qti3AttributeName(qti2Name: string): string;
33
- /** A QTI 2.x response-processing template URI in its QTI 3.0 form; other URIs are kept. */
34
- export declare function qti3TemplateUri(uri: string): string;
35
- /** Convert a QTI 2.x item, test or stimulus document to QTI 3.0. */
36
- export declare function convertQti2ToQti3(xml: string): string;
@@ -1,228 +0,0 @@
1
- /**
2
- * QTI 2.x → QTI 3.0 rename
3
- *
4
- * QTI 3.0 is QTI 2.2's information model under new names: `qti-` prefixed kebab-case elements,
5
- * kebab-case attributes, the `imsqtiasi_v3p0` namespace. `convertQti2ToQti3` applies that rename
6
- * to a QTI 2.x item, test or stimulus document, plus the three structural changes 3.0 makes to
7
- * what the generators emit:
8
- *
9
- * - `rubricBlock` content goes inside `qti-content-body`, after any `qti-stylesheet`, and the
10
- * now-required `use` defaults to `scoring` for a scorer view, else `instructions`.
11
- * - Response-processing template URIs take their 3.0 form; the item player and other 3.0
12
- * processors resolve them by file name.
13
- * - `xsi:schemaLocation` names the 3.0 ASI schema for the QTI namespace.
14
- *
15
- * The document is rewritten as a token stream, so markup, entities and whitespace outside tag
16
- * names and attribute names are kept byte for byte. HTML elements keep their names, as QTI 3
17
- * does. Foreign subtrees — MathML, SVG, any prefixed element and any element declaring another
18
- * default namespace — pass through untouched: Content MathML's `and`, `max` or `sum` would
19
- * otherwise collide with QTI expressions.
20
- *
21
- * Elements 3.0 has no counterpart for (`infoControl`) and APIP are not converted; the input is
22
- * expected to carry neither, and they come out unchanged.
23
- */
24
- import { Qti3ElementNameMapper } from './Qti3ElementNameMapper.js';
25
- import { QTI3_ATTRIBUTE_TO_QTI2 } from './qti3-attribute-map.js';
26
- export const QTI3_NAMESPACE = 'http://www.imsglobal.org/xsd/imsqtiasi_v3p0';
27
- export const QTI3_ASI_SCHEMA_LOCATION = 'https://purl.imsglobal.org/spec/qti/v3p0/schema/xsd/imsqti_asiv3p0_v1p0.xsd';
28
- export const QTI3_RPTEMPLATE_BASE = 'https://purl.imsglobal.org/spec/qti/v3p0/rptemplates/';
29
- const QTI2_NAMESPACES = new Set([
30
- 'http://www.imsglobal.org/xsd/imsqti_v2p0',
31
- 'http://www.imsglobal.org/xsd/imsqti_v2p1',
32
- 'http://www.imsglobal.org/xsd/imsqti_v2p2',
33
- ]);
34
- /** A QTI 2.x response-processing template URI; the file name is group 1. */
35
- const QTI2_RPTEMPLATE = /^https?:\/\/www\.imsglobal\.org\/question\/qti_v2p[012]\/rptemplates\/([A-Za-z_]+?)(?:\.xml)?$/;
36
- /** The HTML elements the QTI 3.0 ASI schema declares; they keep their names. */
37
- export const QTI3_HTML_ELEMENTS = new Set(('a abbr acronym address article aside audio b bdi bdo big blockquote br caption cite code col ' +
38
- 'colgroup dd details dfn div dl dt em figcaption figure footer h1 h2 h3 h4 h5 h6 header hr i img ' +
39
- 'kbd label li nav object ol p param picture pre q rb rp rt rtc ruby samp section small source span ' +
40
- 'strong sub summary sup table tbody td template tfoot th thead tr track tt ul var video').split(' '));
41
- /** Unprefixed roots of a foreign vocabulary. */
42
- const FOREIGN_ROOTS = new Set(['math', 'svg']);
43
- const elementMapper = new Qti3ElementNameMapper();
44
- const QTI3_ATTRIBUTE_BY_QTI2 = new Map();
45
- for (const [kebab, camel] of QTI3_ATTRIBUTE_TO_QTI2) {
46
- if (QTI3_ATTRIBUTE_BY_QTI2.has(camel)) {
47
- throw new Error(`QTI 2 attribute "${camel}" has two QTI 3 names`);
48
- }
49
- QTI3_ATTRIBUTE_BY_QTI2.set(camel, kebab);
50
- }
51
- const START_TAG = /<([A-Za-z_][\w.:-]*)((?:\s+[^\s=>/]+\s*=\s*(?:"[^"]*"|'[^']*'))*)(\s*)(\/?)>/y;
52
- const END_TAG = /<\/([A-Za-z_][\w.:-]*)\s*>/y;
53
- const ATTRIBUTE = /(\s+)([^\s=>/]+)(\s*=\s*)(?:"([^"]*)"|'([^']*)')/g;
54
- /** The QTI 3.0 name of a QTI 2.x element; HTML and unknown names are kept. */
55
- export function qti3ElementName(qti2Name) {
56
- if (QTI3_HTML_ELEMENTS.has(qti2Name))
57
- return qti2Name;
58
- const native = elementMapper.toNative(qti2Name.toLowerCase());
59
- return native.startsWith('qti-') ? native : qti2Name;
60
- }
61
- /** The QTI 3.0 name of a QTI 2.x attribute: kebab-case for a QTI camelCase name, else unchanged. */
62
- export function qti3AttributeName(qti2Name) {
63
- if (!/[A-Z]/.test(qti2Name) || qti2Name.includes(':') || qti2Name.startsWith('data-'))
64
- return qti2Name;
65
- return QTI3_ATTRIBUTE_BY_QTI2.get(qti2Name) ?? qti2Name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
66
- }
67
- /** A QTI 2.x response-processing template URI in its QTI 3.0 form; other URIs are kept. */
68
- export function qti3TemplateUri(uri) {
69
- const match = QTI2_RPTEMPLATE.exec(uri.trim());
70
- return match ? `${QTI3_RPTEMPLATE_BASE}${match[1]}.xml` : uri;
71
- }
72
- /** Convert a QTI 2.x item, test or stimulus document to QTI 3.0. */
73
- export function convertQti2ToQti3(xml) {
74
- const out = [];
75
- const stack = [];
76
- let foreignDepth = 0;
77
- let index = 0;
78
- let rootSeen = false;
79
- const rubric = () => stack[stack.length - 1]?.rubric;
80
- /** Open the rubric's content body before content that is not a leading stylesheet. */
81
- const openContentBody = () => {
82
- const open = rubric();
83
- if (open && !open.opened) {
84
- out.push('<qti-content-body>');
85
- open.opened = true;
86
- }
87
- };
88
- while (index < xml.length) {
89
- const lt = xml.indexOf('<', index);
90
- if (lt === -1) {
91
- out.push(xml.slice(index));
92
- break;
93
- }
94
- if (lt > index) {
95
- const text = xml.slice(index, lt);
96
- if (foreignDepth === 0 && text.trim())
97
- openContentBody();
98
- out.push(text);
99
- }
100
- const special = specialToken(xml, lt);
101
- if (special !== undefined) {
102
- if (foreignDepth === 0 && !xml.startsWith('<?', lt) && !xml.startsWith('<!--', lt))
103
- openContentBody();
104
- out.push(xml.slice(lt, special));
105
- index = special;
106
- continue;
107
- }
108
- END_TAG.lastIndex = lt;
109
- const end = END_TAG.exec(xml);
110
- if (end) {
111
- index = END_TAG.lastIndex;
112
- if (foreignDepth > 0) {
113
- foreignDepth -= 1;
114
- out.push(end[0]);
115
- continue;
116
- }
117
- const open = stack.pop();
118
- if (!open)
119
- throw new Error(`Unexpected </${end[1]}> at offset ${lt}`);
120
- if (open.rubric)
121
- out.push(open.rubric.opened ? '</qti-content-body>' : '<qti-content-body/>');
122
- out.push(`</${open.name}>`);
123
- continue;
124
- }
125
- START_TAG.lastIndex = lt;
126
- const start = START_TAG.exec(xml);
127
- if (!start)
128
- throw new Error(`Malformed markup at offset ${lt}`);
129
- index = START_TAG.lastIndex;
130
- const [tag, name, attrs, space, selfClosing] = start;
131
- if (foreignDepth > 0) {
132
- if (!selfClosing)
133
- foreignDepth += 1;
134
- out.push(tag);
135
- continue;
136
- }
137
- if (isForeign(name, attrs)) {
138
- openContentBody();
139
- rootSeen = true;
140
- if (!selfClosing)
141
- foreignDepth = 1;
142
- out.push(tag);
143
- continue;
144
- }
145
- const qti3Name = qti3ElementName(name);
146
- if (qti3Name !== 'qti-stylesheet')
147
- openContentBody();
148
- const element = { name: qti3Name };
149
- let converted = convertAttributes(attrs, !rootSeen);
150
- rootSeen = true;
151
- if (qti3Name === 'qti-rubric-block') {
152
- converted = withRubricUse(converted);
153
- element.rubric = { opened: false };
154
- }
155
- if (selfClosing) {
156
- out.push(element.rubric
157
- ? `<${qti3Name}${converted}><qti-content-body/></${qti3Name}>`
158
- : `<${qti3Name}${converted}${space}/>`);
159
- continue;
160
- }
161
- out.push(`<${qti3Name}${converted}${space}>`);
162
- stack.push(element);
163
- }
164
- if (stack.length > 0 || foreignDepth > 0) {
165
- throw new Error(`Unclosed <${stack[stack.length - 1]?.name ?? 'element'}>`);
166
- }
167
- return out.join('');
168
- }
169
- /** The end offset of a comment, CDATA section, processing instruction or doctype at `at`. */
170
- function specialToken(xml, at) {
171
- const close = (marker, open) => {
172
- const found = xml.indexOf(marker, at + open.length);
173
- if (found === -1)
174
- throw new Error(`Unterminated ${open} at offset ${at}`);
175
- return found + marker.length;
176
- };
177
- if (xml.startsWith('<!--', at))
178
- return close('-->', '<!--');
179
- if (xml.startsWith('<![CDATA[', at))
180
- return close(']]>', '<![CDATA[');
181
- if (xml.startsWith('<?', at))
182
- return close('?>', '<?');
183
- if (xml.startsWith('<!', at))
184
- return close('>', '<!');
185
- return undefined;
186
- }
187
- function isForeign(name, attrs) {
188
- if (name.includes(':') || FOREIGN_ROOTS.has(name))
189
- return true;
190
- for (const match of attrs.matchAll(ATTRIBUTE)) {
191
- if (match[2] === 'xmlns' && !QTI2_NAMESPACES.has((match[4] ?? match[5] ?? '').trim()))
192
- return true;
193
- }
194
- return false;
195
- }
196
- function convertAttributes(attrs, isRoot) {
197
- return attrs.replace(ATTRIBUTE, (_match, lead, name, eq, dq, sq) => {
198
- const quote = dq === undefined ? "'" : '"';
199
- let value = dq ?? sq ?? '';
200
- if (name === 'xmlns' && QTI2_NAMESPACES.has(value.trim()))
201
- value = QTI3_NAMESPACE;
202
- else if (name === 'template')
203
- value = qti3TemplateUri(value);
204
- else if (isRoot && name === 'xsi:schemaLocation')
205
- value = qti3SchemaLocation(value);
206
- return `${lead}${qti3AttributeName(name)}${eq}${quote}${value}${quote}`;
207
- });
208
- }
209
- /** `xsi:schemaLocation` with the QTI 2.x namespace pair replaced by the 3.0 ASI schema. */
210
- function qti3SchemaLocation(value) {
211
- const parts = value.trim().split(/\s+/);
212
- const pairs = [];
213
- for (let i = 0; i + 1 < parts.length; i += 2) {
214
- const [namespace, location] = [parts[i], parts[i + 1]];
215
- pairs.push(QTI2_NAMESPACES.has(namespace) ? `${QTI3_NAMESPACE} ${QTI3_ASI_SCHEMA_LOCATION}` : `${namespace} ${location}`);
216
- }
217
- return pairs.join(' ');
218
- }
219
- /** A rubric block's attributes with `use`, which QTI 3.0 requires, defaulted from `view`. */
220
- function withRubricUse(attrs) {
221
- const names = [...attrs.matchAll(ATTRIBUTE)].map((match) => match[2]);
222
- if (names.includes('use'))
223
- return attrs;
224
- const view = [...attrs.matchAll(ATTRIBUTE)].find((match) => match[2] === 'view');
225
- const views = (view?.[4] ?? view?.[5] ?? '').split(/\s+/);
226
- return `${attrs} use="${views.includes('scorer') ? 'scoring' : 'instructions'}"`;
227
- }
228
- //# sourceMappingURL=qti2-to-qti3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"qti2-to-qti3.js","sourceRoot":"","sources":["../../src/element-mapper/qti2-to-qti3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,CAAC,MAAM,cAAc,GAAG,6CAA6C,CAAC;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GACpC,6EAA6E,CAAC;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,uDAAuD,CAAC;AAE5F,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC/B,0CAA0C;IAC1C,0CAA0C;IAC1C,0CAA0C;CAC1C,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,eAAe,GAAG,gGAAgG,CAAC;AAEzH,gFAAgF;AAChF,MAAM,CAAC,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CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,IAAI,wBAAwB,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE,CAC7G,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,6FAA6F;AAC7F,SAAS,aAAa,CAAC,KAAa;IACnC,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;IACjF,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,GAAG,KAAK,SAAS,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC;AAClF,CAAC","sourcesContent":["/**\n * QTI 2.x → QTI 3.0 rename\n *\n * QTI 3.0 is QTI 2.2's information model under new names: `qti-` prefixed kebab-case elements,\n * kebab-case attributes, the `imsqtiasi_v3p0` namespace. `convertQti2ToQti3` applies that rename\n * to a QTI 2.x item, test or stimulus document, plus the three structural changes 3.0 makes to\n * what the generators emit:\n *\n * - `rubricBlock` content goes inside `qti-content-body`, after any `qti-stylesheet`, and the\n * now-required `use` defaults to `scoring` for a scorer view, else `instructions`.\n * - Response-processing template URIs take their 3.0 form; the item player and other 3.0\n * processors resolve them by file name.\n * - `xsi:schemaLocation` names the 3.0 ASI schema for the QTI namespace.\n *\n * The document is rewritten as a token stream, so markup, entities and whitespace outside tag\n * names and attribute names are kept byte for byte. HTML elements keep their names, as QTI 3\n * does. Foreign subtrees — MathML, SVG, any prefixed element and any element declaring another\n * default namespace — pass through untouched: Content MathML's `and`, `max` or `sum` would\n * otherwise collide with QTI expressions.\n *\n * Elements 3.0 has no counterpart for (`infoControl`) and APIP are not converted; the input is\n * expected to carry neither, and they come out unchanged.\n */\n\nimport { Qti3ElementNameMapper } from './Qti3ElementNameMapper.js';\nimport { QTI3_ATTRIBUTE_TO_QTI2 } from './qti3-attribute-map.js';\n\nexport const QTI3_NAMESPACE = 'http://www.imsglobal.org/xsd/imsqtiasi_v3p0';\nexport const QTI3_ASI_SCHEMA_LOCATION =\n\t'https://purl.imsglobal.org/spec/qti/v3p0/schema/xsd/imsqti_asiv3p0_v1p0.xsd';\nexport const QTI3_RPTEMPLATE_BASE = 'https://purl.imsglobal.org/spec/qti/v3p0/rptemplates/';\n\nconst QTI2_NAMESPACES = new Set([\n\t'http://www.imsglobal.org/xsd/imsqti_v2p0',\n\t'http://www.imsglobal.org/xsd/imsqti_v2p1',\n\t'http://www.imsglobal.org/xsd/imsqti_v2p2',\n]);\n\n/** A QTI 2.x response-processing template URI; the file name is group 1. */\nconst QTI2_RPTEMPLATE = /^https?:\\/\\/www\\.imsglobal\\.org\\/question\\/qti_v2p[012]\\/rptemplates\\/([A-Za-z_]+?)(?:\\.xml)?$/;\n\n/** The HTML elements the QTI 3.0 ASI schema declares; they keep their names. */\nexport const QTI3_HTML_ELEMENTS: ReadonlySet<string> = new Set(\n\t(\n\t\t'a abbr acronym address article aside audio b bdi bdo big blockquote br caption cite code col ' +\n\t\t'colgroup dd details dfn div dl dt em figcaption figure footer h1 h2 h3 h4 h5 h6 header hr i img ' +\n\t\t'kbd label li nav object ol p param picture pre q rb rp rt rtc ruby samp section small source span ' +\n\t\t'strong sub summary sup table tbody td template tfoot th thead tr track tt ul var video'\n\t).split(' '),\n);\n\n/** Unprefixed roots of a foreign vocabulary. */\nconst FOREIGN_ROOTS = new Set(['math', 'svg']);\n\nconst elementMapper = new Qti3ElementNameMapper();\n\nconst QTI3_ATTRIBUTE_BY_QTI2 = new Map<string, string>();\nfor (const [kebab, camel] of QTI3_ATTRIBUTE_TO_QTI2) {\n\tif (QTI3_ATTRIBUTE_BY_QTI2.has(camel)) {\n\t\tthrow new Error(`QTI 2 attribute \"${camel}\" has two QTI 3 names`);\n\t}\n\tQTI3_ATTRIBUTE_BY_QTI2.set(camel, kebab);\n}\n\nconst START_TAG = /<([A-Za-z_][\\w.:-]*)((?:\\s+[^\\s=>/]+\\s*=\\s*(?:\"[^\"]*\"|'[^']*'))*)(\\s*)(\\/?)>/y;\nconst END_TAG = /<\\/([A-Za-z_][\\w.:-]*)\\s*>/y;\nconst ATTRIBUTE = /(\\s+)([^\\s=>/]+)(\\s*=\\s*)(?:\"([^\"]*)\"|'([^']*)')/g;\n\ninterface OpenElement {\n\t/** The name as written in the output. */\n\tname: string;\n\t/** A `qti-rubric-block` whose `qti-content-body` is open, or still to open. */\n\trubric?: { opened: boolean };\n}\n\n/** The QTI 3.0 name of a QTI 2.x element; HTML and unknown names are kept. */\nexport function qti3ElementName(qti2Name: string): string {\n\tif (QTI3_HTML_ELEMENTS.has(qti2Name)) return qti2Name;\n\tconst native = elementMapper.toNative(qti2Name.toLowerCase());\n\treturn native.startsWith('qti-') ? native : qti2Name;\n}\n\n/** The QTI 3.0 name of a QTI 2.x attribute: kebab-case for a QTI camelCase name, else unchanged. */\nexport function qti3AttributeName(qti2Name: string): string {\n\tif (!/[A-Z]/.test(qti2Name) || qti2Name.includes(':') || qti2Name.startsWith('data-')) return qti2Name;\n\treturn QTI3_ATTRIBUTE_BY_QTI2.get(qti2Name) ?? qti2Name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n}\n\n/** A QTI 2.x response-processing template URI in its QTI 3.0 form; other URIs are kept. */\nexport function qti3TemplateUri(uri: string): string {\n\tconst match = QTI2_RPTEMPLATE.exec(uri.trim());\n\treturn match ? `${QTI3_RPTEMPLATE_BASE}${match[1]}.xml` : uri;\n}\n\n/** Convert a QTI 2.x item, test or stimulus document to QTI 3.0. */\nexport function convertQti2ToQti3(xml: string): string {\n\tconst out: string[] = [];\n\tconst stack: OpenElement[] = [];\n\tlet foreignDepth = 0;\n\tlet index = 0;\n\tlet rootSeen = false;\n\n\tconst rubric = (): OpenElement['rubric'] => stack[stack.length - 1]?.rubric;\n\t/** Open the rubric's content body before content that is not a leading stylesheet. */\n\tconst openContentBody = (): void => {\n\t\tconst open = rubric();\n\t\tif (open && !open.opened) {\n\t\t\tout.push('<qti-content-body>');\n\t\t\topen.opened = true;\n\t\t}\n\t};\n\n\twhile (index < xml.length) {\n\t\tconst lt = xml.indexOf('<', index);\n\t\tif (lt === -1) {\n\t\t\tout.push(xml.slice(index));\n\t\t\tbreak;\n\t\t}\n\t\tif (lt > index) {\n\t\t\tconst text = xml.slice(index, lt);\n\t\t\tif (foreignDepth === 0 && text.trim()) openContentBody();\n\t\t\tout.push(text);\n\t\t}\n\n\t\tconst special = specialToken(xml, lt);\n\t\tif (special !== undefined) {\n\t\t\tif (foreignDepth === 0 && !xml.startsWith('<?', lt) && !xml.startsWith('<!--', lt)) openContentBody();\n\t\t\tout.push(xml.slice(lt, special));\n\t\t\tindex = special;\n\t\t\tcontinue;\n\t\t}\n\n\t\tEND_TAG.lastIndex = lt;\n\t\tconst end = END_TAG.exec(xml);\n\t\tif (end) {\n\t\t\tindex = END_TAG.lastIndex;\n\t\t\tif (foreignDepth > 0) {\n\t\t\t\tforeignDepth -= 1;\n\t\t\t\tout.push(end[0]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst open = stack.pop();\n\t\t\tif (!open) throw new Error(`Unexpected </${end[1]}> at offset ${lt}`);\n\t\t\tif (open.rubric) out.push(open.rubric.opened ? '</qti-content-body>' : '<qti-content-body/>');\n\t\t\tout.push(`</${open.name}>`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tSTART_TAG.lastIndex = lt;\n\t\tconst start = START_TAG.exec(xml);\n\t\tif (!start) throw new Error(`Malformed markup at offset ${lt}`);\n\t\tindex = START_TAG.lastIndex;\n\t\tconst [tag, name, attrs, space, selfClosing] = start as unknown as [string, string, string, string, string];\n\n\t\tif (foreignDepth > 0) {\n\t\t\tif (!selfClosing) foreignDepth += 1;\n\t\t\tout.push(tag);\n\t\t\tcontinue;\n\t\t}\n\t\tif (isForeign(name, attrs)) {\n\t\t\topenContentBody();\n\t\t\trootSeen = true;\n\t\t\tif (!selfClosing) foreignDepth = 1;\n\t\t\tout.push(tag);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst qti3Name = qti3ElementName(name);\n\t\tif (qti3Name !== 'qti-stylesheet') openContentBody();\n\t\tconst element: OpenElement = { name: qti3Name };\n\t\tlet converted = convertAttributes(attrs, !rootSeen);\n\t\trootSeen = true;\n\t\tif (qti3Name === 'qti-rubric-block') {\n\t\t\tconverted = withRubricUse(converted);\n\t\t\telement.rubric = { opened: false };\n\t\t}\n\t\tif (selfClosing) {\n\t\t\tout.push(\n\t\t\t\telement.rubric\n\t\t\t\t\t? `<${qti3Name}${converted}><qti-content-body/></${qti3Name}>`\n\t\t\t\t\t: `<${qti3Name}${converted}${space}/>`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tout.push(`<${qti3Name}${converted}${space}>`);\n\t\tstack.push(element);\n\t}\n\n\tif (stack.length > 0 || foreignDepth > 0) {\n\t\tthrow new Error(`Unclosed <${stack[stack.length - 1]?.name ?? 'element'}>`);\n\t}\n\treturn out.join('');\n}\n\n/** The end offset of a comment, CDATA section, processing instruction or doctype at `at`. */\nfunction specialToken(xml: string, at: number): number | undefined {\n\tconst close = (marker: string, open: string): number => {\n\t\tconst found = xml.indexOf(marker, at + open.length);\n\t\tif (found === -1) throw new Error(`Unterminated ${open} at offset ${at}`);\n\t\treturn found + marker.length;\n\t};\n\tif (xml.startsWith('<!--', at)) return close('-->', '<!--');\n\tif (xml.startsWith('<![CDATA[', at)) return close(']]>', '<![CDATA[');\n\tif (xml.startsWith('<?', at)) return close('?>', '<?');\n\tif (xml.startsWith('<!', at)) return close('>', '<!');\n\treturn undefined;\n}\n\nfunction isForeign(name: string, attrs: string): boolean {\n\tif (name.includes(':') || FOREIGN_ROOTS.has(name)) return true;\n\tfor (const match of attrs.matchAll(ATTRIBUTE)) {\n\t\tif (match[2] === 'xmlns' && !QTI2_NAMESPACES.has((match[4] ?? match[5] ?? '').trim())) return true;\n\t}\n\treturn false;\n}\n\nfunction convertAttributes(attrs: string, isRoot: boolean): string {\n\treturn attrs.replace(ATTRIBUTE, (_match, lead: string, name: string, eq: string, dq?: string, sq?: string) => {\n\t\tconst quote = dq === undefined ? \"'\" : '\"';\n\t\tlet value = dq ?? sq ?? '';\n\t\tif (name === 'xmlns' && QTI2_NAMESPACES.has(value.trim())) value = QTI3_NAMESPACE;\n\t\telse if (name === 'template') value = qti3TemplateUri(value);\n\t\telse if (isRoot && name === 'xsi:schemaLocation') value = qti3SchemaLocation(value);\n\t\treturn `${lead}${qti3AttributeName(name)}${eq}${quote}${value}${quote}`;\n\t});\n}\n\n/** `xsi:schemaLocation` with the QTI 2.x namespace pair replaced by the 3.0 ASI schema. */\nfunction qti3SchemaLocation(value: string): string {\n\tconst parts = value.trim().split(/\\s+/);\n\tconst pairs: string[] = [];\n\tfor (let i = 0; i + 1 < parts.length; i += 2) {\n\t\tconst [namespace, location] = [parts[i] as string, parts[i + 1] as string];\n\t\tpairs.push(\n\t\t\tQTI2_NAMESPACES.has(namespace) ? `${QTI3_NAMESPACE} ${QTI3_ASI_SCHEMA_LOCATION}` : `${namespace} ${location}`,\n\t\t);\n\t}\n\treturn pairs.join(' ');\n}\n\n/** A rubric block's attributes with `use`, which QTI 3.0 requires, defaulted from `view`. */\nfunction withRubricUse(attrs: string): string {\n\tconst names = [...attrs.matchAll(ATTRIBUTE)].map((match) => match[2]);\n\tif (names.includes('use')) return attrs;\n\tconst view = [...attrs.matchAll(ATTRIBUTE)].find((match) => match[2] === 'view');\n\tconst views = (view?.[4] ?? view?.[5] ?? '').split(/\\s+/);\n\treturn `${attrs} use=\"${views.includes('scorer') ? 'scoring' : 'instructions'}\"`;\n}\n"]}
@@ -1,8 +0,0 @@
1
- /** QTI 3.0 kebab-case attribute name → QTI 2.x camelCase equivalent. 79 entries. */
2
- export declare const QTI3_ATTRIBUTE_TO_QTI2: Map<string, string>;
3
- /**
4
- * QTI 2.2 interactions whose content model permits a `prompt` child (it must come first).
5
- * The inline interactions are deliberately absent: moving a prompt into one would trade one
6
- * schema violation for another.
7
- */
8
- export declare const QTI2_PROMPT_BEARING_INTERACTIONS: ReadonlySet<string>;
@@ -1,115 +0,0 @@
1
- // GENERATED FILE — do not edit by hand.
2
- // Regenerate with:
3
- // bun run packages/qti-common/scripts/generate-qti3-attribute-map.ts
4
- //
5
- // Derived from the IMS QTI schemas vendored in packages/to-pie (imsqti_v2p1.xsd, imsqti_v2p2.xsd) by taking every
6
- // camelCase attribute name in the QTI 2.x vocabulary and kebab-casing it, which is exactly
7
- // the QTI 3.0 attribute rename. Attributes already kebab-case in QTI 2.x (`aria-*`) carry
8
- // no uppercase letter and so are absent here by construction — as are `data-*`,
9
- // `xml:lang` and HTML attributes, since lookup is by exact name.
10
- /** QTI 3.0 kebab-case attribute name → QTI 2.x camelCase equivalent. 79 entries. */
11
- export const QTI3_ATTRIBUTE_TO_QTI2 = new Map([
12
- ['allow-comment', 'allowComment'],
13
- ['allow-late-submission', 'allowLateSubmission'],
14
- ['allow-review', 'allowReview'],
15
- ['allow-skipping', 'allowSkipping'],
16
- ['base-type', 'baseType'],
17
- ['case-sensitive', 'caseSensitive'],
18
- ['center-point', 'centerPoint'],
19
- ['centre-point', 'centrePoint'],
20
- ['count-attempt', 'countAttempt'],
21
- ['data-extension', 'dataExtension'],
22
- ['default-value', 'defaultValue'],
23
- ['exclude-category', 'excludeCategory'],
24
- ['expected-length', 'expectedLength'],
25
- ['expected-lines', 'expectedLines'],
26
- ['external-scored', 'externalScored'],
27
- ['field-identifier', 'fieldIdentifier'],
28
- ['hotspot-label', 'hotspotLabel'],
29
- ['include-boundary', 'includeBoundary'],
30
- ['include-category', 'includeCategory'],
31
- ['include-lower-bound', 'includeLowerBound'],
32
- ['include-upper-bound', 'includeUpperBound'],
33
- ['keep-together', 'keepTogether'],
34
- ['long-interpretation', 'longInterpretation'],
35
- ['lower-bound', 'lowerBound'],
36
- ['map-key', 'mapKey'],
37
- ['mapped-value', 'mappedValue'],
38
- ['mapping-indicator', 'mappingIndicator'],
39
- ['mastery-value', 'masteryValue'],
40
- ['match-group', 'matchGroup'],
41
- ['match-max', 'matchMax'],
42
- ['match-min', 'matchMin'],
43
- ['math-variable', 'mathVariable'],
44
- ['max-associations', 'maxAssociations'],
45
- ['max-attempts', 'maxAttempts'],
46
- ['max-choices', 'maxChoices'],
47
- ['max-plays', 'maxPlays'],
48
- ['max-strings', 'maxStrings'],
49
- ['max-time', 'maxTime'],
50
- ['min-associations', 'minAssociations'],
51
- ['min-choices', 'minChoices'],
52
- ['min-plays', 'minPlays'],
53
- ['min-strings', 'minStrings'],
54
- ['min-time', 'minTime'],
55
- ['navigation-mode', 'navigationMode'],
56
- ['normal-maximum', 'normalMaximum'],
57
- ['normal-minimum', 'normalMinimum'],
58
- ['number-repeats', 'numberRepeats'],
59
- ['object-label', 'objectLabel'],
60
- ['outcome-identifier', 'outcomeIdentifier'],
61
- ['param-variable', 'paramVariable'],
62
- ['pattern-mask', 'patternMask'],
63
- ['placeholder-text', 'placeholderText'],
64
- ['power-form', 'powerForm'],
65
- ['response-identifier', 'responseIdentifier'],
66
- ['rounding-mode', 'roundingMode'],
67
- ['section-identifier', 'sectionIdentifier'],
68
- ['show-feedback', 'showFeedback'],
69
- ['show-hide', 'showHide'],
70
- ['show-solution', 'showSolution'],
71
- ['source-identifier', 'sourceIdentifier'],
72
- ['source-value', 'sourceValue'],
73
- ['step-label', 'stepLabel'],
74
- ['string-identifier', 'stringIdentifier'],
75
- ['submission-mode', 'submissionMode'],
76
- ['target-identifier', 'targetIdentifier'],
77
- ['target-type', 'targetType'],
78
- ['target-value', 'targetValue'],
79
- ['template-identifier', 'templateIdentifier'],
80
- ['template-location', 'templateLocation'],
81
- ['time-dependent', 'timeDependent'],
82
- ['tolerance-mode', 'toleranceMode'],
83
- ['tool-name', 'toolName'],
84
- ['tool-version', 'toolVersion'],
85
- ['upper-bound', 'upperBound'],
86
- ['validate-responses', 'validateResponses'],
87
- ['variable-identifier', 'variableIdentifier'],
88
- ['variable-identifier-ref', 'variableIdentifierRef'],
89
- ['weight-identifier', 'weightIdentifier'],
90
- ['with-replacement', 'withReplacement'],
91
- ]);
92
- /**
93
- * QTI 2.2 interactions whose content model permits a `prompt` child (it must come first).
94
- * The inline interactions are deliberately absent: moving a prompt into one would trade one
95
- * schema violation for another.
96
- */
97
- export const QTI2_PROMPT_BEARING_INTERACTIONS = new Set([
98
- 'associateInteraction',
99
- 'choiceInteraction',
100
- 'drawingInteraction',
101
- 'extendedTextInteraction',
102
- 'gapMatchInteraction',
103
- 'graphicAssociateInteraction',
104
- 'graphicGapMatchInteraction',
105
- 'graphicOrderInteraction',
106
- 'hotspotInteraction',
107
- 'hottextInteraction',
108
- 'matchInteraction',
109
- 'mediaInteraction',
110
- 'orderInteraction',
111
- 'selectPointInteraction',
112
- 'sliderInteraction',
113
- 'uploadInteraction',
114
- ]);
115
- //# sourceMappingURL=qti3-attribute-map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"qti3-attribute-map.js","sourceRoot":"","sources":["../../src/element-mapper/qti3-attribute-map.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,mBAAmB;AACnB,uEAAuE;AACvE,EAAE;AACF,kHAAkH;A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,CAAC;IAC/B,CAAC,YAAY,EAAE,WAAW,CAAC;IAC3B,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;IACzC,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;IACrC,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;IACzC,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,cAAc,EAAE,aAAa,CAAC;IAC/B,CAAC,qBAAqB,EAAE,oBAAoB,CAAC;IAC7C,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;IACzC,CAAC,gBAAgB,EAAE,eAAe,CAAC;IACnC,CAAC,gBAAgB,EAAE,eAAe,CAAC;IACnC,CAAC,WAAW,EAAE,UAAU,CAAC;IACzB,CAAC,cAAc,EAAE,aAAa,CAAC;IAC/B,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,oBAAoB,EAAE,mBAAmB,CAAC;IAC3C,CAAC,qBAAqB,EAAE,oBAAoB,CAAC;IAC7C,CAAC,yBAAyB,EAAE,uBAAuB,CAAC;IACpD,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;IACzC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;CACxC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAwB,IAAI,GAAG,CAAC;IAC3E,sBAAsB;IACtB,mBAAmB;IACnB,oBAAoB;IACpB,yBAAyB;IACzB,qBAAqB;IACrB,6BAA6B;IAC7B,4BAA4B;IAC5B,yBAAyB;IACzB,oBAAoB;IACpB,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,wBAAwB;IACxB,mBAAmB;IACnB,mBAAmB;CACpB,CAAC,CAAC","sourcesContent":["// GENERATED FILE — do not edit by hand.\n// Regenerate with:\n// bun run packages/qti-common/scripts/generate-qti3-attribute-map.ts\n//\n// Derived from the IMS QTI schemas vendored in packages/to-pie (imsqti_v2p1.xsd, imsqti_v2p2.xsd) by taking every\n// camelCase attribute name in the QTI 2.x vocabulary and kebab-casing it, which is exactly\n// the QTI 3.0 attribute rename. Attributes already kebab-case in QTI 2.x (`aria-*`) carry\n// no uppercase letter and so are absent here by construction — as are `data-*`,\n// `xml:lang` and HTML attributes, since lookup is by exact name.\n\n/** QTI 3.0 kebab-case attribute name → QTI 2.x camelCase equivalent. 79 entries. */\nexport const QTI3_ATTRIBUTE_TO_QTI2 = new Map<string, string>([\n ['allow-comment', 'allowComment'],\n ['allow-late-submission', 'allowLateSubmission'],\n ['allow-review', 'allowReview'],\n ['allow-skipping', 'allowSkipping'],\n ['base-type', 'baseType'],\n ['case-sensitive', 'caseSensitive'],\n ['center-point', 'centerPoint'],\n ['centre-point', 'centrePoint'],\n ['count-attempt', 'countAttempt'],\n ['data-extension', 'dataExtension'],\n ['default-value', 'defaultValue'],\n ['exclude-category', 'excludeCategory'],\n ['expected-length', 'expectedLength'],\n ['expected-lines', 'expectedLines'],\n ['external-scored', 'externalScored'],\n ['field-identifier', 'fieldIdentifier'],\n ['hotspot-label', 'hotspotLabel'],\n ['include-boundary', 'includeBoundary'],\n ['include-category', 'includeCategory'],\n ['include-lower-bound', 'includeLowerBound'],\n ['include-upper-bound', 'includeUpperBound'],\n ['keep-together', 'keepTogether'],\n ['long-interpretation', 'longInterpretation'],\n ['lower-bound', 'lowerBound'],\n ['map-key', 'mapKey'],\n ['mapped-value', 'mappedValue'],\n ['mapping-indicator', 'mappingIndicator'],\n ['mastery-value', 'masteryValue'],\n ['match-group', 'matchGroup'],\n ['match-max', 'matchMax'],\n ['match-min', 'matchMin'],\n ['math-variable', 'mathVariable'],\n ['max-associations', 'maxAssociations'],\n ['max-attempts', 'maxAttempts'],\n ['max-choices', 'maxChoices'],\n ['max-plays', 'maxPlays'],\n ['max-strings', 'maxStrings'],\n ['max-time', 'maxTime'],\n ['min-associations', 'minAssociations'],\n ['min-choices', 'minChoices'],\n ['min-plays', 'minPlays'],\n ['min-strings', 'minStrings'],\n ['min-time', 'minTime'],\n ['navigation-mode', 'navigationMode'],\n ['normal-maximum', 'normalMaximum'],\n ['normal-minimum', 'normalMinimum'],\n ['number-repeats', 'numberRepeats'],\n ['object-label', 'objectLabel'],\n ['outcome-identifier', 'outcomeIdentifier'],\n ['param-variable', 'paramVariable'],\n ['pattern-mask', 'patternMask'],\n ['placeholder-text', 'placeholderText'],\n ['power-form', 'powerForm'],\n ['response-identifier', 'responseIdentifier'],\n ['rounding-mode', 'roundingMode'],\n ['section-identifier', 'sectionIdentifier'],\n ['show-feedback', 'showFeedback'],\n ['show-hide', 'showHide'],\n ['show-solution', 'showSolution'],\n ['source-identifier', 'sourceIdentifier'],\n ['source-value', 'sourceValue'],\n ['step-label', 'stepLabel'],\n ['string-identifier', 'stringIdentifier'],\n ['submission-mode', 'submissionMode'],\n ['target-identifier', 'targetIdentifier'],\n ['target-type', 'targetType'],\n ['target-value', 'targetValue'],\n ['template-identifier', 'templateIdentifier'],\n ['template-location', 'templateLocation'],\n ['time-dependent', 'timeDependent'],\n ['tolerance-mode', 'toleranceMode'],\n ['tool-name', 'toolName'],\n ['tool-version', 'toolVersion'],\n ['upper-bound', 'upperBound'],\n ['validate-responses', 'validateResponses'],\n ['variable-identifier', 'variableIdentifier'],\n ['variable-identifier-ref', 'variableIdentifierRef'],\n ['weight-identifier', 'weightIdentifier'],\n ['with-replacement', 'withReplacement'],\n]);\n\n/**\n * QTI 2.2 interactions whose content model permits a `prompt` child (it must come first).\n * The inline interactions are deliberately absent: moving a prompt into one would trade one\n * schema violation for another.\n */\nexport const QTI2_PROMPT_BEARING_INTERACTIONS: ReadonlySet<string> = new Set([\n 'associateInteraction',\n 'choiceInteraction',\n 'drawingInteraction',\n 'extendedTextInteraction',\n 'gapMatchInteraction',\n 'graphicAssociateInteraction',\n 'graphicGapMatchInteraction',\n 'graphicOrderInteraction',\n 'hotspotInteraction',\n 'hottextInteraction',\n 'matchInteraction',\n 'mediaInteraction',\n 'orderInteraction',\n 'selectPointInteraction',\n 'sliderInteraction',\n 'uploadInteraction',\n]);\n"]}