@learnosity/lib-qti-converter 0.12.6 → 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 +10 -9
- package/packages/cli/dist/batchProcessors-CUJoQD8a.js +3753 -0
- package/packages/cli/dist/batchProcessors-CUJoQD8a.js.map +1 -0
- 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-CXDJoJpl.js → learnosityToQti-CvfVQ6Kl.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-CXDJoJpl.js.map → learnosityToQti-CvfVQ6Kl.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-7v-s4ybk.js → learnosityToQtiPackage-CXMsJNQD.js} +7 -8
- package/packages/cli/dist/{learnosityToQtiPackage-7v-s4ybk.js.map → learnosityToQtiPackage-CXMsJNQD.js.map} +1 -1
- package/packages/cli/dist/main.js +7 -7
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/nodeFileAccess-BhCoGDOi.js +294 -0
- package/packages/cli/dist/nodeFileAccess-BhCoGDOi.js.map +1 -0
- package/packages/cli/dist/{pathUtils-CgoDQyJk.js → pathUtils-DmtCfutO.js} +27 -167
- package/packages/cli/dist/pathUtils-DmtCfutO.js.map +1 -0
- package/packages/cli/dist/{qtiPackageToLearnosity-hT4QZ7YX.js → qtiPackageToLearnosity-FhfNr7gf.js} +5 -5
- package/packages/cli/dist/{qtiPackageToLearnosity-hT4QZ7YX.js.map → qtiPackageToLearnosity-FhfNr7gf.js.map} +1 -1
- package/packages/cli/dist/{qtiToLearnosity-BU7mHhIu.js → qtiToLearnosity-5lQ5f3-t.js} +5 -5
- package/packages/cli/dist/{qtiToLearnosity-BU7mHhIu.js.map → qtiToLearnosity-5lQ5f3-t.js.map} +1 -1
- package/packages/cli/dist/resolveOptions-lHxSyq9F.js +2879 -0
- package/packages/cli/dist/resolveOptions-lHxSyq9F.js.map +1 -0
- package/packages/cli/dist/{resolveOptions-ehwJSkQy.js → table-7b-8MN2z.js} +2520 -2883
- 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/batchProcessors-C8k2v0o_.js +0 -217
- package/packages/cli/dist/batchProcessors-C8k2v0o_.js.map +0 -1
- package/packages/cli/dist/create-prompt-DU9wLVhI.js.map +0 -1
- package/packages/cli/dist/pathUtils-CgoDQyJk.js.map +0 -1
- package/packages/cli/dist/resolveOptions-ehwJSkQy.js.map +0 -1
- package/packages/cli/dist/table-DYcNeyJ_.js +0 -2306
- package/packages/cli/dist/table-DYcNeyJ_.js.map +0 -1
|
@@ -5840,14 +5840,14 @@ var DomHandler = class {
|
|
|
5840
5840
|
//#endregion
|
|
5841
5841
|
//#region ../../node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/escape.js
|
|
5842
5842
|
const xmlReplacer = /["&'<>$\x80-\uFFFF]/g;
|
|
5843
|
-
const xmlCodeMap
|
|
5843
|
+
const xmlCodeMap = /* @__PURE__ */ new Map([
|
|
5844
5844
|
[34, """],
|
|
5845
5845
|
[38, "&"],
|
|
5846
5846
|
[39, "'"],
|
|
5847
5847
|
[60, "<"],
|
|
5848
5848
|
[62, ">"]
|
|
5849
5849
|
]);
|
|
5850
|
-
const getCodePoint
|
|
5850
|
+
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);
|
|
5851
5851
|
/**
|
|
5852
5852
|
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
|
5853
5853
|
* documents using XML entities.
|
|
@@ -5862,12 +5862,12 @@ function encodeXML$1(str) {
|
|
|
5862
5862
|
while ((match = xmlReplacer.exec(str)) !== null) {
|
|
5863
5863
|
const i = match.index;
|
|
5864
5864
|
const char = str.charCodeAt(i);
|
|
5865
|
-
const next = xmlCodeMap
|
|
5865
|
+
const next = xmlCodeMap.get(char);
|
|
5866
5866
|
if (next !== void 0) {
|
|
5867
5867
|
ret += str.substring(lastIdx, i) + next;
|
|
5868
5868
|
lastIdx = i + 1;
|
|
5869
5869
|
} else {
|
|
5870
|
-
ret += `${str.substring(lastIdx, i)}&#x${getCodePoint
|
|
5870
|
+
ret += `${str.substring(lastIdx, i)}&#x${getCodePoint(str, i).toString(16)};`;
|
|
5871
5871
|
lastIdx = xmlReplacer.lastIndex += Number((char & 64512) === 55296);
|
|
5872
5872
|
}
|
|
5873
5873
|
}
|
|
@@ -5883,7 +5883,7 @@ function encodeXML$1(str) {
|
|
|
5883
5883
|
* @returns Function that escapes all characters matched by the given regular
|
|
5884
5884
|
* expression using the given map of characters to escape to their entities.
|
|
5885
5885
|
*/
|
|
5886
|
-
function getEscaper
|
|
5886
|
+
function getEscaper(regex, map) {
|
|
5887
5887
|
return function escape(data) {
|
|
5888
5888
|
let match;
|
|
5889
5889
|
let lastIdx = 0;
|
|
@@ -5902,7 +5902,7 @@ function getEscaper$1(regex, map) {
|
|
|
5902
5902
|
*
|
|
5903
5903
|
* @param data String to escape.
|
|
5904
5904
|
*/
|
|
5905
|
-
const escapeAttribute$1 = getEscaper
|
|
5905
|
+
const escapeAttribute$1 = getEscaper(/["&\u00A0]/g, /* @__PURE__ */ new Map([
|
|
5906
5906
|
[34, """],
|
|
5907
5907
|
[38, "&"],
|
|
5908
5908
|
[160, " "]
|
|
@@ -5913,7 +5913,7 @@ const escapeAttribute$1 = getEscaper$1(/["&\u00A0]/g, /* @__PURE__ */ new Map([
|
|
|
5913
5913
|
*
|
|
5914
5914
|
* @param data String to escape.
|
|
5915
5915
|
*/
|
|
5916
|
-
const escapeText$1 = getEscaper
|
|
5916
|
+
const escapeText$1 = getEscaper(/[&<>\u00A0]/g, /* @__PURE__ */ new Map([
|
|
5917
5917
|
[38, "&"],
|
|
5918
5918
|
[60, "<"],
|
|
5919
5919
|
[62, ">"],
|
|
@@ -8976,93 +8976,116 @@ function getElementsByTagType(type, nodes, recurse = true, limit = Number.POSITI
|
|
|
8976
8976
|
return filter(Checks["tag_type"](type), nodes, recurse, limit);
|
|
8977
8977
|
}
|
|
8978
8978
|
//#endregion
|
|
8979
|
-
//#region ../../node_modules/.pnpm/entities@8.
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8979
|
+
//#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/escape.js
|
|
8980
|
+
/**
|
|
8981
|
+
* Get the named reference for an XML special character or U+00A0.
|
|
8982
|
+
* @param char Code unit matched by one of the escape regexes.
|
|
8983
|
+
*/
|
|
8984
|
+
function getEscape(char) {
|
|
8985
|
+
return char === 34 ? """ : char === 38 ? "&" : char === 39 ? "'" : char === 60 ? "<" : char === 62 ? ">" : " ";
|
|
8986
|
+
}
|
|
8987
|
+
/**
|
|
8988
|
+
* Matches exactly the characters `encodeXML` escapes: the five XML special
|
|
8989
|
+
* characters plus every non-ASCII code unit (lone surrogates included — no
|
|
8990
|
+
* `u` flag). Kept in sync with `XML_BITSET_VALUE`.
|
|
8991
|
+
*
|
|
8992
|
+
* Shared with `encodeNonAsciiHTML` in `encode.ts`. Because the regex is
|
|
8993
|
+
* stateful (`g` flag), every call site must set `lastIndex` before use.
|
|
8994
|
+
*/
|
|
8995
|
+
const xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
|
|
8987
8996
|
/**
|
|
8988
|
-
*
|
|
8989
|
-
*
|
|
8990
|
-
*
|
|
8997
|
+
* Whether `code` (a UTF-16 code unit) is escaped by {@link encodeXML}: a
|
|
8998
|
+
* non-ASCII unit, or one of the five XML specials flagged in
|
|
8999
|
+
* `XML_BITSET_VALUE` (which is only meaningful for code units 32-63).
|
|
9000
|
+
* @param code Code unit to test.
|
|
8991
9001
|
*/
|
|
8992
|
-
|
|
9002
|
+
function isXmlEscapable(code) {
|
|
9003
|
+
return code >= 128 || code >= 32 && code < 64 && (1342177476 >>> code & 1) === 1;
|
|
9004
|
+
}
|
|
8993
9005
|
/**
|
|
8994
9006
|
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
|
8995
|
-
* documents using XML entities.
|
|
9007
|
+
* documents using XML entities.
|
|
8996
9008
|
*
|
|
8997
9009
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
8998
9010
|
* (eg. `ü`) will be used.
|
|
8999
|
-
* @param input Input string to encode
|
|
9011
|
+
* @param input Input string to encode.
|
|
9000
9012
|
*/
|
|
9001
9013
|
function encodeXML(input) {
|
|
9014
|
+
const { length } = input;
|
|
9002
9015
|
let out;
|
|
9003
9016
|
let last = 0;
|
|
9004
|
-
|
|
9005
|
-
|
|
9017
|
+
let index = 0;
|
|
9018
|
+
while (index < length) {
|
|
9006
9019
|
const char = input.charCodeAt(index);
|
|
9007
|
-
if (
|
|
9020
|
+
if (!isXmlEscapable(char)) {
|
|
9021
|
+
const bound = Math.min(index + 32, length);
|
|
9022
|
+
let next = index + 1;
|
|
9023
|
+
while (next < bound && !isXmlEscapable(input.charCodeAt(next))) next++;
|
|
9024
|
+
if (next < bound) {
|
|
9025
|
+
index = next;
|
|
9026
|
+
continue;
|
|
9027
|
+
}
|
|
9028
|
+
if (next >= length) break;
|
|
9029
|
+
xmlEncodeRegex.lastIndex = next;
|
|
9030
|
+
if (!xmlEncodeRegex.test(input)) break;
|
|
9031
|
+
index = xmlEncodeRegex.lastIndex - 1;
|
|
9032
|
+
continue;
|
|
9033
|
+
}
|
|
9008
9034
|
if (out === void 0) out = input.substring(0, index);
|
|
9009
9035
|
else if (last !== index) out += input.substring(last, index);
|
|
9010
9036
|
if (char < 64) {
|
|
9011
|
-
out +=
|
|
9012
|
-
last = index
|
|
9037
|
+
out += getEscape(char);
|
|
9038
|
+
last = index += 1;
|
|
9013
9039
|
continue;
|
|
9014
9040
|
}
|
|
9015
|
-
const cp =
|
|
9041
|
+
const cp = input.codePointAt(index);
|
|
9016
9042
|
out += `&#x${cp.toString(16)};`;
|
|
9017
9043
|
if (cp !== char) index++;
|
|
9018
|
-
last = index
|
|
9044
|
+
last = index += 1;
|
|
9019
9045
|
}
|
|
9020
9046
|
if (out === void 0) return input;
|
|
9021
9047
|
if (last < length) out += input.substr(last);
|
|
9022
9048
|
return out;
|
|
9023
9049
|
}
|
|
9024
9050
|
/**
|
|
9025
|
-
*
|
|
9026
|
-
*
|
|
9027
|
-
* @param regex
|
|
9028
|
-
*
|
|
9029
|
-
* @
|
|
9030
|
-
* expression using the given map of characters to escape to their entities.
|
|
9051
|
+
* Escape `data` using `re`, mapping each matched character to its entity.
|
|
9052
|
+
* Every match is one UTF-16 code unit, so its index is `lastIndex - 1`.
|
|
9053
|
+
* @param re Global regex matching exactly the characters to escape
|
|
9054
|
+
* (`"`, `&`, `'`, `<`, `>`, `\u00A0` at most).
|
|
9055
|
+
* @param data String to escape.
|
|
9031
9056
|
*/
|
|
9032
|
-
function
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
};
|
|
9057
|
+
function escapeWithRegex(re, data) {
|
|
9058
|
+
re.lastIndex = 0;
|
|
9059
|
+
if (!re.test(data)) return data;
|
|
9060
|
+
let out = "";
|
|
9061
|
+
let last = 0;
|
|
9062
|
+
do {
|
|
9063
|
+
const index = re.lastIndex - 1;
|
|
9064
|
+
if (last !== index) out += data.substring(last, index);
|
|
9065
|
+
const char = data.charCodeAt(index);
|
|
9066
|
+
out += getEscape(char);
|
|
9067
|
+
last = index + 1;
|
|
9068
|
+
} while (re.test(data));
|
|
9069
|
+
return out + data.substring(last);
|
|
9044
9070
|
}
|
|
9071
|
+
const attributeEscapeRegex = /["&\u{A0}]/gu;
|
|
9045
9072
|
/**
|
|
9046
9073
|
* Encodes all characters that have to be escaped in HTML attributes,
|
|
9047
9074
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
9048
9075
|
* @param data String to escape.
|
|
9049
9076
|
*/
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
]));
|
|
9077
|
+
function escapeAttribute(data) {
|
|
9078
|
+
return escapeWithRegex(attributeEscapeRegex, data);
|
|
9079
|
+
}
|
|
9080
|
+
const textEscapeRegex = /[&<>\u{A0}]/gu;
|
|
9055
9081
|
/**
|
|
9056
9082
|
* Encodes all characters that have to be escaped in HTML text,
|
|
9057
9083
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
9058
9084
|
* @param data String to escape.
|
|
9059
9085
|
*/
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
[62, ">"],
|
|
9064
|
-
[160, " "]
|
|
9065
|
-
]));
|
|
9086
|
+
function escapeText(data) {
|
|
9087
|
+
return escapeWithRegex(textEscapeRegex, data);
|
|
9088
|
+
}
|
|
9066
9089
|
//#endregion
|
|
9067
9090
|
//#region ../../node_modules/.pnpm/dom-serializer@3.1.1/node_modules/dom-serializer/dist/foreign-names.js
|
|
9068
9091
|
/**
|
|
@@ -24344,6 +24367,7 @@ function readAssessmentItemOrder(inputXml) {
|
|
|
24344
24367
|
} else if (localName === "value" && capture === "correct") {}
|
|
24345
24368
|
if (capture === "stimulus" && stack.length > stimulusCaptureDepth && localName !== "orderInteraction") stimulusBuf.push(buildOpeningTag$3(tag, localName));
|
|
24346
24369
|
else if (capture === "prompt" && localName !== "prompt") promptBuf.push(buildOpeningTag$3(tag, localName));
|
|
24370
|
+
else if (capture === "choice" && localName !== "simpleChoice") choiceBuf.push(buildOpeningTag$3(tag, localName));
|
|
24347
24371
|
});
|
|
24348
24372
|
parser.on("text", (text) => {
|
|
24349
24373
|
if (capture === "stimulus") stimulusBuf.push(text);
|
|
@@ -24367,6 +24391,8 @@ function readAssessmentItemOrder(inputXml) {
|
|
|
24367
24391
|
capture = null;
|
|
24368
24392
|
} else if (capture === "prompt" && localName !== "prompt") {
|
|
24369
24393
|
if (!QTI_VOID_ELEMENTS.has(localName.toLowerCase())) promptBuf.push(`</${localName}>`);
|
|
24394
|
+
} else if (capture === "choice" && localName !== "simpleChoice") {
|
|
24395
|
+
if (!QTI_VOID_ELEMENTS.has(localName.toLowerCase())) choiceBuf.push(`</${localName}>`);
|
|
24370
24396
|
} else if (localName === "simpleChoice" && capture === "choice") {
|
|
24371
24397
|
const text = normalizeWhitespace(choiceBuf.join(""));
|
|
24372
24398
|
if (currentChoiceId) {
|
|
@@ -24769,14 +24795,14 @@ function readAssessmentItemHotspot(inputXml) {
|
|
|
24769
24795
|
* Convert QTI shape coordinates to Learnosity polygon coordinates
|
|
24770
24796
|
* QTI uses absolute pixel coordinates, Learnosity uses percentage coordinates
|
|
24771
24797
|
*/
|
|
24772
|
-
function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
24798
|
+
function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics, sourceFile) {
|
|
24773
24799
|
const coords = choice.coords.split(",").map((c) => parseFloat(c.trim()));
|
|
24774
24800
|
if (choice.shape === "circle") {
|
|
24775
24801
|
if (coords.length !== 3) {
|
|
24776
24802
|
diagnostics.push({
|
|
24777
24803
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24778
24804
|
level: "error",
|
|
24779
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24805
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24780
24806
|
message: `Invalid circle coords for ${choice.identifier}: expected 3 values (x,y,radius), got ${coords.length}`
|
|
24781
24807
|
});
|
|
24782
24808
|
return null;
|
|
@@ -24799,7 +24825,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24799
24825
|
diagnostics.push({
|
|
24800
24826
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24801
24827
|
level: "error",
|
|
24802
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24828
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24803
24829
|
message: `Invalid rect coords for ${choice.identifier}: expected 4 values (x1,y1,x2,y2), got ${coords.length}`
|
|
24804
24830
|
});
|
|
24805
24831
|
return null;
|
|
@@ -24828,7 +24854,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24828
24854
|
diagnostics.push({
|
|
24829
24855
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24830
24856
|
level: "error",
|
|
24831
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24857
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24832
24858
|
message: `Invalid poly coords for ${choice.identifier}: expected at least 6 values (3 points) in pairs, got ${coords.length}`
|
|
24833
24859
|
});
|
|
24834
24860
|
return null;
|
|
@@ -24844,7 +24870,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24844
24870
|
diagnostics.push({
|
|
24845
24871
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24846
24872
|
level: "error",
|
|
24847
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24873
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24848
24874
|
message: `Invalid ellipse coords for ${choice.identifier}: expected 4 values (cx,cy,rx,ry), got ${coords.length}`
|
|
24849
24875
|
});
|
|
24850
24876
|
return null;
|
|
@@ -24866,7 +24892,7 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics) {
|
|
|
24866
24892
|
diagnostics.push({
|
|
24867
24893
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
24868
24894
|
level: "error",
|
|
24869
|
-
file: `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24895
|
+
file: sourceFile ?? `hotspotChoice[@identifier="${choice.identifier}"]`,
|
|
24870
24896
|
message: `Unsupported shape type: ${choice.shape}`
|
|
24871
24897
|
});
|
|
24872
24898
|
return null;
|
|
@@ -24939,7 +24965,7 @@ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
24939
24965
|
const areas = [];
|
|
24940
24966
|
const choiceIdToIndex = /* @__PURE__ */ new Map();
|
|
24941
24967
|
for (const choice of parsed.hotspotChoices) {
|
|
24942
|
-
const polygon = convertShapeToPolygon(choice, parsed.imageWidth, parsed.imageHeight, diagnostics);
|
|
24968
|
+
const polygon = convertShapeToPolygon(choice, parsed.imageWidth, parsed.imageHeight, diagnostics, sourceFile);
|
|
24943
24969
|
if (polygon) {
|
|
24944
24970
|
choiceIdToIndex.set(choice.identifier, areas.length);
|
|
24945
24971
|
areas.push(polygon);
|
|
@@ -32134,17 +32160,20 @@ function resolveImageDimensions(objectDataPath, sourceFile, packageRoot) {
|
|
|
32134
32160
|
if (!sourceFile || !objectDataPath) return;
|
|
32135
32161
|
const sourceDir = dirname(sourceFile);
|
|
32136
32162
|
let root = sourceDir;
|
|
32163
|
+
let shouldTryPackageRoot = false;
|
|
32137
32164
|
if (packageRoot) {
|
|
32138
32165
|
const resolvedRoot = resolve(packageRoot);
|
|
32139
32166
|
const resolvedSourceDir = resolve(sourceDir);
|
|
32140
32167
|
const rel = relative(resolvedRoot, resolvedSourceDir);
|
|
32141
|
-
|
|
32168
|
+
const sourceInsideRoot = rel === "" || !isAbsolute(rel) && rel.split(sep)[0] !== "..";
|
|
32169
|
+
root = sourceInsideRoot ? resolvedRoot : resolvedSourceDir;
|
|
32170
|
+
shouldTryPackageRoot = sourceInsideRoot && resolvedRoot !== resolvedSourceDir;
|
|
32142
32171
|
}
|
|
32143
32172
|
const candidates = [];
|
|
32144
32173
|
if (isAbsolute(objectDataPath)) candidates.push(objectDataPath);
|
|
32145
32174
|
else {
|
|
32146
32175
|
candidates.push(join(sourceDir, objectDataPath));
|
|
32147
|
-
if (
|
|
32176
|
+
if (shouldTryPackageRoot) candidates.push(join(root, objectDataPath));
|
|
32148
32177
|
}
|
|
32149
32178
|
for (const candidate of candidates) {
|
|
32150
32179
|
const imagePath = containedPath(candidate, root);
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { n as formatDiagnosticsSummaryTable, s as writeDiagnostics } from "./table-DYcNeyJ_.js";
|
|
2
|
-
import { buildPackageFromActivity, convertActivity, convertQtiPackageToLearnosityBundle, ensureUniqueFolderName, loadLearnosityBundle, loadPackageDirectory, mergeActivityPackage, nodeFileAccess, sanitizeFolderName, saveQtiContentPackage, writeLearnosityBundle } from "@learnosity/converter-core/node";
|
|
3
|
-
//#region src/utils/batchProcessors.ts
|
|
4
|
-
/**
|
|
5
|
-
* Per-package conversion tasks, shared by the serial batch path
|
|
6
|
-
* (`processBatch`) and the parallel worker path (`processBatchParallel` via
|
|
7
|
-
* `batchWorker`). Extracting them here keeps a single implementation per
|
|
8
|
-
* direction — the same code runs inline or inside a worker thread.
|
|
9
|
-
*/
|
|
10
|
-
/** Run one batch task in-process (used by the worker and directly in tests). */
|
|
11
|
-
async function runBatchTask(task, quiet = true) {
|
|
12
|
-
if (task.direction === "qti-to-learnosity") return processQtiPackageToLearnosity(task.pkg, task.packageOutputPath, task.options, quiet);
|
|
13
|
-
return processLearnosityToQtiPackage(task.pkg, task.packageOutputPath, task.options, quiet);
|
|
14
|
-
}
|
|
15
|
-
function displayDiagnosticsSummary(diagnostics, quiet) {
|
|
16
|
-
if (quiet) return;
|
|
17
|
-
const summaryTable = formatDiagnosticsSummaryTable(diagnostics);
|
|
18
|
-
if (summaryTable) {
|
|
19
|
-
console.log(" Diagnostics:");
|
|
20
|
-
console.log(summaryTable.split("\n").map((line) => " " + line).join("\n"));
|
|
21
|
-
console.log("");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/** Convert one QTI Content Package directory to a Learnosity bundle on disk. */
|
|
25
|
-
async function processQtiPackageToLearnosity(pkg, packageOutputPath, options, quiet) {
|
|
26
|
-
const loaded = loadPackageDirectory(pkg.path);
|
|
27
|
-
const convertResult = loaded.entries ? convertQtiPackageToLearnosityBundle({ entries: loaded.entries }, {
|
|
28
|
-
organisationId: options.organisationId,
|
|
29
|
-
mediaVault: options.mediaVault,
|
|
30
|
-
customAssetUrl: options.customAssetUrl,
|
|
31
|
-
itemReferenceSource: options.itemReferenceSource,
|
|
32
|
-
itemFilenameSource: options.itemFilenameSource,
|
|
33
|
-
truncateTags: options.truncateTags,
|
|
34
|
-
packageVersion: options.version,
|
|
35
|
-
sourceDir: pkg.path,
|
|
36
|
-
fileAccess: nodeFileAccess
|
|
37
|
-
}) : { diagnostics: loaded.diagnostics };
|
|
38
|
-
const errors = convertResult.diagnostics.filter((d) => d.level === "error");
|
|
39
|
-
const warnings = convertResult.diagnostics.filter((d) => d.level === "warning");
|
|
40
|
-
const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;
|
|
41
|
-
const convertedFiles = convertResult.convertedSourceFiles || [];
|
|
42
|
-
const failedFiles = convertResult.failedSourceFiles || [];
|
|
43
|
-
const filesWithErrors = /* @__PURE__ */ new Set();
|
|
44
|
-
for (const d of convertResult.diagnostics) if (d.level === "error" && d.file) filesWithErrors.add(d.file);
|
|
45
|
-
const convertedWithErrors = convertedFiles.filter((f) => filesWithErrors.has(f)).length;
|
|
46
|
-
const erroredItemCount = failedFiles.length + convertedWithErrors;
|
|
47
|
-
const cleanItemCount = convertedFiles.length - convertedWithErrors;
|
|
48
|
-
if (errors.length > 0 && !hasValidBundle) return {
|
|
49
|
-
success: false,
|
|
50
|
-
errorCount: errors.length,
|
|
51
|
-
warningCount: warnings.length,
|
|
52
|
-
convertedItemCount: cleanItemCount,
|
|
53
|
-
failedItemCount: erroredItemCount,
|
|
54
|
-
message: "Conversion failed"
|
|
55
|
-
};
|
|
56
|
-
const writeResult = await writeLearnosityBundle(convertResult.bundle, {
|
|
57
|
-
outDir: packageOutputPath,
|
|
58
|
-
isZipOutput: false
|
|
59
|
-
});
|
|
60
|
-
const writeErrors = writeResult.diagnostics.filter((d) => d.level === "error");
|
|
61
|
-
if (writeErrors.length > 0) return {
|
|
62
|
-
success: false,
|
|
63
|
-
errorCount: errors.length + writeErrors.length,
|
|
64
|
-
warningCount: warnings.length,
|
|
65
|
-
convertedItemCount: cleanItemCount,
|
|
66
|
-
failedItemCount: erroredItemCount,
|
|
67
|
-
message: "Write failed"
|
|
68
|
-
};
|
|
69
|
-
const diagnosticsPath = `${packageOutputPath}/diagnostics.json`;
|
|
70
|
-
const allDiagnostics = [...convertResult.diagnostics, ...writeResult.diagnostics];
|
|
71
|
-
const convertedActivityFiles = convertResult.convertedActivityFiles || [];
|
|
72
|
-
await writeDiagnostics(allDiagnostics, "file", diagnosticsPath, packageOutputPath, false, {
|
|
73
|
-
inputPath: pkg.path,
|
|
74
|
-
outputPath: packageOutputPath,
|
|
75
|
-
totalItemsFound: convertedFiles.length + failedFiles.length,
|
|
76
|
-
totalActivitiesFound: convertedActivityFiles.length,
|
|
77
|
-
convertedFiles,
|
|
78
|
-
failedFiles,
|
|
79
|
-
convertedActivities: convertedActivityFiles
|
|
80
|
-
});
|
|
81
|
-
if (!quiet) {
|
|
82
|
-
const summaryTable = formatDiagnosticsSummaryTable(allDiagnostics);
|
|
83
|
-
if (summaryTable) {
|
|
84
|
-
console.log(" Diagnostics:");
|
|
85
|
-
console.log(summaryTable.split("\n").map((line) => " " + line).join("\n"));
|
|
86
|
-
console.log("");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
success: true,
|
|
91
|
-
errorCount: errors.length,
|
|
92
|
-
warningCount: warnings.length,
|
|
93
|
-
convertedItemCount: cleanItemCount,
|
|
94
|
-
failedItemCount: erroredItemCount
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
/** Convert one Learnosity bundle directory to a QTI Content Package on disk. */
|
|
98
|
-
async function processLearnosityToQtiPackage(pkg, packageOutputPath, options, quiet) {
|
|
99
|
-
const loadResult = loadLearnosityBundle(pkg.path);
|
|
100
|
-
if (!loadResult.bundle) {
|
|
101
|
-
const errorCount = loadResult.diagnostics.filter((d) => d.level === "error").length;
|
|
102
|
-
displayDiagnosticsSummary(loadResult.diagnostics, quiet);
|
|
103
|
-
return {
|
|
104
|
-
success: false,
|
|
105
|
-
errorCount,
|
|
106
|
-
warningCount: 0,
|
|
107
|
-
message: "Bundle load error"
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
const bundle = loadResult.bundle;
|
|
111
|
-
const allDiagnostics = [...loadResult.diagnostics];
|
|
112
|
-
const allConvertedActivities = [];
|
|
113
|
-
const usedFolderNames = /* @__PURE__ */ new Set();
|
|
114
|
-
const convertedItemRefs = /* @__PURE__ */ new Set();
|
|
115
|
-
const failedItemRefs = /* @__PURE__ */ new Set();
|
|
116
|
-
for (const activityRef of bundle.activityRefs) {
|
|
117
|
-
const convertResult = convertActivity(bundle, activityRef, {
|
|
118
|
-
pretty: options.pretty,
|
|
119
|
-
version: options.qtiVersion,
|
|
120
|
-
customAssetUrl: options.customAssetUrl
|
|
121
|
-
});
|
|
122
|
-
allDiagnostics.push(...convertResult.diagnostics);
|
|
123
|
-
const itemRefs = bundle.activityItemRefs.get(activityRef) ?? [];
|
|
124
|
-
const successfulItemRefs = new Set(convertResult.items.map((item) => item.reference));
|
|
125
|
-
for (const itemRef of itemRefs) if (successfulItemRefs.has(itemRef)) convertedItemRefs.add(itemRef);
|
|
126
|
-
else failedItemRefs.add(itemRef);
|
|
127
|
-
if (convertResult.items.length > 0) {
|
|
128
|
-
const sanitizedName = sanitizeFolderName(activityRef, `activity_${allConvertedActivities.length + 1}`);
|
|
129
|
-
const folderName = ensureUniqueFolderName(sanitizedName, usedFolderNames);
|
|
130
|
-
allConvertedActivities.push({
|
|
131
|
-
activityRef,
|
|
132
|
-
folderName,
|
|
133
|
-
conversion: convertResult
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
for (const itemRef of convertedItemRefs) failedItemRefs.delete(itemRef);
|
|
138
|
-
const convertedFiles = itemRefsToFilenames(bundle, convertedItemRefs);
|
|
139
|
-
const failedFiles = itemRefsToFilenames(bundle, failedItemRefs);
|
|
140
|
-
const convertedActivityFiles = allConvertedActivities.map(({ activityRef }) => `activities/${activityRef}.json`);
|
|
141
|
-
const failedActivityFiles = bundle.activityRefs.filter((ref) => !allConvertedActivities.some((a) => a.activityRef === ref)).map((ref) => `activities/${ref}.json`);
|
|
142
|
-
const totalItemsConverted = convertedItemRefs.size;
|
|
143
|
-
const totalItemsFailed = failedItemRefs.size;
|
|
144
|
-
const writePackageDiagnostics = () => writeDiagnostics(allDiagnostics, "file", `${packageOutputPath}/diagnostics.json`, packageOutputPath, false, {
|
|
145
|
-
inputPath: pkg.path,
|
|
146
|
-
outputPath: packageOutputPath,
|
|
147
|
-
totalItemsFound: totalItemsConverted + totalItemsFailed,
|
|
148
|
-
totalActivitiesFound: bundle.activityRefs.length,
|
|
149
|
-
convertedFiles,
|
|
150
|
-
failedFiles,
|
|
151
|
-
convertedActivities: convertedActivityFiles,
|
|
152
|
-
failedActivities: failedActivityFiles
|
|
153
|
-
});
|
|
154
|
-
if (allConvertedActivities.length === 0) {
|
|
155
|
-
const errorCount = allDiagnostics.filter((d) => d.level === "error").length;
|
|
156
|
-
await writePackageDiagnostics();
|
|
157
|
-
return {
|
|
158
|
-
success: false,
|
|
159
|
-
errorCount,
|
|
160
|
-
warningCount: allDiagnostics.filter((d) => d.level === "warning").length,
|
|
161
|
-
convertedItemCount: 0,
|
|
162
|
-
failedItemCount: totalItemsFailed,
|
|
163
|
-
message: "No activities converted"
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
const pkgData = {
|
|
167
|
-
zipPath: "",
|
|
168
|
-
version: options.qtiVersion,
|
|
169
|
-
resources: [],
|
|
170
|
-
entries: /* @__PURE__ */ new Map(),
|
|
171
|
-
items: [],
|
|
172
|
-
assets: []
|
|
173
|
-
};
|
|
174
|
-
const addedResourceIds = /* @__PURE__ */ new Set();
|
|
175
|
-
for (const { activityRef, folderName, conversion } of allConvertedActivities) {
|
|
176
|
-
const packageResult = buildPackageFromActivity(conversion, {
|
|
177
|
-
bundleDir: pkg.path,
|
|
178
|
-
activityRef,
|
|
179
|
-
version: options.qtiVersion
|
|
180
|
-
});
|
|
181
|
-
allDiagnostics.push(...packageResult.diagnostics);
|
|
182
|
-
mergeActivityPackage(pkgData, folderName, packageResult, addedResourceIds);
|
|
183
|
-
}
|
|
184
|
-
const saveResult = saveQtiContentPackage(pkgData, packageOutputPath);
|
|
185
|
-
allDiagnostics.push(...saveResult.diagnostics);
|
|
186
|
-
const errors = allDiagnostics.filter((d) => d.level === "error");
|
|
187
|
-
const warnings = allDiagnostics.filter((d) => d.level === "warning");
|
|
188
|
-
await writePackageDiagnostics();
|
|
189
|
-
displayDiagnosticsSummary(allDiagnostics, quiet);
|
|
190
|
-
if (errors.length > 0) return {
|
|
191
|
-
success: false,
|
|
192
|
-
errorCount: errors.length,
|
|
193
|
-
warningCount: warnings.length,
|
|
194
|
-
convertedItemCount: totalItemsConverted,
|
|
195
|
-
failedItemCount: totalItemsFailed,
|
|
196
|
-
message: "Conversion failed"
|
|
197
|
-
};
|
|
198
|
-
return {
|
|
199
|
-
success: true,
|
|
200
|
-
errorCount: 0,
|
|
201
|
-
warningCount: warnings.length,
|
|
202
|
-
convertedItemCount: totalItemsConverted,
|
|
203
|
-
failedItemCount: totalItemsFailed
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Map item references to the filenames they were loaded from, for the
|
|
208
|
-
* diagnostics report. Falls back to the reference when the bundle has no
|
|
209
|
-
* filename recorded, so counts always match the listed items.
|
|
210
|
-
*/
|
|
211
|
-
function itemRefsToFilenames(bundle, itemRefs) {
|
|
212
|
-
return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);
|
|
213
|
-
}
|
|
214
|
-
//#endregion
|
|
215
|
-
export { processQtiPackageToLearnosity as n, runBatchTask as r, processLearnosityToQtiPackage as t };
|
|
216
|
-
|
|
217
|
-
//# sourceMappingURL=batchProcessors-C8k2v0o_.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batchProcessors-C8k2v0o_.js","names":[],"sources":["../src/utils/batchProcessors.ts"],"sourcesContent":["/**\n * Per-package conversion tasks, shared by the serial batch path\n * (`processBatch`) and the parallel worker path (`processBatchParallel` via\n * `batchWorker`). Extracting them here keeps a single implementation per\n * direction — the same code runs inline or inside a worker thread.\n */\n\nimport {\n loadPackageDirectory,\n convertQtiPackageToLearnosityBundle,\n writeLearnosityBundle,\n loadLearnosityBundle,\n convertActivity,\n buildPackageFromActivity,\n mergeActivityPackage,\n sanitizeFolderName,\n ensureUniqueFolderName,\n saveQtiContentPackage,\n nodeFileAccess,\n type Diagnostic,\n type ItemFilenameSource,\n type ItemReferenceSource,\n type LearnosityBundleModel,\n type QtiContentPackage,\n} from '@learnosity/converter-core/node';\nimport type { DetectedPackage } from './packageScanner.js';\nimport { writeDiagnostics } from '../io/writeDiagnostics.js';\nimport { formatDiagnosticsSummaryTable } from '../ux/table.js';\n\n/** Options accepted by the per-package processors (subset of resolved CLI options). */\nexport interface BatchPackageOptions {\n organisationId?: number;\n mediaVault?: boolean;\n customAssetUrl?: string;\n itemReferenceSource?: ItemReferenceSource;\n itemFilenameSource?: ItemFilenameSource;\n truncateTags?: boolean;\n version?: string;\n pretty?: boolean;\n qtiVersion?: '2.1' | '2.2';\n}\n\n/** Result of processing one package (matches PackageProcessor's return shape). */\nexport interface PackageResult {\n success: boolean;\n errorCount: number;\n warningCount: number;\n convertedItemCount?: number;\n failedItemCount?: number;\n message?: string;\n}\n\n/** A single package conversion task dispatched to a worker. */\nexport interface BatchTask {\n direction: 'qti-to-learnosity' | 'learnosity-to-qti';\n pkg: DetectedPackage;\n packageOutputPath: string;\n options: BatchPackageOptions;\n}\n\n/** Run one batch task in-process (used by the worker and directly in tests). */\nexport async function runBatchTask(task: BatchTask, quiet = true): Promise<PackageResult> {\n if (task.direction === 'qti-to-learnosity') {\n return processQtiPackageToLearnosity(task.pkg, task.packageOutputPath, task.options, quiet);\n }\n\n return processLearnosityToQtiPackage(task.pkg, task.packageOutputPath, task.options, quiet);\n}\n\nfunction displayDiagnosticsSummary(diagnostics: Diagnostic[], quiet: boolean): void {\n if (quiet) {\n return;\n }\n\n const summaryTable = formatDiagnosticsSummaryTable(diagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n}\n\n/** Convert one QTI Content Package directory to a Learnosity bundle on disk. */\nexport async function processQtiPackageToLearnosity(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Convert the package\n const loaded = loadPackageDirectory(pkg.path);\n const convertResult = loaded.entries\n ? convertQtiPackageToLearnosityBundle(\n { entries: loaded.entries },\n {\n organisationId: options.organisationId,\n mediaVault: options.mediaVault,\n customAssetUrl: options.customAssetUrl,\n itemReferenceSource: options.itemReferenceSource,\n itemFilenameSource: options.itemFilenameSource,\n truncateTags: options.truncateTags,\n packageVersion: options.version,\n sourceDir: pkg.path,\n fileAccess: nodeFileAccess,\n }\n )\n : { diagnostics: loaded.diagnostics };\n\n const errors = convertResult.diagnostics.filter((d) => d.level === 'error');\n const warnings = convertResult.diagnostics.filter((d) => d.level === 'warning');\n const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;\n\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n\n // Count items that have error-level diagnostics (includes both\n // completely failed items and items that converted with errors)\n const filesWithErrors = new Set<string>();\n\n for (const d of convertResult.diagnostics) {\n if (d.level === 'error' && d.file) {\n filesWithErrors.add(d.file);\n }\n }\n\n const convertedWithErrors = convertedFiles.filter((f) => filesWithErrors.has(f)).length;\n const erroredItemCount = failedFiles.length + convertedWithErrors;\n const cleanItemCount = convertedFiles.length - convertedWithErrors;\n\n if (errors.length > 0 && !hasValidBundle) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Conversion failed',\n };\n }\n\n // Write the bundle\n const writeResult = await writeLearnosityBundle(convertResult.bundle!, {\n outDir: packageOutputPath,\n isZipOutput: false,\n });\n\n const writeErrors = writeResult.diagnostics.filter((d) => d.level === 'error');\n\n if (writeErrors.length > 0) {\n return {\n success: false,\n errorCount: errors.length + writeErrors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Write failed',\n };\n }\n\n // In batch mode, always write diagnostics.json to each package directory\n const diagnosticsPath = `${packageOutputPath}/diagnostics.json`;\n const allDiagnostics = [...convertResult.diagnostics, ...writeResult.diagnostics];\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n\n await writeDiagnostics(allDiagnostics, 'file', diagnosticsPath, packageOutputPath, false, {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: convertedFiles.length + failedFiles.length,\n totalActivitiesFound: convertedActivityFiles.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n });\n\n // Show condensed diagnostics summary\n if (!quiet) {\n const summaryTable = formatDiagnosticsSummaryTable(allDiagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n }\n\n return {\n success: true,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n };\n}\n\n/** Convert one Learnosity bundle directory to a QTI Content Package on disk. */\nexport async function processLearnosityToQtiPackage(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Load the bundle\n const loadResult = loadLearnosityBundle(pkg.path);\n\n if (!loadResult.bundle) {\n const errorCount = loadResult.diagnostics.filter((d) => d.level === 'error').length;\n\n displayDiagnosticsSummary(loadResult.diagnostics, quiet);\n\n return {\n success: false,\n errorCount,\n warningCount: 0,\n message: 'Bundle load error',\n };\n }\n\n const bundle = loadResult.bundle;\n const allDiagnostics: Diagnostic[] = [...loadResult.diagnostics];\n\n // Convert all activities in the bundle\n const allConvertedActivities: {\n activityRef: string;\n folderName: string;\n conversion: ReturnType<typeof convertActivity>;\n }[] = [];\n\n // Folder names for tests/<folderName>/assessmentTest.xml must be unique per package\n const usedFolderNames = new Set<string>();\n\n // Track item outcomes for the diagnostics report. Items shared by several\n // activities are counted once, hence the sets.\n const convertedItemRefs = new Set<string>();\n const failedItemRefs = new Set<string>();\n\n for (const activityRef of bundle.activityRefs) {\n const convertResult = convertActivity(bundle, activityRef, {\n pretty: options.pretty,\n version: options.qtiVersion,\n customAssetUrl: options.customAssetUrl,\n });\n\n allDiagnostics.push(...convertResult.diagnostics);\n\n const itemRefs = bundle.activityItemRefs.get(activityRef) ?? [];\n const successfulItemRefs = new Set(convertResult.items.map((item) => item.reference));\n\n for (const itemRef of itemRefs) {\n if (successfulItemRefs.has(itemRef)) {\n convertedItemRefs.add(itemRef);\n } else {\n failedItemRefs.add(itemRef);\n }\n }\n\n if (convertResult.items.length > 0) {\n const sanitizedName = sanitizeFolderName(\n activityRef,\n `activity_${allConvertedActivities.length + 1}`\n );\n const folderName = ensureUniqueFolderName(sanitizedName, usedFolderNames);\n\n allConvertedActivities.push({ activityRef, folderName, conversion: convertResult });\n }\n }\n\n // An item that converted in one activity is not a failure elsewhere.\n for (const itemRef of convertedItemRefs) {\n failedItemRefs.delete(itemRef);\n }\n\n const convertedFiles = itemRefsToFilenames(bundle, convertedItemRefs);\n const failedFiles = itemRefsToFilenames(bundle, failedItemRefs);\n const convertedActivityFiles = allConvertedActivities.map(\n ({ activityRef }) => `activities/${activityRef}.json`\n );\n const failedActivityFiles = bundle.activityRefs\n .filter((ref) => !allConvertedActivities.some((a) => a.activityRef === ref))\n .map((ref) => `activities/${ref}.json`);\n const totalItemsConverted = convertedItemRefs.size;\n const totalItemsFailed = failedItemRefs.size;\n\n // In batch mode, always write diagnostics.json to each package directory,\n // including when the package fails, so the report explains what happened.\n // Reads allDiagnostics when called, so later diagnostics are included.\n const writePackageDiagnostics = () =>\n writeDiagnostics(\n allDiagnostics,\n 'file',\n `${packageOutputPath}/diagnostics.json`,\n packageOutputPath,\n false,\n {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: totalItemsConverted + totalItemsFailed,\n totalActivitiesFound: bundle.activityRefs.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n failedActivities: failedActivityFiles,\n }\n );\n\n if (allConvertedActivities.length === 0) {\n const errorCount = allDiagnostics.filter((d) => d.level === 'error').length;\n\n await writePackageDiagnostics();\n\n return {\n success: false,\n errorCount,\n warningCount: allDiagnostics.filter((d) => d.level === 'warning').length,\n convertedItemCount: 0,\n failedItemCount: totalItemsFailed,\n message: 'No activities converted',\n };\n }\n\n // Build package with all activities\n const pkgData: QtiContentPackage = {\n zipPath: '',\n version: options.qtiVersion,\n resources: [],\n entries: new Map(),\n items: [],\n assets: [],\n };\n\n const addedResourceIds = new Set<string>();\n\n for (const { activityRef, folderName, conversion } of allConvertedActivities) {\n const packageResult = buildPackageFromActivity(conversion, {\n bundleDir: pkg.path,\n activityRef,\n version: options.qtiVersion,\n });\n\n allDiagnostics.push(...packageResult.diagnostics);\n\n // Relocates the assessmentTest to tests/<folderName>/assessmentTest.xml and\n // wires manifest dependencies, matching the single-package output layout.\n mergeActivityPackage(pkgData, folderName, packageResult, addedResourceIds);\n }\n\n // Save the package\n const saveResult = saveQtiContentPackage(pkgData, packageOutputPath);\n\n allDiagnostics.push(...saveResult.diagnostics);\n\n const errors = allDiagnostics.filter((d) => d.level === 'error');\n const warnings = allDiagnostics.filter((d) => d.level === 'warning');\n\n await writePackageDiagnostics();\n\n displayDiagnosticsSummary(allDiagnostics, quiet);\n\n if (errors.length > 0) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n message: 'Conversion failed',\n };\n }\n\n return {\n success: true,\n errorCount: 0,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n };\n}\n\n/**\n * Map item references to the filenames they were loaded from, for the\n * diagnostics report. Falls back to the reference when the bundle has no\n * filename recorded, so counts always match the listed items.\n */\nfunction itemRefsToFilenames(bundle: LearnosityBundleModel, itemRefs: Set<string>): string[] {\n return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);\n}\n"],"mappings":";;;;;;;;;;AA6DA,eAAsB,aAAa,MAAiB,QAAQ,MAA8B;CACtF,IAAI,KAAK,cAAc,qBACnB,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;CAG9F,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;AAC9F;AAEA,SAAS,0BAA0B,aAA2B,OAAsB;CAChF,IAAI,OACA;CAGJ,MAAM,eAAe,8BAA8B,WAAW;CAE9D,IAAI,cAAc;EACd,QAAQ,IAAI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