@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
|
@@ -281,6 +281,7 @@ interface ConversionOptions {
|
|
|
281
281
|
preserveAssetFilenames?: boolean;
|
|
282
282
|
itemReferenceSource?: ItemReferenceSource;
|
|
283
283
|
truncateTags?: boolean;
|
|
284
|
+
splitCsvTags?: boolean;
|
|
284
285
|
/**
|
|
285
286
|
* Optional filesystem access for passage/LOM lookups. Omit for in-memory /
|
|
286
287
|
* browser use (disk lookups become no-ops). Node callers can inject
|
|
@@ -2577,6 +2578,7 @@ interface ConvertOptions {
|
|
|
2577
2578
|
sourceHrefBase?: string;
|
|
2578
2579
|
itemReferenceSource?: ItemReferenceSource;
|
|
2579
2580
|
truncateTags?: boolean;
|
|
2581
|
+
splitCsvTags?: boolean;
|
|
2580
2582
|
fileAccess?: FileAccess;
|
|
2581
2583
|
packageRoot?: string;
|
|
2582
2584
|
}
|
|
@@ -2629,6 +2631,7 @@ interface ConvertQtiPackageToLearnosityBundleOptions {
|
|
|
2629
2631
|
itemFilenameSource?: ItemFilenameSource;
|
|
2630
2632
|
packageVersion?: string;
|
|
2631
2633
|
truncateTags?: boolean;
|
|
2634
|
+
splitCsvTags?: boolean;
|
|
2632
2635
|
/** Base directory for resolving item source paths (Node disk conversion). */
|
|
2633
2636
|
sourceDir?: string;
|
|
2634
2637
|
/** Injected filesystem access for passage/LOM lookups (Node only). */
|
|
@@ -22992,6 +22992,34 @@ function md5hex(input) {
|
|
|
22992
22992
|
return hex;
|
|
22993
22993
|
}
|
|
22994
22994
|
//#endregion
|
|
22995
|
+
//#region src/qti-to-learnosity/utils/generateQuestionReference.ts
|
|
22996
|
+
/**
|
|
22997
|
+
* Shared utility for generating Learnosity question references.
|
|
22998
|
+
*/
|
|
22999
|
+
/**
|
|
23000
|
+
* Generate a Learnosity question reference from the resolved item reference and
|
|
23001
|
+
* the question's position within that item.
|
|
23002
|
+
*
|
|
23003
|
+
* The reference is `md5hex(`${itemRef}_${index}`)`, which guarantees it is both
|
|
23004
|
+
* unique (scoped to the item plus the per-item ordinal) and repeatable.
|
|
23005
|
+
*
|
|
23006
|
+
* - `itemRef` is the ALREADY-RESOLVED Learnosity item reference. Because it is
|
|
23007
|
+
* resolved upstream, the question reference automatically inherits the user's
|
|
23008
|
+
* `--item-reference-source` choice (item `identifier`, a `uuid`, or the source
|
|
23009
|
+
* filename) without this helper needing to re-read that option.
|
|
23010
|
+
* - `index` is the question's 1-BASED ordinal WITHIN the item. It is reset per
|
|
23011
|
+
* item, not a global counter: the first question in an item is `1`, the second
|
|
23012
|
+
* `2`, and so on. Single-question items always use `1` (a lone question is
|
|
23013
|
+
* `_1`), so there is no bare, unsuffixed variant.
|
|
23014
|
+
*
|
|
23015
|
+
* @param itemRef Resolved Learnosity item reference.
|
|
23016
|
+
* @param index 1-based ordinal of the question within the item.
|
|
23017
|
+
* @returns A 32-character lowercase hex MD5 question reference.
|
|
23018
|
+
*/
|
|
23019
|
+
function generateQuestionReference(itemRef, index) {
|
|
23020
|
+
return md5hex(`${itemRef}_${index}`);
|
|
23021
|
+
}
|
|
23022
|
+
//#endregion
|
|
22995
23023
|
//#region src/qti-to-learnosity/utils/mediaFeature.ts
|
|
22996
23024
|
/**
|
|
22997
23025
|
* Build a stable UUID-shaped identifier for a media feature.
|
|
@@ -23515,7 +23543,7 @@ function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
23515
23543
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23516
23544
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23517
23545
|
};
|
|
23518
|
-
const questionRef =
|
|
23546
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
23519
23547
|
const stems = parsed.stems.map((stem) => transformAssetUrls(stem.text, {
|
|
23520
23548
|
organisationId,
|
|
23521
23549
|
mediaVault,
|
|
@@ -23937,7 +23965,7 @@ function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisatio
|
|
|
23937
23965
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23938
23966
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23939
23967
|
};
|
|
23940
|
-
const questionRef =
|
|
23968
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
23941
23969
|
const possibleResponses = parsed.gapTexts.map((gt) => transformAssetUrls(gt.text, {
|
|
23942
23970
|
organisationId,
|
|
23943
23971
|
mediaVault,
|
|
@@ -24405,7 +24433,7 @@ function convertInlineChoiceToLearnosity(inputXml, diagnostics, lomTags, organis
|
|
|
24405
24433
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24406
24434
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24407
24435
|
};
|
|
24408
|
-
const questionRef =
|
|
24436
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
24409
24437
|
const possibleResponses = parsed.interactions.map((interaction) => interaction.choices.map((choice) => transformAssetUrls(choice.text, transformOpts)));
|
|
24410
24438
|
const validationValue = buildValidationValues(parsed.interactions, parsed.responseDeclarations, diagnostics, transformOpts, sourceFile);
|
|
24411
24439
|
if (!validationValue) return { diagnostics };
|
|
@@ -24684,7 +24712,7 @@ function convertOrderToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
24684
24712
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24685
24713
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24686
24714
|
};
|
|
24687
|
-
const questionRef =
|
|
24715
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
24688
24716
|
const stimulus = transformAssetUrls(parsed.stimulusText ?? "", {
|
|
24689
24717
|
organisationId,
|
|
24690
24718
|
mediaVault,
|
|
@@ -25135,7 +25163,7 @@ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25135
25163
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25136
25164
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25137
25165
|
};
|
|
25138
|
-
const questionRef =
|
|
25166
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
25139
25167
|
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
25140
25168
|
const imageSource = organisationId ? transformUrl(parsed.imageSource, organisationId, mediaVault, customAssetUrl, transformContext) : parsed.imageSource;
|
|
25141
25169
|
const areas = [];
|
|
@@ -25433,7 +25461,7 @@ function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25433
25461
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25434
25462
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25435
25463
|
};
|
|
25436
|
-
const questionRef =
|
|
25464
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
25437
25465
|
if (parsed.shuffle) diagnostics.push({
|
|
25438
25466
|
code: DiagnosticCode.QTI_SHUFFLE_NOT_SUPPORTED,
|
|
25439
25467
|
level: "warning",
|
|
@@ -25945,8 +25973,9 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25945
25973
|
const questions = [];
|
|
25946
25974
|
const widgets = [];
|
|
25947
25975
|
const questionSpans = [];
|
|
25948
|
-
for (
|
|
25949
|
-
const
|
|
25976
|
+
for (let i = 0; i < parsed.interactions.length; i++) {
|
|
25977
|
+
const interaction = parsed.interactions[i];
|
|
25978
|
+
const questionRef = generateQuestionReference(itemRef, i + 1);
|
|
25950
25979
|
const stimulus = interaction.stimulusText ? transformAssetUrls(interaction.stimulusText, {
|
|
25951
25980
|
organisationId,
|
|
25952
25981
|
mediaVault,
|
|
@@ -26390,7 +26419,7 @@ function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26390
26419
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26391
26420
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26392
26421
|
};
|
|
26393
|
-
const questionRef =
|
|
26422
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26394
26423
|
const stimulus = normalizeFinalText(transformAssetUrls((parsed.templateText || "").replace(/{{response}}(?:\s*<\/[^>]+>)*\s*$/, "").trim(), {
|
|
26395
26424
|
organisationId,
|
|
26396
26425
|
mediaVault,
|
|
@@ -26484,7 +26513,7 @@ function convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26484
26513
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26485
26514
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26486
26515
|
};
|
|
26487
|
-
const questionRef =
|
|
26516
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26488
26517
|
const stimulus = parsed.stimulusText ? normalizeFinalText(transformAssetUrls(parsed.stimulusText, {
|
|
26489
26518
|
organisationId,
|
|
26490
26519
|
mediaVault,
|
|
@@ -26734,7 +26763,7 @@ function readAssessmentItemExtendedText(inputXml) {
|
|
|
26734
26763
|
/**
|
|
26735
26764
|
* Build multi-interaction extended text item (multiple longtextV2 questions)
|
|
26736
26765
|
*/
|
|
26737
|
-
function buildMultiExtendedTextItem(parsed,
|
|
26766
|
+
function buildMultiExtendedTextItem(parsed, _inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26738
26767
|
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26739
26768
|
const transformContext = {
|
|
26740
26769
|
finalItemReference: itemRef,
|
|
@@ -26744,9 +26773,8 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26744
26773
|
const questions = [];
|
|
26745
26774
|
const widgets = [];
|
|
26746
26775
|
const questionSpans = [];
|
|
26747
|
-
const responseIdentifiers = extractResponseIdentifiers(inputXml, "extendedTextInteraction");
|
|
26748
26776
|
for (let i = 0; i < stimulusOverride.length; i++) {
|
|
26749
|
-
const questionRef =
|
|
26777
|
+
const questionRef = generateQuestionReference(itemRef, i + 1);
|
|
26750
26778
|
const stimulus = transformAssetUrls(stimulusOverride[i], {
|
|
26751
26779
|
organisationId,
|
|
26752
26780
|
mediaVault,
|
|
@@ -26788,16 +26816,6 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26788
26816
|
};
|
|
26789
26817
|
}
|
|
26790
26818
|
/**
|
|
26791
|
-
* Extract responseIdentifier values from interactions in XML
|
|
26792
|
-
*/
|
|
26793
|
-
function extractResponseIdentifiers(inputXml, interactionTag) {
|
|
26794
|
-
const responseIdentifiers = [];
|
|
26795
|
-
const interactionPattern = new RegExp(`<${assertXmlTagName(interactionTag)}[^>]+responseIdentifier=["']([^"']+)["']`, "g");
|
|
26796
|
-
let match;
|
|
26797
|
-
while ((match = interactionPattern.exec(inputXml)) !== null) responseIdentifiers.push(match[1]);
|
|
26798
|
-
return responseIdentifiers;
|
|
26799
|
-
}
|
|
26800
|
-
/**
|
|
26801
26819
|
* Convert extended text (extendedTextInteraction) to Learnosity longtextV2
|
|
26802
26820
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
26803
26821
|
*/
|
|
@@ -26813,7 +26831,7 @@ function convertExtendedTextToLearnosity(inputXml, diagnostics, lomTags, sourceF
|
|
|
26813
26831
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26814
26832
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26815
26833
|
};
|
|
26816
|
-
const questionRef =
|
|
26834
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26817
26835
|
const stimulusRaw = stimulusOverride && stimulusOverride.length === 1 ? stimulusOverride[0] : parsed.stimulusText;
|
|
26818
26836
|
const stimulus = stimulusRaw ? transformAssetUrls(stimulusRaw, {
|
|
26819
26837
|
organisationId,
|
|
@@ -27189,7 +27207,7 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
27189
27207
|
};
|
|
27190
27208
|
});
|
|
27191
27209
|
const validationValue = buildValidationValue$1(parsed.hotspots, parsed.correctPairs, gapImgIdToResponse);
|
|
27192
|
-
const questionRef =
|
|
27210
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27193
27211
|
const question = {
|
|
27194
27212
|
type: "imageclozeassociationV2",
|
|
27195
27213
|
image: {
|
|
@@ -27563,7 +27581,7 @@ function convertDrawingToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
27563
27581
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27564
27582
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27565
27583
|
};
|
|
27566
|
-
const questionRef =
|
|
27584
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27567
27585
|
const questionData = { type: "drawing" };
|
|
27568
27586
|
const stimulus = buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
27569
27587
|
if (stimulus !== void 0) questionData.stimulus = stimulus;
|
|
@@ -27876,7 +27894,7 @@ function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisa
|
|
|
27876
27894
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27877
27895
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27878
27896
|
};
|
|
27879
|
-
const questionRef =
|
|
27897
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27880
27898
|
const stimulus = transformAssetUrls(parsed.stimulusText ? `<p>${parsed.stimulusText}</p>` : "", {
|
|
27881
27899
|
organisationId,
|
|
27882
27900
|
mediaVault,
|
|
@@ -28343,6 +28361,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28343
28361
|
}
|
|
28344
28362
|
const allQuestions = [];
|
|
28345
28363
|
const allWidgets = [];
|
|
28364
|
+
let placeholderRefCounter = 0;
|
|
28346
28365
|
const processResult = (result, subDiagnostics) => {
|
|
28347
28366
|
if (result.item) {
|
|
28348
28367
|
allQuestions.push(...result.item.questions);
|
|
@@ -28399,7 +28418,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28399
28418
|
if (groupEntries.length > 0) {
|
|
28400
28419
|
const correctResponses = [];
|
|
28401
28420
|
for (const entry of groupEntries) if (entry.correctResponse) correctResponses.push(entry.correctResponse);
|
|
28402
|
-
const questionRef =
|
|
28421
|
+
const questionRef = `__mixed_placeholder_${placeholderRefCounter++}`;
|
|
28403
28422
|
const templateParts = [];
|
|
28404
28423
|
const groupWrapperOpen = group.wrapperOpens[0];
|
|
28405
28424
|
if (groupWrapperOpen) templateParts.push(groupWrapperOpen);
|
|
@@ -28563,6 +28582,17 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28563
28582
|
});
|
|
28564
28583
|
return { diagnostics };
|
|
28565
28584
|
}
|
|
28585
|
+
const reassignedWidgets = /* @__PURE__ */ new Set();
|
|
28586
|
+
allQuestions.forEach((question, idx) => {
|
|
28587
|
+
const oldRef = question.reference;
|
|
28588
|
+
const newRef = generateQuestionReference(itemRef, idx + 1);
|
|
28589
|
+
const widget = allWidgets.find((w) => w.widget_type === "response" && w.reference === oldRef && !reassignedWidgets.has(w));
|
|
28590
|
+
if (widget) {
|
|
28591
|
+
widget.reference = newRef;
|
|
28592
|
+
reassignedWidgets.add(widget);
|
|
28593
|
+
}
|
|
28594
|
+
question.reference = newRef;
|
|
28595
|
+
});
|
|
28566
28596
|
const allFeatures = [];
|
|
28567
28597
|
if (hasPassageContent(inputXml)) {
|
|
28568
28598
|
if (extractPassageFromItemBody(inputXml)) {
|
|
@@ -28837,6 +28867,18 @@ function readAssessmentItemPassage(inputXml) {
|
|
|
28837
28867
|
*/
|
|
28838
28868
|
const MAX_TAG_LENGTH = 255;
|
|
28839
28869
|
/**
|
|
28870
|
+
* Split a tag value on commas into separate trimmed values.
|
|
28871
|
+
*
|
|
28872
|
+
* When `splitCsvTags` is false the value is returned unchanged as a single
|
|
28873
|
+
* element. When true, the value is split on literal commas, each part is
|
|
28874
|
+
* trimmed, and empty parts (from leading/trailing/double commas) are dropped.
|
|
28875
|
+
* A value without a comma yields a single trimmed element.
|
|
28876
|
+
*/
|
|
28877
|
+
function splitTagValue(value, splitCsvTags) {
|
|
28878
|
+
if (!splitCsvTags) return [value];
|
|
28879
|
+
return value.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
28880
|
+
}
|
|
28881
|
+
/**
|
|
28840
28882
|
* Validate and optionally truncate tag types and tag names
|
|
28841
28883
|
*
|
|
28842
28884
|
* @param tags - Tags to validate
|
|
@@ -28898,9 +28940,10 @@ function validateAndProcessTags(tags, options = {}) {
|
|
|
28898
28940
|
* Extracts csm:labelledGUID entries as Learnosity tags
|
|
28899
28941
|
*
|
|
28900
28942
|
* @param metadataXml - XML containing Common Cartridge metadata
|
|
28943
|
+
* @param splitCsvTags - Split comma-separated GUID values into separate elements (default: true)
|
|
28901
28944
|
* @returns Tags object with type->name[] mapping
|
|
28902
28945
|
*/
|
|
28903
|
-
function parseCommonCartridgeTags(metadataXml) {
|
|
28946
|
+
function parseCommonCartridgeTags(metadataXml, splitCsvTags = true) {
|
|
28904
28947
|
const tags = {};
|
|
28905
28948
|
const stack = [];
|
|
28906
28949
|
let inLabel = false;
|
|
@@ -28929,7 +28972,7 @@ function parseCommonCartridgeTags(metadataXml) {
|
|
|
28929
28972
|
inLabel = false;
|
|
28930
28973
|
} else if (localName === "GUID" && inGuid) {
|
|
28931
28974
|
const guidValue = textBuf.join("").trim();
|
|
28932
|
-
if (currentLabel && guidValue) addTagValue(tags, currentLabel, guidValue);
|
|
28975
|
+
if (currentLabel && guidValue) addTagValue(tags, currentLabel, guidValue, splitCsvTags);
|
|
28933
28976
|
inGuid = false;
|
|
28934
28977
|
} else if (localName === "labelledGUID") currentLabel = "";
|
|
28935
28978
|
stack.pop();
|
|
@@ -28941,17 +28984,23 @@ function parseCommonCartridgeTags(metadataXml) {
|
|
|
28941
28984
|
return tags;
|
|
28942
28985
|
}
|
|
28943
28986
|
/**
|
|
28944
|
-
* Add a tag value to the tags object
|
|
28987
|
+
* Add a tag value to the tags object, splitting comma-separated values when
|
|
28988
|
+
* enabled and deduplicating in insertion order.
|
|
28989
|
+
*
|
|
28990
|
+
* @param splitCsvTags - Split a comma-separated value into separate elements (default: true)
|
|
28945
28991
|
*/
|
|
28946
|
-
function addTagValue(tags, source, value) {
|
|
28947
|
-
tags[source] = tags[source] ?? [];
|
|
28948
|
-
if (!
|
|
28992
|
+
function addTagValue(tags, source, value, splitCsvTags = true) {
|
|
28993
|
+
const existing = tags[source] = tags[source] ?? [];
|
|
28994
|
+
for (const part of splitTagValue(value, splitCsvTags)) if (!existing.includes(part)) existing.push(part);
|
|
28949
28995
|
}
|
|
28950
28996
|
/**
|
|
28951
28997
|
* Parse LOM XML and extract tags for Learnosity
|
|
28952
28998
|
* Extracts classification/taxonPath entries grouped by source langstring
|
|
28999
|
+
*
|
|
29000
|
+
* @param lomXml - XML containing LOM metadata
|
|
29001
|
+
* @param splitCsvTags - Split comma-separated taxon entry values into separate elements (default: true)
|
|
28953
29002
|
*/
|
|
28954
|
-
function parseLomXml(lomXml) {
|
|
29003
|
+
function parseLomXml(lomXml, splitCsvTags = true) {
|
|
28955
29004
|
const tags = {};
|
|
28956
29005
|
const stack = [];
|
|
28957
29006
|
let inTaxonPathSource = false;
|
|
@@ -28983,7 +29032,7 @@ function parseLomXml(lomXml) {
|
|
|
28983
29032
|
inTaxonPathSource = false;
|
|
28984
29033
|
} else if (inTaxonEntry) {
|
|
28985
29034
|
const value = textBuf.join("").trim();
|
|
28986
|
-
if (value && currentSource) addTagValue(tags, currentSource, value);
|
|
29035
|
+
if (value && currentSource) addTagValue(tags, currentSource, value, splitCsvTags);
|
|
28987
29036
|
inTaxonEntry = false;
|
|
28988
29037
|
}
|
|
28989
29038
|
}
|
|
@@ -29008,8 +29057,9 @@ function parseLomXml(lomXml) {
|
|
|
29008
29057
|
* @returns Merged tags object and diagnostics
|
|
29009
29058
|
*/
|
|
29010
29059
|
function parseMetadataTags(metadataXml, options = {}) {
|
|
29011
|
-
const
|
|
29012
|
-
const
|
|
29060
|
+
const splitCsvTags = options.splitCsvTags ?? true;
|
|
29061
|
+
const lomTags = parseLomXml(metadataXml, splitCsvTags);
|
|
29062
|
+
const ccTags = parseCommonCartridgeTags(metadataXml, splitCsvTags);
|
|
29013
29063
|
const mergedTags = { ...lomTags };
|
|
29014
29064
|
for (const [tagType, tagValues] of Object.entries(ccTags)) {
|
|
29015
29065
|
const values = tagValues;
|
|
@@ -29082,7 +29132,7 @@ function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationI
|
|
|
29082
29132
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
29083
29133
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
29084
29134
|
};
|
|
29085
|
-
const questionRef =
|
|
29135
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
29086
29136
|
const questionData = { type: "fileupload" };
|
|
29087
29137
|
if (parsed.stimulus) try {
|
|
29088
29138
|
questionData.stimulus = transformAssetUrls(parsed.stimulus, {
|
|
@@ -29401,6 +29451,7 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
|
|
|
29401
29451
|
if (lomXml) try {
|
|
29402
29452
|
const tagResult = parseMetadataTags(lomXml, {
|
|
29403
29453
|
truncateTags: opts.truncateTags,
|
|
29454
|
+
splitCsvTags: opts.splitCsvTags,
|
|
29404
29455
|
filePath: opts.inputPath
|
|
29405
29456
|
});
|
|
29406
29457
|
lomTags = tagResult.tags;
|
|
@@ -29547,6 +29598,7 @@ function convertQtiToLearnosity(input, opts) {
|
|
|
29547
29598
|
customAssetUrl: opts.customAssetUrl,
|
|
29548
29599
|
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29549
29600
|
itemReferenceSource: opts.itemReferenceSource,
|
|
29601
|
+
splitCsvTags: opts.splitCsvTags,
|
|
29550
29602
|
fileAccess: opts.fileAccess
|
|
29551
29603
|
});
|
|
29552
29604
|
return Promise.resolve({
|
|
@@ -31649,6 +31701,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
31649
31701
|
customAssetUrl: opts?.customAssetUrl,
|
|
31650
31702
|
preserveAssetFilenames: opts?.preserveAssetFilenames ?? false,
|
|
31651
31703
|
itemReferenceSource: opts?.itemReferenceSource,
|
|
31704
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
31652
31705
|
fileAccess: opts?.fileAccess,
|
|
31653
31706
|
packageRoot: opts?.sourceDir,
|
|
31654
31707
|
finalItemReference,
|
|
@@ -31685,6 +31738,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
31685
31738
|
if (itemResource.metadataXml) try {
|
|
31686
31739
|
const tagResult = parseMetadataTags(itemResource.metadataXml, {
|
|
31687
31740
|
truncateTags: opts?.truncateTags,
|
|
31741
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
31688
31742
|
filePath: itemResource.href
|
|
31689
31743
|
});
|
|
31690
31744
|
diagnostics.push(...tagResult.diagnostics);
|
|
@@ -31782,6 +31836,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
31782
31836
|
if (testResource.metadataXml) try {
|
|
31783
31837
|
const tagResult = parseMetadataTags(testResource.metadataXml, {
|
|
31784
31838
|
truncateTags: opts?.truncateTags,
|
|
31839
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
31785
31840
|
filePath: testResource.href
|
|
31786
31841
|
});
|
|
31787
31842
|
diagnostics.push(...tagResult.diagnostics);
|
|
@@ -281,6 +281,7 @@ interface ConversionOptions {
|
|
|
281
281
|
preserveAssetFilenames?: boolean;
|
|
282
282
|
itemReferenceSource?: ItemReferenceSource;
|
|
283
283
|
truncateTags?: boolean;
|
|
284
|
+
splitCsvTags?: boolean;
|
|
284
285
|
/**
|
|
285
286
|
* Optional filesystem access for passage/LOM lookups. Omit for in-memory /
|
|
286
287
|
* browser use (disk lookups become no-ops). Node callers can inject
|
|
@@ -2585,6 +2586,7 @@ interface ConvertOptions {
|
|
|
2585
2586
|
sourceHrefBase?: string;
|
|
2586
2587
|
itemReferenceSource?: ItemReferenceSource;
|
|
2587
2588
|
truncateTags?: boolean;
|
|
2589
|
+
splitCsvTags?: boolean;
|
|
2588
2590
|
fileAccess?: FileAccess;
|
|
2589
2591
|
packageRoot?: string;
|
|
2590
2592
|
}
|
|
@@ -2637,6 +2639,7 @@ interface ConvertQtiPackageToLearnosityBundleOptions {
|
|
|
2637
2639
|
itemFilenameSource?: ItemFilenameSource;
|
|
2638
2640
|
packageVersion?: string;
|
|
2639
2641
|
truncateTags?: boolean;
|
|
2642
|
+
splitCsvTags?: boolean;
|
|
2640
2643
|
/** Base directory for resolving item source paths (Node disk conversion). */
|
|
2641
2644
|
sourceDir?: string;
|
|
2642
2645
|
/** Injected filesystem access for passage/LOM lookups (Node only). */
|
|
@@ -2890,6 +2893,8 @@ interface ConvertQtiPackageToLearnosityOptions {
|
|
|
2890
2893
|
itemFilenameSource?: ItemFilenameSource;
|
|
2891
2894
|
/** Truncate tag types and names to 255 characters instead of failing */
|
|
2892
2895
|
truncateTags?: boolean;
|
|
2896
|
+
/** Split comma-separated tag values into separate array elements (default: true) */
|
|
2897
|
+
splitCsvTags?: boolean;
|
|
2893
2898
|
}
|
|
2894
2899
|
/**
|
|
2895
2900
|
* Result of converting a QTI Content Package to Learnosity
|