@learnosity/lib-qti-converter 0.12.4 → 0.12.6

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.
Files changed (30) hide show
  1. package/README.md +28 -3
  2. package/docs/EXAMPLES.md +47 -21
  3. package/docs/FAQ.md +11 -1
  4. package/docs/GETTING_STARTED.md +34 -18
  5. package/package.json +1 -1
  6. package/packages/cli/dist/{batchProcessors-C55IxXri.js → batchProcessors-C8k2v0o_.js} +3 -2
  7. package/packages/cli/dist/batchProcessors-C8k2v0o_.js.map +1 -0
  8. package/packages/cli/dist/batchWorker.js +1 -1
  9. package/packages/cli/dist/{learnosityToQti-B0PoimXr.js → learnosityToQti-CXDJoJpl.js} +6 -5
  10. package/packages/cli/dist/learnosityToQti-CXDJoJpl.js.map +1 -0
  11. package/packages/cli/dist/{learnosityToQtiPackage-Dwgys922.js → learnosityToQtiPackage-7v-s4ybk.js} +10 -6
  12. package/packages/cli/dist/learnosityToQtiPackage-7v-s4ybk.js.map +1 -0
  13. package/packages/cli/dist/main.js +4 -4
  14. package/packages/cli/dist/{pathUtils-CwZnJ55s.js → pathUtils-CgoDQyJk.js} +2 -1
  15. package/packages/cli/dist/pathUtils-CgoDQyJk.js.map +1 -0
  16. package/packages/cli/dist/{qtiPackageToLearnosity-HPtU5x5h.js → qtiPackageToLearnosity-hT4QZ7YX.js} +3 -3
  17. package/packages/cli/dist/{qtiPackageToLearnosity-HPtU5x5h.js.map → qtiPackageToLearnosity-hT4QZ7YX.js.map} +1 -1
  18. package/packages/cli/dist/{qtiToLearnosity-jiFTBiQU.js → qtiToLearnosity-BU7mHhIu.js} +3 -3
  19. package/packages/cli/dist/{qtiToLearnosity-jiFTBiQU.js.map → qtiToLearnosity-BU7mHhIu.js.map} +1 -1
  20. package/packages/cli/dist/{resolveOptions-gH_YAxxc.js → resolveOptions-ehwJSkQy.js} +121 -13
  21. package/packages/cli/dist/resolveOptions-ehwJSkQy.js.map +1 -0
  22. package/packages/core/dist/index.d.ts +30 -0
  23. package/packages/core/dist/index.js +155 -17
  24. package/packages/core/dist/node.d.ts +35 -0
  25. package/packages/core/dist/node.js +349 -22
  26. package/packages/cli/dist/batchProcessors-C55IxXri.js.map +0 -1
  27. package/packages/cli/dist/learnosityToQti-B0PoimXr.js.map +0 -1
  28. package/packages/cli/dist/learnosityToQtiPackage-Dwgys922.js.map +0 -1
  29. package/packages/cli/dist/pathUtils-CwZnJ55s.js.map +0 -1
  30. package/packages/cli/dist/resolveOptions-gH_YAxxc.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { createRequire as createRequire$1 } from "module";
3
- import { existsSync, readFileSync } from "fs";
3
+ import { closeSync, existsSync, openSync, readFileSync, readSync, realpathSync } from "fs";
4
4
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "path";
5
5
  import * as fs from "node:fs";
6
6
  import { existsSync as existsSync$1, readFileSync as readFileSync$1, readdirSync, statSync, writeFileSync } from "node:fs";
@@ -180,6 +180,7 @@ const DiagnosticCode = {
180
180
  QTI_PACKAGE_MULTIPLE_TESTS: "QTI_PACKAGE_MULTIPLE_TESTS",
181
181
  QTI_PACKAGE_NO_CONTENT: "QTI_PACKAGE_NO_CONTENT",
182
182
  QTI_PACKAGE_DUPLICATE_IDENTIFIER: "QTI_PACKAGE_DUPLICATE_IDENTIFIER",
183
+ QTI_ITEM_CONVERSION_FAILED: "QTI_ITEM_CONVERSION_FAILED",
183
184
  LRN_BUNDLE_WRITTEN: "LRN_BUNDLE_WRITTEN",
184
185
  QTI_DOWNGRADE_NAMESPACE: "QTI_DOWNGRADE_NAMESPACE",
185
186
  QTI_DOWNGRADE_SCHEMA_LOCATION: "QTI_DOWNGRADE_SCHEMA_LOCATION",
@@ -20450,7 +20451,7 @@ function buildAssessmentItemXml(ast, pretty, version) {
20450
20451
  itemBody: "",
20451
20452
  modalFeedback: []
20452
20453
  };
20453
- sections.stylesheets.push(`${indent}<stylesheet href="assets/css/lrn-normalize.css" type="text/css"/>${nl}`);
20454
+ sections.stylesheets.push(`${indent}<stylesheet href="./assets/css/lrn-normalize.css" type="text/css"/>${nl}`);
20454
20455
  if (ast.layout && ast.interactions) buildMultiWidgetItemSections(ast, diagnostics, sections, indent, indent2, indent3, nl);
20455
20456
  else if (!ast.layout && ast.interactions && ast.interactions.length > 1) buildSequentialInteractionsSections(ast, diagnostics, sections, indent, indent2, indent3, nl);
20456
20457
  else {
@@ -23137,7 +23138,7 @@ const MEDIA_SRC_PATTERN = /(<(?:img|audio|video|source)\s+[^>]*src=["'])([^"']+)
23137
23138
  * "images/photo.png" → "photo.png"
23138
23139
  * "/assets/video.mp4" → "video.mp4"
23139
23140
  */
23140
- function extractFilename(url) {
23141
+ function extractFilename$1(url) {
23141
23142
  const segments = url.split("?")[0].split("#")[0].split("/");
23142
23143
  return segments[segments.length - 1];
23143
23144
  }
@@ -23164,7 +23165,7 @@ function transformUrl(url, organisationId, mediaVault = false, customAssetUrl) {
23164
23165
  if (url.includes("assets.learnosity.com") || url.includes("media-vault.learnosity.com")) return url;
23165
23166
  if (url.match(/^https?:\/\//i)) return url;
23166
23167
  if (url.startsWith("data:")) return url;
23167
- const filename = extractFilename(url);
23168
+ const filename = extractFilename$1(url);
23168
23169
  if (!isSupportedAsset(filename)) return url;
23169
23170
  return buildLearnosityAssetUrl(filename, organisationId, mediaVault, customAssetUrl);
23170
23171
  }
@@ -24909,13 +24910,28 @@ function buildHotspotValidation(correctResponses, choiceIdToIndex) {
24909
24910
  /**
24910
24911
  * Convert hotspotInteraction to Learnosity hotspot
24911
24912
  */
24912
- function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
24913
+ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
24913
24914
  const parsed = readAssessmentItemHotspot(inputXml);
24914
24915
  const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
24915
24916
  diagnostics.push(...updatedDiagnostics);
24916
24917
  if (hasErrors(diagnostics)) return { diagnostics };
24917
- if (!parsed.identifier || !parsed.responseIdentifier || !parsed.imageSource || !parsed.imageWidth || !parsed.imageHeight) return { diagnostics };
24918
+ if (!parsed.identifier || !parsed.responseIdentifier || !parsed.imageSource) return { diagnostics };
24918
24919
  if (parsed.hotspotChoices.length === 0) return { diagnostics };
24920
+ if (!parsed.imageWidth || !parsed.imageHeight) {
24921
+ const resolved = fileAccess?.resolveImageDimensions?.(parsed.imageSource, sourceFile, packageRoot);
24922
+ if (resolved) {
24923
+ parsed.imageWidth = parsed.imageWidth || resolved.width;
24924
+ parsed.imageHeight = parsed.imageHeight || resolved.height;
24925
+ } else {
24926
+ diagnostics.push({
24927
+ code: DiagnosticCode.LRN_MISSING_REQUIRED_FIELD,
24928
+ level: "error",
24929
+ file: sourceFile ?? "hotspotInteraction",
24930
+ message: `hotspotInteraction image "${parsed.imageSource}" is missing width/height attributes and its dimensions could not be determined from the image file. Hotspot coordinate conversion requires image dimensions.`
24931
+ });
24932
+ return { diagnostics };
24933
+ }
24934
+ }
24919
24935
  const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
24920
24936
  const questionRef = md5hex(itemRef);
24921
24937
  const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl);
@@ -28020,6 +28036,7 @@ function computeClosingTags(html) {
28020
28036
  */
28021
28037
  function getConverterMap() {
28022
28038
  const wrapSourceFirst = (fn) => (xml, diag, tags, orgId, sf, mv, cau, irs, stimuli) => fn(xml, diag, tags, sf, orgId, mv, cau, irs, stimuli);
28039
+ const hotspotConverter = (xml, diag, tags, orgId, sf, mv, cau, irs, _stimuli, fileAccess, packageRoot) => convertHotspotToLearnosity(xml, diag, tags, orgId, sf, mv, cau, irs, fileAccess, packageRoot);
28023
28040
  return {
28024
28041
  choiceInteraction: wrapSourceFirst(convertMcqToLearnosity),
28025
28042
  textEntryInteraction: wrapSourceFirst(convertTextEntryToLearnosity),
@@ -28028,7 +28045,7 @@ function getConverterMap() {
28028
28045
  gapMatchInteraction: convertGapMatchToLearnosity,
28029
28046
  inlineChoiceInteraction: convertInlineChoiceToLearnosity,
28030
28047
  orderInteraction: convertOrderToLearnosity,
28031
- hotspotInteraction: convertHotspotToLearnosity,
28048
+ hotspotInteraction: hotspotConverter,
28032
28049
  hottextInteraction: convertHottextToLearnosity,
28033
28050
  graphicGapMatchInteraction: convertGraphicGapMatchToLearnosity,
28034
28051
  drawingInteraction: convertDrawingToLearnosity,
@@ -28042,7 +28059,7 @@ const CONVERTER_MAP = getConverterMap();
28042
28059
  * Strategy: Call each individual converter for its interaction type,
28043
28060
  * then combine all questions and widgets into a single composite item
28044
28061
  */
28045
- function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess) {
28062
+ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
28046
28063
  const metadata = extractItemMetadata(inputXml);
28047
28064
  const { segments } = segmentItemBodyByInteractions(inputXml);
28048
28065
  const stimuliByType = /* @__PURE__ */ new Map();
@@ -28259,7 +28276,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
28259
28276
  continue;
28260
28277
  }
28261
28278
  const converter = CONVERTER_MAP[group.type];
28262
- if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli), subDiagnostics);
28279
+ if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli, fileAccess, packageRoot), subDiagnostics);
28263
28280
  }
28264
28281
  if (allQuestions.length === 0) {
28265
28282
  diagnostics.push({
@@ -28896,7 +28913,7 @@ const SINGLE_INTERACTION_CONVERTERS = /* @__PURE__ */ new Map([
28896
28913
  ["matchInteraction", (xml, diag, lom, opts) => convertMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
28897
28914
  ["gapMatchInteraction", (xml, diag, lom, opts) => convertGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
28898
28915
  ["orderInteraction", (xml, diag, lom, opts) => convertOrderToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
28899
- ["hotspotInteraction", (xml, diag, lom, opts) => convertHotspotToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
28916
+ ["hotspotInteraction", (xml, diag, lom, opts) => convertHotspotToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot)],
28900
28917
  ["hottextInteraction", (xml, diag, lom, opts) => convertHottextToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
28901
28918
  ["graphicGapMatchInteraction", (xml, diag, lom, opts) => convertGraphicGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
28902
28919
  ["drawingInteraction", (xml, diag, lom, opts) => convertDrawingToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
@@ -29024,7 +29041,7 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
29024
29041
  const { counts, allInteractions } = countAllInteractions(inputXml);
29025
29042
  const presentTypes = INTERACTION_NAMES.filter((name) => counts[name] > 0);
29026
29043
  if (presentTypes.reduce((sum, name) => sum + counts[name], 0) === 0) return handleNoInteractions(inputXml, diagnostics, allInteractions, lomTags, opts);
29027
- if (presentTypes.length > 1) return convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess);
29044
+ if (presentTypes.length > 1) return convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot);
29028
29045
  return dispatchSingleInteractionConverter(presentTypes[0], inputXml, counts[presentTypes[0]], diagnostics, lomTags, opts);
29029
29046
  } catch (error) {
29030
29047
  diagnostics.push({
@@ -29037,6 +29054,97 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
29037
29054
  }
29038
29055
  }
29039
29056
  //#endregion
29057
+ //#region src/learnosity-mapper/forwardAssetUrlTransform.ts
29058
+ /**
29059
+ * Forward-direction (Learnosity → QTI) asset URL transformation.
29060
+ *
29061
+ * Learnosity item/stimulus content references assets using Learnosity's own
29062
+ * path convention (for example `/vendor/learnosity/itembank/assets/<hash>_<name>.mp3`).
29063
+ * When converting to a QTI Content Package, those references must point at the
29064
+ * assets that ship inside the package.
29065
+ *
29066
+ * This module rewrites the *prefix* of an asset reference while preserving the
29067
+ * final path segment (the filename), mirroring the reverse-direction helper in
29068
+ * `qti-to-learnosity/utils/assetUrlTransform.ts`.
29069
+ *
29070
+ * Rules:
29071
+ * - Default prefix is `./assets/` so a reference resolves to `./assets/<filename>`.
29072
+ * - A caller-supplied `customAssetUrl` replaces the entire prefix up to the
29073
+ * filename, e.g. `https://cdn.example.com/media` → `https://cdn.example.com/media/<filename>`.
29074
+ * - Remote (`http(s)://`), protocol-relative (`//`) and `data:` URIs are left
29075
+ * untouched.
29076
+ * - References that already point at internal package paths (`assets/`,
29077
+ * `./assets/`, `stimuli/`, `items/`, or a relative `../` path) are left
29078
+ * untouched so we never rewrite converter-generated internal references
29079
+ * (e.g. `assets/gapimgs/...`, `assets/css/lrn-normalize.css`).
29080
+ */
29081
+ /** Default output prefix applied when no `customAssetUrl` is provided. */
29082
+ const DEFAULT_FORWARD_ASSET_PREFIX = "./assets";
29083
+ /**
29084
+ * Extract the filename (last path segment) from a URL/path, ignoring any query
29085
+ * string or hash fragment.
29086
+ *
29087
+ * Examples:
29088
+ * "/vendor/learnosity/itembank/assets/hash_name.mp3" → "hash_name.mp3"
29089
+ * "images/photo.png?v=2" → "photo.png"
29090
+ */
29091
+ function extractFilename(url) {
29092
+ const segments = url.split("?")[0].split("#")[0].split("/");
29093
+ return segments[segments.length - 1];
29094
+ }
29095
+ /**
29096
+ * Determine whether a reference is one we should leave untouched (remote/data
29097
+ * URIs and converter-generated internal package paths).
29098
+ */
29099
+ function isNonRewritableReference(url) {
29100
+ const trimmed = url.trim();
29101
+ if (trimmed === "") return true;
29102
+ if (/^https?:\/\//i.test(trimmed) || trimmed.startsWith("//") || trimmed.startsWith("data:")) return true;
29103
+ if (trimmed.startsWith("assets/") || trimmed.startsWith("./assets/") || trimmed.startsWith("stimuli/") || trimmed.startsWith("items/") || trimmed.startsWith("tests/") || trimmed.startsWith("../")) return true;
29104
+ return false;
29105
+ }
29106
+ /**
29107
+ * Build the output base prefix (without a trailing slash).
29108
+ */
29109
+ function resolveBasePrefix(customAssetUrl) {
29110
+ const base = customAssetUrl && customAssetUrl.trim() !== "" ? customAssetUrl.trim() : DEFAULT_FORWARD_ASSET_PREFIX;
29111
+ return base.endsWith("/") ? base.slice(0, -1) : base;
29112
+ }
29113
+ /**
29114
+ * Rewrite a single asset reference to the forward-direction package prefix.
29115
+ *
29116
+ * @param url - The incoming Learnosity asset reference.
29117
+ * @param customAssetUrl - Optional base URL/prefix that replaces everything up
29118
+ * to the filename. Defaults to `./assets`.
29119
+ * @returns The rewritten reference, or the original string when it should not
29120
+ * be rewritten.
29121
+ */
29122
+ function transformForwardAssetUrl(url, customAssetUrl) {
29123
+ if (isNonRewritableReference(url)) return url;
29124
+ const filename = extractFilename(url);
29125
+ if (filename === "") return url;
29126
+ return `${resolveBasePrefix(customAssetUrl)}/${filename}`;
29127
+ }
29128
+ /**
29129
+ * Rewrite every asset reference found in a fragment of QTI XML / XHTML.
29130
+ *
29131
+ * Handles the attributes used by the forward serializers and mappers:
29132
+ * - `src="..."` (img, qh5:source, qh5:track, audio/video source)
29133
+ * - `data="..."` (object elements, e.g. media fallbacks, image backgrounds)
29134
+ * - `href="..."` (download fallback anchors for media)
29135
+ *
29136
+ * Internal references (`stimuli/...`, `assets/...`, the CSS stylesheet, gap
29137
+ * images, etc.) are preserved by {@link transformForwardAssetUrl}.
29138
+ */
29139
+ function transformForwardAssetUrlsInXml(xml, customAssetUrl) {
29140
+ if (!xml) return xml;
29141
+ return xml.replace(/\b(src|data|href)=("|')([^"']*)\2/gi, (match, attr, quote, value) => {
29142
+ const rewritten = transformForwardAssetUrl(value, customAssetUrl);
29143
+ if (rewritten === value) return match;
29144
+ return `${attr}=${quote}${rewritten}${quote}`;
29145
+ });
29146
+ }
29147
+ //#endregion
29040
29148
  //#region src/conversions.ts
29041
29149
  /**
29042
29150
  * Convert QTI XML to Learnosity JSON.
@@ -29103,8 +29211,9 @@ function convertLearnosityToQti(input, opts) {
29103
29211
  output: "",
29104
29212
  diagnostics: allDiagnostics
29105
29213
  });
29214
+ const output = transformForwardAssetUrlsInXml(serializeResult.xml, opts.customAssetUrl);
29106
29215
  return Promise.resolve({
29107
- output: serializeResult.xml,
29216
+ output,
29108
29217
  diagnostics: allDiagnostics
29109
29218
  });
29110
29219
  }
@@ -29770,6 +29879,7 @@ function convertActivity(bundle, activityRef, options = {}) {
29770
29879
  const stimuliByRef = /* @__PURE__ */ new Map();
29771
29880
  const pretty = options.pretty ?? false;
29772
29881
  const version = options.version ?? "2.2";
29882
+ const customAssetUrl = options.customAssetUrl;
29773
29883
  const itemRefs = bundle.activityItemRefs.get(activityRef);
29774
29884
  if (!itemRefs) {
29775
29885
  diagnostics.push({
@@ -29804,7 +29914,7 @@ function convertActivity(bundle, activityRef, options = {}) {
29804
29914
  diagnostics.push(...itemDiagnostics);
29805
29915
  if (parseResult.diagnostics.some((d) => d.code === DiagnosticCode.LRN_UNSUPPORTED_QUESTION_TYPE)) continue;
29806
29916
  if (!parseResult.model) continue;
29807
- collectStimuliFromFeatures(parseResult.model.features, stimuliByRef, stimuli, diagnostics);
29917
+ collectStimuliFromFeatures(parseResult.model.features, stimuliByRef, stimuli, diagnostics, customAssetUrl);
29808
29918
  const mapResult = mapLearnosityToAst(parseResult.model);
29809
29919
  const mapDiagnostics = mapResult.diagnostics.map((d) => ({
29810
29920
  ...d,
@@ -29823,7 +29933,7 @@ function convertActivity(bundle, activityRef, options = {}) {
29823
29933
  diagnostics.push(...serializeDiagnostics);
29824
29934
  if (serializeResult.xml) items.push({
29825
29935
  reference: itemRef,
29826
- xml: serializeResult.xml,
29936
+ xml: transformForwardAssetUrlsInXml(serializeResult.xml, customAssetUrl),
29827
29937
  ast: mapResult.ast,
29828
29938
  diagnostics: [
29829
29939
  ...parseResult.diagnostics,
@@ -29888,7 +29998,7 @@ function convertActivity(bundle, activityRef, options = {}) {
29888
29998
  /**
29889
29999
  * Collect sharedpassage features and convert them to stimulus entries (deduplicated)
29890
30000
  */
29891
- function collectStimuliFromFeatures(features, stimuliByRef, stimuli, diagnostics) {
30001
+ function collectStimuliFromFeatures(features, stimuliByRef, stimuli, diagnostics, customAssetUrl) {
29892
30002
  for (const feature of features) {
29893
30003
  if (feature.type !== "sharedpassage" || !feature.data || typeof feature.data !== "object" || !("type" in feature.data)) continue;
29894
30004
  if (stimuliByRef.has(feature.reference)) continue;
@@ -29896,7 +30006,7 @@ function collectStimuliFromFeatures(features, stimuliByRef, stimuli, diagnostics
29896
30006
  if (stimulusAst) {
29897
30007
  const stimulusEntry = {
29898
30008
  reference: feature.reference,
29899
- xml: serializeAssessmentStimulusAsHtml(stimulusAst)
30009
+ xml: transformForwardAssetUrlsInXml(serializeAssessmentStimulusAsHtml(stimulusAst), customAssetUrl)
29900
30010
  };
29901
30011
  stimuliByRef.set(feature.reference, stimulusEntry);
29902
30012
  stimuli.push(stimulusEntry);
@@ -31295,6 +31405,30 @@ function posixJoin(dir, rel) {
31295
31405
  return `${dir.replace(/\/+$/, "")}/${rel.replace(/^\.?\//, "")}`;
31296
31406
  }
31297
31407
  /**
31408
+ * Guarantee that a failed item conversion is represented by at least one
31409
+ * error-level diagnostic keyed to the item's href.
31410
+ *
31411
+ * Some converters can return without an item AND without pushing an error
31412
+ * (silent early-returns), which previously left the diagnostics report showing a
31413
+ * non-zero failed count with an empty errors array. When the per-item result
31414
+ * carried no error, this appends a synthetic {@link DiagnosticCode.QTI_ITEM_CONVERSION_FAILED}
31415
+ * so the failed count and the errors list can never diverge.
31416
+ *
31417
+ * @param itemDiagnostics - diagnostics produced for the single failed item
31418
+ * @param href - the item's manifest href (used as the diagnostic `file`)
31419
+ * @returns the diagnostics to append (either empty, when a real error already
31420
+ * exists, or a one-element array with the synthetic fallback)
31421
+ */
31422
+ function ensureFailedItemDiagnostic(itemDiagnostics, href) {
31423
+ if (itemDiagnostics.some((d) => d.level === "error")) return [];
31424
+ return [{
31425
+ code: DiagnosticCode.QTI_ITEM_CONVERSION_FAILED,
31426
+ level: "error",
31427
+ file: href,
31428
+ message: `Item conversion failed for "${href}" but produced no specific error diagnostic. The item may use an unsupported interaction or be missing required data.`
31429
+ }];
31430
+ }
31431
+ /**
31298
31432
  * Normalize a forward-slash relative path (collapse `.`/`//`, resolve `..`).
31299
31433
  * Pure replacement for `node:path`'s `normalize(...).split(sep).join('/')` on
31300
31434
  * the forward-slash paths used as entry keys.
@@ -31520,7 +31654,8 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
31520
31654
  mediaVault: opts?.mediaVault,
31521
31655
  customAssetUrl: opts?.customAssetUrl,
31522
31656
  itemReferenceSource: opts?.itemReferenceSource,
31523
- fileAccess: opts?.fileAccess
31657
+ fileAccess: opts?.fileAccess,
31658
+ packageRoot: opts?.sourceDir
31524
31659
  });
31525
31660
  diagnostics.push(...itemResult.diagnostics);
31526
31661
  if (itemResult.item) {
@@ -31570,7 +31705,10 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
31570
31705
  if (!qtiRefToMd5Refs.has(itemResource.identifier)) qtiRefToMd5Refs.set(itemResource.identifier, []);
31571
31706
  qtiRefToMd5Refs.get(itemResource.identifier)?.push(md5Ref);
31572
31707
  convertedSourceFiles.push(itemResource.href);
31573
- } else failedSourceFiles.push(itemResource.href);
31708
+ } else {
31709
+ failedSourceFiles.push(itemResource.href);
31710
+ diagnostics.push(...ensureFailedItemDiagnostic(itemResult.diagnostics, itemResource.href));
31711
+ }
31574
31712
  }
31575
31713
  if (items.size === 0 && itemResourcesToConvert.length > 0) {
31576
31714
  diagnostics.push({
@@ -31753,7 +31891,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
31753
31891
  * @param root - Directory the path must stay within
31754
31892
  * @returns Absolute path if contained by root, undefined otherwise
31755
31893
  */
31756
- function containedPath(candidate, root) {
31894
+ function containedPath$1(candidate, root) {
31757
31895
  const resolvedRoot = resolve(root);
31758
31896
  const resolvedCandidate = resolve(candidate);
31759
31897
  const rel = relative(resolvedRoot, resolvedCandidate);
@@ -31778,7 +31916,7 @@ function resolvePassageFile(objectDataPath, sourceFile) {
31778
31916
  candidates.push(join(root, objectDataPath));
31779
31917
  }
31780
31918
  for (const candidate of candidates) {
31781
- const passagePath = containedPath(candidate, root);
31919
+ const passagePath = containedPath$1(candidate, root);
31782
31920
  if (!passagePath || !existsSync(passagePath)) continue;
31783
31921
  try {
31784
31922
  return readFileSync(passagePath, "utf-8").replace(/^\uFEFF/, "");
@@ -31829,10 +31967,198 @@ function findAndReadLomFile(itemPath) {
31829
31967
  }
31830
31968
  }
31831
31969
  //#endregion
31970
+ //#region src/qti-to-learnosity/utils/imageDimensions.ts
31971
+ /**
31972
+ * Image dimension resolver
31973
+ *
31974
+ * Resolves an image file referenced by a QTI `<object data="...">` /
31975
+ * `<img src="...">` tag and reads its intrinsic pixel dimensions directly from
31976
+ * the file header. This is a dependency-free reader for the formats commonly
31977
+ * found in QTI packages (GIF, PNG, JPEG). It reads only the small header region
31978
+ * needed to determine dimensions, not the whole file.
31979
+ *
31980
+ * QTI legitimately allows an `<object>` without width/height attributes, but
31981
+ * some Learnosity question types (e.g. hotspot) need pixel dimensions to convert
31982
+ * absolute coordinates into percentages. When the markup omits them, the
31983
+ * dimensions are recovered from the referenced image file.
31984
+ */
31985
+ /**
31986
+ * Only the leading bytes of an image are needed to read its dimensions: GIF and
31987
+ * PNG carry them in the first ~24 bytes, and a JPEG's first Start-Of-Frame
31988
+ * marker is virtually always within the first segments. Cap the read so a huge
31989
+ * asset can never be loaded whole into memory.
31990
+ */
31991
+ const MAX_HEADER_BYTES = 65536;
31992
+ /**
31993
+ * Check that `resolvedCandidate` stays lexically inside `resolvedRoot`.
31994
+ *
31995
+ * Both arguments must already be absolute/normalised. Returns true when the
31996
+ * candidate is contained (and is not the root itself).
31997
+ */
31998
+ function isContained(resolvedCandidate, resolvedRoot) {
31999
+ const rel = relative(resolvedRoot, resolvedCandidate);
32000
+ return rel !== "" && !isAbsolute(rel) && rel.split(sep)[0] !== "..";
32001
+ }
32002
+ /**
32003
+ * Resolve `candidate` and confirm it stays inside `root`, both lexically and
32004
+ * after dereferencing symlinks.
32005
+ *
32006
+ * The `data`/`src` attribute comes from the QTI file being converted, which is
32007
+ * untrusted input. A lexical check alone is insufficient: a package could place
32008
+ * a symlink under `root` that targets a file outside it (e.g. `/dev/zero`), so
32009
+ * the real path is re-verified against the real root before it is returned for
32010
+ * reading.
32011
+ *
32012
+ * @returns The real (symlink-dereferenced) absolute path if contained, else undefined.
32013
+ */
32014
+ function containedPath(candidate, root) {
32015
+ const resolvedRoot = resolve(root);
32016
+ const resolvedCandidate = resolve(candidate);
32017
+ if (!isContained(resolvedCandidate, resolvedRoot)) return;
32018
+ if (!existsSync(resolvedCandidate)) return;
32019
+ let realCandidate;
32020
+ let realRoot;
32021
+ try {
32022
+ realCandidate = realpathSync(resolvedCandidate);
32023
+ realRoot = realpathSync(resolvedRoot);
32024
+ } catch {
32025
+ return;
32026
+ }
32027
+ if (!isContained(realCandidate, realRoot)) return;
32028
+ return realCandidate;
32029
+ }
32030
+ /**
32031
+ * Read up to {@link MAX_HEADER_BYTES} from the start of a file without loading
32032
+ * the whole file into memory. Returns the bytes actually read.
32033
+ */
32034
+ function readHeaderBytes(path) {
32035
+ let fd;
32036
+ try {
32037
+ fd = openSync(path, "r");
32038
+ const buf = Buffer.alloc(MAX_HEADER_BYTES);
32039
+ const bytesRead = readSync(fd, buf, 0, MAX_HEADER_BYTES, 0);
32040
+ return buf.subarray(0, bytesRead);
32041
+ } catch {
32042
+ return;
32043
+ } finally {
32044
+ if (fd !== void 0) try {
32045
+ closeSync(fd);
32046
+ } catch {}
32047
+ }
32048
+ }
32049
+ /**
32050
+ * Read image dimensions from an in-memory file header buffer.
32051
+ * Exported for unit testing without touching the filesystem.
32052
+ *
32053
+ * Supports GIF (87a/89a), PNG, and JPEG (baseline and progressive).
32054
+ *
32055
+ * @param buf - The image file bytes (at least the header region)
32056
+ * @returns The pixel dimensions, or undefined if the format is unrecognised
32057
+ */
32058
+ function readImageDimensionsFromBuffer(buf) {
32059
+ if (buf.length >= 10 && buf[0] === 71 && buf[1] === 73 && buf[2] === 70) {
32060
+ const width = buf.readUInt16LE(6);
32061
+ const height = buf.readUInt16LE(8);
32062
+ if (width > 0 && height > 0) return {
32063
+ width,
32064
+ height
32065
+ };
32066
+ return;
32067
+ }
32068
+ if (buf.length >= 24 && buf[0] === 137 && buf[1] === 80 && buf[2] === 78 && buf[3] === 71) {
32069
+ const width = buf.readUInt32BE(16);
32070
+ const height = buf.readUInt32BE(20);
32071
+ if (width > 0 && height > 0) return {
32072
+ width,
32073
+ height
32074
+ };
32075
+ return;
32076
+ }
32077
+ if (buf.length >= 4 && buf[0] === 255 && buf[1] === 216) {
32078
+ let offset = 2;
32079
+ while (offset + 9 < buf.length) {
32080
+ if (buf[offset] !== 255) {
32081
+ offset++;
32082
+ continue;
32083
+ }
32084
+ let markerOffset = offset;
32085
+ while (markerOffset < buf.length && buf[markerOffset] === 255) markerOffset++;
32086
+ if (markerOffset >= buf.length) break;
32087
+ const marker = buf[markerOffset];
32088
+ const segmentStart = markerOffset + 1;
32089
+ if (marker === 0) {
32090
+ offset = segmentStart;
32091
+ continue;
32092
+ }
32093
+ if (marker === 216 || marker === 217 || marker >= 208 && marker <= 215) {
32094
+ offset = segmentStart;
32095
+ continue;
32096
+ }
32097
+ if (segmentStart + 1 >= buf.length) break;
32098
+ const segmentLength = buf.readUInt16BE(segmentStart);
32099
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
32100
+ if (segmentStart + 6 >= buf.length) break;
32101
+ const height = buf.readUInt16BE(segmentStart + 3);
32102
+ const width = buf.readUInt16BE(segmentStart + 5);
32103
+ if (width > 0 && height > 0) return {
32104
+ width,
32105
+ height
32106
+ };
32107
+ return;
32108
+ }
32109
+ offset = segmentStart + segmentLength;
32110
+ }
32111
+ }
32112
+ }
32113
+ /**
32114
+ * Resolve and read the intrinsic dimensions of an image referenced by a QTI
32115
+ * `<object>`/`<img>` tag.
32116
+ *
32117
+ * Security model: the `objectDataPath` comes from untrusted QTI markup, so every
32118
+ * resolved path is confined to a containment root before it is read.
32119
+ *
32120
+ * - When `packageRoot` is supplied (the normal case for package conversion), any
32121
+ * asset located anywhere inside the package is allowed — including assets a
32122
+ * sibling directory up, e.g. `questions/item.xml` referencing
32123
+ * `../images/foo.png`. This does not rely on directory names.
32124
+ * - When `packageRoot` is omitted (in-memory callers with no package context),
32125
+ * the read is confined to the source file's own directory. This is the safe
32126
+ * default: no path is read from outside where the item lives.
32127
+ *
32128
+ * @param objectDataPath - Path from the data/src attribute (e.g. "754493.gif")
32129
+ * @param sourceFile - Absolute path to the source QTI XML file
32130
+ * @param packageRoot - Absolute path to the package root that bounds all reads
32131
+ * @returns The image dimensions, or undefined if it cannot be resolved/read.
32132
+ */
32133
+ function resolveImageDimensions(objectDataPath, sourceFile, packageRoot) {
32134
+ if (!sourceFile || !objectDataPath) return;
32135
+ const sourceDir = dirname(sourceFile);
32136
+ let root = sourceDir;
32137
+ if (packageRoot) {
32138
+ const resolvedRoot = resolve(packageRoot);
32139
+ const resolvedSourceDir = resolve(sourceDir);
32140
+ const rel = relative(resolvedRoot, resolvedSourceDir);
32141
+ root = rel === "" || !isAbsolute(rel) && rel.split(sep)[0] !== ".." ? resolvedRoot : resolvedSourceDir;
32142
+ }
32143
+ const candidates = [];
32144
+ if (isAbsolute(objectDataPath)) candidates.push(objectDataPath);
32145
+ else {
32146
+ candidates.push(join(sourceDir, objectDataPath));
32147
+ if (resolve(root) !== resolve(sourceDir)) candidates.push(join(root, objectDataPath));
32148
+ }
32149
+ for (const candidate of candidates) {
32150
+ const imagePath = containedPath(candidate, root);
32151
+ if (!imagePath) continue;
32152
+ const buf = readHeaderBytes(imagePath);
32153
+ if (buf) return readImageDimensionsFromBuffer(buf);
32154
+ }
32155
+ }
32156
+ //#endregion
31832
32157
  //#region src/qti-to-learnosity/nodeFileAccess.ts
31833
32158
  const nodeFileAccess = {
31834
32159
  resolvePassageFile,
31835
- findAndReadLomFile
32160
+ findAndReadLomFile,
32161
+ resolveImageDimensions
31836
32162
  };
31837
32163
  //#endregion
31838
32164
  //#region src/qti-package/readZip.ts
@@ -32979,7 +33305,8 @@ function convertLearnosityToQtiPackage(opts) {
32979
33305
  for (const activityRef of activityRefs) {
32980
33306
  const conversion = convertActivity(bundle, activityRef, {
32981
33307
  pretty: opts.pretty,
32982
- version: qtiVersion
33308
+ version: qtiVersion,
33309
+ customAssetUrl: opts.customAssetUrl
32983
33310
  });
32984
33311
  allDiagnostics.push(...conversion.diagnostics);
32985
33312
  if (conversion.items.length === 0 && !conversion.testXml) continue;
@@ -1 +0,0 @@
1
- {"version":3,"file":"batchProcessors-C55IxXri.js","names":[],"sources":["../src/utils/batchProcessors.ts"],"sourcesContent":["/**\n * Per-package conversion tasks, shared by the serial batch path\n * (`processBatch`) and the parallel worker path (`processBatchParallel` via\n * `batchWorker`). Extracting them here keeps a single implementation per\n * direction — the same code runs inline or inside a worker thread.\n */\n\nimport {\n loadPackageDirectory,\n convertQtiPackageToLearnosityBundle,\n writeLearnosityBundle,\n loadLearnosityBundle,\n convertActivity,\n buildPackageFromActivity,\n mergeActivityPackage,\n sanitizeFolderName,\n ensureUniqueFolderName,\n saveQtiContentPackage,\n nodeFileAccess,\n type Diagnostic,\n type ItemFilenameSource,\n type ItemReferenceSource,\n type LearnosityBundleModel,\n type QtiContentPackage,\n} from '@learnosity/converter-core/node';\nimport type { DetectedPackage } from './packageScanner.js';\nimport { writeDiagnostics } from '../io/writeDiagnostics.js';\nimport { formatDiagnosticsSummaryTable } from '../ux/table.js';\n\n/** Options accepted by the per-package processors (subset of resolved CLI options). */\nexport interface BatchPackageOptions {\n organisationId?: number;\n mediaVault?: boolean;\n customAssetUrl?: string;\n itemReferenceSource?: ItemReferenceSource;\n itemFilenameSource?: ItemFilenameSource;\n truncateTags?: boolean;\n version?: string;\n pretty?: boolean;\n qtiVersion?: '2.1' | '2.2';\n}\n\n/** Result of processing one package (matches PackageProcessor's return shape). */\nexport interface PackageResult {\n success: boolean;\n errorCount: number;\n warningCount: number;\n convertedItemCount?: number;\n failedItemCount?: number;\n message?: string;\n}\n\n/** A single package conversion task dispatched to a worker. */\nexport interface BatchTask {\n direction: 'qti-to-learnosity' | 'learnosity-to-qti';\n pkg: DetectedPackage;\n packageOutputPath: string;\n options: BatchPackageOptions;\n}\n\n/** Run one batch task in-process (used by the worker and directly in tests). */\nexport async function runBatchTask(task: BatchTask, quiet = true): Promise<PackageResult> {\n if (task.direction === 'qti-to-learnosity') {\n return processQtiPackageToLearnosity(task.pkg, task.packageOutputPath, task.options, quiet);\n }\n\n return processLearnosityToQtiPackage(task.pkg, task.packageOutputPath, task.options, quiet);\n}\n\nfunction displayDiagnosticsSummary(diagnostics: Diagnostic[], quiet: boolean): void {\n if (quiet) {\n return;\n }\n\n const summaryTable = formatDiagnosticsSummaryTable(diagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n}\n\n/** Convert one QTI Content Package directory to a Learnosity bundle on disk. */\nexport async function processQtiPackageToLearnosity(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Convert the package\n const loaded = loadPackageDirectory(pkg.path);\n const convertResult = loaded.entries\n ? convertQtiPackageToLearnosityBundle(\n { entries: loaded.entries },\n {\n organisationId: options.organisationId,\n mediaVault: options.mediaVault,\n customAssetUrl: options.customAssetUrl,\n itemReferenceSource: options.itemReferenceSource,\n itemFilenameSource: options.itemFilenameSource,\n truncateTags: options.truncateTags,\n packageVersion: options.version,\n sourceDir: pkg.path,\n fileAccess: nodeFileAccess,\n }\n )\n : { diagnostics: loaded.diagnostics };\n\n const errors = convertResult.diagnostics.filter((d) => d.level === 'error');\n const warnings = convertResult.diagnostics.filter((d) => d.level === 'warning');\n const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;\n\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n\n // Count items that have error-level diagnostics (includes both\n // completely failed items and items that converted with errors)\n const filesWithErrors = new Set<string>();\n\n for (const d of convertResult.diagnostics) {\n if (d.level === 'error' && d.file) {\n filesWithErrors.add(d.file);\n }\n }\n\n const convertedWithErrors = convertedFiles.filter((f) => filesWithErrors.has(f)).length;\n const erroredItemCount = failedFiles.length + convertedWithErrors;\n const cleanItemCount = convertedFiles.length - convertedWithErrors;\n\n if (errors.length > 0 && !hasValidBundle) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Conversion failed',\n };\n }\n\n // Write the bundle\n const writeResult = await writeLearnosityBundle(convertResult.bundle!, {\n outDir: packageOutputPath,\n isZipOutput: false,\n });\n\n const writeErrors = writeResult.diagnostics.filter((d) => d.level === 'error');\n\n if (writeErrors.length > 0) {\n return {\n success: false,\n errorCount: errors.length + writeErrors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Write failed',\n };\n }\n\n // In batch mode, always write diagnostics.json to each package directory\n const diagnosticsPath = `${packageOutputPath}/diagnostics.json`;\n const allDiagnostics = [...convertResult.diagnostics, ...writeResult.diagnostics];\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n\n await writeDiagnostics(allDiagnostics, 'file', diagnosticsPath, packageOutputPath, false, {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: convertedFiles.length + failedFiles.length,\n totalActivitiesFound: convertedActivityFiles.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n });\n\n // Show condensed diagnostics summary\n if (!quiet) {\n const summaryTable = formatDiagnosticsSummaryTable(allDiagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n }\n\n return {\n success: true,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n };\n}\n\n/** Convert one Learnosity bundle directory to a QTI Content Package on disk. */\nexport async function processLearnosityToQtiPackage(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Load the bundle\n const loadResult = loadLearnosityBundle(pkg.path);\n\n if (!loadResult.bundle) {\n const errorCount = loadResult.diagnostics.filter((d) => d.level === 'error').length;\n\n displayDiagnosticsSummary(loadResult.diagnostics, quiet);\n\n return {\n success: false,\n errorCount,\n warningCount: 0,\n message: 'Bundle load error',\n };\n }\n\n const bundle = loadResult.bundle;\n const allDiagnostics: Diagnostic[] = [...loadResult.diagnostics];\n\n // Convert all activities in the bundle\n const allConvertedActivities: {\n activityRef: string;\n folderName: string;\n conversion: ReturnType<typeof convertActivity>;\n }[] = [];\n\n // Folder names for tests/<folderName>/assessmentTest.xml must be unique per package\n const usedFolderNames = new Set<string>();\n\n // Track item outcomes for the diagnostics report. Items shared by several\n // activities are counted once, hence the sets.\n const convertedItemRefs = new Set<string>();\n const failedItemRefs = new Set<string>();\n\n for (const activityRef of bundle.activityRefs) {\n const convertResult = convertActivity(bundle, activityRef, {\n pretty: options.pretty,\n version: options.qtiVersion,\n });\n\n allDiagnostics.push(...convertResult.diagnostics);\n\n const itemRefs = bundle.activityItemRefs.get(activityRef) ?? [];\n const successfulItemRefs = new Set(convertResult.items.map((item) => item.reference));\n\n for (const itemRef of itemRefs) {\n if (successfulItemRefs.has(itemRef)) {\n convertedItemRefs.add(itemRef);\n } else {\n failedItemRefs.add(itemRef);\n }\n }\n\n if (convertResult.items.length > 0) {\n const sanitizedName = sanitizeFolderName(\n activityRef,\n `activity_${allConvertedActivities.length + 1}`\n );\n const folderName = ensureUniqueFolderName(sanitizedName, usedFolderNames);\n\n allConvertedActivities.push({ activityRef, folderName, conversion: convertResult });\n }\n }\n\n // An item that converted in one activity is not a failure elsewhere.\n for (const itemRef of convertedItemRefs) {\n failedItemRefs.delete(itemRef);\n }\n\n const convertedFiles = itemRefsToFilenames(bundle, convertedItemRefs);\n const failedFiles = itemRefsToFilenames(bundle, failedItemRefs);\n const convertedActivityFiles = allConvertedActivities.map(\n ({ activityRef }) => `activities/${activityRef}.json`\n );\n const failedActivityFiles = bundle.activityRefs\n .filter((ref) => !allConvertedActivities.some((a) => a.activityRef === ref))\n .map((ref) => `activities/${ref}.json`);\n const totalItemsConverted = convertedItemRefs.size;\n const totalItemsFailed = failedItemRefs.size;\n\n // In batch mode, always write diagnostics.json to each package directory,\n // including when the package fails, so the report explains what happened.\n // Reads allDiagnostics when called, so later diagnostics are included.\n const writePackageDiagnostics = () =>\n writeDiagnostics(\n allDiagnostics,\n 'file',\n `${packageOutputPath}/diagnostics.json`,\n packageOutputPath,\n false,\n {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: totalItemsConverted + totalItemsFailed,\n totalActivitiesFound: bundle.activityRefs.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n failedActivities: failedActivityFiles,\n }\n );\n\n if (allConvertedActivities.length === 0) {\n const errorCount = allDiagnostics.filter((d) => d.level === 'error').length;\n\n await writePackageDiagnostics();\n\n return {\n success: false,\n errorCount,\n warningCount: allDiagnostics.filter((d) => d.level === 'warning').length,\n convertedItemCount: 0,\n failedItemCount: totalItemsFailed,\n message: 'No activities converted',\n };\n }\n\n // Build package with all activities\n const pkgData: QtiContentPackage = {\n zipPath: '',\n version: options.qtiVersion,\n resources: [],\n entries: new Map(),\n items: [],\n assets: [],\n };\n\n const addedResourceIds = new Set<string>();\n\n for (const { activityRef, folderName, conversion } of allConvertedActivities) {\n const packageResult = buildPackageFromActivity(conversion, {\n bundleDir: pkg.path,\n activityRef,\n version: options.qtiVersion,\n });\n\n allDiagnostics.push(...packageResult.diagnostics);\n\n // Relocates the assessmentTest to tests/<folderName>/assessmentTest.xml and\n // wires manifest dependencies, matching the single-package output layout.\n mergeActivityPackage(pkgData, folderName, packageResult, addedResourceIds);\n }\n\n // Save the package\n const saveResult = saveQtiContentPackage(pkgData, packageOutputPath);\n\n allDiagnostics.push(...saveResult.diagnostics);\n\n const errors = allDiagnostics.filter((d) => d.level === 'error');\n const warnings = allDiagnostics.filter((d) => d.level === 'warning');\n\n await writePackageDiagnostics();\n\n displayDiagnosticsSummary(allDiagnostics, quiet);\n\n if (errors.length > 0) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n message: 'Conversion failed',\n };\n }\n\n return {\n success: true,\n errorCount: 0,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n };\n}\n\n/**\n * Map item references to the filenames they were loaded from, for the\n * diagnostics report. Falls back to the reference when the bundle has no\n * filename recorded, so counts always match the listed items.\n */\nfunction itemRefsToFilenames(bundle: LearnosityBundleModel, itemRefs: Set<string>): string[] {\n return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);\n}\n"],"mappings":";;;;;;;;;;AA6DA,eAAsB,aAAa,MAAiB,QAAQ,MAA8B;CACtF,IAAI,KAAK,cAAc,qBACnB,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;CAG9F,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;AAC9F;AAEA,SAAS,0BAA0B,aAA2B,OAAsB;CAChF,IAAI,OACA;CAGJ,MAAM,eAAe,8BAA8B,WAAW;CAE9D,IAAI,cAAc;EACd,QAAQ,IAAI,gBAAgB;EAC5B,QAAQ,IACJ,aACK,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,OAAO,IAAI,CAAC,CAC1B,KAAK,IAAI,CAClB;EACA,QAAQ,IAAI,EAAE;CAClB;AACJ;;AAGA,eAAsB,8BAClB,KACA,mBACA,SACA,OACsB;CAEtB,MAAM,SAAS,qBAAqB,IAAI,IAAI;CAC5C,MAAM,gBAAgB,OAAO,UACvB,oCACI,EAAE,SAAS,OAAO,QAAQ,GAC1B;EACI,gBAAgB,QAAQ;EACxB,YAAY,QAAQ;EACpB,gBAAgB,QAAQ;EACxB,qBAAqB,QAAQ;EAC7B,oBAAoB,QAAQ;EAC5B,cAAc,QAAQ;EACtB,gBAAgB,QAAQ;EACxB,WAAW,IAAI;EACf,YAAY;CAChB,CACJ,IACA,EAAE,aAAa,OAAO,YAAY;CAExC,MAAM,SA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CAAC;CACb;CAEA,MAAM,mCAAmB,IAAI,IAAY;CAEzC,KAAK,MAAM,EAAE,aAAa,YAAY,gBAAgB,wBAAwB;EAC1E,MAAM,gBAAgB,yBAAyB,YAAY;GACvD,WAAW,IAAI;GACf;GACA,SAAS,QAAQ;EACrB,CAAC;EAED,eAAe,KAAK,GAAG,cAAc,WAAW;EAIhD,qBAAqB,SAAS,YAAY,eAAe,gBAAgB;CAC7E;CAGA,MAAM,aAAa,sBAAsB,SAAS,iBAAiB;CAEnE,eAAe,KAAK,GAAG,WAAW,WAAW;CAE7C,MAAM,SAAS,eAAe,QAAQ,MAAM,EAAE,UAAU,OAAO;CAC/D,MAAM,WAAW,eAAe,QAAQ,MAAM,EAAE,UAAU,SAAS;CAEnE,MAAM,wBAAwB;CAE9B,0BAA0B,gBAAgB,KAAK;CAE/C,IAAI,OAAO,SAAS,GAChB,OAAO;EACH,SAAS;EACT,YAAY,OAAO;EACnB,cAAc,SAAS;EACvB,oBAAoB;EACpB,iBAAiB;EACjB,SAAS;CACb;CAGJ,OAAO;EACH,SAAS;EACT,YAAY;EACZ,cAAc,SAAS;EACvB,oBAAoB;EACpB,iBAAiB;CACrB;AACJ;;;;;;AAOA,SAAS,oBAAoB,QAA+B,UAAiC;CACzF,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,YAAY,OAAO,kBAAkB,IAAI,OAAO,KAAK,OAAO;AAC1F"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"learnosityToQti-B0PoimXr.js","names":[],"sources":["../src/commands/learnosityToQti.ts"],"sourcesContent":["import type { Command } from 'commander';\nimport type { ConversionOptions, Diagnostic } from '@learnosity/converter-core';\nimport { convertLearnosityToQti } from '@learnosity/converter-core';\nimport { copyFile, mkdir } from 'fs/promises';\nimport { dirname, join, basename } from 'path';\nimport { readInput, parseJsonInput } 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 learnosity-to-qti command\n */\nexport function registerLearnosityToQtiCommand(program: Command, version: string): void {\n program\n .command('learnosity-to-qti')\n .description('Convert a single Learnosity item to QTI')\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('--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', 'Verbose output (default: false)')\n .option('--pretty', 'Pretty-print JSON output (default: false)')\n .option('-q, --quiet', 'Suppress non-essential output (default: false)')\n .option(\n '--include-learnosity-source',\n 'Copy input file to source/ folder alongside output (default: false)'\n )\n .action(async (opts: CliOptions) => {\n await executeLearnosityToQti(opts, version);\n });\n}\n\nasync function copySourceFile(inputPath: string, outputPath: string): Promise<void> {\n const outputDir = dirname(outputPath);\n\n // Both paths are CLI arguments the operator chose. 'source' is a literal and\n // basename() strips any directory part of inputPath, so the copy stays inside\n // the requested output directory.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const sourceDir = join(outputDir, 'source');\n\n await mkdir(sourceDir, { recursive: true });\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n await copyFile(inputPath, join(sourceDir, basename(inputPath)));\n}\n\n/**\n * Execute learnosity-to-qti conversion\n */\nasync function executeLearnosityToQti(cliOpts: CliOptions, version: string): Promise<void> {\n const allDiagnostics: Diagnostic[] = [];\n const quiet = cliOpts.quiet ?? false;\n\n try {\n showBanner('learnosity-to-qti', 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 and parse input\n progress.startStage('Reading input...');\n const inputText = await readInput(resolved.inputPath);\n const input = parseJsonInput(inputText);\n\n progress.succeedStage('Input read');\n\n // Convert\n progress.startStage('Converting Learnosity to QTI...');\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 };\n const result = await convertLearnosityToQti(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 // Check for errors before writing output\n const errorCount = countErrors(allDiagnostics);\n\n if (errorCount > 0) {\n progress.failStage('Conversion failed');\n console.log('\\n' + formatDiagnosticsTable(allDiagnostics));\n process.exit(1);\n }\n\n // Write output only if no errors\n if (result.output) {\n progress.startStage('Writing output...');\n await writeOutput(resolved.outputPath, result.output, resolved.pretty);\n progress.succeedStage('Output written');\n }\n\n // Copy source file if requested\n if (\n cliOpts.includeLearnositySource &&\n resolved.inputPath !== '-' &&\n resolved.outputPath !== '-'\n ) {\n progress.startStage('Copying source file...');\n await copySourceFile(resolved.inputPath, resolved.outputPath);\n progress.succeedStage('Source file copied');\n }\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 // Check for warnings if fail-on-warn\n const warningCount = allDiagnostics.filter((d) => d.level === 'warning').length;\n\n if (warningCount > 0 && cliOpts.failOnWarn) {\n process.stderr.write(\n `\\n${warningCount} warning(s) found - exiting with error (--fail-on-warn)\\n`\n );\n process.exit(1);\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"],"mappings":";;;;;;;;;AAmBA,SAAgB,+BAA+B,SAAkB,SAAuB;CACpF,QACK,QAAQ,mBAAmB,CAAC,CAC5B,YAAY,yCAAyC,CAAC,CACtD,OAAO,eAAe,oCAAkC,CAAC,CACzD,OAAO,gBAAg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