@learnosity/lib-qti-converter 0.14.0 → 0.15.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.
- package/docs/EXAMPLES.md +13 -11
- package/docs/GETTING_STARTED.md +11 -0
- package/docs/QTI_METADATA_TO_TAGS.md +47 -4
- package/docs/TAGS_TO_QTI_METADATA.md +8 -7
- package/package.json +1 -1
- package/packages/cli/dist/{batchProcessors-DWG8qk7G.js → batchProcessors-B6Xmhfaz.js} +6 -2
- package/packages/cli/dist/{batchProcessors-DWG8qk7G.js.map → batchProcessors-B6Xmhfaz.js.map} +1 -1
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{learnosityToQti-C7cTRTU2.js → learnosityToQti-hFKA3KnZ.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-C7cTRTU2.js.map → learnosityToQti-hFKA3KnZ.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-C84dQKKi.js → learnosityToQtiPackage-DI7bYisT.js} +4 -4
- package/packages/cli/dist/{learnosityToQtiPackage-C84dQKKi.js.map → learnosityToQtiPackage-DI7bYisT.js.map} +1 -1
- package/packages/cli/dist/main.js +4 -4
- package/packages/cli/dist/{pathUtils-Cr9IcK0n.js → pathUtils-DkptaCiz.js} +13 -3
- package/packages/cli/dist/{pathUtils-Cr9IcK0n.js.map → pathUtils-DkptaCiz.js.map} +1 -1
- package/packages/cli/dist/{qtiPackageToLearnosity-BBfZgWBh.js → qtiPackageToLearnosity-JDifZn8o.js} +12 -6
- package/packages/cli/dist/qtiPackageToLearnosity-JDifZn8o.js.map +1 -0
- package/packages/cli/dist/{qtiToLearnosity-C9OW_n7Z.js → qtiToLearnosity-Be0s-5Dr.js} +6 -5
- package/packages/cli/dist/qtiToLearnosity-Be0s-5Dr.js.map +1 -0
- package/packages/cli/dist/{resolveOptions-D_UECo_9.js → resolveOptions-BotCofhl.js} +13 -4
- package/packages/cli/dist/resolveOptions-BotCofhl.js.map +1 -0
- package/packages/cli/dist/{table-D1ydwhbX.js → table-DlY4LGmL.js} +91 -40
- package/packages/cli/dist/table-DlY4LGmL.js.map +1 -0
- package/packages/core/dist/index.d.ts +3 -0
- package/packages/core/dist/index.js +94 -39
- package/packages/core/dist/node.d.ts +5 -0
- package/packages/core/dist/node.js +95 -39
- package/packages/cli/dist/qtiPackageToLearnosity-BBfZgWBh.js.map +0 -1
- package/packages/cli/dist/qtiToLearnosity-C9OW_n7Z.js.map +0 -1
- package/packages/cli/dist/resolveOptions-D_UECo_9.js.map +0 -1
- package/packages/cli/dist/table-D1ydwhbX.js.map +0 -1
|
@@ -22999,6 +22999,34 @@ function md5hex(input) {
|
|
|
22999
22999
|
return hex;
|
|
23000
23000
|
}
|
|
23001
23001
|
//#endregion
|
|
23002
|
+
//#region src/qti-to-learnosity/utils/generateQuestionReference.ts
|
|
23003
|
+
/**
|
|
23004
|
+
* Shared utility for generating Learnosity question references.
|
|
23005
|
+
*/
|
|
23006
|
+
/**
|
|
23007
|
+
* Generate a Learnosity question reference from the resolved item reference and
|
|
23008
|
+
* the question's position within that item.
|
|
23009
|
+
*
|
|
23010
|
+
* The reference is `md5hex(`${itemRef}_${index}`)`, which guarantees it is both
|
|
23011
|
+
* unique (scoped to the item plus the per-item ordinal) and repeatable.
|
|
23012
|
+
*
|
|
23013
|
+
* - `itemRef` is the ALREADY-RESOLVED Learnosity item reference. Because it is
|
|
23014
|
+
* resolved upstream, the question reference automatically inherits the user's
|
|
23015
|
+
* `--item-reference-source` choice (item `identifier`, a `uuid`, or the source
|
|
23016
|
+
* filename) without this helper needing to re-read that option.
|
|
23017
|
+
* - `index` is the question's 1-BASED ordinal WITHIN the item. It is reset per
|
|
23018
|
+
* item, not a global counter: the first question in an item is `1`, the second
|
|
23019
|
+
* `2`, and so on. Single-question items always use `1` (a lone question is
|
|
23020
|
+
* `_1`), so there is no bare, unsuffixed variant.
|
|
23021
|
+
*
|
|
23022
|
+
* @param itemRef Resolved Learnosity item reference.
|
|
23023
|
+
* @param index 1-based ordinal of the question within the item.
|
|
23024
|
+
* @returns A 32-character lowercase hex MD5 question reference.
|
|
23025
|
+
*/
|
|
23026
|
+
function generateQuestionReference(itemRef, index) {
|
|
23027
|
+
return md5hex(`${itemRef}_${index}`);
|
|
23028
|
+
}
|
|
23029
|
+
//#endregion
|
|
23002
23030
|
//#region src/qti-to-learnosity/utils/mediaFeature.ts
|
|
23003
23031
|
/**
|
|
23004
23032
|
* Build a stable UUID-shaped identifier for a media feature.
|
|
@@ -23522,7 +23550,7 @@ function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
23522
23550
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23523
23551
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23524
23552
|
};
|
|
23525
|
-
const questionRef =
|
|
23553
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
23526
23554
|
const stems = parsed.stems.map((stem) => transformAssetUrls(stem.text, {
|
|
23527
23555
|
organisationId,
|
|
23528
23556
|
mediaVault,
|
|
@@ -23944,7 +23972,7 @@ function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisatio
|
|
|
23944
23972
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23945
23973
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23946
23974
|
};
|
|
23947
|
-
const questionRef =
|
|
23975
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
23948
23976
|
const possibleResponses = parsed.gapTexts.map((gt) => transformAssetUrls(gt.text, {
|
|
23949
23977
|
organisationId,
|
|
23950
23978
|
mediaVault,
|
|
@@ -24412,7 +24440,7 @@ function convertInlineChoiceToLearnosity(inputXml, diagnostics, lomTags, organis
|
|
|
24412
24440
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24413
24441
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24414
24442
|
};
|
|
24415
|
-
const questionRef =
|
|
24443
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
24416
24444
|
const possibleResponses = parsed.interactions.map((interaction) => interaction.choices.map((choice) => transformAssetUrls(choice.text, transformOpts)));
|
|
24417
24445
|
const validationValue = buildValidationValues(parsed.interactions, parsed.responseDeclarations, diagnostics, transformOpts, sourceFile);
|
|
24418
24446
|
if (!validationValue) return { diagnostics };
|
|
@@ -24691,7 +24719,7 @@ function convertOrderToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
24691
24719
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24692
24720
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24693
24721
|
};
|
|
24694
|
-
const questionRef =
|
|
24722
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
24695
24723
|
const stimulus = transformAssetUrls(parsed.stimulusText ?? "", {
|
|
24696
24724
|
organisationId,
|
|
24697
24725
|
mediaVault,
|
|
@@ -25142,7 +25170,7 @@ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25142
25170
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25143
25171
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25144
25172
|
};
|
|
25145
|
-
const questionRef =
|
|
25173
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
25146
25174
|
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
25147
25175
|
const imageSource = organisationId ? transformUrl(parsed.imageSource, organisationId, mediaVault, customAssetUrl, transformContext) : parsed.imageSource;
|
|
25148
25176
|
const areas = [];
|
|
@@ -25440,7 +25468,7 @@ function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25440
25468
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25441
25469
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25442
25470
|
};
|
|
25443
|
-
const questionRef =
|
|
25471
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
25444
25472
|
if (parsed.shuffle) diagnostics.push({
|
|
25445
25473
|
code: DiagnosticCode.QTI_SHUFFLE_NOT_SUPPORTED,
|
|
25446
25474
|
level: "warning",
|
|
@@ -25952,8 +25980,9 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25952
25980
|
const questions = [];
|
|
25953
25981
|
const widgets = [];
|
|
25954
25982
|
const questionSpans = [];
|
|
25955
|
-
for (
|
|
25956
|
-
const
|
|
25983
|
+
for (let i = 0; i < parsed.interactions.length; i++) {
|
|
25984
|
+
const interaction = parsed.interactions[i];
|
|
25985
|
+
const questionRef = generateQuestionReference(itemRef, i + 1);
|
|
25957
25986
|
const stimulus = interaction.stimulusText ? transformAssetUrls(interaction.stimulusText, {
|
|
25958
25987
|
organisationId,
|
|
25959
25988
|
mediaVault,
|
|
@@ -26397,7 +26426,7 @@ function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26397
26426
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26398
26427
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26399
26428
|
};
|
|
26400
|
-
const questionRef =
|
|
26429
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26401
26430
|
const stimulus = normalizeFinalText(transformAssetUrls((parsed.templateText || "").replace(/{{response}}(?:\s*<\/[^>]+>)*\s*$/, "").trim(), {
|
|
26402
26431
|
organisationId,
|
|
26403
26432
|
mediaVault,
|
|
@@ -26491,7 +26520,7 @@ function convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26491
26520
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26492
26521
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26493
26522
|
};
|
|
26494
|
-
const questionRef =
|
|
26523
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26495
26524
|
const stimulus = parsed.stimulusText ? normalizeFinalText(transformAssetUrls(parsed.stimulusText, {
|
|
26496
26525
|
organisationId,
|
|
26497
26526
|
mediaVault,
|
|
@@ -26741,7 +26770,7 @@ function readAssessmentItemExtendedText(inputXml) {
|
|
|
26741
26770
|
/**
|
|
26742
26771
|
* Build multi-interaction extended text item (multiple longtextV2 questions)
|
|
26743
26772
|
*/
|
|
26744
|
-
function buildMultiExtendedTextItem(parsed,
|
|
26773
|
+
function buildMultiExtendedTextItem(parsed, _inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26745
26774
|
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26746
26775
|
const transformContext = {
|
|
26747
26776
|
finalItemReference: itemRef,
|
|
@@ -26751,9 +26780,8 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26751
26780
|
const questions = [];
|
|
26752
26781
|
const widgets = [];
|
|
26753
26782
|
const questionSpans = [];
|
|
26754
|
-
const responseIdentifiers = extractResponseIdentifiers(inputXml, "extendedTextInteraction");
|
|
26755
26783
|
for (let i = 0; i < stimulusOverride.length; i++) {
|
|
26756
|
-
const questionRef =
|
|
26784
|
+
const questionRef = generateQuestionReference(itemRef, i + 1);
|
|
26757
26785
|
const stimulus = transformAssetUrls(stimulusOverride[i], {
|
|
26758
26786
|
organisationId,
|
|
26759
26787
|
mediaVault,
|
|
@@ -26795,16 +26823,6 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26795
26823
|
};
|
|
26796
26824
|
}
|
|
26797
26825
|
/**
|
|
26798
|
-
* Extract responseIdentifier values from interactions in XML
|
|
26799
|
-
*/
|
|
26800
|
-
function extractResponseIdentifiers(inputXml, interactionTag) {
|
|
26801
|
-
const responseIdentifiers = [];
|
|
26802
|
-
const interactionPattern = new RegExp(`<${assertXmlTagName(interactionTag)}[^>]+responseIdentifier=["']([^"']+)["']`, "g");
|
|
26803
|
-
let match;
|
|
26804
|
-
while ((match = interactionPattern.exec(inputXml)) !== null) responseIdentifiers.push(match[1]);
|
|
26805
|
-
return responseIdentifiers;
|
|
26806
|
-
}
|
|
26807
|
-
/**
|
|
26808
26826
|
* Convert extended text (extendedTextInteraction) to Learnosity longtextV2
|
|
26809
26827
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
26810
26828
|
*/
|
|
@@ -26820,7 +26838,7 @@ function convertExtendedTextToLearnosity(inputXml, diagnostics, lomTags, sourceF
|
|
|
26820
26838
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26821
26839
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26822
26840
|
};
|
|
26823
|
-
const questionRef =
|
|
26841
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26824
26842
|
const stimulusRaw = stimulusOverride && stimulusOverride.length === 1 ? stimulusOverride[0] : parsed.stimulusText;
|
|
26825
26843
|
const stimulus = stimulusRaw ? transformAssetUrls(stimulusRaw, {
|
|
26826
26844
|
organisationId,
|
|
@@ -27196,7 +27214,7 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
27196
27214
|
};
|
|
27197
27215
|
});
|
|
27198
27216
|
const validationValue = buildValidationValue$1(parsed.hotspots, parsed.correctPairs, gapImgIdToResponse);
|
|
27199
|
-
const questionRef =
|
|
27217
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27200
27218
|
const question = {
|
|
27201
27219
|
type: "imageclozeassociationV2",
|
|
27202
27220
|
image: {
|
|
@@ -27570,7 +27588,7 @@ function convertDrawingToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
27570
27588
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27571
27589
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27572
27590
|
};
|
|
27573
|
-
const questionRef =
|
|
27591
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27574
27592
|
const questionData = { type: "drawing" };
|
|
27575
27593
|
const stimulus = buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
27576
27594
|
if (stimulus !== void 0) questionData.stimulus = stimulus;
|
|
@@ -27883,7 +27901,7 @@ function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisa
|
|
|
27883
27901
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27884
27902
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27885
27903
|
};
|
|
27886
|
-
const questionRef =
|
|
27904
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27887
27905
|
const stimulus = transformAssetUrls(parsed.stimulusText ? `<p>${parsed.stimulusText}</p>` : "", {
|
|
27888
27906
|
organisationId,
|
|
27889
27907
|
mediaVault,
|
|
@@ -28350,6 +28368,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28350
28368
|
}
|
|
28351
28369
|
const allQuestions = [];
|
|
28352
28370
|
const allWidgets = [];
|
|
28371
|
+
let placeholderRefCounter = 0;
|
|
28353
28372
|
const processResult = (result, subDiagnostics) => {
|
|
28354
28373
|
if (result.item) {
|
|
28355
28374
|
allQuestions.push(...result.item.questions);
|
|
@@ -28406,7 +28425,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28406
28425
|
if (groupEntries.length > 0) {
|
|
28407
28426
|
const correctResponses = [];
|
|
28408
28427
|
for (const entry of groupEntries) if (entry.correctResponse) correctResponses.push(entry.correctResponse);
|
|
28409
|
-
const questionRef =
|
|
28428
|
+
const questionRef = `__mixed_placeholder_${placeholderRefCounter++}`;
|
|
28410
28429
|
const templateParts = [];
|
|
28411
28430
|
const groupWrapperOpen = group.wrapperOpens[0];
|
|
28412
28431
|
if (groupWrapperOpen) templateParts.push(groupWrapperOpen);
|
|
@@ -28570,6 +28589,17 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28570
28589
|
});
|
|
28571
28590
|
return { diagnostics };
|
|
28572
28591
|
}
|
|
28592
|
+
const reassignedWidgets = /* @__PURE__ */ new Set();
|
|
28593
|
+
allQuestions.forEach((question, idx) => {
|
|
28594
|
+
const oldRef = question.reference;
|
|
28595
|
+
const newRef = generateQuestionReference(itemRef, idx + 1);
|
|
28596
|
+
const widget = allWidgets.find((w) => w.widget_type === "response" && w.reference === oldRef && !reassignedWidgets.has(w));
|
|
28597
|
+
if (widget) {
|
|
28598
|
+
widget.reference = newRef;
|
|
28599
|
+
reassignedWidgets.add(widget);
|
|
28600
|
+
}
|
|
28601
|
+
question.reference = newRef;
|
|
28602
|
+
});
|
|
28573
28603
|
const allFeatures = [];
|
|
28574
28604
|
if (hasPassageContent(inputXml)) {
|
|
28575
28605
|
if (extractPassageFromItemBody(inputXml)) {
|
|
@@ -28844,6 +28874,18 @@ function readAssessmentItemPassage(inputXml) {
|
|
|
28844
28874
|
*/
|
|
28845
28875
|
const MAX_TAG_LENGTH = 255;
|
|
28846
28876
|
/**
|
|
28877
|
+
* Split a tag value on commas into separate trimmed values.
|
|
28878
|
+
*
|
|
28879
|
+
* When `splitCsvTags` is false the value is returned unchanged as a single
|
|
28880
|
+
* element. When true, the value is split on literal commas, each part is
|
|
28881
|
+
* trimmed, and empty parts (from leading/trailing/double commas) are dropped.
|
|
28882
|
+
* A value without a comma yields a single trimmed element.
|
|
28883
|
+
*/
|
|
28884
|
+
function splitTagValue(value, splitCsvTags) {
|
|
28885
|
+
if (!splitCsvTags) return [value];
|
|
28886
|
+
return value.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
28887
|
+
}
|
|
28888
|
+
/**
|
|
28847
28889
|
* Validate and optionally truncate tag types and tag names
|
|
28848
28890
|
*
|
|
28849
28891
|
* @param tags - Tags to validate
|
|
@@ -28905,9 +28947,10 @@ function validateAndProcessTags(tags, options = {}) {
|
|
|
28905
28947
|
* Extracts csm:labelledGUID entries as Learnosity tags
|
|
28906
28948
|
*
|
|
28907
28949
|
* @param metadataXml - XML containing Common Cartridge metadata
|
|
28950
|
+
* @param splitCsvTags - Split comma-separated GUID values into separate elements (default: true)
|
|
28908
28951
|
* @returns Tags object with type->name[] mapping
|
|
28909
28952
|
*/
|
|
28910
|
-
function parseCommonCartridgeTags(metadataXml) {
|
|
28953
|
+
function parseCommonCartridgeTags(metadataXml, splitCsvTags = true) {
|
|
28911
28954
|
const tags = {};
|
|
28912
28955
|
const stack = [];
|
|
28913
28956
|
let inLabel = false;
|
|
@@ -28936,7 +28979,7 @@ function parseCommonCartridgeTags(metadataXml) {
|
|
|
28936
28979
|
inLabel = false;
|
|
28937
28980
|
} else if (localName === "GUID" && inGuid) {
|
|
28938
28981
|
const guidValue = textBuf.join("").trim();
|
|
28939
|
-
if (currentLabel && guidValue) addTagValue(tags, currentLabel, guidValue);
|
|
28982
|
+
if (currentLabel && guidValue) addTagValue(tags, currentLabel, guidValue, splitCsvTags);
|
|
28940
28983
|
inGuid = false;
|
|
28941
28984
|
} else if (localName === "labelledGUID") currentLabel = "";
|
|
28942
28985
|
stack.pop();
|
|
@@ -28948,17 +28991,23 @@ function parseCommonCartridgeTags(metadataXml) {
|
|
|
28948
28991
|
return tags;
|
|
28949
28992
|
}
|
|
28950
28993
|
/**
|
|
28951
|
-
* Add a tag value to the tags object
|
|
28994
|
+
* Add a tag value to the tags object, splitting comma-separated values when
|
|
28995
|
+
* enabled and deduplicating in insertion order.
|
|
28996
|
+
*
|
|
28997
|
+
* @param splitCsvTags - Split a comma-separated value into separate elements (default: true)
|
|
28952
28998
|
*/
|
|
28953
|
-
function addTagValue(tags, source, value) {
|
|
28954
|
-
tags[source] = tags[source] ?? [];
|
|
28955
|
-
if (!
|
|
28999
|
+
function addTagValue(tags, source, value, splitCsvTags = true) {
|
|
29000
|
+
const existing = tags[source] = tags[source] ?? [];
|
|
29001
|
+
for (const part of splitTagValue(value, splitCsvTags)) if (!existing.includes(part)) existing.push(part);
|
|
28956
29002
|
}
|
|
28957
29003
|
/**
|
|
28958
29004
|
* Parse LOM XML and extract tags for Learnosity
|
|
28959
29005
|
* Extracts classification/taxonPath entries grouped by source langstring
|
|
29006
|
+
*
|
|
29007
|
+
* @param lomXml - XML containing LOM metadata
|
|
29008
|
+
* @param splitCsvTags - Split comma-separated taxon entry values into separate elements (default: true)
|
|
28960
29009
|
*/
|
|
28961
|
-
function parseLomXml(lomXml) {
|
|
29010
|
+
function parseLomXml(lomXml, splitCsvTags = true) {
|
|
28962
29011
|
const tags = {};
|
|
28963
29012
|
const stack = [];
|
|
28964
29013
|
let inTaxonPathSource = false;
|
|
@@ -28990,7 +29039,7 @@ function parseLomXml(lomXml) {
|
|
|
28990
29039
|
inTaxonPathSource = false;
|
|
28991
29040
|
} else if (inTaxonEntry) {
|
|
28992
29041
|
const value = textBuf.join("").trim();
|
|
28993
|
-
if (value && currentSource) addTagValue(tags, currentSource, value);
|
|
29042
|
+
if (value && currentSource) addTagValue(tags, currentSource, value, splitCsvTags);
|
|
28994
29043
|
inTaxonEntry = false;
|
|
28995
29044
|
}
|
|
28996
29045
|
}
|
|
@@ -29015,8 +29064,9 @@ function parseLomXml(lomXml) {
|
|
|
29015
29064
|
* @returns Merged tags object and diagnostics
|
|
29016
29065
|
*/
|
|
29017
29066
|
function parseMetadataTags(metadataXml, options = {}) {
|
|
29018
|
-
const
|
|
29019
|
-
const
|
|
29067
|
+
const splitCsvTags = options.splitCsvTags ?? true;
|
|
29068
|
+
const lomTags = parseLomXml(metadataXml, splitCsvTags);
|
|
29069
|
+
const ccTags = parseCommonCartridgeTags(metadataXml, splitCsvTags);
|
|
29020
29070
|
const mergedTags = { ...lomTags };
|
|
29021
29071
|
for (const [tagType, tagValues] of Object.entries(ccTags)) {
|
|
29022
29072
|
const values = tagValues;
|
|
@@ -29089,7 +29139,7 @@ function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationI
|
|
|
29089
29139
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
29090
29140
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
29091
29141
|
};
|
|
29092
|
-
const questionRef =
|
|
29142
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
29093
29143
|
const questionData = { type: "fileupload" };
|
|
29094
29144
|
if (parsed.stimulus) try {
|
|
29095
29145
|
questionData.stimulus = transformAssetUrls(parsed.stimulus, {
|
|
@@ -29408,6 +29458,7 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
|
|
|
29408
29458
|
if (lomXml) try {
|
|
29409
29459
|
const tagResult = parseMetadataTags(lomXml, {
|
|
29410
29460
|
truncateTags: opts.truncateTags,
|
|
29461
|
+
splitCsvTags: opts.splitCsvTags,
|
|
29411
29462
|
filePath: opts.inputPath
|
|
29412
29463
|
});
|
|
29413
29464
|
lomTags = tagResult.tags;
|
|
@@ -29554,6 +29605,7 @@ function convertQtiToLearnosity(input, opts) {
|
|
|
29554
29605
|
customAssetUrl: opts.customAssetUrl,
|
|
29555
29606
|
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29556
29607
|
itemReferenceSource: opts.itemReferenceSource,
|
|
29608
|
+
splitCsvTags: opts.splitCsvTags,
|
|
29557
29609
|
fileAccess: opts.fileAccess
|
|
29558
29610
|
});
|
|
29559
29611
|
return Promise.resolve({
|
|
@@ -32181,6 +32233,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
32181
32233
|
customAssetUrl: opts?.customAssetUrl,
|
|
32182
32234
|
preserveAssetFilenames: opts?.preserveAssetFilenames ?? false,
|
|
32183
32235
|
itemReferenceSource: opts?.itemReferenceSource,
|
|
32236
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
32184
32237
|
fileAccess: opts?.fileAccess,
|
|
32185
32238
|
packageRoot: opts?.sourceDir,
|
|
32186
32239
|
finalItemReference,
|
|
@@ -32217,6 +32270,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
32217
32270
|
if (itemResource.metadataXml) try {
|
|
32218
32271
|
const tagResult = parseMetadataTags(itemResource.metadataXml, {
|
|
32219
32272
|
truncateTags: opts?.truncateTags,
|
|
32273
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
32220
32274
|
filePath: itemResource.href
|
|
32221
32275
|
});
|
|
32222
32276
|
diagnostics.push(...tagResult.diagnostics);
|
|
@@ -32314,6 +32368,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
32314
32368
|
if (testResource.metadataXml) try {
|
|
32315
32369
|
const tagResult = parseMetadataTags(testResource.metadataXml, {
|
|
32316
32370
|
truncateTags: opts?.truncateTags,
|
|
32371
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
32317
32372
|
filePath: testResource.href
|
|
32318
32373
|
});
|
|
32319
32374
|
diagnostics.push(...tagResult.diagnostics);
|
|
@@ -33839,6 +33894,7 @@ async function convertQtiPackageToLearnosity(opts) {
|
|
|
33839
33894
|
itemReferenceSource: opts.itemReferenceSource,
|
|
33840
33895
|
itemFilenameSource: opts.itemFilenameSource,
|
|
33841
33896
|
truncateTags: opts.truncateTags,
|
|
33897
|
+
splitCsvTags: opts.splitCsvTags,
|
|
33842
33898
|
sourceDir,
|
|
33843
33899
|
fileAccess: sourceDir ? nodeFileAccess : void 0,
|
|
33844
33900
|
sourceLabel: opts.inputPath
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"qtiPackageToLearnosity-BBfZgWBh.js","names":["input"],"sources":["../src/commands/qtiPackageToLearnosity.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Command } from 'commander';\nimport type {\n Diagnostic,\n ItemFilenameSource,\n ItemReferenceSource,\n} from '@learnosity/converter-core';\nimport {\n convertQtiPackageToLearnosityBundle,\n writeLearnosityBundle,\n loadPackageDirectory,\n nodeFileAccess,\n} from '@learnosity/converter-core/node';\nimport { existsSync, statSync, readFileSync } from 'fs';\nimport { input } from '@inquirer/prompts';\nimport { writeDiagnostics, type WriteDiagnosticsOptions } from '../io/writeDiagnostics.js';\nimport { showBanner } from '../ux/banner.js';\nimport { formatDiagnosticsTable } from '../ux/table.js';\nimport type { CliOptions } from '../options/types.js';\nimport { loadConfig } from '../options/loadConfig.js';\nimport { expandTilde } from '../utils/pathUtils.js';\nimport { processBatch, processBatchParallel } from '../utils/batchProcessing.js';\nimport { processQtiPackageToLearnosity } from '../utils/batchProcessors.js';\nimport { displayConfiguration, configField } from '../utils/configOutput.js';\n\n/**\n * Register qti-package-to-learnosity command\n */\nexport function registerQtiPackageToLearnosityCommand(program: Command, version: string): void {\n program\n .command('qti-package-to-learnosity')\n .alias('convert qti-package')\n .description('Convert a QTI Content Package to a Learnosity bundle')\n .option('--in <path>', 'Input package path (.zip or directory)')\n .option('--out <path>', 'Output bundle path (.zip or directory)')\n .option(\n '--format <type>',\n 'Output format: zip or dir (default: auto-detect from --out path)'\n )\n .option(\n '--organisation_id <number>',\n 'Organisation ID for Learnosity CDN asset URLs',\n parseInt\n )\n .option('--org_id <number>', 'Alias for --organisation_id', parseInt)\n .option('--mediavault', 'Use media-vault subdomain instead of assets (default: false)')\n .option(\n '--custom-asset-url <url>',\n 'Custom asset URL prefix to override default Learnosity CDN'\n )\n .option(\n '--preserve-asset-filenames',\n 'Preserve original QTI asset basenames instead of using hashed names (default: false)'\n )\n .option(\n '--item-reference-source <source>',\n 'How to generate item references: itemIdentifier (default), qti (deprecated alias of itemIdentifier), sourceFilename, or uuid'\n )\n .option(\n '--item-filename-source <source>',\n 'How to name output JSON files: itemIdentifier, qti, or sourceFilename (default: same as --item-reference-source)'\n )\n .option(\n '--truncate-tags',\n 'Truncate tag types and names to 255 characters instead of failing (default: false)'\n )\n .option('--recursive', 'Process all subdirectories in the input path (default: false)')\n .option(\n '--concurrency <number>',\n 'Worker threads for --recursive batch conversion (default: 1 = serial)',\n parseInt\n )\n .option('--diagnostics <mode>', 'Diagnostics output (stderr|file|both|none, default: file)')\n .option('--fail-on-warn', 'Exit with error code 1 if warnings exist (default: false)')\n .option('--config <path>', 'Path to config file')\n .option('--no-config', 'Disable config file loading')\n .option('-i, --interactive', 'Enable interactive prompts (default: false)')\n .option('--verbose', 'Show INFO level diagnostics in table (default: false)')\n .option('-q, --quiet', 'Suppress non-essential output (default: false)')\n .action(async (opts: CliOptions) => {\n await executeQtiPackageToLearnosity(opts, version);\n });\n}\n\n/**\n * Write diagnostics to file and/or stderr depending on mode\n */\nasync function outputDiagnostics(\n allDiagnostics: Diagnostic[],\n diagnosticsMode: string,\n verbose: boolean,\n diagnosticsPath: string,\n outputPath: string,\n metadata: WriteDiagnosticsOptions\n): Promise<void> {\n if (diagnosticsMode === 'file' || diagnosticsMode === 'both') {\n await writeDiagnostics(\n allDiagnostics,\n 'file',\n diagnosticsPath,\n outputPath,\n false,\n metadata\n );\n }\n\n if (diagnosticsMode === 'stderr' || diagnosticsMode === 'both') {\n const table = formatDiagnosticsTable(allDiagnostics, verbose);\n\n if (table) {\n console.error(table);\n }\n }\n}\n\n/**\n * Resolve an interactive or CLI-provided path option\n * Returns the expanded path or exits with an error.\n */\nasync function resolvePathOption(\n value: string | undefined,\n interactive: boolean,\n promptMessage: string,\n errorMessage: string\n): Promise<string> {\n let resolved = value;\n\n if (!resolved && interactive) {\n resolved = await input({ message: promptMessage });\n }\n\n if (!resolved) {\n console.error(errorMessage);\n process.exit(1);\n }\n\n return expandTilde(resolved);\n}\n\n/**\n * Parse the --diagnostics CLI option into mode and optional custom path\n */\nfunction resolveDiagnosticsConfig(diagnosticsOpt: string | undefined): {\n mode: 'file' | 'stderr' | 'both' | 'none';\n customPath?: string;\n} {\n const validModes = ['stderr', 'file', 'both', 'none'] as const;\n\n if (!diagnosticsOpt || validModes.includes(diagnosticsOpt as any)) {\n return { mode: (diagnosticsOpt as (typeof validModes)[number]) ?? 'file' };\n }\n\n return { mode: 'file', customPath: diagnosticsOpt };\n}\n\n/**\n * Resolve organisation ID from CLI options with optional interactive prompt\n */\nasync function resolveOrganisationId(\n cliOpts: CliOptions,\n interactive: boolean,\n configOrgId?: number\n): Promise<number> {\n let organisationId = (cliOpts as any).organisation_id ?? (cliOpts as any).org_id ?? configOrgId;\n\n if (organisationId === undefined && interactive) {\n const orgIdInput = await input({\n message: 'Organisation ID for Learnosity CDN asset URLs:',\n });\n\n organisationId = orgIdInput ? parseInt(orgIdInput, 10) : undefined;\n }\n\n if (organisationId === undefined || organisationId === null) {\n console.error(\n 'Error: --organisation_id is required. Use -i or --interactive for prompts or specify --organisation_id <number>'\n );\n process.exit(1);\n }\n\n return organisationId;\n}\n\n/**\n * Validate input path exists and determine its type\n */\nfunction validateInputPath(inputPath: string): { isZipInput: boolean } {\n if (!existsSync(inputPath)) {\n console.error(`Error: Input not found: ${inputPath}`);\n process.exit(1);\n }\n\n const isZipInput = inputPath.toLowerCase().endsWith('.zip');\n\n if (!isZipInput && !statSync(inputPath).isDirectory()) {\n console.error(`Error: Input must be a directory or .zip file: ${inputPath}`);\n process.exit(1);\n }\n\n return { isZipInput };\n}\n\n/**\n * Resolve output format (zip or directory) from path and explicit format option\n */\nfunction resolveOutputFormat(\n outputPath: string,\n formatOption?: string\n): { isZipOutput: boolean; finalOutputPath: string } {\n if (formatOption) {\n const fmt = formatOption.toLowerCase();\n\n if (fmt !== 'zip' && fmt !== 'dir') {\n console.error('Error: --format must be \"zip\" or \"dir\"');\n process.exit(1);\n }\n\n const isZipOutput = fmt === 'zip';\n const finalOutputPath =\n isZipOutput && !outputPath.toLowerCase().endsWith('.zip')\n ? `${outputPath}.zip`\n : outputPath;\n\n return { isZipOutput, finalOutputPath };\n }\n\n return {\n isZipOutput: outputPath.toLowerCase().endsWith('.zip'),\n finalOutputPath: outputPath,\n };\n}\n\n/**\n * Display conversion progress for activities and items\n */\nfunction displayConversionProgress(convertResult: any): void {\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n\n if (convertedActivityFiles.length > 0) {\n process.stderr.write(' Assessment tests:\\n');\n convertedActivityFiles.forEach((sourceFile: string, index: number) => {\n process.stderr.write(\n ` [${index + 1}/${convertedActivityFiles.length}] ${sourceFile} \\x1b[32m✓\\x1b[0m\\n`\n );\n });\n process.stderr.write('\\n');\n }\n\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n const totalFiles = convertedFiles.length + failedFiles.length;\n\n if (totalFiles > 0) {\n process.stderr.write(' Assessment items:\\n');\n const successSet = new Set(convertedFiles);\n const allFiles = [...convertedFiles, ...failedFiles].sort();\n\n allFiles.forEach((sourceFile: string, index: number) => {\n const isSuccess = successSet.has(sourceFile);\n const status = isSuccess ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m';\n\n process.stderr.write(` [${index + 1}/${totalFiles}] ${sourceFile} ${status}\\n`);\n });\n\n if (failedFiles.length > 0) {\n process.stderr.write(\n `\\nConversion completed with ERRORS (${convertedFiles.length} succeeded, ${failedFiles.length} failed)\\n`\n );\n process.stderr.write(\n `Proceeding with ${convertedFiles.length} successfully converted items...\\n\\n`\n );\n } else {\n process.stderr.write(`\\nConverted ${convertedFiles.length} items ✓\\n\\n`);\n }\n }\n}\n\n/**\n * Build metadata object for diagnostics output\n */\nfunction buildDiagnosticsMetadata(\n inputPath: string,\n outputPath: string,\n convertResult: any,\n failed: boolean\n): WriteDiagnosticsOptions {\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n const itemRefs = convertResult.bundle\n ? (Array.from(convertResult.bundle.items.keys()) as string[])\n : [];\n\n return {\n inputPath,\n outputPath,\n totalItemsFound: failed ? itemRefs.length : convertedFiles.length + failedFiles.length,\n totalActivitiesFound: convertedActivityFiles.length,\n convertedFiles: failed ? [] : convertedFiles,\n failedFiles: failed ? itemRefs.map((ref: string) => `items/${ref}.xml`) : failedFiles,\n convertedActivities: convertedActivityFiles,\n };\n}\n\n/**\n * Execute qti-package-to-learnosity conversion\n */\nasync function executeQtiPackageToLearnosity(cliOpts: CliOptions, version: string): Promise<void> {\n const allDiagnostics: Diagnostic[] = [];\n const startTime = Date.now();\n const quiet = cliOpts.quiet ?? false;\n\n try {\n showBanner('qti-package-to-learnosity', version, quiet);\n\n const interactive = cliOpts.interactive ?? false;\n\n // Load config file (CLI flags take precedence over config values)\n const { config, diagnostics: configDiagnostics } = await loadConfig(\n cliOpts.config,\n cliOpts.noConfig\n );\n\n allDiagnostics.push(...configDiagnostics);\n\n if (configDiagnostics.some((d) => d.level === 'error')) {\n console.log('\\n' + formatDiagnosticsTable(configDiagnostics));\n process.exit(1);\n\n return;\n }\n\n const inputPath = await resolvePathOption(\n cliOpts.in,\n interactive,\n 'Input QTI package path (.zip or directory):',\n 'Error: --in is required. Use -i or --interactive for prompts or specify --in <path>'\n );\n\n const outputPath = await resolvePathOption(\n cliOpts.out,\n interactive,\n 'Output bundle path (.zip or directory):',\n 'Error: --out is required. Use -i or --interactive for prompts or specify --out <path>'\n );\n\n const failOnWarn = cliOpts.failOnWarn ?? false;\n const verbose = cliOpts.verbose ?? config?.verbose ?? false;\n const { mode: diagnosticsMode, customPath: customDiagnosticsPath } =\n resolveDiagnosticsConfig(cliOpts.diagnostics ?? config?.diagnostics);\n const organisationId = await resolveOrganisationId(\n cliOpts,\n interactive,\n config?.organisationId\n );\n const mediaVault = (cliOpts as any).mediavault ?? config?.mediaVault ?? false;\n const customAssetUrl = (cliOpts as any).customAssetUrl ?? config?.customAssetUrl;\n const preserveAssetFilenames =\n cliOpts.preserveAssetFilenames ?? config?.preserveAssetFilenames ?? false;\n const itemReferenceSource =\n (cliOpts as any).itemReferenceSource ?? config?.itemReferenceSource;\n const itemFilenameSource =\n (cliOpts as any).itemFilenameSource ?? config?.itemFilenameSource;\n const truncateTags = (cliOpts as any).truncateTags ?? config?.truncateTags ?? false;\n\n const { isZipInput } = validateInputPath(inputPath);\n\n // Handle recursive batch processing\n if ((cliOpts as any).recursive) {\n if (isZipInput) {\n console.error(\n 'Error: --recursive flag cannot be used with ZIP input. Please provide a directory containing subdirectories.'\n );\n process.exit(1);\n\n return;\n }\n\n await executeBatchQtiPackageToLearnosity({\n inputPath,\n outputPath,\n organisationId,\n mediaVault,\n customAssetUrl,\n preserveAssetFilenames,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n diagnosticsMode,\n failOnWarn,\n verbose,\n quiet,\n version,\n concurrency: cliOpts.concurrency ?? 1,\n });\n\n return;\n }\n\n const { isZipOutput, finalOutputPath } = resolveOutputFormat(outputPath, cliOpts.format);\n\n if (!quiet) {\n displayConfiguration(\n [\n configField('Input:', inputPath),\n configField('Output:', finalOutputPath),\n configField('Format:', isZipOutput ? 'ZIP' : 'directory'),\n configField('Diagnostics:', diagnosticsMode),\n configField('Org ID:', organisationId),\n configField('Media vault:', mediaVault),\n configField('Preserve asset filenames:', preserveAssetFilenames),\n configField('Item ref src:', itemReferenceSource ?? 'itemIdentifier (default)'),\n configField('Item filename:', itemFilenameSource ?? 'same as item ref src'),\n configField('Verbose:', verbose),\n configField('Fail on warn:', failOnWarn),\n ],\n { quiet }\n );\n }\n\n // Step 1: Convert package to bundle model\n process.stderr.write('Converting QTI package...\\n');\n\n const convertOpts = {\n organisationId,\n mediaVault,\n customAssetUrl,\n preserveAssetFilenames,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n packageVersion: version,\n };\n let convertResult;\n\n if (isZipInput) {\n convertResult = convertQtiPackageToLearnosityBundle(\n { zipBytes: new Uint8Array(readFileSync(inputPath)) },\n convertOpts\n );\n } else {\n const loaded = loadPackageDirectory(inputPath);\n\n convertResult = loaded.entries\n ? convertQtiPackageToLearnosityBundle(\n { entries: loaded.entries },\n { ...convertOpts, sourceDir: inputPath, fileAccess: nodeFileAccess }\n )\n : { diagnostics: loaded.diagnostics };\n }\n\n allDiagnostics.push(...convertResult.diagnostics);\n\n displayConversionProgress(convertResult);\n\n const getDiagPath = () =>\n customDiagnosticsPath ||\n (isZipOutput\n ? finalOutputPath.replace(/\\.zip$/i, '-diagnostics.json')\n : `${finalOutputPath.replace(/\\/$/, '')}/diagnostics.json`);\n\n // Check for critical errors\n const errors = allDiagnostics.filter((d) => d.level === 'error');\n const warnings = allDiagnostics.filter((d) => d.level === 'warning');\n const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;\n\n if (errors.length > 0 && !hasValidBundle) {\n process.stderr.write('\\nConversion FAILED with errors\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n buildDiagnosticsMetadata(inputPath, finalOutputPath, convertResult, true)\n );\n process.exit(1);\n\n return;\n }\n\n if (failOnWarn && warnings.length > 0) {\n process.stderr.write('\\nConversion completed with WARNINGS (fail-on-warn mode)\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n buildDiagnosticsMetadata(\n inputPath,\n finalOutputPath,\n convertResult,\n errors.length > 0\n )\n );\n process.exit(1);\n\n return;\n }\n\n if (!convertResult.bundle) {\n process.stderr.write('\\nConversion FAILED: no bundle generated\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n {\n inputPath,\n outputPath: finalOutputPath,\n totalItemsFound: 0,\n convertedFiles: [],\n failedFiles: [],\n }\n );\n process.exit(1);\n\n return;\n }\n\n // Step 2: Write bundle to directory or ZIP\n process.stderr.write(`Writing ${isZipOutput ? 'ZIP' : 'directory'} package... `);\n const writeResult = await writeLearnosityBundle(convertResult.bundle, {\n outDir: finalOutputPath,\n isZipOutput,\n });\n\n allDiagnostics.push(...writeResult.diagnostics);\n\n if (writeResult.diagnostics.some((d) => d.level === 'error')) {\n process.stderr.write('FAILED\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n outputPath,\n buildDiagnosticsMetadata(inputPath, outputPath, convertResult, true)\n );\n process.exit(1);\n\n return;\n }\n\n process.stderr.write('✓\\n');\n\n // Step 3: Write final diagnostics on success\n const successMetadata = buildDiagnosticsMetadata(\n inputPath,\n finalOutputPath,\n convertResult,\n false\n );\n\n if (diagnosticsMode === 'file' || diagnosticsMode === 'both') {\n const diagnosticsPath = getDiagPath();\n\n process.stderr.write(`Writing diagnostics to ${diagnosticsPath}... `);\n await outputDiagnostics(\n allDiagnostics,\n 'file',\n verbose,\n diagnosticsPath,\n finalOutputPath,\n successMetadata\n );\n process.stderr.write('✓\\n');\n }\n\n if (diagnosticsMode === 'stderr' || diagnosticsMode === 'both') {\n await outputDiagnostics(\n allDiagnostics,\n 'stderr',\n verbose,\n getDiagPath(),\n finalOutputPath,\n successMetadata\n );\n }\n\n const elapsedTime = ((Date.now() - startTime) / 1000).toFixed(1);\n\n process.stderr.write(`\\nCompleted in ${elapsedTime}s\\n`);\n\n const failedFiles = convertResult.failedSourceFiles || [];\n\n if (failedFiles.length > 0) {\n process.stderr.write(\n `\\nPackage written with ${failedFiles.length} item(s) skipped due to errors\\n`\n );\n }\n\n process.exit(0);\n } catch (error) {\n if (error instanceof Error && error.name === 'ExitPromptError') {\n process.exit(130);\n }\n console.error('\\n' + (error instanceof Error ? error.message : 'Unknown error'));\n process.exit(1);\n }\n}\n\n/**\n * Execute batch QTI package to Learnosity conversion for multiple subdirectories\n */\nasync function executeBatchQtiPackageToLearnosity(opts: {\n inputPath: string;\n outputPath: string;\n organisationId: number;\n mediaVault: boolean;\n customAssetUrl?: string;\n preserveAssetFilenames: boolean;\n itemReferenceSource?: ItemReferenceSource;\n itemFilenameSource?: ItemFilenameSource;\n truncateTags: boolean;\n diagnosticsMode: string;\n failOnWarn: boolean;\n verbose: boolean;\n quiet: boolean;\n version: string;\n concurrency: number;\n}): Promise<void> {\n const {\n inputPath,\n outputPath,\n organisationId,\n mediaVault,\n customAssetUrl,\n preserveAssetFilenames,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n diagnosticsMode,\n failOnWarn,\n verbose,\n quiet,\n version,\n concurrency,\n } = opts;\n\n if (concurrency > 1) {\n await processBatchParallel({\n inputPath,\n outputPath,\n packageType: 'qti',\n direction: 'qti-to-learnosity',\n options: {\n organisationId,\n mediaVault,\n customAssetUrl,\n preserveAssetFilenames,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n version,\n },\n concurrency,\n quiet,\n });\n\n return;\n }\n\n // Display configuration\n displayConfiguration(\n [\n configField('Input:', inputPath),\n configField('Output:', outputPath),\n configField('Format:', 'directory'),\n configField('Diagnostics:', diagnosticsMode),\n configField('Org ID:', organisationId),\n configField('Media vault:', mediaVault),\n configField('Preserve asset filenames:', preserveAssetFilenames),\n configField('Item ref src:', itemReferenceSource ?? 'itemIdentifier (default)'),\n configField('Item filename:', itemFilenameSource ?? 'same as item ref src'),\n configField('Truncate tags:', truncateTags),\n configField('Recursive:', true),\n configField('Verbose:', verbose),\n configField('Fail on warn:', failOnWarn),\n ],\n { quiet }\n );\n\n if (!quiet) {\n console.log('🔄 Batch Processing Mode');\n console.log(`Scanning: ${inputPath}\\n`);\n }\n\n // Use generic batch processor\n await processBatch({\n inputPath,\n outputPath,\n packageType: 'qti',\n options: opts,\n quiet,\n processPackage: (pkg, packageOutputPath, options) =>\n processQtiPackageToLearnosity(pkg, packageOutputPath, options, quiet),\n });\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgB,sCAAsC,SAAkB,SAAuB;CAC3F,QACK,QAAQ,2BAA2B,CAAC,CACpC,MAAM,qBAAqB,CAAC,CAC5B,YAAY,sDAAsD,CAAC,CACnE,OAAO,eAAe,wCAAwC,CAAC,CAC/D,OAAO,gBAAgB,wCAAwC,CAAC,CAChE,OACG,mBACA,kEACJ,CAAC,CACA,OACG,8BACA,iDACA,QACJ,CAAC,CACA,OAA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U;EACjC,YAAY,WAAW,WAAW;EAClC,YAAY,gBAAgB,eAAe;EAC3C,YAAY,WAAW,cAAc;EACrC,YAAY,gBAAgB,UAAU;EACtC,YAAY,6BAA6B,sBAAsB;EAC/D,YAAY,iBAAiB,uBAAuB,0BAA0B;EAC9E,YAAY,kBAAkB,sBAAsB,sBAAsB;EAC1E,YAAY,kBAAkB,YAAY;EAC1C,YAAY,cAAc,IAAI;EAC9B,YAAY,YAAY,OAAO;EAC/B,YAAY,iBAAiB,UAAU;CAC3C,GACA,EAAE,MAAM,CACZ;CAEA,IAAI,CAAC,OAAO;EACR,QAAQ,IAAI,0BAA0B;EACtC,QAAQ,IAAI,aAAa,UAAU,GAAG;CAC1C;CAGA,MAAM,aAAa;EACf;EACA;EACA,aAAa;EACb,SAAS;EACT;EACA,iBAAiB,KAAK,mBAAmB,YACrC,8BAA8B,KAAK,mBAAmB,SAAS,KAAK;CAC5E,CAAC;AACL"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"qtiToLearnosity-C9OW_n7Z.js","names":[],"sources":["../src/commands/qtiToLearnosity.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Command } from 'commander';\nimport type { ConversionOptions, Diagnostic } from '@learnosity/converter-core';\nimport { convertQtiToLearnosity } from '@learnosity/converter-core';\nimport { nodeFileAccess } from '@learnosity/converter-core/node';\nimport { readInput } from '../io/readInput.js';\nimport { writeOutput } from '../io/writeOutput.js';\nimport { writeDiagnostics } from '../io/writeDiagnostics.js';\nimport { showBanner } from '../ux/banner.js';\nimport { showResolvedOptions } from '../ux/resolvedOptions.js';\nimport { ProgressTracker } from '../ux/progress.js';\nimport { formatDiagnosticsTable, countErrors } from '../ux/table.js';\nimport { loadConfig } from '../options/loadConfig.js';\nimport { resolveOptions } from '../options/resolveOptions.js';\nimport type { CliOptions } from '../options/types.js';\n\n/**\n * Register qti-to-learnosity command\n */\nexport function registerQtiToLearnosityCommand(program: Command, version: string): void {\n program\n .command('qti-to-learnosity')\n .description('Convert a single QTI file to Learnosity JSON')\n .option('--in <path>', 'Input file path or \"-\" for stdin')\n .option('--out <path>', 'Output file path or \"-\" for stdout')\n .option('--qti-version <version>', 'QTI version (2.1 or 2.2, default: 2.2)')\n .option(\n '--output-format <format>',\n 'Output format (dir|zip|stdout, default: auto-detect from output path)'\n )\n .option(\n '--diagnostics <mode>',\n 'Diagnostics output (stderr|file|both|none, default: file for file output, stderr for stdout)'\n )\n .option(\n '--organisation_id <number>',\n 'Organisation ID for Learnosity CDN asset URLs',\n parseInt\n )\n .option('--org_id <number>', 'Alias for --organisation_id', parseInt)\n .option('--mediavault', 'Use media-vault subdomain instead of assets (default: false)')\n .option(\n '--custom-asset-url <url>',\n 'Custom asset URL prefix to override default Learnosity CDN'\n )\n .option(\n '--preserve-asset-filenames',\n 'Preserve original QTI asset basenames instead of using hashed names (default: false)'\n )\n .option(\n '--item-reference-source <source>',\n 'How to generate item references: itemIdentifier (default), qti (deprecated alias of itemIdentifier), sourceFilename, or uuid'\n )\n .option(\n '--truncate-tags',\n 'Truncate tag types and names to 255 characters instead of failing (default: false)'\n )\n .option('--config <path>', 'Path to config file')\n .option('--no-config', 'Disable config file loading')\n .option('-i, --interactive', 'Enable interactive prompts (default: false)')\n .option('--verbose', 'Verbose output (default: false)')\n .option('--pretty', 'Pretty-print JSON output (default: false)')\n .option('-q, --quiet', 'Suppress non-essential output (default: false)')\n .action(async (opts: CliOptions) => {\n await executeQtiToLearnosity(opts, version);\n });\n}\n\nasync function resolveOutputFilePath(outputPath: string, itemReference?: string): Promise<string> {\n if (outputPath === '-' || !itemReference) {\n return outputPath;\n }\n\n const fs = await import('fs/promises');\n\n try {\n const stat = await fs.stat(outputPath);\n\n if (stat.isDirectory()) {\n return `${outputPath}/${itemReference}.json`;\n }\n } catch {\n if (outputPath.endsWith('/') || !outputPath.includes('.')) {\n return `${outputPath}${outputPath.endsWith('/') ? '' : '/'}${itemReference}.json`;\n }\n }\n\n return outputPath;\n}\n\n/**\n * Execute qti-to-learnosity conversion\n */\nasync function executeQtiToLearnosity(cliOpts: CliOptions, version: string): Promise<void> {\n const allDiagnostics: Diagnostic[] = [];\n const quiet = cliOpts.quiet ?? false;\n\n try {\n showBanner('qti-to-learnosity', version, quiet);\n\n // Load config\n const {\n config,\n diagnostics: configDiagnostics,\n configPath,\n } = await loadConfig(cliOpts.config, cliOpts.noConfig);\n\n allDiagnostics.push(...configDiagnostics);\n\n // Check for config errors\n const configErrors = configDiagnostics.filter((d) => d.level === 'error');\n\n if (configErrors.length > 0) {\n console.log('\\n' + formatDiagnosticsTable(configDiagnostics));\n process.exit(1);\n }\n\n // Resolve options\n const {\n options: resolved,\n diagnostics: resolveDiagnostics,\n withSources,\n } = await resolveOptions(cliOpts, config, false, configPath);\n\n allDiagnostics.push(...resolveDiagnostics);\n\n // Show resolved options\n showResolvedOptions(resolved, withSources, quiet);\n\n const progress = new ProgressTracker(resolved.verbose);\n\n // Read input\n progress.startStage('Reading input...');\n const input = await readInput(resolved.inputPath);\n\n progress.succeedStage('Input read');\n\n // Convert\n progress.startStage('Converting QTI to Learnosity...');\n const conversionOpts: ConversionOptions = {\n qtiVersion: resolved.qtiVersion,\n outputFormat: resolved.outputFormat,\n diagnostics: resolved.diagnostics,\n verbose: resolved.verbose,\n pretty: resolved.pretty,\n inputPath: resolved.inputPath,\n organisationId: resolved.organisationId, // TASK 030\n mediaVault: resolved.mediaVault,\n customAssetUrl: resolved.customAssetUrl,\n preserveAssetFilenames: resolved.preserveAssetFilenames,\n itemReferenceSource: resolved.itemReferenceSource,\n truncateTags: resolved.truncateTags,\n fileAccess: nodeFileAccess,\n };\n const result = await convertQtiToLearnosity(input, conversionOpts);\n\n // Set diagnostics file to input filename only\n const inputFilename = resolved.inputPath.split('/').pop() ?? resolved.inputPath;\n const prefixedDiagnostics = result.diagnostics.map((d) => ({\n ...d,\n file: inputFilename,\n }));\n\n allDiagnostics.push(...prefixedDiagnostics);\n progress.succeedStage('Conversion complete');\n\n // Determine output path - use MD5-based filename if output is a directory\n const itemReference = (result.output as any).reference;\n const finalOutputPath = await resolveOutputFilePath(resolved.outputPath, itemReference);\n\n // Write output\n progress.startStage('Writing output...');\n await writeOutput(finalOutputPath, result.output, resolved.pretty);\n progress.succeedStage('Output written');\n\n // Write diagnostics\n if (resolved.diagnostics !== 'none') {\n progress.startStage('Writing diagnostics...');\n const hasErrors = allDiagnostics.some((d) => d.level === 'error');\n\n await writeDiagnostics(\n allDiagnostics,\n resolved.diagnostics,\n resolved.diagnosticsPath,\n resolved.outputPath,\n resolved.verbose,\n {\n inputPath: resolved.inputPath,\n outputPath: resolved.outputPath,\n totalItemsFound: 1,\n convertedFiles: hasErrors ? [] : [inputFilename],\n failedFiles: hasErrors ? [inputFilename] : [],\n }\n );\n progress.succeedStage('Diagnostics written');\n }\n\n // Display diagnostics table only if mode is stderr or both\n if (resolved.diagnostics === 'stderr' || resolved.diagnostics === 'both') {\n console.log('\\n' + formatDiagnosticsTable(allDiagnostics));\n }\n\n const errorCount = countErrors(allDiagnostics);\n\n process.exit(errorCount > 0 ? 1 : 0);\n } catch (error) {\n if (error instanceof Error && error.name === 'ExitPromptError') {\n process.exit(130);\n }\n console.error('\\n' + (error instanceof Error ? error.message : 'Unknown error'));\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,+BAA+B,SAAkB,SAAuB;CACpF,QACK,QAAQ,mBAAmB,CAAC,CAC5B,YAAY,8CAA8C,CAAC,CAC3D,OAAO,eAAe,oCAAkC,CAAC,CACzD,OAAO,gBAAgB,sCAAoC,CAAC,CAC5D,OAAO,2BAA2B,wCAAwC,CAAC,CAC3E,OACG,4BACA,uEACJ,CAAC,CACA,OACG,wBACA,8FACJ,CAAC,CACA,OACG,8BACA,iDACA,QACJ,CAAC,CACA,OAAO,qBAAqB,+BAA+B,QAAQ,CAAC,CACpE,OAAO,gBAAgB,8DAA8D,CAAC,CACtF,OACG,4BACA,4DACJ,C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