@learnosity/lib-qti-converter 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/EXAMPLES.md +48 -34
- package/docs/GETTING_STARTED.md +43 -28
- package/docs/LEARNOSITY_BUNDLE_FORMAT.md +1 -1
- package/docs/QTI_METADATA_TO_TAGS.md +47 -4
- package/docs/TAGS_TO_QTI_METADATA.md +8 -7
- package/package.json +1 -1
- package/packages/cli/dist/{batchProcessors-DgiDpfpP.js → batchProcessors-B6Xmhfaz.js} +32 -6
- package/packages/cli/dist/batchProcessors-B6Xmhfaz.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{learnosityToQti-CIj5603P.js → learnosityToQti-hFKA3KnZ.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-CIj5603P.js.map → learnosityToQti-hFKA3KnZ.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-n6nGGr32.js → learnosityToQtiPackage-DI7bYisT.js} +4 -4
- package/packages/cli/dist/{learnosityToQtiPackage-n6nGGr32.js.map → learnosityToQtiPackage-DI7bYisT.js.map} +1 -1
- package/packages/cli/dist/main.js +4 -4
- package/packages/cli/dist/{pathUtils-mTQZ0wYS.js → pathUtils-DkptaCiz.js} +22 -7
- package/packages/cli/dist/{pathUtils-mTQZ0wYS.js.map → pathUtils-DkptaCiz.js.map} +1 -1
- package/packages/cli/dist/{qtiPackageToLearnosity-B4cD8jUw.js → qtiPackageToLearnosity-JDifZn8o.js} +14 -8
- package/packages/cli/dist/qtiPackageToLearnosity-JDifZn8o.js.map +1 -0
- package/packages/cli/dist/{qtiToLearnosity-DDjcpShJ.js → qtiToLearnosity-Be0s-5Dr.js} +6 -5
- package/packages/cli/dist/qtiToLearnosity-Be0s-5Dr.js.map +1 -0
- package/packages/cli/dist/{resolveOptions-Czapkfc1.js → resolveOptions-BotCofhl.js} +15 -5
- package/packages/cli/dist/resolveOptions-BotCofhl.js.map +1 -0
- package/packages/cli/dist/{table-DTSv0atR.js → table-DlY4LGmL.js} +98 -43
- package/packages/cli/dist/table-DlY4LGmL.js.map +1 -0
- package/packages/core/dist/index.d.ts +10 -4
- package/packages/core/dist/index.js +128 -46
- package/packages/core/dist/node.d.ts +13 -5
- package/packages/core/dist/node.js +129 -46
- package/packages/cli/dist/batchProcessors-DgiDpfpP.js.map +0 -1
- package/packages/cli/dist/qtiPackageToLearnosity-B4cD8jUw.js.map +0 -1
- package/packages/cli/dist/qtiToLearnosity-DDjcpShJ.js.map +0 -1
- package/packages/cli/dist/resolveOptions-Czapkfc1.js.map +0 -1
- package/packages/cli/dist/table-DTSv0atR.js.map +0 -1
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 (
|
|
211
|
+
**Default behavior (QTI identifier references):**
|
|
212
212
|
|
|
213
|
-
By default (`--item-reference-source
|
|
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
|
-
|
|
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
|
-
|
|
249
|
+
**`qti` as a deprecated alias:**
|
|
237
250
|
|
|
238
|
-
|
|
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: `
|
|
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
|
|
271
|
+
--item-reference-source itemIdentifier \
|
|
260
272
|
--item-filename-source sourceFilename
|
|
261
273
|
```
|
|
262
274
|
|
|
@@ -772,19 +784,20 @@ The package exports the following for library consumers:
|
|
|
772
784
|
|
|
773
785
|
`convertQtiToLearnosity` and `convertLearnosityToQti` accept a `ConversionOptions` object:
|
|
774
786
|
|
|
775
|
-
| Option | Type
|
|
776
|
-
| --------------------- |
|
|
777
|
-
| `qtiVersion` | `'2.1'` \| `'2.2'`
|
|
778
|
-
| `outputFormat` | `'dir'` \| `'zip'` \| `'stdout'`
|
|
779
|
-
| `diagnostics` | `'stderr'` \| `'file'` \| `'both'` \| `'none'`
|
|
780
|
-
| `verbose` | `boolean`
|
|
781
|
-
| `pretty` | `boolean`
|
|
782
|
-
| `inputPath` | `string`
|
|
783
|
-
| `organisationId` | `number`
|
|
784
|
-
| `mediaVault` | `boolean`
|
|
785
|
-
| `customAssetUrl` | `string`
|
|
786
|
-
| `itemReferenceSource` | `'
|
|
787
|
-
| `truncateTags` | `boolean`
|
|
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 |
|
|
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 |
|
|
788
801
|
|
|
789
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.
|
|
790
803
|
|
|
@@ -792,17 +805,18 @@ The package exports the following for library consumers:
|
|
|
792
805
|
|
|
793
806
|
`convertQtiPackageToLearnosity` accepts a `ConvertQtiPackageToLearnosityOptions` object:
|
|
794
807
|
|
|
795
|
-
| Option | Type
|
|
796
|
-
| --------------------- |
|
|
797
|
-
| `inputPath` | `string`
|
|
798
|
-
| `zipBytes` | `Uint8Array`
|
|
799
|
-
| `outputPath` | `string`
|
|
800
|
-
| `organisationId` | `number`
|
|
801
|
-
| `mediaVault` | `boolean`
|
|
802
|
-
| `customAssetUrl` | `string`
|
|
803
|
-
| `itemReferenceSource` | `'
|
|
804
|
-
| `itemFilenameSource` | `'
|
|
805
|
-
| `truncateTags` | `boolean`
|
|
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 |
|
|
806
820
|
|
|
807
821
|
\* Either `inputPath` or `zipBytes` must be provided.
|
|
808
822
|
|
package/docs/GETTING_STARTED.md
CHANGED
|
@@ -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: `
|
|
324
|
+
Control how item references are generated. Options: `itemIdentifier` (default), `qti` (deprecated alias of `itemIdentifier`), `sourceFilename`, or `uuid`.
|
|
325
325
|
|
|
326
|
-
**Default (`
|
|
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
|
-
#
|
|
330
|
+
# If the XML has identifier="item-001", item reference will be: "item-001"
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
|
|
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
|
|
337
|
-
#
|
|
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
|
-
|
|
340
|
+
**`--item-reference-source qti`**: Deprecated alias of `itemIdentifier`; produces the identical result. New integrations should use `itemIdentifier`.
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
Use the default (`itemIdentifier`) when:
|
|
343
|
+
|
|
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
|
-
|
|
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: `
|
|
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
|
|
|
@@ -495,6 +499,16 @@ Truncate tag types and names to 255 characters instead of failing the conversion
|
|
|
495
499
|
lcon qti-to-learnosity --in item.xml --out item.json --truncate-tags
|
|
496
500
|
```
|
|
497
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
|
+
|
|
498
512
|
### `--fail-on-warn`
|
|
499
513
|
|
|
500
514
|
_Available for: `learnosity-to-qti`, `learnosity-to-qti-package`, `qti-package-to-learnosity`_
|
|
@@ -569,8 +583,8 @@ Create `lrn-converter.config.json` in your working directory to set default opti
|
|
|
569
583
|
"organisationId": 12345,
|
|
570
584
|
"mediaVault": false,
|
|
571
585
|
"customAssetUrl": "https://my-cdn.example.com/assets",
|
|
572
|
-
"itemReferenceSource": "
|
|
573
|
-
"itemFilenameSource": "
|
|
586
|
+
"itemReferenceSource": "itemIdentifier",
|
|
587
|
+
"itemFilenameSource": "sourceFilename"
|
|
574
588
|
}
|
|
575
589
|
```
|
|
576
590
|
|
|
@@ -578,21 +592,22 @@ Create `lrn-converter.config.json` in your working directory to set default opti
|
|
|
578
592
|
|
|
579
593
|
All options are optional. CLI flags override config file values.
|
|
580
594
|
|
|
581
|
-
| Option | Type
|
|
582
|
-
| ------------------------ |
|
|
583
|
-
| `qtiVersion` | `"2.1"` \| `"2.2"`
|
|
584
|
-
| `outputFormat` | `"dir"` \| `"zip"` \| `"stdout"`
|
|
585
|
-
| `diagnostics` | `"stderr"` \| `"file"` \| `"both"` \| `"none"`
|
|
586
|
-
| `pretty` | `boolean`
|
|
587
|
-
| `verbose` | `boolean`
|
|
588
|
-
| `output` | `string`
|
|
589
|
-
| `organisationId` | `number`
|
|
590
|
-
| `mediaVault` | `boolean`
|
|
591
|
-
| `customAssetUrl` | `string`
|
|
592
|
-
| `preserveAssetFilenames` | `boolean`
|
|
593
|
-
| `truncateTags` | `boolean`
|
|
594
|
-
| `
|
|
595
|
-
| `
|
|
595
|
+
| Option | Type | Default | Description |
|
|
596
|
+
| ------------------------ | --------------------------------------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
597
|
+
| `qtiVersion` | `"2.1"` \| `"2.2"` | `"2.2"` | QTI version to use for conversion |
|
|
598
|
+
| `outputFormat` | `"dir"` \| `"zip"` \| `"stdout"` | `"dir"` | Output format (auto-detected based on output path) |
|
|
599
|
+
| `diagnostics` | `"stderr"` \| `"file"` \| `"both"` \| `"none"` | `"file"` | Where to write diagnostic messages |
|
|
600
|
+
| `pretty` | `boolean` | `false` | Pretty-print JSON/XML output |
|
|
601
|
+
| `verbose` | `boolean` | `false` | Show detailed progress information |
|
|
602
|
+
| `output` | `string` | `"-"` | Default output directory for interactive mode |
|
|
603
|
+
| `organisationId` | `number` | - | Organisation ID for Learnosity CDN asset URLs |
|
|
604
|
+
| `mediaVault` | `boolean` | `false` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
|
|
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`) |
|
|
606
|
+
| `preserveAssetFilenames` | `boolean` | `false` | QTI → Learnosity only: opt out of deterministic hashed asset names and preserve the original final QTI basename; collisions remain errors |
|
|
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 |
|
|
609
|
+
| `itemReferenceSource` | `"itemIdentifier"` \| `"qti"` \| `"sourceFilename"` \| `"uuid"` | `"itemIdentifier"` | How to generate item references (QTI → Learnosity only). `"qti"` is a deprecated alias of `"itemIdentifier"` |
|
|
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"` |
|
|
596
611
|
|
|
597
612
|
### Config File Usage
|
|
598
613
|
|
|
@@ -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": "
|
|
53
|
+
"itemReferenceSource": "itemIdentifier"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"items": ["item_001", "item_002"],
|
|
@@ -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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
|
277
|
-
| --------------------- |
|
|
278
|
-
| Formats supported | LOM + Common Cartridge
|
|
279
|
-
| Metadata location | Manifest inline + standalone files
|
|
280
|
-
| Tag length validation | 255-char limit enforced
|
|
281
|
-
| Truncation option | `--truncate-tags` available
|
|
282
|
-
|
|
|
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,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-
|
|
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-DlY4LGmL.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"}`;
|
|
@@ -2555,6 +2575,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
2555
2575
|
customAssetUrl: opts?.customAssetUrl,
|
|
2556
2576
|
preserveAssetFilenames: opts?.preserveAssetFilenames ?? false,
|
|
2557
2577
|
itemReferenceSource: opts?.itemReferenceSource,
|
|
2578
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
2558
2579
|
fileAccess: opts?.fileAccess,
|
|
2559
2580
|
packageRoot: opts?.sourceDir,
|
|
2560
2581
|
finalItemReference,
|
|
@@ -2591,6 +2612,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
2591
2612
|
if (itemResource.metadataXml) try {
|
|
2592
2613
|
const tagResult = parseMetadataTags(itemResource.metadataXml, {
|
|
2593
2614
|
truncateTags: opts?.truncateTags,
|
|
2615
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
2594
2616
|
filePath: itemResource.href
|
|
2595
2617
|
});
|
|
2596
2618
|
diagnostics.push(...tagResult.diagnostics);
|
|
@@ -2612,7 +2634,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
2612
2634
|
inputXml: itemXml
|
|
2613
2635
|
});
|
|
2614
2636
|
const filenameSource = opts?.itemFilenameSource;
|
|
2615
|
-
if (filenameSource && filenameSource !== (opts.itemReferenceSource
|
|
2637
|
+
if (filenameSource && normalizeRefSource(filenameSource) !== normalizeRefSource(opts.itemReferenceSource)) {
|
|
2616
2638
|
const qtiIdentifier = readAssessmentItemIdentifier(itemXml, md5Ref);
|
|
2617
2639
|
const filename = generateItemReference(qtiIdentifier, filenameSource, itemFilePath);
|
|
2618
2640
|
itemFilenames.set(md5Ref, filename);
|
|
@@ -2644,8 +2666,10 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
2644
2666
|
const activitiesManifest = {};
|
|
2645
2667
|
if (testResources.length > 0) for (const testResource of testResources) {
|
|
2646
2668
|
let activityReference;
|
|
2647
|
-
if (opts?.itemReferenceSource === "
|
|
2648
|
-
|
|
2669
|
+
if (normalizeRefSource(opts?.itemReferenceSource) === "itemIdentifier") {
|
|
2670
|
+
const testEntry = entries.get(normalizeHref(testResource.href));
|
|
2671
|
+
activityReference = testEntry ? readAssessmentTestIdentifier(decodeUtf8(testEntry.data), testResource.identifier) : testResource.identifier;
|
|
2672
|
+
} else {
|
|
2649
2673
|
const hrefParts = testResource.href.split("/");
|
|
2650
2674
|
activityReference = hrefParts[hrefParts.length - 1].replace(/\.xml$/i, "");
|
|
2651
2675
|
}
|
|
@@ -2687,6 +2711,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
2687
2711
|
if (testResource.metadataXml) try {
|
|
2688
2712
|
const tagResult = parseMetadataTags(testResource.metadataXml, {
|
|
2689
2713
|
truncateTags: opts?.truncateTags,
|
|
2714
|
+
splitCsvTags: opts?.splitCsvTags,
|
|
2690
2715
|
filePath: testResource.href
|
|
2691
2716
|
});
|
|
2692
2717
|
diagnostics.push(...tagResult.diagnostics);
|
|
@@ -2781,7 +2806,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
2781
2806
|
mediaVault: opts?.mediaVault ?? false,
|
|
2782
2807
|
customAssetUrl: opts?.customAssetUrl,
|
|
2783
2808
|
preserveAssetFilenames: opts?.preserveAssetFilenames ?? false,
|
|
2784
|
-
itemReferenceSource: opts?.itemReferenceSource ?? "
|
|
2809
|
+
itemReferenceSource: opts?.itemReferenceSource ?? "itemIdentifier"
|
|
2785
2810
|
}
|
|
2786
2811
|
},
|
|
2787
2812
|
items: Array.from(items.keys()).sort(),
|
|
@@ -3762,6 +3787,7 @@ async function processQtiPackageToLearnosity(pkg, packageOutputPath, options, qu
|
|
|
3762
3787
|
itemReferenceSource: options.itemReferenceSource,
|
|
3763
3788
|
itemFilenameSource: options.itemFilenameSource,
|
|
3764
3789
|
truncateTags: options.truncateTags,
|
|
3790
|
+
splitCsvTags: options.splitCsvTags,
|
|
3765
3791
|
packageVersion: options.version,
|
|
3766
3792
|
sourceDir: pkg.path,
|
|
3767
3793
|
fileAccess: nodeFileAccess
|
|
@@ -3944,4 +3970,4 @@ function itemRefsToFilenames(bundle, itemRefs) {
|
|
|
3944
3970
|
//#endregion
|
|
3945
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 };
|
|
3946
3972
|
|
|
3947
|
-
//# sourceMappingURL=batchProcessors-
|
|
3973
|
+
//# sourceMappingURL=batchProcessors-B6Xmhfaz.js.map
|