@learnosity/lib-qti-converter 0.15.1 → 0.16.1

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 (46) hide show
  1. package/README.md +57 -9
  2. package/docs/EXAMPLES.md +4 -2
  3. package/docs/FAQ.md +20 -0
  4. package/docs/GETTING_STARTED.md +1 -1
  5. package/docs/SUPPORTED_INTERACTIONS.md +1 -1
  6. package/package.json +10 -10
  7. package/packages/cli/dist/{batchProcessors-B6yUImA3.js → batchProcessors-BI6C89vy.js} +138 -102
  8. package/packages/cli/dist/batchProcessors-BI6C89vy.js.map +1 -0
  9. package/packages/cli/dist/batchWorker.js +2 -3
  10. package/packages/cli/dist/{configOutput-FwkFyQmk.js → configOutput-CJ-ryN3j.js} +5 -9
  11. package/packages/cli/dist/{configOutput-FwkFyQmk.js.map → configOutput-CJ-ryN3j.js.map} +1 -1
  12. package/packages/cli/dist/{create-prompt-dWckcotJ.js → create-prompt-m0MC0vT_.js} +38 -57
  13. package/packages/cli/dist/create-prompt-m0MC0vT_.js.map +1 -0
  14. package/packages/cli/dist/{dist-DXDR2peT.js → dist-8MaFD1oj.js} +6 -10
  15. package/packages/cli/dist/dist-8MaFD1oj.js.map +1 -0
  16. package/packages/cli/dist/{learnosityToQti-DIxeAztu.js → learnosityToQti-BDf_faIV.js} +5 -6
  17. package/packages/cli/dist/{learnosityToQti-DIxeAztu.js.map → learnosityToQti-BDf_faIV.js.map} +1 -1
  18. package/packages/cli/dist/{learnosityToQtiPackage-CMFop6H4.js → learnosityToQtiPackage-w-BXgsLt.js} +16 -15
  19. package/packages/cli/dist/learnosityToQtiPackage-w-BXgsLt.js.map +1 -0
  20. package/packages/cli/dist/main.js +22 -29
  21. package/packages/cli/dist/main.js.map +1 -1
  22. package/packages/cli/dist/{nodeFileAccess-BhCoGDOi.js → nodeFileAccess-BBS4FAK7.js} +5 -9
  23. package/packages/cli/dist/{nodeFileAccess-BhCoGDOi.js.map → nodeFileAccess-BBS4FAK7.js.map} +1 -1
  24. package/packages/cli/dist/pathUtils-BUJJCvvp.js +2919 -0
  25. package/packages/cli/dist/pathUtils-BUJJCvvp.js.map +1 -0
  26. package/packages/cli/dist/{qtiPackageToLearnosity-Sk_1j12c.js → qtiPackageToLearnosity-C24effmB.js} +7 -8
  27. package/packages/cli/dist/{qtiPackageToLearnosity-Sk_1j12c.js.map → qtiPackageToLearnosity-C24effmB.js.map} +1 -1
  28. package/packages/cli/dist/{qtiToLearnosity-_tybImv1.js → qtiToLearnosity-BEOaukuf.js} +6 -7
  29. package/packages/cli/dist/{qtiToLearnosity-_tybImv1.js.map → qtiToLearnosity-BEOaukuf.js.map} +1 -1
  30. package/packages/cli/dist/{resolveOptions-6ReJUr-D.js → resolveOptions-l0Hpn8hY.js} +322 -359
  31. package/packages/cli/dist/resolveOptions-l0Hpn8hY.js.map +1 -0
  32. package/packages/cli/dist/{rolldown-runtime-DktXgydw.js → rolldown-runtime-BVN1G_yT.js} +5 -6
  33. package/packages/cli/dist/{table-CLUiytPO.js → table-BkrwlSAQ.js} +15578 -4894
  34. package/packages/cli/dist/table-BkrwlSAQ.js.map +1 -0
  35. package/packages/core/dist/index.d.ts +36 -59
  36. package/packages/core/dist/index.js +15415 -4712
  37. package/packages/core/dist/node.d.ts +38 -81
  38. package/packages/core/dist/node.js +13598 -2857
  39. package/packages/cli/dist/batchProcessors-B6yUImA3.js.map +0 -1
  40. package/packages/cli/dist/create-prompt-dWckcotJ.js.map +0 -1
  41. package/packages/cli/dist/dist-DXDR2peT.js.map +0 -1
  42. package/packages/cli/dist/learnosityToQtiPackage-CMFop6H4.js.map +0 -1
  43. package/packages/cli/dist/pathUtils-6nZKvVmg.js +0 -2272
  44. package/packages/cli/dist/pathUtils-6nZKvVmg.js.map +0 -1
  45. package/packages/cli/dist/resolveOptions-6ReJUr-D.js.map +0 -1
  46. package/packages/cli/dist/table-CLUiytPO.js.map +0 -1
@@ -1,13 +1,13 @@
1
- import { C as mapLearnosityToAst, D as DiagnosticCode, E as parseLearnosityItem, S as downgradeAssessmentTestToQti21, T as sanitizeHtmlContent, _ as md5hex, b as serializeAssessmentItem, c as transformForwardAssetUrlsInXml, d as getAllPassageDataPaths, f as generateItemReference, g as serializeQtiAssetIdentity, h as selectQtiAssetFilename, l as convertQtiAssessmentItemToLearnosity, m as isSupportedQtiAssetPath, n as formatDiagnosticsSummaryTable, p as canonicalizeQtiAssetHref, s as writeDiagnostics, u as parseMetadataTags, v as getAttr$2, w as normalizeXhtmlVoidElements, x as escapeXml$3, y as require_saxes } from "./table-CLUiytPO.js";
2
- import { t as nodeFileAccess } from "./nodeFileAccess-BhCoGDOi.js";
3
- import * as path$1 from "node:path";
1
+ import { C as escapeXml$3, D as DiagnosticCode, E as parseLearnosityItem, S as buildGapImageSvgFromText, T as normalizeXhtmlVoidElements, _ as getAttr$2, b as downgradeAssessmentTestToQti21, c as convertQtiAssessmentItemToLearnosity, d as generateItemReference, f as canonicalizeQtiAssetHref, g as md5hex, h as serializeQtiAssetIdentity, l as parseMetadataTags, m as selectQtiAssetFilename, n as formatDiagnosticsSummaryTable, o as writeDiagnostics, p as isSupportedQtiAssetPath, s as transformForwardAssetUrlsInXml, u as getAllPassageDataPaths, v as require_saxes, w as sanitizeHtmlContent, x as mapLearnosityToAst, y as serializeAssessmentItem } from "./table-BkrwlSAQ.js";
2
+ import { t as nodeFileAccess } from "./nodeFileAccess-BBS4FAK7.js";
3
+ import * as path from "node:path";
4
4
  import { join, relative, sep } from "node:path";
5
- import * as fs$1 from "node:fs";
5
+ import * as fs from "node:fs";
6
6
  import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
7
7
  import * as crypto from "node:crypto";
8
8
  import { createRequire } from "module";
9
9
  import { mkdir, writeFile } from "node:fs/promises";
10
- //#region ../core/src/qti-package/pathSafety.ts
10
+ // ../core/src/qti-package/pathSafety.ts
11
11
  var import_saxes = require_saxes();
12
12
  /**
13
13
  * ZIP entry path safety validation (zip-slip protection)
@@ -30,8 +30,7 @@ function validateZipEntryPath(entryPath) {
30
30
  if (normalized.includes("..")) return null;
31
31
  return normalized;
32
32
  }
33
- //#endregion
34
- //#region ../core/src/qti-package/parseManifest.ts
33
+ // ../core/src/qti-package/parseManifest.ts
35
34
  /**
36
35
  * IMS manifest XML parsing using saxes
37
36
  */
@@ -159,8 +158,7 @@ function parseManifest(manifestXml, zipPath) {
159
158
  diagnostics
160
159
  };
161
160
  }
162
- //#endregion
163
- //#region ../core/src/qti-package/uuid.ts
161
+ // ../core/src/qti-package/uuid.ts
164
162
  /**
165
163
  * Dependency-free RFC 4122 version-4 UUID generator.
166
164
  *
@@ -177,8 +175,7 @@ function uuidv4() {
177
175
  bytes[8] = bytes[8] & 63 | 128;
178
176
  return HEX[bytes[0]] + HEX[bytes[1]] + HEX[bytes[2]] + HEX[bytes[3]] + "-" + HEX[bytes[4]] + HEX[bytes[5]] + "-" + HEX[bytes[6]] + HEX[bytes[7]] + "-" + HEX[bytes[8]] + HEX[bytes[9]] + "-" + HEX[bytes[10]] + HEX[bytes[11]] + HEX[bytes[12]] + HEX[bytes[13]] + HEX[bytes[14]] + HEX[bytes[15]];
179
177
  }
180
- //#endregion
181
- //#region ../core/src/qti-package/buildManifest.ts
178
+ // ../core/src/qti-package/buildManifest.ts
182
179
  /**
183
180
  * IMS manifest XML generation
184
181
  */
@@ -211,7 +208,7 @@ function buildManifest(resources, version = "2.2") {
211
208
  lines.push(" xmlns:imsmd=\"http://www.imsglobal.org/xsd/imsmd_v1p2\"");
212
209
  lines.push(` xmlns:imsqti="${qtiMetadataNs}"`);
213
210
  lines.push(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
214
- lines.push(" xsi:schemaLocation=\"http://www.imsglobal.org/xsd/imscp_v1p1 http://www.imsglobal.org/xsd/imscp_v1p1.xsd");
211
+ lines.push(` xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 http://www.imsglobal.org/xsd/qti/qti${qtiVersionTag}/qti${qtiVersionTag}_imscpv1p2_v1p0.xsd`);
215
212
  lines.push(" http://www.imsglobal.org/xsd/imsmd_v1p2 http://www.imsglobal.org/xsd/imsmd_v1p2p2.xsd");
216
213
  lines.push(` ${qtiMetadataNs} ${qtiMetadataXsd}">`);
217
214
  lines.push(" <metadata>");
@@ -236,8 +233,7 @@ function buildManifest(resources, version = "2.2") {
236
233
  function escapeXml$2(str) {
237
234
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
238
235
  }
239
- //#endregion
240
- //#region ../core/src/qti-package/testDependencies.ts
236
+ // ../core/src/qti-package/testDependencies.ts
241
237
  /**
242
238
  * Extract item and stimulus dependencies from QTI assessmentTest XML,
243
239
  * and map hrefs to manifest resource identifiers.
@@ -300,8 +296,7 @@ function mapHrefToResourceId(href) {
300
296
  }
301
297
  return null;
302
298
  }
303
- //#endregion
304
- //#region ../core/src/learnosity-mapper/mapActivityToTest.ts
299
+ // ../core/src/learnosity-mapper/mapActivityToTest.ts
305
300
  /**
306
301
  * Maps Learnosity Activity to QTI 2.2 assessmentTest AST (TASK 005)
307
302
  */
@@ -418,18 +413,17 @@ function mapSectionsToQti(learnositySections, activityTitle, diagnostics) {
418
413
  navigationMode: hasLinearSection ? "linear" : "nonlinear"
419
414
  };
420
415
  }
421
- //#endregion
422
- //#region ../core/src/learnosity-mapper/mapStimulusToAst.ts
416
+ // ../core/src/learnosity-mapper/mapStimulusToAst.ts
423
417
  /**
424
418
  * Convert Learnosity sharedpassage to QTI assessmentStimulus
425
419
  */
426
420
  function mapSharedpassageToStimulus(reference, data, diagnostics) {
427
- const contentResult = sanitizeHtmlContent(data.content, `features[${reference}].content`);
421
+ const contentResult = sanitizeHtmlContent(data.content, `features[${reference}].content`, { stripQtiInvalidAttributes: false });
428
422
  diagnostics.push(...contentResult.diagnostics);
429
423
  let stimulusBody = contentResult.content;
430
424
  stimulusBody = convertMediaSpansToObjects(stimulusBody, diagnostics);
431
425
  if (data.heading) {
432
- const headingResult = sanitizeHtmlContent(data.heading, `features[${reference}].heading`);
426
+ const headingResult = sanitizeHtmlContent(data.heading, `features[${reference}].heading`, { stripQtiInvalidAttributes: false });
433
427
  diagnostics.push(...headingResult.diagnostics);
434
428
  stimulusBody = `<h2 class="lrn-hdg">${headingResult.content}</h2>` + stimulusBody;
435
429
  }
@@ -520,8 +514,7 @@ function sanitizeIdentifier(ref) {
520
514
  function escapeXml$1(text) {
521
515
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
522
516
  }
523
- //#endregion
524
- //#region ../core/src/qti-serializer/serializeAssessmentStimulus.ts
517
+ // ../core/src/qti-serializer/serializeAssessmentStimulus.ts
525
518
  /**
526
519
  * Serialize QtiAssessmentStimulus to HTML (for embedding via object element)
527
520
  * Returns just the stimulus body HTML without QTI XML wrapper
@@ -552,8 +545,7 @@ ${bodyContent}
552
545
  function escapeXml(text) {
553
546
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
554
547
  }
555
- //#endregion
556
- //#region ../core/src/qti-serializer/serializeAssessmentTest.ts
548
+ // ../core/src/qti-serializer/serializeAssessmentTest.ts
557
549
  /**
558
550
  * Serializes QTI 2.2/2.1 assessmentTest AST to XML (TASK 005, TASK 008)
559
551
  */
@@ -607,8 +599,7 @@ function buildAssessmentTestXml(test, pretty, version) {
607
599
  parts.push(`${indent}<testPart identifier="${escapeXml$3(testPart.identifier)}" navigationMode="${testPart.navigationMode}" submissionMode="${testPart.submissionMode}">`);
608
600
  if (pretty) parts.push("\n");
609
601
  for (const section of testPart.sections) {
610
- let sectionAttrs = `identifier="${escapeXml$3(section.identifier)}" title="${escapeXml$3(section.title)}" visible="${section.visible}"`;
611
- if (section.shuffle !== void 0) sectionAttrs += ` shuffle="${section.shuffle}"`;
602
+ const sectionAttrs = `identifier="${escapeXml$3(section.identifier)}" title="${escapeXml$3(section.title)}" visible="${section.visible}"`;
612
603
  parts.push(`${indent2}<assessmentSection ${sectionAttrs}>`);
613
604
  if (pretty) parts.push("\n");
614
605
  if (section.timeLimits) {
@@ -621,6 +612,10 @@ function buildAssessmentTestXml(test, pretty, version) {
621
612
  parts.push(`${indent3}<selection ${selectionAttrs}/>`);
622
613
  if (pretty) parts.push("\n");
623
614
  }
615
+ if (section.shuffle) {
616
+ parts.push(`${indent3}<ordering shuffle="true"/>`);
617
+ if (pretty) parts.push("\n");
618
+ }
624
619
  for (const itemRef of section.itemRefs) {
625
620
  parts.push(`${indent3}<assessmentItemRef identifier="${escapeXml$3(itemRef.identifier)}" href="${escapeXml$3(itemRef.href)}"/>`);
626
621
  if (pretty) parts.push("\n");
@@ -635,8 +630,7 @@ function buildAssessmentTestXml(test, pretty, version) {
635
630
  if (pretty) parts.push("\n");
636
631
  return parts.join("");
637
632
  }
638
- //#endregion
639
- //#region ../core/src/learnosity-mapper/convertActivity.ts
633
+ // ../core/src/learnosity-mapper/convertActivity.ts
640
634
  /**
641
635
  * Convert Learnosity Activity to QTI (TASK 005, TASK 008, TASK 023)
642
636
  *
@@ -646,6 +640,12 @@ function buildAssessmentTestXml(test, pretty, version) {
646
640
  * - Sharedpassages → assessmentStimulus resources
647
641
  */
648
642
  /**
643
+ * Items are written to `items/` and stimuli to `stimuli/` (see
644
+ * buildPackageFromActivity), one folder below the package root, so relative
645
+ * asset references must step up with `../` to reach `assets/`.
646
+ */
647
+ const PACKAGE_SUBFOLDER_ASSET_OPTIONS = { packageRootRelativePath: ".." };
648
+ /**
649
649
  * Convert a Learnosity Activity to QTI 2.2/2.1 assessmentTest + items
650
650
  *
651
651
  * @param bundle - Loaded Learnosity bundle
@@ -714,7 +714,7 @@ function convertActivity(bundle, activityRef, options = {}) {
714
714
  diagnostics.push(...serializeDiagnostics);
715
715
  if (serializeResult.xml) items.push({
716
716
  reference: itemRef,
717
- xml: transformForwardAssetUrlsInXml(serializeResult.xml, customAssetUrl),
717
+ xml: transformForwardAssetUrlsInXml(serializeResult.xml, customAssetUrl, PACKAGE_SUBFOLDER_ASSET_OPTIONS),
718
718
  ast: mapResult.ast,
719
719
  diagnostics: [
720
720
  ...parseResult.diagnostics,
@@ -787,7 +787,7 @@ function collectStimuliFromFeatures(features, stimuliByRef, stimuli, diagnostics
787
787
  if (stimulusAst) {
788
788
  const stimulusEntry = {
789
789
  reference: feature.reference,
790
- xml: transformForwardAssetUrlsInXml(serializeAssessmentStimulusAsHtml(stimulusAst), customAssetUrl)
790
+ xml: transformForwardAssetUrlsInXml(serializeAssessmentStimulusAsHtml(stimulusAst), customAssetUrl, PACKAGE_SUBFOLDER_ASSET_OPTIONS)
791
791
  };
792
792
  stimuliByRef.set(feature.reference, stimulusEntry);
793
793
  stimuli.push(stimulusEntry);
@@ -889,8 +889,7 @@ function extractSections(rawSections, convertedItems) {
889
889
  }
890
890
  return sections;
891
891
  }
892
- //#endregion
893
- //#region ../core/src/learnosity-mapper/sanitizeFolderName.ts
892
+ // ../core/src/learnosity-mapper/sanitizeFolderName.ts
894
893
  /**
895
894
  * Sanitize activity reference for use as folder name
896
895
  */
@@ -934,8 +933,7 @@ function ensureUniqueFolderName(desiredName, usedNames) {
934
933
  usedNames.add(uniqueName);
935
934
  return uniqueName;
936
935
  }
937
- //#endregion
938
- //#region ../core/src/learnosity-mapper/mergeActivityPackage.ts
936
+ // ../core/src/learnosity-mapper/mergeActivityPackage.ts
939
937
  /**
940
938
  * Rewrite item/stimulus/asset hrefs inside an assessmentTest that has been moved
941
939
  * into tests/<folderName>/ (two levels deep) so they resolve against the package root.
@@ -999,8 +997,7 @@ function mergeActivityPackage(pkg, folderName, packageResult, addedResourceIds)
999
997
  pkg.items.push(...actPackage.items);
1000
998
  for (const asset of actPackage.assets) if (!pkg.assets.some((a) => a.identifier === asset.identifier)) pkg.assets.push(asset);
1001
999
  }
1002
- //#endregion
1003
- //#region ../core/src/qti-to-learnosity/convertAssessmentTestToActivity.ts
1000
+ // ../core/src/qti-to-learnosity/convertAssessmentTestToActivity.ts
1004
1001
  /**
1005
1002
  * QTI assessmentTest → Learnosity Activity converter (streaming-safe, v1)
1006
1003
  * TASK 013
@@ -1141,8 +1138,7 @@ function convertAssessmentTestToLearnosityActivity(inputXml) {
1141
1138
  return { diagnostics };
1142
1139
  }
1143
1140
  }
1144
- //#endregion
1145
- //#region ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
1141
+ // ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
1146
1142
  var require = createRequire("/");
1147
1143
  var _a;
1148
1144
  try {
@@ -2079,8 +2075,7 @@ function unzipSync(data, opts) {
2079
2075
  }
2080
2076
  return files;
2081
2077
  }
2082
- //#endregion
2083
- //#region ../core/src/qti-package/zipCodec.ts
2078
+ // ../core/src/qti-package/zipCodec.ts
2084
2079
  /**
2085
2080
  * Pure ZIP codec backed by fflate.
2086
2081
  *
@@ -2162,8 +2157,7 @@ function zipEntriesToBytes(files) {
2162
2157
  function textToBytes(text) {
2163
2158
  return strToU8(text);
2164
2159
  }
2165
- //#endregion
2166
- //#region ../core/src/qti-to-learnosity/utils/assetFilenameRegistry.ts
2160
+ // ../core/src/qti-to-learnosity/utils/assetFilenameRegistry.ts
2167
2161
  /**
2168
2162
  * Browser-safe registry for item-scoped QTI asset filenames.
2169
2163
  *
@@ -2264,8 +2258,7 @@ var AssetFilenameRegistry = class {
2264
2258
  this.byFilename.clear();
2265
2259
  }
2266
2260
  };
2267
- //#endregion
2268
- //#region ../core/src/qti-to-learnosity/convertQtiPackageToLearnosityBundle.ts
2261
+ // ../core/src/qti-to-learnosity/convertQtiPackageToLearnosityBundle.ts
2269
2262
  /**
2270
2263
  * QTI Content Package → Learnosity Bundle converter (v1)
2271
2264
  * TASK 014
@@ -2854,8 +2847,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
2854
2847
  return { diagnostics };
2855
2848
  }
2856
2849
  }
2857
- //#endregion
2858
- //#region ../core/src/qti-package/writeZip.ts
2850
+ // ../core/src/qti-package/writeZip.ts
2859
2851
  /**
2860
2852
  * Deterministic ZIP writing (Node.js file-path entry point).
2861
2853
  *
@@ -2881,8 +2873,7 @@ function writeZip(zipPath, files) {
2881
2873
  }));
2882
2874
  writeFileSync(zipPath, zipEntriesToBytes(entries));
2883
2875
  }
2884
- //#endregion
2885
- //#region ../core/src/qti-package/savePackage.ts
2876
+ // ../core/src/qti-package/savePackage.ts
2886
2877
  /**
2887
2878
  * QTI Content Package saving to ZIP or directory
2888
2879
  */
@@ -2928,21 +2919,20 @@ function saveQtiContentPackage(pkg, outputPath) {
2928
2919
  * @param files Array of files to write
2929
2920
  */
2930
2921
  function writeDirectory(dirPath, files) {
2931
- if (!fs$1.existsSync(dirPath)) fs$1.mkdirSync(dirPath, { recursive: true });
2922
+ if (!fs.existsSync(dirPath)) fs.mkdirSync(dirPath, { recursive: true });
2932
2923
  for (const file of files) {
2933
- const fullPath = path$1.join(dirPath, file.path);
2924
+ const fullPath = path.join(dirPath, file.path);
2934
2925
  if (file.path.endsWith("/")) {
2935
- if (!fs$1.existsSync(fullPath)) fs$1.mkdirSync(fullPath, { recursive: true });
2926
+ if (!fs.existsSync(fullPath)) fs.mkdirSync(fullPath, { recursive: true });
2936
2927
  continue;
2937
2928
  }
2938
- const dir = path$1.dirname(fullPath);
2939
- if (!fs$1.existsSync(dir)) fs$1.mkdirSync(dir, { recursive: true });
2929
+ const dir = path.dirname(fullPath);
2930
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
2940
2931
  const content = typeof file.content === "string" ? file.content : file.content;
2941
- fs$1.writeFileSync(fullPath, content);
2932
+ fs.writeFileSync(fullPath, content);
2942
2933
  }
2943
2934
  }
2944
- //#endregion
2945
- //#region ../core/src/learnosity-bundle/pathSafetyFs.ts
2935
+ // ../core/src/learnosity-bundle/pathSafetyFs.ts
2946
2936
  /**
2947
2937
  * Path safety validation for filesystem operations
2948
2938
  * Part of TASK 004D - prevents directory traversal attacks similar to zip-slip protection
@@ -2961,13 +2951,13 @@ function writeDirectory(dirPath, files) {
2961
2951
  * @returns true if safe, false otherwise
2962
2952
  */
2963
2953
  function isPathSafe(relativePath, baseDir) {
2964
- if (path$1.isAbsolute(relativePath)) return false;
2965
- const normalized = path$1.normalize(relativePath);
2954
+ if (path.isAbsolute(relativePath)) return false;
2955
+ const normalized = path.normalize(relativePath);
2966
2956
  if (normalized.includes("..")) return false;
2967
- const fullPath = path$1.join(baseDir, normalized);
2968
- const resolvedBase = path$1.resolve(baseDir);
2969
- const resolvedFull = path$1.resolve(fullPath);
2970
- if (!resolvedFull.startsWith(resolvedBase + path$1.sep) && resolvedFull !== resolvedBase) return false;
2957
+ const fullPath = path.join(baseDir, normalized);
2958
+ const resolvedBase = path.resolve(baseDir);
2959
+ const resolvedFull = path.resolve(fullPath);
2960
+ if (!resolvedFull.startsWith(resolvedBase + path.sep) && resolvedFull !== resolvedBase) return false;
2971
2961
  return true;
2972
2962
  }
2973
2963
  /**
@@ -2978,7 +2968,7 @@ function isPathSafe(relativePath, baseDir) {
2978
2968
  */
2979
2969
  function isSymlink(fullPath) {
2980
2970
  try {
2981
- return fs$1.lstatSync(fullPath).isSymbolicLink();
2971
+ return fs.lstatSync(fullPath).isSymbolicLink();
2982
2972
  } catch {
2983
2973
  return false;
2984
2974
  }
@@ -2993,12 +2983,11 @@ function isSymlink(fullPath) {
2993
2983
  */
2994
2984
  function safeResolve(relativePath, baseDir) {
2995
2985
  if (!isPathSafe(relativePath, baseDir)) return null;
2996
- const fullPath = path$1.join(baseDir, relativePath);
2986
+ const fullPath = path.join(baseDir, relativePath);
2997
2987
  if (isSymlink(fullPath)) return null;
2998
2988
  return fullPath;
2999
2989
  }
3000
- //#endregion
3001
- //#region ../core/src/learnosity-bundle/loadLearnosityBundle.ts
2990
+ // ../core/src/learnosity-bundle/loadLearnosityBundle.ts
3002
2991
  /**
3003
2992
  * Learnosity bundle loader (manifest.json + activities + items + assets)
3004
2993
  * Part of TASK 004D
@@ -3011,7 +3000,7 @@ function safeResolve(relativePath, baseDir) {
3011
3000
  */
3012
3001
  function loadLearnosityBundle(bundleDir) {
3013
3002
  const diagnostics = [];
3014
- if (!fs$1.existsSync(bundleDir)) {
3003
+ if (!fs.existsSync(bundleDir)) {
3015
3004
  diagnostics.push({
3016
3005
  code: DiagnosticCode.LRN_BUNDLE_DIR_NOT_FOUND,
3017
3006
  level: "error",
@@ -3020,7 +3009,7 @@ function loadLearnosityBundle(bundleDir) {
3020
3009
  });
3021
3010
  return { diagnostics };
3022
3011
  }
3023
- if (!fs$1.statSync(bundleDir).isDirectory()) {
3012
+ if (!fs.statSync(bundleDir).isDirectory()) {
3024
3013
  diagnostics.push({
3025
3014
  code: DiagnosticCode.LRN_BUNDLE_DIR_NOT_FOUND,
3026
3015
  level: "error",
@@ -3029,8 +3018,8 @@ function loadLearnosityBundle(bundleDir) {
3029
3018
  });
3030
3019
  return { diagnostics };
3031
3020
  }
3032
- const manifestPath = path$1.join(bundleDir, "manifest.json");
3033
- if (!fs$1.existsSync(manifestPath)) {
3021
+ const manifestPath = path.join(bundleDir, "manifest.json");
3022
+ if (!fs.existsSync(manifestPath)) {
3034
3023
  diagnostics.push({
3035
3024
  code: DiagnosticCode.LRN_MANIFEST_MISSING,
3036
3025
  level: "error",
@@ -3041,7 +3030,7 @@ function loadLearnosityBundle(bundleDir) {
3041
3030
  }
3042
3031
  let manifestRaw;
3043
3032
  try {
3044
- const manifestContent = fs$1.readFileSync(manifestPath, "utf-8");
3033
+ const manifestContent = fs.readFileSync(manifestPath, "utf-8");
3045
3034
  manifestRaw = JSON.parse(manifestContent);
3046
3035
  } catch (err) {
3047
3036
  diagnostics.push({
@@ -3054,10 +3043,10 @@ function loadLearnosityBundle(bundleDir) {
3054
3043
  }
3055
3044
  const manifest = validateManifest(manifestRaw, diagnostics);
3056
3045
  if (!manifest) return { diagnostics };
3057
- const itemsDir = path$1.join(bundleDir, "items");
3046
+ const itemsDir = path.join(bundleDir, "items");
3058
3047
  const autoCreatedActivities = /* @__PURE__ */ new Set();
3059
- if (Object.keys(manifest.activities).length === 0 && fs$1.existsSync(itemsDir) && fs$1.statSync(itemsDir).isDirectory()) {
3060
- const itemFiles = fs$1.readdirSync(itemsDir).filter((f) => f.endsWith(".json"));
3048
+ if (Object.keys(manifest.activities).length === 0 && fs.existsSync(itemsDir) && fs.statSync(itemsDir).isDirectory()) {
3049
+ const itemFiles = fs.readdirSync(itemsDir).filter((f) => f.endsWith(".json"));
3061
3050
  if (itemFiles.length > 0) {
3062
3051
  const defaultActivityRef = "default_activity";
3063
3052
  const items = itemFiles.map((f) => ({ reference: f.replace(/\.json$/, "") }));
@@ -3104,7 +3093,7 @@ function loadLearnosityBundle(bundleDir) {
3104
3093
  activityItemRefs.set(activityRef, itemRefs);
3105
3094
  let activityFilePath = `activities/${activityRef}.json`;
3106
3095
  let activityFullPath = safeResolve(activityFilePath, bundleDir);
3107
- if (!activityFullPath || !fs$1.existsSync(activityFullPath)) {
3096
+ if (!activityFullPath || !fs.existsSync(activityFullPath)) {
3108
3097
  activityFilePath = `activities/${`${md5Hash(activityRef)}.json`}`;
3109
3098
  activityFullPath = safeResolve(activityFilePath, bundleDir);
3110
3099
  }
@@ -3117,7 +3106,7 @@ function loadLearnosityBundle(bundleDir) {
3117
3106
  });
3118
3107
  continue;
3119
3108
  }
3120
- if (!fs$1.existsSync(activityFullPath)) {
3109
+ if (!fs.existsSync(activityFullPath)) {
3121
3110
  if (!autoCreatedActivities.has(activityRef)) diagnostics.push({
3122
3111
  code: DiagnosticCode.LRN_ACTIVITY_FILE_MISSING,
3123
3112
  level: "warning",
@@ -3127,7 +3116,7 @@ function loadLearnosityBundle(bundleDir) {
3127
3116
  continue;
3128
3117
  }
3129
3118
  try {
3130
- const activityContent = fs$1.readFileSync(activityFullPath, "utf-8");
3119
+ const activityContent = fs.readFileSync(activityFullPath, "utf-8");
3131
3120
  const activityJson = JSON.parse(activityContent);
3132
3121
  activitiesJsonByRef.set(activityRef, activityJson);
3133
3122
  if (itemRefs.length === 0 && activityJson && typeof activityJson === "object" && "data" in activityJson) {
@@ -3165,11 +3154,11 @@ function loadLearnosityBundle(bundleDir) {
3165
3154
  const originalItemFilePath = `items/${itemRef}.json`;
3166
3155
  let itemFilePath = originalItemFilePath;
3167
3156
  let itemFullPath = safeResolve(itemFilePath, bundleDir);
3168
- if (!itemFullPath || !fs$1.existsSync(itemFullPath)) {
3157
+ if (!itemFullPath || !fs.existsSync(itemFullPath)) {
3169
3158
  itemFilePath = `items/${`${md5Hash(itemRef)}.json`}`;
3170
3159
  itemFullPath = safeResolve(itemFilePath, bundleDir);
3171
3160
  }
3172
- if ((!itemFullPath || !fs$1.existsSync(itemFullPath)) && itemRefToId.has(itemRef)) {
3161
+ if ((!itemFullPath || !fs.existsSync(itemFullPath)) && itemRefToId.has(itemRef)) {
3173
3162
  itemFilePath = `items/${`${md5Hash(itemRefToId.get(itemRef))}.json`}`;
3174
3163
  itemFullPath = safeResolve(itemFilePath, bundleDir);
3175
3164
  }
@@ -3182,7 +3171,7 @@ function loadLearnosityBundle(bundleDir) {
3182
3171
  });
3183
3172
  continue;
3184
3173
  }
3185
- if (!fs$1.existsSync(itemFullPath)) {
3174
+ if (!fs.existsSync(itemFullPath)) {
3186
3175
  diagnostics.push({
3187
3176
  code: DiagnosticCode.LRN_ITEM_FILE_MISSING,
3188
3177
  level: "error",
@@ -3192,7 +3181,7 @@ function loadLearnosityBundle(bundleDir) {
3192
3181
  continue;
3193
3182
  }
3194
3183
  try {
3195
- const itemContent = fs$1.readFileSync(itemFullPath, "utf-8");
3184
+ const itemContent = fs.readFileSync(itemFullPath, "utf-8");
3196
3185
  const itemJson = JSON.parse(itemContent);
3197
3186
  itemsJsonByRef.set(itemRef, itemJson);
3198
3187
  itemRefToFilename.set(itemRef, itemFilePath);
@@ -3333,8 +3322,7 @@ function validateManifest(raw, diagnostics) {
3333
3322
  function md5Hash(str) {
3334
3323
  return crypto.createHash("md5").update(str).digest("hex");
3335
3324
  }
3336
- //#endregion
3337
- //#region ../core/src/learnosity-bundle/writeLearnosityBundle.ts
3325
+ // ../core/src/learnosity-bundle/writeLearnosityBundle.ts
3338
3326
  /**
3339
3327
  * Write Learnosity Bundle to directory with deterministic JSON
3340
3328
  * TASK 014
@@ -3435,8 +3423,7 @@ async function writeLearnosityBundle(bundle, options) {
3435
3423
  return { diagnostics };
3436
3424
  }
3437
3425
  }
3438
- //#endregion
3439
- //#region ../core/src/qti-serializer/serializeLomMetadata.ts
3426
+ // ../core/src/qti-serializer/serializeLomMetadata.ts
3440
3427
  /**
3441
3428
  * Serialize LOM metadata to XML
3442
3429
  *
@@ -3484,8 +3471,7 @@ function serializeLomMetadata(metadata) {
3484
3471
  parts.push("</imsmd:lom>");
3485
3472
  return parts.join("\n");
3486
3473
  }
3487
- //#endregion
3488
- //#region ../core/src/qti-package/assets/lrnNormalizeCss.ts
3474
+ // ../core/src/qti-package/assets/lrnNormalizeCss.ts
3489
3475
  /**
3490
3476
  * Embedded lrn-normalize.css content.
3491
3477
  *
@@ -3511,17 +3497,34 @@ const LRN_NORMALIZE_CSS = `/* Utility styles for converter-introduced normalizat
3511
3497
  .lrn-norm-underline {
3512
3498
  text-decoration: underline;
3513
3499
  }
3500
+ /* Converted from <s>, <strike> and <del> */
3501
+ .lrn-norm-strikethrough {
3502
+ text-decoration: line-through;
3503
+ }
3504
+ /* Converted from <ins> */
3505
+ .lrn-norm-inserted {
3506
+ text-decoration: underline;
3507
+ }
3508
+ /* Converted from <mark> */
3509
+ .lrn-norm-highlight {
3510
+ background-color: yellow;
3511
+ color: inherit;
3512
+ }
3514
3513
 
3515
3514
  /* Stimulus content embedded via object element */
3516
- object[type="text/html"] {
3515
+ object[type='text/html'] {
3517
3516
  display: block;
3518
3517
  width: 100vw;
3519
3518
  height: 100vh;
3520
3519
  border: none;
3521
3520
  }
3521
+
3522
+ .lrn-norm-math-entry {
3523
+ width: 100%;
3524
+ box-sizing: border-box; /* so padding/border don't overflow the wrapper */
3525
+ }
3522
3526
  `;
3523
- //#endregion
3524
- //#region ../core/src/learnosity-mapper/buildPackageFromActivity.ts
3527
+ // ../core/src/learnosity-mapper/buildPackageFromActivity.ts
3525
3528
  /**
3526
3529
  * Build IMS Content Package from converted Activity (TASK 005, TASK 008)
3527
3530
  */
@@ -3619,15 +3622,15 @@ function buildPackageFromActivity(conversion, options) {
3619
3622
  };
3620
3623
  pkg.resources.push(stimulusResource);
3621
3624
  }
3622
- const assetsDir = path$1.join(options.bundleDir, "assets");
3623
- if (fs$1.existsSync(assetsDir) && fs$1.statSync(assetsDir).isDirectory()) {
3624
- const assetFiles = fs$1.readdirSync(assetsDir, {
3625
+ const assetsDir = path.join(options.bundleDir, "assets");
3626
+ if (fs.existsSync(assetsDir) && fs.statSync(assetsDir).isDirectory()) {
3627
+ const assetFiles = fs.readdirSync(assetsDir, {
3625
3628
  recursive: true,
3626
3629
  withFileTypes: true
3627
3630
  });
3628
3631
  for (const entry of assetFiles) if (entry.isFile()) {
3629
- const entryPath = entry.parentPath ? path$1.join(entry.parentPath, entry.name) : entry.name;
3630
- const relativePath = path$1.relative(assetsDir, entryPath);
3632
+ const entryPath = entry.parentPath ? path.join(entry.parentPath, entry.name) : entry.name;
3633
+ const relativePath = path.relative(assetsDir, entryPath);
3631
3634
  const safeRelativePath = relativePath.replace(/\\/g, "/");
3632
3635
  const assetPath = `assets/${safeRelativePath}`;
3633
3636
  const resolvedPath = safeResolve(relativePath, assetsDir);
@@ -3641,7 +3644,7 @@ function buildPackageFromActivity(conversion, options) {
3641
3644
  continue;
3642
3645
  }
3643
3646
  try {
3644
- const data = fs$1.readFileSync(resolvedPath);
3647
+ const data = fs.readFileSync(resolvedPath);
3645
3648
  pkg.entries.set(assetPath, {
3646
3649
  file: assetPath,
3647
3650
  size: data.length,
@@ -3669,6 +3672,33 @@ function buildPackageFromActivity(conversion, options) {
3669
3672
  pkg.resources.push(assetResource);
3670
3673
  }
3671
3674
  }
3675
+ const takenIdentifiers = new Set(pkg.resources.map((r) => r.identifier));
3676
+ for (const item of conversion.items) for (const gapImg of collectGapImgs(item.ast)) {
3677
+ const gapImgPath = gapImg.objectData;
3678
+ if (!gapImgPath.startsWith("assets/gapimgs/") || pkg.entries.has(gapImgPath)) continue;
3679
+ const { svg } = buildGapImageSvgFromText(gapImg.altText, gapImg.identifier);
3680
+ const data = Buffer.from(svg, "utf-8");
3681
+ const baseIdentifier = `asset_${gapImgPath.replace(/^assets\//, "").replace(/[^a-zA-Z0-9]/g, "_")}`;
3682
+ let identifier = baseIdentifier;
3683
+ for (let n = 2; takenIdentifiers.has(identifier); n++) identifier = `${baseIdentifier}_${n}`;
3684
+ takenIdentifiers.add(identifier);
3685
+ pkg.entries.set(gapImgPath, {
3686
+ file: gapImgPath,
3687
+ size: data.length,
3688
+ data
3689
+ });
3690
+ pkg.assets.push({
3691
+ identifier,
3692
+ href: gapImgPath,
3693
+ type: "image/svg+xml"
3694
+ });
3695
+ pkg.resources.push({
3696
+ identifier,
3697
+ type: "webcontent",
3698
+ href: gapImgPath,
3699
+ files: [gapImgPath]
3700
+ });
3701
+ }
3672
3702
  const cssPath = "assets/css/lrn-normalize.css";
3673
3703
  pkg.entries.set(cssPath, {
3674
3704
  file: cssPath,
@@ -3697,8 +3727,16 @@ function buildPackageFromActivity(conversion, options) {
3697
3727
  diagnostics
3698
3728
  };
3699
3729
  }
3700
- //#endregion
3701
- //#region ../core/src/qti-to-learnosity/loadPackageDirectory.ts
3730
+ /** All gapImg choices of every graphicGapMatch interaction in an item (single, multiple or in a layout). */
3731
+ function collectGapImgs(ast) {
3732
+ if (!ast) return [];
3733
+ const interactions = [];
3734
+ if (ast.interaction) interactions.push(ast.interaction);
3735
+ if (ast.interactions) interactions.push(...ast.interactions);
3736
+ for (const column of ast.layout?.columns ?? []) for (const widget of column.widgets) if (widget.interaction) interactions.push(widget.interaction);
3737
+ return interactions.flatMap((interaction) => interaction.type === "graphicGapMatch" ? interaction.gapImgs : []);
3738
+ }
3739
+ // ../core/src/qti-to-learnosity/loadPackageDirectory.ts
3702
3740
  /**
3703
3741
  * Node.js-only loader that reads a QTI Content Package **directory** from disk
3704
3742
  * into an in-memory entries map, for feeding into the (pure)
@@ -3754,8 +3792,7 @@ function loadPackageDirectory(dirPath) {
3754
3792
  diagnostics
3755
3793
  };
3756
3794
  }
3757
- //#endregion
3758
- //#region src/utils/batchProcessors.ts
3795
+ // src/utils/batchProcessors.ts
3759
3796
  /**
3760
3797
  * Per-package conversion tasks, shared by the serial batch path
3761
3798
  * (`processBatch`) and the parallel worker path (`processBatchParallel` via
@@ -3967,7 +4004,6 @@ async function processLearnosityToQtiPackage(pkg, packageOutputPath, options, qu
3967
4004
  function itemRefsToFilenames(bundle, itemRefs) {
3968
4005
  return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);
3969
4006
  }
3970
- //#endregion
3971
4007
  export { buildPackageFromActivity as a, saveQtiContentPackage as c, ensureUniqueFolderName as d, sanitizeFolderName as f, loadPackageDirectory as i, convertQtiPackageToLearnosityBundle as l, processQtiPackageToLearnosity as n, writeLearnosityBundle as o, convertActivity as p, runBatchTask as r, loadLearnosityBundle as s, processLearnosityToQtiPackage as t, mergeActivityPackage as u };
3972
4008
 
3973
- //# sourceMappingURL=batchProcessors-B6yUImA3.js.map
4009
+ //# sourceMappingURL=batchProcessors-BI6C89vy.js.map