@learnosity/lib-qti-converter 0.14.0 → 0.15.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 (39) hide show
  1. package/docs/EXAMPLES.md +13 -11
  2. package/docs/GETTING_STARTED.md +11 -0
  3. package/docs/QTI_METADATA_TO_TAGS.md +47 -4
  4. package/docs/TAGS_TO_QTI_METADATA.md +8 -7
  5. package/package.json +8 -8
  6. package/packages/cli/dist/{batchProcessors-DWG8qk7G.js → batchProcessors-B6yUImA3.js} +6 -2
  7. package/packages/cli/dist/{batchProcessors-DWG8qk7G.js.map → batchProcessors-B6yUImA3.js.map} +1 -1
  8. package/packages/cli/dist/batchWorker.js +1 -1
  9. package/packages/cli/dist/{create-prompt-DyNnKXYU.js → create-prompt-dWckcotJ.js} +45 -43
  10. package/packages/cli/dist/create-prompt-dWckcotJ.js.map +1 -0
  11. package/packages/cli/dist/{dist-D3v6G5F8.js → dist-DXDR2peT.js} +6 -6
  12. package/packages/cli/dist/{dist-D3v6G5F8.js.map → dist-DXDR2peT.js.map} +1 -1
  13. package/packages/cli/dist/{learnosityToQti-C7cTRTU2.js → learnosityToQti-DIxeAztu.js} +4 -4
  14. package/packages/cli/dist/{learnosityToQti-C7cTRTU2.js.map → learnosityToQti-DIxeAztu.js.map} +1 -1
  15. package/packages/cli/dist/{learnosityToQtiPackage-C84dQKKi.js → learnosityToQtiPackage-CMFop6H4.js} +7 -7
  16. package/packages/cli/dist/{learnosityToQtiPackage-C84dQKKi.js.map → learnosityToQtiPackage-CMFop6H4.js.map} +1 -1
  17. package/packages/cli/dist/main.js +5 -5
  18. package/packages/cli/dist/main.js.map +1 -1
  19. package/packages/cli/dist/{pathUtils-Cr9IcK0n.js → pathUtils-6nZKvVmg.js} +18 -8
  20. package/packages/cli/dist/pathUtils-6nZKvVmg.js.map +1 -0
  21. package/packages/cli/dist/{qtiPackageToLearnosity-BBfZgWBh.js → qtiPackageToLearnosity-Sk_1j12c.js} +12 -6
  22. package/packages/cli/dist/qtiPackageToLearnosity-Sk_1j12c.js.map +1 -0
  23. package/packages/cli/dist/{qtiToLearnosity-C9OW_n7Z.js → qtiToLearnosity-_tybImv1.js} +6 -5
  24. package/packages/cli/dist/qtiToLearnosity-_tybImv1.js.map +1 -0
  25. package/packages/cli/dist/{resolveOptions-D_UECo_9.js → resolveOptions-6ReJUr-D.js} +23 -17
  26. package/packages/cli/dist/resolveOptions-6ReJUr-D.js.map +1 -0
  27. package/packages/cli/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-DktXgydw.js} +1 -1
  28. package/packages/cli/dist/{table-D1ydwhbX.js → table-CLUiytPO.js} +99 -48
  29. package/packages/cli/dist/table-CLUiytPO.js.map +1 -0
  30. package/packages/core/dist/index.d.ts +3 -0
  31. package/packages/core/dist/index.js +95 -40
  32. package/packages/core/dist/node.d.ts +5 -0
  33. package/packages/core/dist/node.js +96 -40
  34. package/packages/cli/dist/create-prompt-DyNnKXYU.js.map +0 -1
  35. package/packages/cli/dist/pathUtils-Cr9IcK0n.js.map +0 -1
  36. package/packages/cli/dist/qtiPackageToLearnosity-BBfZgWBh.js.map +0 -1
  37. package/packages/cli/dist/qtiToLearnosity-C9OW_n7Z.js.map +0 -1
  38. package/packages/cli/dist/resolveOptions-D_UECo_9.js.map +0 -1
  39. package/packages/cli/dist/table-D1ydwhbX.js.map +0 -1
package/docs/EXAMPLES.md CHANGED
@@ -797,6 +797,7 @@ The package exports the following for library consumers:
797
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
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
799
  | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
800
+ | `splitCsvTags` | `boolean` | No | `--no-split-csv-tags` | Split comma-separated tag values into separate array elements (default: `true`); pass `--no-split-csv-tags` to keep them as a single value |
800
801
 
801
802
  **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.
802
803
 
@@ -804,17 +805,18 @@ The package exports the following for library consumers:
804
805
 
805
806
  `convertQtiPackageToLearnosity` accepts a `ConvertQtiPackageToLearnosityOptions` object:
806
807
 
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 |
808
+ | Option | Type | Required | CLI Equivalent | Description |
809
+ | --------------------- | --------------------------------------------------------------- | -------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
810
+ | `inputPath` | `string` | \* | `--in` | Path to QTI package directory or .zip file |
811
+ | `zipBytes` | `Uint8Array` | \* | N/A | Raw ZIP bytes (alternative to `inputPath`) |
812
+ | `outputPath` | `string` | No | `--out` | Output path (directory or .zip). Omit to skip writing to disk |
813
+ | `organisationId` | `number` | No | `--organisation_id` | Organisation ID for Learnosity CDN asset URLs |
814
+ | `mediaVault` | `boolean` | No | `--mediavault` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
815
+ | `customAssetUrl` | `string` | No | `--custom-asset-url` | Custom base URL for assets (overrides default Learnosity CDN and `mediaVault`) |
816
+ | `itemReferenceSource` | `'itemIdentifier'` \| `'qti'` \| `'sourceFilename'` \| `'uuid'` | No | `--item-reference-source` | How to generate item references. Default: `'itemIdentifier'`. `'qti'` is a deprecated alias of `'itemIdentifier'` |
817
+ | `itemFilenameSource` | `'itemIdentifier'` \| `'qti'` \| `'sourceFilename'` | No | `--item-filename-source` | How to name output files. `'qti'` is a deprecated alias of `'itemIdentifier'` |
818
+ | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
819
+ | `splitCsvTags` | `boolean` | No | `--no-split-csv-tags` | Split comma-separated tag values into separate array elements (default: `true`); pass `--no-split-csv-tags` to keep them as a single value |
818
820
 
819
821
  \* Either `inputPath` or `zipBytes` must be provided.
820
822
 
@@ -499,6 +499,16 @@ Truncate tag types and names to 255 characters instead of failing the conversion
499
499
  lcon qti-to-learnosity --in item.xml --out item.json --truncate-tags
500
500
  ```
501
501
 
502
+ ### `--no-split-csv-tags`
503
+
504
+ _Available for: `qti-to-learnosity`, `qti-package-to-learnosity`_
505
+
506
+ By default, a comma-separated tag value is split so each item becomes a separate array element (trimmed, empties dropped). Pass this flag to keep comma-containing values as a single value instead.
507
+
508
+ ```bash
509
+ lcon qti-to-learnosity --in item.xml --out item.json --no-split-csv-tags
510
+ ```
511
+
502
512
  ### `--fail-on-warn`
503
513
 
504
514
  _Available for: `learnosity-to-qti`, `learnosity-to-qti-package`, `qti-package-to-learnosity`_
@@ -595,6 +605,7 @@ All options are optional. CLI flags override config file values.
595
605
  | `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
606
  | `preserveAssetFilenames` | `boolean` | `false` | QTI → Learnosity only: opt out of deterministic hashed asset names and preserve the original final QTI basename; collisions remain errors |
597
607
  | `truncateTags` | `boolean` | `false` | Truncate tag types and names to 255 characters instead of failing |
608
+ | `splitCsvTags` | `boolean` | `true` | Split comma-separated tag values into separate array elements (QTI → Learnosity only); pass `--no-split-csv-tags` to keep them as a single value |
598
609
  | `itemReferenceSource` | `"itemIdentifier"` \| `"qti"` \| `"sourceFilename"` \| `"uuid"` | `"itemIdentifier"` | How to generate item references (QTI → Learnosity only). `"qti"` is a deprecated alias of `"itemIdentifier"` |
599
610
  | `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"` |
600
611
 
@@ -17,9 +17,9 @@ The converter searches for metadata in two locations:
17
17
 
18
18
  1. **Manifest metadata** - `<metadata>` blocks within each `<resource>` element in `imsmanifest.xml`
19
19
  2. **Standalone LOM files** - Files named `<itemId>.lom.xml` located in a `metadata/` folder resolved relative to the item XML (not alongside the item file). The finder checks, in order:
20
- - `items/<id>.xml` → `metadata/<id>.lom.xml` (sibling `metadata/` beside the `items/` folder)
21
- - `<dir>/<id>.xml` → `<dir>/metadata/<id>.lom.xml`
22
- - `<dir>/<id>.xml` → `<dir>/../metadata/<id>.lom.xml`
20
+ - `items/<id>.xml` → `metadata/<id>.lom.xml` (sibling `metadata/` beside the `items/` folder)
21
+ - `<dir>/<id>.xml` → `<dir>/metadata/<id>.lom.xml`
22
+ - `<dir>/<id>.xml` → `<dir>/../metadata/<id>.lom.xml`
23
23
 
24
24
  When both sources are present, **manifest tags take priority** over standalone-LOM tags: the converter merges via `mergeTagObjects(existingTags, tagResult.tags)`, where the manifest-derived tags are the base that wins on any conflicting tag type.
25
25
 
@@ -87,7 +87,7 @@ When both sources are present, **manifest tags take priority** over standalone-L
87
87
  - Tag values come from `<imsmd:taxon>/<imsmd:entry>` elements
88
88
 
89
89
  > **Note on casing:** the parser accepts both `taxonPath`/`taxonpath` and
90
- > `langstring`/`langString`. When the converter *emits* LOM (Learnosity → QTI),
90
+ > `langstring`/`langString`. When the converter _emits_ LOM (Learnosity → QTI),
91
91
  > it always writes the lowercase IMS MD v1.2 element names — `imsmd:taxonpath`
92
92
  > and `imsmd:langstring`.
93
93
 
@@ -191,6 +191,49 @@ When both LOM and Common Cartridge metadata are present in the same resource, th
191
191
 
192
192
  ---
193
193
 
194
+ ## Comma-Separated Tag Values
195
+
196
+ By **default**, a single tag value that contains comma-separated items is split so
197
+ each item becomes a separate element in the tag's array. This applies to both the
198
+ LOM `<imsmd:taxon>/<imsmd:entry>` values and the Common Cartridge `<csm:GUID>`
199
+ values. Each split item is trimmed, and empty items (from leading, trailing, or
200
+ double commas) are dropped. Splitting happens before deduplication, so repeated
201
+ items collapse to a single entry.
202
+
203
+ For example, this LOM taxon entry:
204
+
205
+ ```xml
206
+ <imsmd:taxonPath>
207
+ <imsmd:source><imsmd:string>ABStandardGUIDs</imsmd:string></imsmd:source>
208
+ <imsmd:taxon>
209
+ <imsmd:entry>
210
+ <imsmd:string>EE1A4834-A645-11E2-8098-4A539DFF4B22,A3DF22D0-3B97-46F0-9AF2-A1725261601A,B4B0E4F0-AF48-4CEB-8227-264B292A3058</imsmd:string>
211
+ </imsmd:entry>
212
+ </imsmd:taxon>
213
+ </imsmd:taxonPath>
214
+ ```
215
+
216
+ produces three separate array elements:
217
+
218
+ ```json
219
+ {
220
+ "tags": {
221
+ "ABStandardGUIDs": [
222
+ "EE1A4834-A645-11E2-8098-4A539DFF4B22",
223
+ "A3DF22D0-3B97-46F0-9AF2-A1725261601A",
224
+ "B4B0E4F0-AF48-4CEB-8227-264B292A3058"
225
+ ]
226
+ }
227
+ }
228
+ ```
229
+
230
+ To keep comma-containing values as a single value instead, pass
231
+ `--no-split-csv-tags` on the CLI (or set `splitCsvTags: false` in a config file).
232
+ With splitting disabled, the example above yields a single-element array holding
233
+ the whole comma-separated string.
234
+
235
+ ---
236
+
194
237
  ## Tag Validation and Length Limits
195
238
 
196
239
  ### Maximum Tag Length
@@ -273,13 +273,14 @@ The `metadata/` folder is only present when at least one item has tags.
273
273
 
274
274
  ## Differences from QTI-to-Learnosity Direction
275
275
 
276
- | Aspect | QTI → Learnosity | Learnosity → QTI |
277
- | --------------------- | ---------------------------------- | --------------------- |
278
- | Formats supported | LOM + Common Cartridge | LOM only |
279
- | Metadata location | Manifest inline + standalone files | Standalone files only |
280
- | Tag length validation | 255-char limit enforced | No length validation |
281
- | Truncation option | `--truncate-tags` available | Not applicable |
282
- | Merge behavior | Manifest tags take priority | N/A (single source) |
276
+ | Aspect | QTI → Learnosity | Learnosity → QTI |
277
+ | --------------------- | --------------------------------------------- | --------------------- |
278
+ | Formats supported | LOM + Common Cartridge | LOM only |
279
+ | Metadata location | Manifest inline + standalone files | Standalone files only |
280
+ | Tag length validation | 255-char limit enforced | No length validation |
281
+ | Truncation option | `--truncate-tags` available | Not applicable |
282
+ | CSV value splitting | On by default; `--no-split-csv-tags` disables | Not applicable |
283
+ | Merge behavior | Manifest tags take priority | N/A (single source) |
283
284
 
284
285
  ---
285
286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@learnosity/lib-qti-converter",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "QTI ↔ Learnosity JSON converter",
6
6
  "license": "MIT",
@@ -73,18 +73,18 @@
73
73
  },
74
74
  "devDependencies": {
75
75
  "@arethetypeswrong/cli": "^0.18.5",
76
- "@types/node": "^26.6.2",
77
- "@typescript-eslint/eslint-plugin": "^8.70.0",
78
- "@typescript-eslint/parser": "^8.70.0",
76
+ "@types/node": "^26.6.5",
77
+ "@typescript-eslint/eslint-plugin": "^8.71.2",
78
+ "@typescript-eslint/parser": "^8.71.2",
79
79
  "@typescript/native": "npm:typescript@^7.0.2",
80
80
  "@vitest/coverage-v8": "^4.1.11",
81
- "eslint": "^10.11.0",
81
+ "eslint": "^10.12.0",
82
82
  "glob": "^13.0.6",
83
- "publint": "^0.3.24",
84
- "tsdown": "^0.23.0",
83
+ "publint": "^0.3.25",
84
+ "tsdown": "^0.23.1",
85
85
  "tsx": "^4.23.15",
86
86
  "typescript": "npm:@typescript/typescript6@^6.0.2",
87
- "vite": "^8.3.0",
87
+ "vite": "^8.3.4",
88
88
  "vitest": "^4.1.11"
89
89
  },
90
90
  "engines": {
@@ -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-D1ydwhbX.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-CLUiytPO.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";
@@ -2575,6 +2575,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
2575
2575
  customAssetUrl: opts?.customAssetUrl,
2576
2576
  preserveAssetFilenames: opts?.preserveAssetFilenames ?? false,
2577
2577
  itemReferenceSource: opts?.itemReferenceSource,
2578
+ splitCsvTags: opts?.splitCsvTags,
2578
2579
  fileAccess: opts?.fileAccess,
2579
2580
  packageRoot: opts?.sourceDir,
2580
2581
  finalItemReference,
@@ -2611,6 +2612,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
2611
2612
  if (itemResource.metadataXml) try {
2612
2613
  const tagResult = parseMetadataTags(itemResource.metadataXml, {
2613
2614
  truncateTags: opts?.truncateTags,
2615
+ splitCsvTags: opts?.splitCsvTags,
2614
2616
  filePath: itemResource.href
2615
2617
  });
2616
2618
  diagnostics.push(...tagResult.diagnostics);
@@ -2709,6 +2711,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
2709
2711
  if (testResource.metadataXml) try {
2710
2712
  const tagResult = parseMetadataTags(testResource.metadataXml, {
2711
2713
  truncateTags: opts?.truncateTags,
2714
+ splitCsvTags: opts?.splitCsvTags,
2712
2715
  filePath: testResource.href
2713
2716
  });
2714
2717
  diagnostics.push(...tagResult.diagnostics);
@@ -3784,6 +3787,7 @@ async function processQtiPackageToLearnosity(pkg, packageOutputPath, options, qu
3784
3787
  itemReferenceSource: options.itemReferenceSource,
3785
3788
  itemFilenameSource: options.itemFilenameSource,
3786
3789
  truncateTags: options.truncateTags,
3790
+ splitCsvTags: options.splitCsvTags,
3787
3791
  packageVersion: options.version,
3788
3792
  sourceDir: pkg.path,
3789
3793
  fileAccess: nodeFileAccess
@@ -3966,4 +3970,4 @@ function itemRefsToFilenames(bundle, itemRefs) {
3966
3970
  //#endregion
3967
3971
  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 };
3968
3972
 
3969
- //# sourceMappingURL=batchProcessors-DWG8qk7G.js.map
3973
+ //# sourceMappingURL=batchProcessors-B6yUImA3.js.map