@learnosity/lib-qti-converter 0.13.0 → 0.14.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.
Files changed (31) hide show
  1. package/docs/EXAMPLES.md +46 -34
  2. package/docs/GETTING_STARTED.md +32 -28
  3. package/docs/LEARNOSITY_BUNDLE_FORMAT.md +1 -1
  4. package/package.json +1 -1
  5. package/packages/cli/dist/{batchProcessors-DgiDpfpP.js → batchProcessors-DWG8qk7G.js} +28 -6
  6. package/packages/cli/dist/batchProcessors-DWG8qk7G.js.map +1 -0
  7. package/packages/cli/dist/batchWorker.js +1 -1
  8. package/packages/cli/dist/{learnosityToQti-CIj5603P.js → learnosityToQti-C7cTRTU2.js} +4 -4
  9. package/packages/cli/dist/{learnosityToQti-CIj5603P.js.map → learnosityToQti-C7cTRTU2.js.map} +1 -1
  10. package/packages/cli/dist/{learnosityToQtiPackage-n6nGGr32.js → learnosityToQtiPackage-C84dQKKi.js} +4 -4
  11. package/packages/cli/dist/{learnosityToQtiPackage-n6nGGr32.js.map → learnosityToQtiPackage-C84dQKKi.js.map} +1 -1
  12. package/packages/cli/dist/main.js +4 -4
  13. package/packages/cli/dist/{pathUtils-mTQZ0wYS.js → pathUtils-Cr9IcK0n.js} +11 -6
  14. package/packages/cli/dist/{pathUtils-mTQZ0wYS.js.map → pathUtils-Cr9IcK0n.js.map} +1 -1
  15. package/packages/cli/dist/{qtiPackageToLearnosity-B4cD8jUw.js → qtiPackageToLearnosity-BBfZgWBh.js} +7 -7
  16. package/packages/cli/dist/qtiPackageToLearnosity-BBfZgWBh.js.map +1 -0
  17. package/packages/cli/dist/{qtiToLearnosity-DDjcpShJ.js → qtiToLearnosity-C9OW_n7Z.js} +5 -5
  18. package/packages/cli/dist/qtiToLearnosity-C9OW_n7Z.js.map +1 -0
  19. package/packages/cli/dist/{resolveOptions-Czapkfc1.js → resolveOptions-D_UECo_9.js} +5 -4
  20. package/packages/cli/dist/resolveOptions-D_UECo_9.js.map +1 -0
  21. package/packages/cli/dist/{table-DTSv0atR.js → table-D1ydwhbX.js} +8 -4
  22. package/packages/cli/dist/table-D1ydwhbX.js.map +1 -0
  23. package/packages/core/dist/index.d.ts +7 -4
  24. package/packages/core/dist/index.js +34 -7
  25. package/packages/core/dist/node.d.ts +8 -5
  26. package/packages/core/dist/node.js +34 -7
  27. package/packages/cli/dist/batchProcessors-DgiDpfpP.js.map +0 -1
  28. package/packages/cli/dist/qtiPackageToLearnosity-B4cD8jUw.js.map +0 -1
  29. package/packages/cli/dist/qtiToLearnosity-DDjcpShJ.js.map +0 -1
  30. package/packages/cli/dist/resolveOptions-Czapkfc1.js.map +0 -1
  31. package/packages/cli/dist/table-DTSv0atR.js.map +0 -1
package/docs/EXAMPLES.md CHANGED
@@ -208,17 +208,30 @@ When converting QTI to Learnosity, `<rubricBlock view="scorer">` elements are au
208
208
 
209
209
  ### 5. Control Item Reference Generation
210
210
 
211
- **Default behavior (source-filename references):**
211
+ **Default behavior (QTI identifier references):**
212
212
 
213
- By default (`--item-reference-source sourceFilename`), the converter derives each item reference from the source XML filename with the `.xml` extension removed:
213
+ By default (`--item-reference-source itemIdentifier`), the converter derives each item reference from the QTI `identifier` attribute in the XML (ignoring the filename):
214
214
 
215
215
  ```bash
216
216
  lcon qti-to-learnosity \
217
217
  --in Items/my-custom-item.xml \
218
218
  --out item.json
219
+ # If the XML has identifier="item-001", the reference will be: "item-001"
219
220
  ```
220
221
 
221
- Package conversions (`qti-package-to-learnosity`) use each item's source filename, so `Items/my-custom-item.xml` yields the reference `"my-custom-item"`. For single-item `qti-to-learnosity` conversions the source filename is not passed to the reference generator, so the reference falls back to the raw QTI `identifier` attribute from the XML.
222
+ Both package conversions (`qti-package-to-learnosity`) and single-item `qti-to-learnosity` conversions use the QTI `identifier` by default.
223
+
224
+ **Use source filenames for references:**
225
+
226
+ Pass `--item-reference-source sourceFilename` to derive each item reference from the source XML filename with the `.xml` extension removed (this was the default in earlier versions):
227
+
228
+ ```bash
229
+ lcon qti-to-learnosity \
230
+ --in Items/my-custom-item.xml \
231
+ --out item.json \
232
+ --item-reference-source sourceFilename
233
+ # Reference will be: "my-custom-item"
234
+ ```
222
235
 
223
236
  **Generate hashed references to avoid collisions:**
224
237
 
@@ -233,30 +246,29 @@ lcon qti-to-learnosity \
233
246
 
234
247
  This produces a stable MD5 hash (e.g., `"5d41402abc4b2a76b9719d911017c592"`), ensuring no conflicts when multiple conversions are imported into the same database while maintaining consistency across repeated conversions of the same item.
235
248
 
236
- **Use QTI identifier for human-readable references:**
249
+ **`qti` as a deprecated alias:**
237
250
 
238
- When you want item references to match the QTI identifier attribute from the XML:
251
+ `--item-reference-source qti` is a deprecated alias of `itemIdentifier` and produces the identical result. It remains accepted for backward compatibility, but new integrations should use `itemIdentifier` (or simply omit the option, since it is the default):
239
252
 
240
253
  ```bash
241
254
  lcon qti-to-learnosity \
242
255
  --in item.xml \
243
256
  --out item.json \
244
257
  --item-reference-source qti
258
+ # Same result as --item-reference-source itemIdentifier
245
259
  ```
246
260
 
247
- This uses the QTI identifier attribute from the XML (e.g., if the XML has `identifier="item-001"`, the reference will be `"item-001"`).
248
-
249
261
  **Decouple item reference from output filename:**
250
262
 
251
- Use `--item-filename-source` to control output JSON filenames independently from the item reference. Values: `sourceFilename` or `qti`. When omitted, filenames match whatever `--item-reference-source` produces.
263
+ Use `--item-filename-source` to control output JSON filenames independently from the item reference. Values: `itemIdentifier`, `qti` (deprecated alias of `itemIdentifier`), or `sourceFilename`. When omitted, filenames match whatever `--item-reference-source` produces.
252
264
 
253
- For example, use QTI identifiers as references but name the output files after the source XML filenames:
265
+ For example, use QTI identifiers as references (the default) but name the output files after the source XML filenames:
254
266
 
255
267
  ```bash
256
268
  lcon qti-package-to-learnosity \
257
269
  --in ./qti-package \
258
270
  --out ./output \
259
- --item-reference-source qti \
271
+ --item-reference-source itemIdentifier \
260
272
  --item-filename-source sourceFilename
261
273
  ```
262
274
 
@@ -772,19 +784,19 @@ The package exports the following for library consumers:
772
784
 
773
785
  `convertQtiToLearnosity` and `convertLearnosityToQti` accept a `ConversionOptions` object:
774
786
 
775
- | Option | Type | Required | CLI Equivalent | Description |
776
- | --------------------- | ---------------------------------------------- | -------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
777
- | `qtiVersion` | `'2.1'` \| `'2.2'` | Yes | `--qti-version` | QTI version to use for conversion |
778
- | `outputFormat` | `'dir'` \| `'zip'` \| `'stdout'` | No | `--output-format` | Output format |
779
- | `diagnostics` | `'stderr'` \| `'file'` \| `'both'` \| `'none'` | No | `--diagnostics` | Where to write diagnostic messages. Use `'none'` when using as a library |
780
- | `verbose` | `boolean` | No | `--verbose` | Include INFO-level diagnostics in the result |
781
- | `pretty` | `boolean` | No | `--pretty` | Pretty-print JSON/XML output |
782
- | `inputPath` | `string` | No | `--in` | Path to input file (used for LOM metadata lookup) |
783
- | `organisationId` | `number` | No | `--organisation_id` | Organisation ID for Learnosity CDN asset URLs |
784
- | `mediaVault` | `boolean` | No | `--mediavault` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
785
- | `customAssetUrl` | `string` | No | `--custom-asset-url` | Custom base URL/prefix for assets. QTI → Learnosity: overrides default Learnosity CDN and `mediaVault`. Learnosity → QTI: replaces the asset prefix up to the filename (default `./assets`) |
786
- | `itemReferenceSource` | `'sourceFilename'` \| `'qti'` \| `'uuid'` | No | `--item-reference-source` | How to generate item references. Default: `'sourceFilename'` |
787
- | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
787
+ | Option | Type | Required | CLI Equivalent | Description |
788
+ | --------------------- | --------------------------------------------------------------- | -------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
789
+ | `qtiVersion` | `'2.1'` \| `'2.2'` | Yes | `--qti-version` | QTI version to use for conversion |
790
+ | `outputFormat` | `'dir'` \| `'zip'` \| `'stdout'` | No | `--output-format` | Output format |
791
+ | `diagnostics` | `'stderr'` \| `'file'` \| `'both'` \| `'none'` | No | `--diagnostics` | Where to write diagnostic messages. Use `'none'` when using as a library |
792
+ | `verbose` | `boolean` | No | `--verbose` | Include INFO-level diagnostics in the result |
793
+ | `pretty` | `boolean` | No | `--pretty` | Pretty-print JSON/XML output |
794
+ | `inputPath` | `string` | No | `--in` | Path to input file (used for LOM metadata lookup) |
795
+ | `organisationId` | `number` | No | `--organisation_id` | Organisation ID for Learnosity CDN asset URLs |
796
+ | `mediaVault` | `boolean` | No | `--mediavault` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
797
+ | `customAssetUrl` | `string` | No | `--custom-asset-url` | Custom base URL/prefix for assets. QTI → Learnosity: overrides default Learnosity CDN and `mediaVault`. Learnosity → QTI: replaces the asset prefix up to the filename (default `./assets`) |
798
+ | `itemReferenceSource` | `'itemIdentifier'` \| `'qti'` \| `'sourceFilename'` \| `'uuid'` | No | `--item-reference-source` | How to generate item references. Default: `'itemIdentifier'`. `'qti'` is a deprecated alias of `'itemIdentifier'` |
799
+ | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
788
800
 
789
801
  **Note:** Only `qtiVersion` is required; all other options are optional. `outputFormat`, `diagnostics`, and `verbose` are CLI-only — they are ignored by the library API (`convertQtiToLearnosity` / `convertLearnosityToQti`) and only take effect when running the `lcon` CLI.
790
802
 
@@ -792,17 +804,17 @@ The package exports the following for library consumers:
792
804
 
793
805
  `convertQtiPackageToLearnosity` accepts a `ConvertQtiPackageToLearnosityOptions` object:
794
806
 
795
- | Option | Type | Required | CLI Equivalent | Description |
796
- | --------------------- | ----------------------------------------- | -------- | ------------------------- | ------------------------------------------------------------------------------ |
797
- | `inputPath` | `string` | \* | `--in` | Path to QTI package directory or .zip file |
798
- | `zipBytes` | `Uint8Array` | \* | N/A | Raw ZIP bytes (alternative to `inputPath`) |
799
- | `outputPath` | `string` | No | `--out` | Output path (directory or .zip). Omit to skip writing to disk |
800
- | `organisationId` | `number` | No | `--organisation_id` | Organisation ID for Learnosity CDN asset URLs |
801
- | `mediaVault` | `boolean` | No | `--mediavault` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
802
- | `customAssetUrl` | `string` | No | `--custom-asset-url` | Custom base URL for assets (overrides default Learnosity CDN and `mediaVault`) |
803
- | `itemReferenceSource` | `'sourceFilename'` \| `'qti'` \| `'uuid'` | No | `--item-reference-source` | How to generate item references. Default: `'sourceFilename'` |
804
- | `itemFilenameSource` | `'sourceFilename'` \| `'qti'` | No | `--item-filename-source` | How to name output files |
805
- | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
807
+ | Option | Type | Required | CLI Equivalent | Description |
808
+ | --------------------- | --------------------------------------------------------------- | -------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------- |
809
+ | `inputPath` | `string` | \* | `--in` | Path to QTI package directory or .zip file |
810
+ | `zipBytes` | `Uint8Array` | \* | N/A | Raw ZIP bytes (alternative to `inputPath`) |
811
+ | `outputPath` | `string` | No | `--out` | Output path (directory or .zip). Omit to skip writing to disk |
812
+ | `organisationId` | `number` | No | `--organisation_id` | Organisation ID for Learnosity CDN asset URLs |
813
+ | `mediaVault` | `boolean` | No | `--mediavault` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
814
+ | `customAssetUrl` | `string` | No | `--custom-asset-url` | Custom base URL for assets (overrides default Learnosity CDN and `mediaVault`) |
815
+ | `itemReferenceSource` | `'itemIdentifier'` \| `'qti'` \| `'sourceFilename'` \| `'uuid'` | No | `--item-reference-source` | How to generate item references. Default: `'itemIdentifier'`. `'qti'` is a deprecated alias of `'itemIdentifier'` |
816
+ | `itemFilenameSource` | `'itemIdentifier'` \| `'qti'` \| `'sourceFilename'` | No | `--item-filename-source` | How to name output files. `'qti'` is a deprecated alias of `'itemIdentifier'` |
817
+ | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
806
818
 
807
819
  \* Either `inputPath` or `zipBytes` must be provided.
808
820
 
@@ -321,40 +321,44 @@ The selected basename is used consistently in generated JSON URLs and physical b
321
321
 
322
322
  _Available for: `qti-to-learnosity`, `qti-package-to-learnosity`_
323
323
 
324
- Control how item references are generated. Options: `sourceFilename` (default) or `qti`.
324
+ Control how item references are generated. Options: `itemIdentifier` (default), `qti` (deprecated alias of `itemIdentifier`), `sourceFilename`, or `uuid`.
325
325
 
326
- **Default (`sourceFilename`)**: Uses the source filename without the .xml extension for human-readable references.
326
+ **Default (`itemIdentifier`)**: Uses the QTI `identifier` attribute from the XML (ignores the filename).
327
327
 
328
328
  ```bash
329
329
  lcon qti-to-learnosity --in Items/my-item.xml --out item.json
330
- # Item reference will be: "my-item"
330
+ # If the XML has identifier="item-001", item reference will be: "item-001"
331
331
  ```
332
332
 
333
- **QTI mode (`--item-reference-source qti`)**: Uses the QTI identifier attribute from the XML (ignores the filename).
333
+ **`--item-reference-source sourceFilename`**: Uses the source filename without the `.xml` extension for human-readable references (this was the default in earlier versions).
334
334
 
335
335
  ```bash
336
- lcon qti-to-learnosity --in Items/my-item.xml --out item.json --item-reference-source qti
337
- # If the XML has identifier="item-001", item reference will be: "item-001"
336
+ lcon qti-to-learnosity --in Items/my-item.xml --out item.json --item-reference-source sourceFilename
337
+ # Item reference will be: "my-item"
338
338
  ```
339
339
 
340
- Use QTI mode when:
340
+ **`--item-reference-source qti`**: Deprecated alias of `itemIdentifier`; produces the identical result. New integrations should use `itemIdentifier`.
341
+
342
+ Use the default (`itemIdentifier`) when:
341
343
 
342
- - You want item references to match the QTI identifier attribute in the XML
344
+ - You want item references to match the QTI `identifier` attribute in the XML
343
345
  - The QTI identifiers are more meaningful than the filenames
344
- - You're migrating from an older version of the converter
346
+
347
+ Use `sourceFilename` when you need the earlier filename-based behaviour.
345
348
 
346
349
  ### `--item-filename-source`
347
350
 
348
351
  _Available for: `qti-package-to-learnosity`_
349
352
 
350
- Control how output JSON files are named, independently from the item reference. Values: `sourceFilename` or `qti`.
353
+ Control how output JSON files are named, independently from the item reference. Values: `itemIdentifier`, `qti` (deprecated alias of `itemIdentifier`), or `sourceFilename`.
351
354
 
352
355
  **Default:** When omitted, output filenames match the item reference (i.e. whatever `--item-reference-source` produces). The option only has an effect when its value differs from `--item-reference-source`.
353
356
 
354
357
  | Value | Behavior |
355
358
  | ---------------- | -------------------------------------------------------------------------- |
359
+ | `itemIdentifier` | Name output files after the QTI `identifier` attribute from the XML |
360
+ | `qti` | Deprecated alias of `itemIdentifier` |
356
361
  | `sourceFilename` | Name output files after the source XML filename (without `.xml` extension) |
357
- | `qti` | Name output files after the QTI `identifier` attribute from the XML |
358
362
 
359
363
  This is useful when you want the `item.reference` inside the JSON to use one naming strategy, but the output filename on disk to use another.
360
364
 
@@ -569,8 +573,8 @@ Create `lrn-converter.config.json` in your working directory to set default opti
569
573
  "organisationId": 12345,
570
574
  "mediaVault": false,
571
575
  "customAssetUrl": "https://my-cdn.example.com/assets",
572
- "itemReferenceSource": "sourceFilename",
573
- "itemFilenameSource": "qti"
576
+ "itemReferenceSource": "itemIdentifier",
577
+ "itemFilenameSource": "sourceFilename"
574
578
  }
575
579
  ```
576
580
 
@@ -578,21 +582,21 @@ Create `lrn-converter.config.json` in your working directory to set default opti
578
582
 
579
583
  All options are optional. CLI flags override config file values.
580
584
 
581
- | Option | Type | Default | Description |
582
- | ------------------------ | ---------------------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
583
- | `qtiVersion` | `"2.1"` \| `"2.2"` | `"2.2"` | QTI version to use for conversion |
584
- | `outputFormat` | `"dir"` \| `"zip"` \| `"stdout"` | `"dir"` | Output format (auto-detected based on output path) |
585
- | `diagnostics` | `"stderr"` \| `"file"` \| `"both"` \| `"none"` | `"file"` | Where to write diagnostic messages |
586
- | `pretty` | `boolean` | `false` | Pretty-print JSON/XML output |
587
- | `verbose` | `boolean` | `false` | Show detailed progress information |
588
- | `output` | `string` | `"-"` | Default output directory for interactive mode |
589
- | `organisationId` | `number` | - | Organisation ID for Learnosity CDN asset URLs |
590
- | `mediaVault` | `boolean` | `false` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
591
- | `customAssetUrl` | `string` | - | Custom base URL/prefix for assets. QTI → Learnosity: overrides the default Learnosity CDN and `mediaVault`. Learnosity → QTI: replaces the asset prefix up to the filename (default `./assets`) |
592
- | `preserveAssetFilenames` | `boolean` | `false` | QTI → Learnosity only: opt out of deterministic hashed asset names and preserve the original final QTI basename; collisions remain errors |
593
- | `truncateTags` | `boolean` | `false` | Truncate tag types and names to 255 characters instead of failing |
594
- | `itemReferenceSource` | `"sourceFilename"` \| `"qti"` \| `"uuid"` | `"sourceFilename"` | How to generate item references (QTI → Learnosity only) |
595
- | `itemFilenameSource` | `"sourceFilename"` \| `"qti"` | Same as `itemReferenceSource` | How to name output JSON files. Defaults to the resolved `itemReferenceSource` value if omitted |
585
+ | Option | Type | Default | Description |
586
+ | ------------------------ | --------------------------------------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
587
+ | `qtiVersion` | `"2.1"` \| `"2.2"` | `"2.2"` | QTI version to use for conversion |
588
+ | `outputFormat` | `"dir"` \| `"zip"` \| `"stdout"` | `"dir"` | Output format (auto-detected based on output path) |
589
+ | `diagnostics` | `"stderr"` \| `"file"` \| `"both"` \| `"none"` | `"file"` | Where to write diagnostic messages |
590
+ | `pretty` | `boolean` | `false` | Pretty-print JSON/XML output |
591
+ | `verbose` | `boolean` | `false` | Show detailed progress information |
592
+ | `output` | `string` | `"-"` | Default output directory for interactive mode |
593
+ | `organisationId` | `number` | - | Organisation ID for Learnosity CDN asset URLs |
594
+ | `mediaVault` | `boolean` | `false` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
595
+ | `customAssetUrl` | `string` | - | Custom base URL/prefix for assets. QTI → Learnosity: overrides the default Learnosity CDN and `mediaVault`. Learnosity → QTI: replaces the asset prefix up to the filename (default `./assets`) |
596
+ | `preserveAssetFilenames` | `boolean` | `false` | QTI → Learnosity only: opt out of deterministic hashed asset names and preserve the original final QTI basename; collisions remain errors |
597
+ | `truncateTags` | `boolean` | `false` | Truncate tag types and names to 255 characters instead of failing |
598
+ | `itemReferenceSource` | `"itemIdentifier"` \| `"qti"` \| `"sourceFilename"` \| `"uuid"` | `"itemIdentifier"` | How to generate item references (QTI → Learnosity only). `"qti"` is a deprecated alias of `"itemIdentifier"` |
599
+ | `itemFilenameSource` | `"itemIdentifier"` \| `"qti"` \| `"sourceFilename"` | Same as `itemReferenceSource` | How to name output JSON files. Defaults to the resolved `itemReferenceSource` value if omitted. `"qti"` is a deprecated alias of `"itemIdentifier"` |
596
600
 
597
601
  ### Config File Usage
598
602
 
@@ -50,7 +50,7 @@ The manifest file defines the structure of the bundle and maps activities to the
50
50
  "organisationId": 12345,
51
51
  "mediaVault": false,
52
52
  "customAssetUrl": "https://cdn.example.com/assets",
53
- "itemReferenceSource": "sourceFilename"
53
+ "itemReferenceSource": "itemIdentifier"
54
54
  }
55
55
  },
56
56
  "items": ["item_001", "item_002"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@learnosity/lib-qti-converter",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "description": "QTI ↔ Learnosity JSON converter",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
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-DTSv0atR.js";
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-D1ydwhbX.js";
2
2
  import { t as nodeFileAccess } from "./nodeFileAccess-BhCoGDOi.js";
3
3
  import * as path$1 from "node:path";
4
4
  import { join, relative, sep } from "node:path";
@@ -2278,6 +2278,15 @@ var AssetFilenameRegistry = class {
2278
2278
  * - Does not write outputs if any error diagnostics exist
2279
2279
  * - Deterministic ordering and stable JSON serialization
2280
2280
  */
2281
+ /**
2282
+ * Normalize an item reference / filename source for comparison and defaulting.
2283
+ * `'qti'` is a deprecated alias of `'itemIdentifier'`, and an omitted value
2284
+ * defaults to `'itemIdentifier'`.
2285
+ */
2286
+ function normalizeRefSource(source) {
2287
+ if (source === "qti" || source === void 0) return "itemIdentifier";
2288
+ return source;
2289
+ }
2281
2290
  const utf8Decoder = new TextDecoder();
2282
2291
  /** Decode entry bytes as UTF-8 (works for both Uint8Array and Node Buffer). */
2283
2292
  function decodeUtf8(data) {
@@ -2329,6 +2338,17 @@ function readAssessmentItemIdentifier(inputXml, fallback) {
2329
2338
  } catch {}
2330
2339
  return identifier;
2331
2340
  }
2341
+ function readAssessmentTestIdentifier(inputXml, fallback) {
2342
+ let identifier = fallback;
2343
+ const parser = new import_saxes.SaxesParser({ xmlns: true });
2344
+ parser.on("opentag", (tag) => {
2345
+ if ((tag.local ?? tag.name) === "assessmentTest") identifier = getAttr$2(tag, "identifier") ?? fallback;
2346
+ });
2347
+ try {
2348
+ parser.write(inputXml).close();
2349
+ } catch {}
2350
+ return identifier;
2351
+ }
2332
2352
  function uniqueItemReference(baseReference, sourceHref, items) {
2333
2353
  if (!items.has(baseReference)) return baseReference;
2334
2354
  const readableCandidate = `${baseReference}_${normalizeHref(sourceHref).split("/").at(-1)?.replace(/\.xml$/i, "") ?? "item"}`;
@@ -2612,7 +2632,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
2612
2632
  inputXml: itemXml
2613
2633
  });
2614
2634
  const filenameSource = opts?.itemFilenameSource;
2615
- if (filenameSource && filenameSource !== (opts.itemReferenceSource ?? "sourceFilename")) {
2635
+ if (filenameSource && normalizeRefSource(filenameSource) !== normalizeRefSource(opts.itemReferenceSource)) {
2616
2636
  const qtiIdentifier = readAssessmentItemIdentifier(itemXml, md5Ref);
2617
2637
  const filename = generateItemReference(qtiIdentifier, filenameSource, itemFilePath);
2618
2638
  itemFilenames.set(md5Ref, filename);
@@ -2644,8 +2664,10 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
2644
2664
  const activitiesManifest = {};
2645
2665
  if (testResources.length > 0) for (const testResource of testResources) {
2646
2666
  let activityReference;
2647
- if (opts?.itemReferenceSource === "qti") activityReference = testResource.identifier;
2648
- else {
2667
+ if (normalizeRefSource(opts?.itemReferenceSource) === "itemIdentifier") {
2668
+ const testEntry = entries.get(normalizeHref(testResource.href));
2669
+ activityReference = testEntry ? readAssessmentTestIdentifier(decodeUtf8(testEntry.data), testResource.identifier) : testResource.identifier;
2670
+ } else {
2649
2671
  const hrefParts = testResource.href.split("/");
2650
2672
  activityReference = hrefParts[hrefParts.length - 1].replace(/\.xml$/i, "");
2651
2673
  }
@@ -2781,7 +2803,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
2781
2803
  mediaVault: opts?.mediaVault ?? false,
2782
2804
  customAssetUrl: opts?.customAssetUrl,
2783
2805
  preserveAssetFilenames: opts?.preserveAssetFilenames ?? false,
2784
- itemReferenceSource: opts?.itemReferenceSource ?? "sourceFilename"
2806
+ itemReferenceSource: opts?.itemReferenceSource ?? "itemIdentifier"
2785
2807
  }
2786
2808
  },
2787
2809
  items: Array.from(items.keys()).sort(),
@@ -3944,4 +3966,4 @@ function itemRefsToFilenames(bundle, itemRefs) {
3944
3966
  //#endregion
3945
3967
  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 };
3946
3968
 
3947
- //# sourceMappingURL=batchProcessors-DgiDpfpP.js.map
3969
+ //# sourceMappingURL=batchProcessors-DWG8qk7G.js.map