@learnosity/lib-qti-converter 0.12.7 → 0.12.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/package.json +8 -8
- package/packages/cli/dist/{batchProcessors-DU1HwpHY.js → batchProcessors-CUJoQD8a.js} +3 -3
- package/packages/cli/dist/{batchProcessors-DU1HwpHY.js.map → batchProcessors-CUJoQD8a.js.map} +1 -1
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{create-prompt-DU9wLVhI.js → create-prompt-DyNnKXYU.js} +63 -53
- package/packages/cli/dist/create-prompt-DyNnKXYU.js.map +1 -0
- package/packages/cli/dist/{dist-DjpU2mIj.js → dist-D3v6G5F8.js} +6 -6
- package/packages/cli/dist/{dist-DjpU2mIj.js.map → dist-D3v6G5F8.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQti-BSbH3jyx.js → learnosityToQti-CvfVQ6Kl.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-BSbH3jyx.js.map → learnosityToQti-CvfVQ6Kl.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-B0xRzYmy.js → learnosityToQtiPackage-CXMsJNQD.js} +7 -7
- package/packages/cli/dist/{learnosityToQtiPackage-B0xRzYmy.js.map → learnosityToQtiPackage-CXMsJNQD.js.map} +1 -1
- package/packages/cli/dist/main.js +5 -5
- package/packages/cli/dist/{nodeFileAccess-BkzSHCOh.js → nodeFileAccess-BhCoGDOi.js} +6 -3
- package/packages/cli/dist/{nodeFileAccess-BkzSHCOh.js.map → nodeFileAccess-BhCoGDOi.js.map} +1 -1
- package/packages/cli/dist/{pathUtils-B9yPTlVF.js → pathUtils-DmtCfutO.js} +26 -20
- package/packages/cli/dist/pathUtils-DmtCfutO.js.map +1 -0
- package/packages/cli/dist/{qtiPackageToLearnosity-C7JaaUDU.js → qtiPackageToLearnosity-FhfNr7gf.js} +5 -5
- package/packages/cli/dist/{qtiPackageToLearnosity-C7JaaUDU.js.map → qtiPackageToLearnosity-FhfNr7gf.js.map} +1 -1
- package/packages/cli/dist/{qtiToLearnosity-CYoG2aIX.js → qtiToLearnosity-5lQ5f3-t.js} +5 -5
- package/packages/cli/dist/{qtiToLearnosity-CYoG2aIX.js.map → qtiToLearnosity-5lQ5f3-t.js.map} +1 -1
- package/packages/cli/dist/{resolveOptions-CW80R2EQ.js → resolveOptions-lHxSyq9F.js} +5 -5
- package/packages/cli/dist/{resolveOptions-CW80R2EQ.js.map → resolveOptions-lHxSyq9F.js.map} +1 -1
- package/packages/cli/dist/{table-DjOn2Tsk.js → table-7b-8MN2z.js} +91 -65
- package/packages/cli/dist/table-7b-8MN2z.js.map +1 -0
- package/packages/core/dist/index.d.ts +184 -184
- package/packages/core/dist/index.js +90 -64
- package/packages/core/dist/node.d.ts +196 -196
- package/packages/core/dist/node.js +95 -66
- package/packages/cli/dist/create-prompt-DU9wLVhI.js.map +0 -1
- package/packages/cli/dist/pathUtils-B9yPTlVF.js.map +0 -1
- package/packages/cli/dist/table-DjOn2Tsk.js.map +0 -1
|
@@ -5833,14 +5833,14 @@ var DomHandler = class {
|
|
|
5833
5833
|
//#endregion
|
|
5834
5834
|
//#region ../../node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/escape.js
|
|
5835
5835
|
const xmlReplacer = /["&'<>$\x80-\uFFFF]/g;
|
|
5836
|
-
const xmlCodeMap
|
|
5836
|
+
const xmlCodeMap = /* @__PURE__ */ new Map([
|
|
5837
5837
|
[34, """],
|
|
5838
5838
|
[38, "&"],
|
|
5839
5839
|
[39, "'"],
|
|
5840
5840
|
[60, "<"],
|
|
5841
5841
|
[62, ">"]
|
|
5842
5842
|
]);
|
|
5843
|
-
const getCodePoint
|
|
5843
|
+
const getCodePoint = String.prototype.codePointAt != null ? (str, index) => str.codePointAt(index) : (c, index) => (c.charCodeAt(index) & 64512) === 55296 ? (c.charCodeAt(index) - 55296) * 1024 + c.charCodeAt(index + 1) - 56320 + 65536 : c.charCodeAt(index);
|
|
5844
5844
|
/**
|
|
5845
5845
|
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
|
5846
5846
|
* documents using XML entities.
|
|
@@ -5855,12 +5855,12 @@ function encodeXML$1(str) {
|
|
|
5855
5855
|
while ((match = xmlReplacer.exec(str)) !== null) {
|
|
5856
5856
|
const i = match.index;
|
|
5857
5857
|
const char = str.charCodeAt(i);
|
|
5858
|
-
const next = xmlCodeMap
|
|
5858
|
+
const next = xmlCodeMap.get(char);
|
|
5859
5859
|
if (next !== void 0) {
|
|
5860
5860
|
ret += str.substring(lastIdx, i) + next;
|
|
5861
5861
|
lastIdx = i + 1;
|
|
5862
5862
|
} else {
|
|
5863
|
-
ret += `${str.substring(lastIdx, i)}&#x${getCodePoint
|
|
5863
|
+
ret += `${str.substring(lastIdx, i)}&#x${getCodePoint(str, i).toString(16)};`;
|
|
5864
5864
|
lastIdx = xmlReplacer.lastIndex += Number((char & 64512) === 55296);
|
|
5865
5865
|
}
|
|
5866
5866
|
}
|
|
@@ -5876,7 +5876,7 @@ function encodeXML$1(str) {
|
|
|
5876
5876
|
* @returns Function that escapes all characters matched by the given regular
|
|
5877
5877
|
* expression using the given map of characters to escape to their entities.
|
|
5878
5878
|
*/
|
|
5879
|
-
function getEscaper
|
|
5879
|
+
function getEscaper(regex, map) {
|
|
5880
5880
|
return function escape(data) {
|
|
5881
5881
|
let match;
|
|
5882
5882
|
let lastIdx = 0;
|
|
@@ -5895,7 +5895,7 @@ function getEscaper$1(regex, map) {
|
|
|
5895
5895
|
*
|
|
5896
5896
|
* @param data String to escape.
|
|
5897
5897
|
*/
|
|
5898
|
-
const escapeAttribute$1 = getEscaper
|
|
5898
|
+
const escapeAttribute$1 = getEscaper(/["&\u00A0]/g, /* @__PURE__ */ new Map([
|
|
5899
5899
|
[34, """],
|
|
5900
5900
|
[38, "&"],
|
|
5901
5901
|
[160, " "]
|
|
@@ -5906,7 +5906,7 @@ const escapeAttribute$1 = getEscaper$1(/["&\u00A0]/g, /* @__PURE__ */ new Map([
|
|
|
5906
5906
|
*
|
|
5907
5907
|
* @param data String to escape.
|
|
5908
5908
|
*/
|
|
5909
|
-
const escapeText$1 = getEscaper
|
|
5909
|
+
const escapeText$1 = getEscaper(/[&<>\u00A0]/g, /* @__PURE__ */ new Map([
|
|
5910
5910
|
[38, "&"],
|
|
5911
5911
|
[60, "<"],
|
|
5912
5912
|
[62, ">"],
|
|
@@ -8969,93 +8969,116 @@ function getElementsByTagType(type, nodes, recurse = true, limit = Number.POSITI
|
|
|
8969
8969
|
return filter(Checks["tag_type"](type), nodes, recurse, limit);
|
|
8970
8970
|
}
|
|
8971
8971
|
//#endregion
|
|
8972
|
-
//#region ../../node_modules/.pnpm/entities@8.
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8972
|
+
//#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/escape.js
|
|
8973
|
+
/**
|
|
8974
|
+
* Get the named reference for an XML special character or U+00A0.
|
|
8975
|
+
* @param char Code unit matched by one of the escape regexes.
|
|
8976
|
+
*/
|
|
8977
|
+
function getEscape(char) {
|
|
8978
|
+
return char === 34 ? """ : char === 38 ? "&" : char === 39 ? "'" : char === 60 ? "<" : char === 62 ? ">" : " ";
|
|
8979
|
+
}
|
|
8980
|
+
/**
|
|
8981
|
+
* Matches exactly the characters `encodeXML` escapes: the five XML special
|
|
8982
|
+
* characters plus every non-ASCII code unit (lone surrogates included — no
|
|
8983
|
+
* `u` flag). Kept in sync with `XML_BITSET_VALUE`.
|
|
8984
|
+
*
|
|
8985
|
+
* Shared with `encodeNonAsciiHTML` in `encode.ts`. Because the regex is
|
|
8986
|
+
* stateful (`g` flag), every call site must set `lastIndex` before use.
|
|
8987
|
+
*/
|
|
8988
|
+
const xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
|
|
8980
8989
|
/**
|
|
8981
|
-
*
|
|
8982
|
-
*
|
|
8983
|
-
*
|
|
8990
|
+
* Whether `code` (a UTF-16 code unit) is escaped by {@link encodeXML}: a
|
|
8991
|
+
* non-ASCII unit, or one of the five XML specials flagged in
|
|
8992
|
+
* `XML_BITSET_VALUE` (which is only meaningful for code units 32-63).
|
|
8993
|
+
* @param code Code unit to test.
|
|
8984
8994
|
*/
|
|
8985
|
-
|
|
8995
|
+
function isXmlEscapable(code) {
|
|
8996
|
+
return code >= 128 || code >= 32 && code < 64 && (1342177476 >>> code & 1) === 1;
|
|
8997
|
+
}
|
|
8986
8998
|
/**
|
|
8987
8999
|
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
|
8988
|
-
* documents using XML entities.
|
|
9000
|
+
* documents using XML entities.
|
|
8989
9001
|
*
|
|
8990
9002
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
8991
9003
|
* (eg. `ü`) will be used.
|
|
8992
|
-
* @param input Input string to encode
|
|
9004
|
+
* @param input Input string to encode.
|
|
8993
9005
|
*/
|
|
8994
9006
|
function encodeXML(input) {
|
|
9007
|
+
const { length } = input;
|
|
8995
9008
|
let out;
|
|
8996
9009
|
let last = 0;
|
|
8997
|
-
|
|
8998
|
-
|
|
9010
|
+
let index = 0;
|
|
9011
|
+
while (index < length) {
|
|
8999
9012
|
const char = input.charCodeAt(index);
|
|
9000
|
-
if (
|
|
9013
|
+
if (!isXmlEscapable(char)) {
|
|
9014
|
+
const bound = Math.min(index + 32, length);
|
|
9015
|
+
let next = index + 1;
|
|
9016
|
+
while (next < bound && !isXmlEscapable(input.charCodeAt(next))) next++;
|
|
9017
|
+
if (next < bound) {
|
|
9018
|
+
index = next;
|
|
9019
|
+
continue;
|
|
9020
|
+
}
|
|
9021
|
+
if (next >= length) break;
|
|
9022
|
+
xmlEncodeRegex.lastIndex = next;
|
|
9023
|
+
if (!xmlEncodeRegex.test(input)) break;
|
|
9024
|
+
index = xmlEncodeRegex.lastIndex - 1;
|
|
9025
|
+
continue;
|
|
9026
|
+
}
|
|
9001
9027
|
if (out === void 0) out = input.substring(0, index);
|
|
9002
9028
|
else if (last !== index) out += input.substring(last, index);
|
|
9003
9029
|
if (char < 64) {
|
|
9004
|
-
out +=
|
|
9005
|
-
last = index
|
|
9030
|
+
out += getEscape(char);
|
|
9031
|
+
last = index += 1;
|
|
9006
9032
|
continue;
|
|
9007
9033
|
}
|
|
9008
|
-
const cp =
|
|
9034
|
+
const cp = input.codePointAt(index);
|
|
9009
9035
|
out += `&#x${cp.toString(16)};`;
|
|
9010
9036
|
if (cp !== char) index++;
|
|
9011
|
-
last = index
|
|
9037
|
+
last = index += 1;
|
|
9012
9038
|
}
|
|
9013
9039
|
if (out === void 0) return input;
|
|
9014
9040
|
if (last < length) out += input.substr(last);
|
|
9015
9041
|
return out;
|
|
9016
9042
|
}
|
|
9017
9043
|
/**
|
|
9018
|
-
*
|
|
9019
|
-
*
|
|
9020
|
-
* @param regex
|
|
9021
|
-
*
|
|
9022
|
-
* @
|
|
9023
|
-
* expression using the given map of characters to escape to their entities.
|
|
9044
|
+
* Escape `data` using `re`, mapping each matched character to its entity.
|
|
9045
|
+
* Every match is one UTF-16 code unit, so its index is `lastIndex - 1`.
|
|
9046
|
+
* @param re Global regex matching exactly the characters to escape
|
|
9047
|
+
* (`"`, `&`, `'`, `<`, `>`, `\u00A0` at most).
|
|
9048
|
+
* @param data String to escape.
|
|
9024
9049
|
*/
|
|
9025
|
-
function
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
};
|
|
9050
|
+
function escapeWithRegex(re, data) {
|
|
9051
|
+
re.lastIndex = 0;
|
|
9052
|
+
if (!re.test(data)) return data;
|
|
9053
|
+
let out = "";
|
|
9054
|
+
let last = 0;
|
|
9055
|
+
do {
|
|
9056
|
+
const index = re.lastIndex - 1;
|
|
9057
|
+
if (last !== index) out += data.substring(last, index);
|
|
9058
|
+
const char = data.charCodeAt(index);
|
|
9059
|
+
out += getEscape(char);
|
|
9060
|
+
last = index + 1;
|
|
9061
|
+
} while (re.test(data));
|
|
9062
|
+
return out + data.substring(last);
|
|
9037
9063
|
}
|
|
9064
|
+
const attributeEscapeRegex = /["&\u{A0}]/gu;
|
|
9038
9065
|
/**
|
|
9039
9066
|
* Encodes all characters that have to be escaped in HTML attributes,
|
|
9040
9067
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
9041
9068
|
* @param data String to escape.
|
|
9042
9069
|
*/
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
]));
|
|
9070
|
+
function escapeAttribute(data) {
|
|
9071
|
+
return escapeWithRegex(attributeEscapeRegex, data);
|
|
9072
|
+
}
|
|
9073
|
+
const textEscapeRegex = /[&<>\u{A0}]/gu;
|
|
9048
9074
|
/**
|
|
9049
9075
|
* Encodes all characters that have to be escaped in HTML text,
|
|
9050
9076
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
9051
9077
|
* @param data String to escape.
|
|
9052
9078
|
*/
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
[62, ">"],
|
|
9057
|
-
[160, " "]
|
|
9058
|
-
]));
|
|
9079
|
+
function escapeText(data) {
|
|
9080
|
+
return escapeWithRegex(textEscapeRegex, data);
|
|
9081
|
+
}
|
|
9059
9082
|
//#endregion
|
|
9060
9083
|
//#region ../../node_modules/.pnpm/dom-serializer@3.1.1/node_modules/dom-serializer/dist/foreign-names.js
|
|
9061
9084
|
/**
|
|
@@ -24337,6 +24360,7 @@ function readAssessmentItemOrder(inputXml) {
|
|
|
24337
24360
|
} else if (localName === "value" && capture === "correct") {}
|
|
24338
24361
|
if (capture === "stimulus" && stack.length > stimulusCaptureDepth && localName !== "orderInteraction") stimulusBuf.push(buildOpeningTag$3(tag, localName));
|
|
24339
24362
|
else if (capture === "prompt" && localName !== "prompt") promptBuf.push(buildOpeningTag$3(tag, localName));
|
|
24363
|
+
else if (capture === "choice" && localName !== "simpleChoice") choiceBuf.push(buildOpeningTag$3(tag, localName));
|
|
24340
24364
|
});
|
|
24341
24365
|
parser.on("text", (text) => {
|
|
24342
24366
|
if (capture === "stimulus") stimulusBuf.push(text);
|
|
@@ -24360,6 +24384,8 @@ function readAssessmentItemOrder(inputXml) {
|
|
|
24360
24384
|
capture = null;
|
|
24361
24385
|
} else if (capture === "prompt" && localName !== "prompt") {
|
|
24362
24386
|
if (!QTI_VOID_ELEMENTS.has(localName.toLowerCase())) promptBuf.push(`</${localName}>`);
|
|
24387
|
+
} else if (capture === "choice" && localName !== "simpleChoice") {
|
|
24388
|
+
if (!QTI_VOID_ELEMENTS.has(localName.toLowerCase())) choiceBuf.push(`</${localName}>`);
|
|
24363
24389
|
} else if (localName === "simpleChoice" && capture === "choice") {
|
|
24364
24390
|
const text = normalizeWhitespace(choiceBuf.join(""));
|
|
24365
24391
|
if (currentChoiceId) {
|
|
@@ -24762,14 +24788,14 @@ function readAssessmentItemHotspot(inputXml) {
|
|
|
24762
24788
|
* Convert QTI shape coordinates to Learnosity polygon coordinates
|
|
24763
24789
|
* QTI uses absolute pixel coordinates, Learnosity uses percentage coordinates
|
|
24764
24790
|
*/
|
|
24765
|
-
function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
24791
|
+
function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics, sourceFile) {
|
|
24766
24792
|
const coords = choice.coords.split(",").map((c) => parseFloat(c.trim()));
|
|
24767
24793
|
if (choice.shape === "circle") {
|
|
24768
24794
|
if (coords.length !== 3) {
|
|
24769
24795
|
diagnostics.push({
|
|
24770
24796
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24771
24797
|
level: "error",
|
|
24772
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24798
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24773
24799
|
message: `Invalid circle coords for ${choice.identifier}: expected 3 values (x,y,radius), got ${coords.length}`
|
|
24774
24800
|
});
|
|
24775
24801
|
return null;
|
|
@@ -24792,7 +24818,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24792
24818
|
diagnostics.push({
|
|
24793
24819
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24794
24820
|
level: "error",
|
|
24795
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24821
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24796
24822
|
message: `Invalid rect coords for ${choice.identifier}: expected 4 values (x1,y1,x2,y2), got ${coords.length}`
|
|
24797
24823
|
});
|
|
24798
24824
|
return null;
|
|
@@ -24821,7 +24847,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24821
24847
|
diagnostics.push({
|
|
24822
24848
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24823
24849
|
level: "error",
|
|
24824
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24850
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24825
24851
|
message: `Invalid poly coords for ${choice.identifier}: expected at least 6 values (3 points) in pairs, got ${coords.length}`
|
|
24826
24852
|
});
|
|
24827
24853
|
return null;
|
|
@@ -24837,7 +24863,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24837
24863
|
diagnostics.push({
|
|
24838
24864
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24839
24865
|
level: "error",
|
|
24840
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24866
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24841
24867
|
message: `Invalid ellipse coords for ${choice.identifier}: expected 4 values (cx,cy,rx,ry), got ${coords.length}`
|
|
24842
24868
|
});
|
|
24843
24869
|
return null;
|
|
@@ -24859,7 +24885,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24859
24885
|
diagnostics.push({
|
|
24860
24886
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24861
24887
|
level: "error",
|
|
24862
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24888
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24863
24889
|
message: `Unsupported shape type: ${choice.shape}`
|
|
24864
24890
|
});
|
|
24865
24891
|
return null;
|
|
@@ -24932,7 +24958,7 @@ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
24932
24958
|
const areas = [];
|
|
24933
24959
|
const choiceIdToIndex = /* @__PURE__ */ new Map();
|
|
24934
24960
|
for (const choice of parsed.hotspotChoices) {
|
|
24935
|
-
const polygon = convertShapeToPolygon(choice, parsed.imageWidth, parsed.imageHeight, diagnostics);
|
|
24961
|
+
const polygon = convertShapeToPolygon(choice, parsed.imageWidth, parsed.imageHeight, diagnostics, sourceFile);
|
|
24936
24962
|
if (polygon) {
|
|
24937
24963
|
choiceIdToIndex.set(choice.identifier, areas.length);
|
|
24938
24964
|
areas.push(polygon);
|