@learnosity/lib-qti-converter 0.13.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 +48 -34
- package/docs/GETTING_STARTED.md +43 -28
- package/docs/LEARNOSITY_BUNDLE_FORMAT.md +1 -1
- 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-DgiDpfpP.js → batchProcessors-B6Xmhfaz.js} +32 -6
- package/packages/cli/dist/batchProcessors-B6Xmhfaz.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{learnosityToQti-CIj5603P.js → learnosityToQti-hFKA3KnZ.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-CIj5603P.js.map → learnosityToQti-hFKA3KnZ.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-n6nGGr32.js → learnosityToQtiPackage-DI7bYisT.js} +4 -4
- package/packages/cli/dist/{learnosityToQtiPackage-n6nGGr32.js.map → learnosityToQtiPackage-DI7bYisT.js.map} +1 -1
- package/packages/cli/dist/main.js +4 -4
- package/packages/cli/dist/{pathUtils-mTQZ0wYS.js → pathUtils-DkptaCiz.js} +22 -7
- package/packages/cli/dist/{pathUtils-mTQZ0wYS.js.map → pathUtils-DkptaCiz.js.map} +1 -1
- package/packages/cli/dist/{qtiPackageToLearnosity-B4cD8jUw.js → qtiPackageToLearnosity-JDifZn8o.js} +14 -8
- package/packages/cli/dist/qtiPackageToLearnosity-JDifZn8o.js.map +1 -0
- package/packages/cli/dist/{qtiToLearnosity-DDjcpShJ.js → qtiToLearnosity-Be0s-5Dr.js} +6 -5
- package/packages/cli/dist/qtiToLearnosity-Be0s-5Dr.js.map +1 -0
- package/packages/cli/dist/{resolveOptions-Czapkfc1.js → resolveOptions-BotCofhl.js} +15 -5
- package/packages/cli/dist/resolveOptions-BotCofhl.js.map +1 -0
- package/packages/cli/dist/{table-DTSv0atR.js → table-DlY4LGmL.js} +98 -43
- package/packages/cli/dist/table-DlY4LGmL.js.map +1 -0
- package/packages/core/dist/index.d.ts +10 -4
- package/packages/core/dist/index.js +128 -46
- package/packages/core/dist/node.d.ts +13 -5
- package/packages/core/dist/node.js +129 -46
- package/packages/cli/dist/batchProcessors-DgiDpfpP.js.map +0 -1
- package/packages/cli/dist/qtiPackageToLearnosity-B4cD8jUw.js.map +0 -1
- package/packages/cli/dist/qtiToLearnosity-DDjcpShJ.js.map +0 -1
- package/packages/cli/dist/resolveOptions-Czapkfc1.js.map +0 -1
- package/packages/cli/dist/table-DTSv0atR.js.map +0 -1
|
@@ -22899,6 +22899,34 @@ function md5hex(input) {
|
|
|
22899
22899
|
return hex;
|
|
22900
22900
|
}
|
|
22901
22901
|
//#endregion
|
|
22902
|
+
//#region ../core/src/qti-to-learnosity/utils/generateQuestionReference.ts
|
|
22903
|
+
/**
|
|
22904
|
+
* Shared utility for generating Learnosity question references.
|
|
22905
|
+
*/
|
|
22906
|
+
/**
|
|
22907
|
+
* Generate a Learnosity question reference from the resolved item reference and
|
|
22908
|
+
* the question's position within that item.
|
|
22909
|
+
*
|
|
22910
|
+
* The reference is `md5hex(`${itemRef}_${index}`)`, which guarantees it is both
|
|
22911
|
+
* unique (scoped to the item plus the per-item ordinal) and repeatable.
|
|
22912
|
+
*
|
|
22913
|
+
* - `itemRef` is the ALREADY-RESOLVED Learnosity item reference. Because it is
|
|
22914
|
+
* resolved upstream, the question reference automatically inherits the user's
|
|
22915
|
+
* `--item-reference-source` choice (item `identifier`, a `uuid`, or the source
|
|
22916
|
+
* filename) without this helper needing to re-read that option.
|
|
22917
|
+
* - `index` is the question's 1-BASED ordinal WITHIN the item. It is reset per
|
|
22918
|
+
* item, not a global counter: the first question in an item is `1`, the second
|
|
22919
|
+
* `2`, and so on. Single-question items always use `1` (a lone question is
|
|
22920
|
+
* `_1`), so there is no bare, unsuffixed variant.
|
|
22921
|
+
*
|
|
22922
|
+
* @param itemRef Resolved Learnosity item reference.
|
|
22923
|
+
* @param index 1-based ordinal of the question within the item.
|
|
22924
|
+
* @returns A 32-character lowercase hex MD5 question reference.
|
|
22925
|
+
*/
|
|
22926
|
+
function generateQuestionReference(itemRef, index) {
|
|
22927
|
+
return md5hex(`${itemRef}_${index}`);
|
|
22928
|
+
}
|
|
22929
|
+
//#endregion
|
|
22902
22930
|
//#region ../core/src/qti-to-learnosity/utils/mediaFeature.ts
|
|
22903
22931
|
/**
|
|
22904
22932
|
* Build a stable UUID-shaped identifier for a media feature.
|
|
@@ -23268,12 +23296,16 @@ function transformAssetUrls(html, options) {
|
|
|
23268
23296
|
//#endregion
|
|
23269
23297
|
//#region ../core/src/qti-to-learnosity/utils/generateItemReference.ts
|
|
23270
23298
|
/**
|
|
23271
|
-
* Generate item reference based on the configured source
|
|
23299
|
+
* Generate item reference based on the configured source.
|
|
23300
|
+
*
|
|
23301
|
+
* - `'itemIdentifier'` (default) and its deprecated alias `'qti'`, as well as an
|
|
23302
|
+
* omitted source, return the QTI `identifier`.
|
|
23303
|
+
* - `'uuid'` returns an MD5 hash of the QTI `identifier`.
|
|
23304
|
+
* - `'sourceFilename'` derives the reference from the source file name.
|
|
23272
23305
|
*/
|
|
23273
23306
|
function generateItemReference(qtiIdentifier, itemReferenceSource, sourceFile) {
|
|
23274
|
-
if (itemReferenceSource === "qti") return qtiIdentifier;
|
|
23275
23307
|
if (itemReferenceSource === "uuid") return md5hex(qtiIdentifier);
|
|
23276
|
-
if (sourceFile) return (sourceFile.split(/[\\/]/).pop() ?? sourceFile).replace(/\.xml$/i, "");
|
|
23308
|
+
if (itemReferenceSource === "sourceFilename" && sourceFile) return (sourceFile.split(/[\\/]/).pop() ?? sourceFile).replace(/\.xml$/i, "");
|
|
23277
23309
|
return qtiIdentifier;
|
|
23278
23310
|
}
|
|
23279
23311
|
//#endregion
|
|
@@ -23418,7 +23450,7 @@ function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
23418
23450
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23419
23451
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23420
23452
|
};
|
|
23421
|
-
const questionRef =
|
|
23453
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
23422
23454
|
const stems = parsed.stems.map((stem) => transformAssetUrls(stem.text, {
|
|
23423
23455
|
organisationId,
|
|
23424
23456
|
mediaVault,
|
|
@@ -23840,7 +23872,7 @@ function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisatio
|
|
|
23840
23872
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23841
23873
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23842
23874
|
};
|
|
23843
|
-
const questionRef =
|
|
23875
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
23844
23876
|
const possibleResponses = parsed.gapTexts.map((gt) => transformAssetUrls(gt.text, {
|
|
23845
23877
|
organisationId,
|
|
23846
23878
|
mediaVault,
|
|
@@ -24308,7 +24340,7 @@ function convertInlineChoiceToLearnosity(inputXml, diagnostics, lomTags, organis
|
|
|
24308
24340
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24309
24341
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24310
24342
|
};
|
|
24311
|
-
const questionRef =
|
|
24343
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
24312
24344
|
const possibleResponses = parsed.interactions.map((interaction) => interaction.choices.map((choice) => transformAssetUrls(choice.text, transformOpts)));
|
|
24313
24345
|
const validationValue = buildValidationValues(parsed.interactions, parsed.responseDeclarations, diagnostics, transformOpts, sourceFile);
|
|
24314
24346
|
if (!validationValue) return { diagnostics };
|
|
@@ -24587,7 +24619,7 @@ function convertOrderToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
24587
24619
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24588
24620
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24589
24621
|
};
|
|
24590
|
-
const questionRef =
|
|
24622
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
24591
24623
|
const stimulus = transformAssetUrls(parsed.stimulusText ?? "", {
|
|
24592
24624
|
organisationId,
|
|
24593
24625
|
mediaVault,
|
|
@@ -25038,7 +25070,7 @@ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25038
25070
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25039
25071
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25040
25072
|
};
|
|
25041
|
-
const questionRef =
|
|
25073
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
25042
25074
|
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
25043
25075
|
const imageSource = organisationId ? transformUrl(parsed.imageSource, organisationId, mediaVault, customAssetUrl, transformContext) : parsed.imageSource;
|
|
25044
25076
|
const areas = [];
|
|
@@ -25336,7 +25368,7 @@ function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25336
25368
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25337
25369
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25338
25370
|
};
|
|
25339
|
-
const questionRef =
|
|
25371
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
25340
25372
|
if (parsed.shuffle) diagnostics.push({
|
|
25341
25373
|
code: DiagnosticCode.QTI_SHUFFLE_NOT_SUPPORTED,
|
|
25342
25374
|
level: "warning",
|
|
@@ -25848,8 +25880,9 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25848
25880
|
const questions = [];
|
|
25849
25881
|
const widgets = [];
|
|
25850
25882
|
const questionSpans = [];
|
|
25851
|
-
for (
|
|
25852
|
-
const
|
|
25883
|
+
for (let i = 0; i < parsed.interactions.length; i++) {
|
|
25884
|
+
const interaction = parsed.interactions[i];
|
|
25885
|
+
const questionRef = generateQuestionReference(itemRef, i + 1);
|
|
25853
25886
|
const stimulus = interaction.stimulusText ? transformAssetUrls(interaction.stimulusText, {
|
|
25854
25887
|
organisationId,
|
|
25855
25888
|
mediaVault,
|
|
@@ -26293,7 +26326,7 @@ function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26293
26326
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26294
26327
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26295
26328
|
};
|
|
26296
|
-
const questionRef =
|
|
26329
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26297
26330
|
const stimulus = normalizeFinalText(transformAssetUrls((parsed.templateText || "").replace(/{{response}}(?:\s*<\/[^>]+>)*\s*$/, "").trim(), {
|
|
26298
26331
|
organisationId,
|
|
26299
26332
|
mediaVault,
|
|
@@ -26387,7 +26420,7 @@ function convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26387
26420
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26388
26421
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26389
26422
|
};
|
|
26390
|
-
const questionRef =
|
|
26423
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26391
26424
|
const stimulus = parsed.stimulusText ? normalizeFinalText(transformAssetUrls(parsed.stimulusText, {
|
|
26392
26425
|
organisationId,
|
|
26393
26426
|
mediaVault,
|
|
@@ -26637,7 +26670,7 @@ function readAssessmentItemExtendedText(inputXml) {
|
|
|
26637
26670
|
/**
|
|
26638
26671
|
* Build multi-interaction extended text item (multiple longtextV2 questions)
|
|
26639
26672
|
*/
|
|
26640
|
-
function buildMultiExtendedTextItem(parsed,
|
|
26673
|
+
function buildMultiExtendedTextItem(parsed, _inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26641
26674
|
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26642
26675
|
const transformContext = {
|
|
26643
26676
|
finalItemReference: itemRef,
|
|
@@ -26647,9 +26680,8 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26647
26680
|
const questions = [];
|
|
26648
26681
|
const widgets = [];
|
|
26649
26682
|
const questionSpans = [];
|
|
26650
|
-
const responseIdentifiers = extractResponseIdentifiers(inputXml, "extendedTextInteraction");
|
|
26651
26683
|
for (let i = 0; i < stimulusOverride.length; i++) {
|
|
26652
|
-
const questionRef =
|
|
26684
|
+
const questionRef = generateQuestionReference(itemRef, i + 1);
|
|
26653
26685
|
const stimulus = transformAssetUrls(stimulusOverride[i], {
|
|
26654
26686
|
organisationId,
|
|
26655
26687
|
mediaVault,
|
|
@@ -26691,16 +26723,6 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26691
26723
|
};
|
|
26692
26724
|
}
|
|
26693
26725
|
/**
|
|
26694
|
-
* Extract responseIdentifier values from interactions in XML
|
|
26695
|
-
*/
|
|
26696
|
-
function extractResponseIdentifiers(inputXml, interactionTag) {
|
|
26697
|
-
const responseIdentifiers = [];
|
|
26698
|
-
const interactionPattern = new RegExp(`<${assertXmlTagName(interactionTag)}[^>]+responseIdentifier=["']([^"']+)["']`, "g");
|
|
26699
|
-
let match;
|
|
26700
|
-
while ((match = interactionPattern.exec(inputXml)) !== null) responseIdentifiers.push(match[1]);
|
|
26701
|
-
return responseIdentifiers;
|
|
26702
|
-
}
|
|
26703
|
-
/**
|
|
26704
26726
|
* Convert extended text (extendedTextInteraction) to Learnosity longtextV2
|
|
26705
26727
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
26706
26728
|
*/
|
|
@@ -26716,7 +26738,7 @@ function convertExtendedTextToLearnosity(inputXml, diagnostics, lomTags, sourceF
|
|
|
26716
26738
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26717
26739
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26718
26740
|
};
|
|
26719
|
-
const questionRef =
|
|
26741
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
26720
26742
|
const stimulusRaw = stimulusOverride && stimulusOverride.length === 1 ? stimulusOverride[0] : parsed.stimulusText;
|
|
26721
26743
|
const stimulus = stimulusRaw ? transformAssetUrls(stimulusRaw, {
|
|
26722
26744
|
organisationId,
|
|
@@ -27092,7 +27114,7 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
27092
27114
|
};
|
|
27093
27115
|
});
|
|
27094
27116
|
const validationValue = buildValidationValue$1(parsed.hotspots, parsed.correctPairs, gapImgIdToResponse);
|
|
27095
|
-
const questionRef =
|
|
27117
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27096
27118
|
const question = {
|
|
27097
27119
|
type: "imageclozeassociationV2",
|
|
27098
27120
|
image: {
|
|
@@ -27466,7 +27488,7 @@ function convertDrawingToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
27466
27488
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27467
27489
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27468
27490
|
};
|
|
27469
|
-
const questionRef =
|
|
27491
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27470
27492
|
const questionData = { type: "drawing" };
|
|
27471
27493
|
const stimulus = buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
27472
27494
|
if (stimulus !== void 0) questionData.stimulus = stimulus;
|
|
@@ -27779,7 +27801,7 @@ function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisa
|
|
|
27779
27801
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27780
27802
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27781
27803
|
};
|
|
27782
|
-
const questionRef =
|
|
27804
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
27783
27805
|
const stimulus = transformAssetUrls(parsed.stimulusText ? `<p>${parsed.stimulusText}</p>` : "", {
|
|
27784
27806
|
organisationId,
|
|
27785
27807
|
mediaVault,
|
|
@@ -28246,6 +28268,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28246
28268
|
}
|
|
28247
28269
|
const allQuestions = [];
|
|
28248
28270
|
const allWidgets = [];
|
|
28271
|
+
let placeholderRefCounter = 0;
|
|
28249
28272
|
const processResult = (result, subDiagnostics) => {
|
|
28250
28273
|
if (result.item) {
|
|
28251
28274
|
allQuestions.push(...result.item.questions);
|
|
@@ -28302,7 +28325,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28302
28325
|
if (groupEntries.length > 0) {
|
|
28303
28326
|
const correctResponses = [];
|
|
28304
28327
|
for (const entry of groupEntries) if (entry.correctResponse) correctResponses.push(entry.correctResponse);
|
|
28305
|
-
const questionRef =
|
|
28328
|
+
const questionRef = `__mixed_placeholder_${placeholderRefCounter++}`;
|
|
28306
28329
|
const templateParts = [];
|
|
28307
28330
|
const groupWrapperOpen = group.wrapperOpens[0];
|
|
28308
28331
|
if (groupWrapperOpen) templateParts.push(groupWrapperOpen);
|
|
@@ -28466,6 +28489,17 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28466
28489
|
});
|
|
28467
28490
|
return { diagnostics };
|
|
28468
28491
|
}
|
|
28492
|
+
const reassignedWidgets = /* @__PURE__ */ new Set();
|
|
28493
|
+
allQuestions.forEach((question, idx) => {
|
|
28494
|
+
const oldRef = question.reference;
|
|
28495
|
+
const newRef = generateQuestionReference(itemRef, idx + 1);
|
|
28496
|
+
const widget = allWidgets.find((w) => w.widget_type === "response" && w.reference === oldRef && !reassignedWidgets.has(w));
|
|
28497
|
+
if (widget) {
|
|
28498
|
+
widget.reference = newRef;
|
|
28499
|
+
reassignedWidgets.add(widget);
|
|
28500
|
+
}
|
|
28501
|
+
question.reference = newRef;
|
|
28502
|
+
});
|
|
28469
28503
|
const allFeatures = [];
|
|
28470
28504
|
if (hasPassageContent(inputXml)) {
|
|
28471
28505
|
if (extractPassageFromItemBody(inputXml)) {
|
|
@@ -28740,6 +28774,18 @@ function readAssessmentItemPassage(inputXml) {
|
|
|
28740
28774
|
*/
|
|
28741
28775
|
const MAX_TAG_LENGTH = 255;
|
|
28742
28776
|
/**
|
|
28777
|
+
* Split a tag value on commas into separate trimmed values.
|
|
28778
|
+
*
|
|
28779
|
+
* When `splitCsvTags` is false the value is returned unchanged as a single
|
|
28780
|
+
* element. When true, the value is split on literal commas, each part is
|
|
28781
|
+
* trimmed, and empty parts (from leading/trailing/double commas) are dropped.
|
|
28782
|
+
* A value without a comma yields a single trimmed element.
|
|
28783
|
+
*/
|
|
28784
|
+
function splitTagValue(value, splitCsvTags) {
|
|
28785
|
+
if (!splitCsvTags) return [value];
|
|
28786
|
+
return value.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
28787
|
+
}
|
|
28788
|
+
/**
|
|
28743
28789
|
* Validate and optionally truncate tag types and tag names
|
|
28744
28790
|
*
|
|
28745
28791
|
* @param tags - Tags to validate
|
|
@@ -28801,9 +28847,10 @@ function validateAndProcessTags(tags, options = {}) {
|
|
|
28801
28847
|
* Extracts csm:labelledGUID entries as Learnosity tags
|
|
28802
28848
|
*
|
|
28803
28849
|
* @param metadataXml - XML containing Common Cartridge metadata
|
|
28850
|
+
* @param splitCsvTags - Split comma-separated GUID values into separate elements (default: true)
|
|
28804
28851
|
* @returns Tags object with type->name[] mapping
|
|
28805
28852
|
*/
|
|
28806
|
-
function parseCommonCartridgeTags(metadataXml) {
|
|
28853
|
+
function parseCommonCartridgeTags(metadataXml, splitCsvTags = true) {
|
|
28807
28854
|
const tags = {};
|
|
28808
28855
|
const stack = [];
|
|
28809
28856
|
let inLabel = false;
|
|
@@ -28832,7 +28879,7 @@ function parseCommonCartridgeTags(metadataXml) {
|
|
|
28832
28879
|
inLabel = false;
|
|
28833
28880
|
} else if (localName === "GUID" && inGuid) {
|
|
28834
28881
|
const guidValue = textBuf.join("").trim();
|
|
28835
|
-
if (currentLabel && guidValue) addTagValue(tags, currentLabel, guidValue);
|
|
28882
|
+
if (currentLabel && guidValue) addTagValue(tags, currentLabel, guidValue, splitCsvTags);
|
|
28836
28883
|
inGuid = false;
|
|
28837
28884
|
} else if (localName === "labelledGUID") currentLabel = "";
|
|
28838
28885
|
stack.pop();
|
|
@@ -28844,17 +28891,23 @@ function parseCommonCartridgeTags(metadataXml) {
|
|
|
28844
28891
|
return tags;
|
|
28845
28892
|
}
|
|
28846
28893
|
/**
|
|
28847
|
-
* Add a tag value to the tags object
|
|
28894
|
+
* Add a tag value to the tags object, splitting comma-separated values when
|
|
28895
|
+
* enabled and deduplicating in insertion order.
|
|
28896
|
+
*
|
|
28897
|
+
* @param splitCsvTags - Split a comma-separated value into separate elements (default: true)
|
|
28848
28898
|
*/
|
|
28849
|
-
function addTagValue(tags, source, value) {
|
|
28850
|
-
tags[source] = tags[source] ?? [];
|
|
28851
|
-
if (!
|
|
28899
|
+
function addTagValue(tags, source, value, splitCsvTags = true) {
|
|
28900
|
+
const existing = tags[source] = tags[source] ?? [];
|
|
28901
|
+
for (const part of splitTagValue(value, splitCsvTags)) if (!existing.includes(part)) existing.push(part);
|
|
28852
28902
|
}
|
|
28853
28903
|
/**
|
|
28854
28904
|
* Parse LOM XML and extract tags for Learnosity
|
|
28855
28905
|
* Extracts classification/taxonPath entries grouped by source langstring
|
|
28906
|
+
*
|
|
28907
|
+
* @param lomXml - XML containing LOM metadata
|
|
28908
|
+
* @param splitCsvTags - Split comma-separated taxon entry values into separate elements (default: true)
|
|
28856
28909
|
*/
|
|
28857
|
-
function parseLomXml(lomXml) {
|
|
28910
|
+
function parseLomXml(lomXml, splitCsvTags = true) {
|
|
28858
28911
|
const tags = {};
|
|
28859
28912
|
const stack = [];
|
|
28860
28913
|
let inTaxonPathSource = false;
|
|
@@ -28886,7 +28939,7 @@ function parseLomXml(lomXml) {
|
|
|
28886
28939
|
inTaxonPathSource = false;
|
|
28887
28940
|
} else if (inTaxonEntry) {
|
|
28888
28941
|
const value = textBuf.join("").trim();
|
|
28889
|
-
if (value && currentSource) addTagValue(tags, currentSource, value);
|
|
28942
|
+
if (value && currentSource) addTagValue(tags, currentSource, value, splitCsvTags);
|
|
28890
28943
|
inTaxonEntry = false;
|
|
28891
28944
|
}
|
|
28892
28945
|
}
|
|
@@ -28911,8 +28964,9 @@ function parseLomXml(lomXml) {
|
|
|
28911
28964
|
* @returns Merged tags object and diagnostics
|
|
28912
28965
|
*/
|
|
28913
28966
|
function parseMetadataTags(metadataXml, options = {}) {
|
|
28914
|
-
const
|
|
28915
|
-
const
|
|
28967
|
+
const splitCsvTags = options.splitCsvTags ?? true;
|
|
28968
|
+
const lomTags = parseLomXml(metadataXml, splitCsvTags);
|
|
28969
|
+
const ccTags = parseCommonCartridgeTags(metadataXml, splitCsvTags);
|
|
28916
28970
|
const mergedTags = { ...lomTags };
|
|
28917
28971
|
for (const [tagType, tagValues] of Object.entries(ccTags)) {
|
|
28918
28972
|
const values = tagValues;
|
|
@@ -28985,7 +29039,7 @@ function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationI
|
|
|
28985
29039
|
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
28986
29040
|
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
28987
29041
|
};
|
|
28988
|
-
const questionRef =
|
|
29042
|
+
const questionRef = generateQuestionReference(itemRef, 1);
|
|
28989
29043
|
const questionData = { type: "fileupload" };
|
|
28990
29044
|
if (parsed.stimulus) try {
|
|
28991
29045
|
questionData.stimulus = transformAssetUrls(parsed.stimulus, {
|
|
@@ -29304,6 +29358,7 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
|
|
|
29304
29358
|
if (lomXml) try {
|
|
29305
29359
|
const tagResult = parseMetadataTags(lomXml, {
|
|
29306
29360
|
truncateTags: opts.truncateTags,
|
|
29361
|
+
splitCsvTags: opts.splitCsvTags,
|
|
29307
29362
|
filePath: opts.inputPath
|
|
29308
29363
|
});
|
|
29309
29364
|
lomTags = tagResult.tags;
|
|
@@ -31677,4 +31732,4 @@ function formatDiagnosticsSummaryTable(diagnostics) {
|
|
|
31677
31732
|
//#endregion
|
|
31678
31733
|
export { mapLearnosityToAst as C, DiagnosticCode as D, parseLearnosityItem as E, downgradeAssessmentTestToQti21 as S, sanitizeHtmlContent as T, md5hex as _, require_cli_table3 as a, serializeAssessmentItem as b, transformForwardAssetUrlsInXml as c, getAllPassageDataPaths as d, generateItemReference as f, serializeQtiAssetIdentity as g, selectQtiAssetFilename as h, chalk as i, convertQtiAssessmentItemToLearnosity as l, isSupportedQtiAssetPath as m, formatDiagnosticsSummaryTable as n, require_string_width as o, canonicalizeQtiAssetHref as p, formatDiagnosticsTable as r, writeDiagnostics as s, countErrors as t, parseMetadataTags as u, getAttr$3 as v, normalizeXhtmlVoidElements as w, escapeXml as x, require_saxes as y };
|
|
31679
31734
|
|
|
31680
|
-
//# sourceMappingURL=table-
|
|
31735
|
+
//# sourceMappingURL=table-DlY4LGmL.js.map
|