@learnosity/lib-qti-converter 0.12.8 → 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.
- package/docs/EXAMPLES.md +46 -34
- package/docs/GETTING_STARTED.md +88 -31
- package/docs/LEARNOSITY_BUNDLE_FORMAT.md +24 -8
- package/package.json +1 -1
- package/packages/cli/dist/{batchProcessors-CUJoQD8a.js → batchProcessors-DWG8qk7G.js} +296 -80
- package/packages/cli/dist/batchProcessors-DWG8qk7G.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{learnosityToQti-CvfVQ6Kl.js → learnosityToQti-C7cTRTU2.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-CvfVQ6Kl.js.map → learnosityToQti-C7cTRTU2.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-CXMsJNQD.js → learnosityToQtiPackage-C84dQKKi.js} +4 -4
- package/packages/cli/dist/{learnosityToQtiPackage-CXMsJNQD.js.map → learnosityToQtiPackage-C84dQKKi.js.map} +1 -1
- package/packages/cli/dist/main.js +4 -4
- package/packages/cli/dist/{pathUtils-DmtCfutO.js → pathUtils-Cr9IcK0n.js} +21 -6
- package/packages/cli/dist/{pathUtils-DmtCfutO.js.map → pathUtils-Cr9IcK0n.js.map} +1 -1
- package/packages/cli/dist/{qtiPackageToLearnosity-FhfNr7gf.js → qtiPackageToLearnosity-BBfZgWBh.js} +14 -8
- package/packages/cli/dist/qtiPackageToLearnosity-BBfZgWBh.js.map +1 -0
- package/packages/cli/dist/{qtiToLearnosity-5lQ5f3-t.js → qtiToLearnosity-C9OW_n7Z.js} +6 -5
- package/packages/cli/dist/qtiToLearnosity-C9OW_n7Z.js.map +1 -0
- package/packages/cli/dist/{resolveOptions-lHxSyq9F.js → resolveOptions-D_UECo_9.js} +22 -7
- package/packages/cli/dist/resolveOptions-D_UECo_9.js.map +1 -0
- package/packages/cli/dist/{table-7b-8MN2z.js → table-D1ydwhbX.js} +536 -175
- package/packages/cli/dist/table-D1ydwhbX.js.map +1 -0
- package/packages/core/dist/index.d.ts +20 -4
- package/packages/core/dist/index.js +802 -246
- package/packages/core/dist/node.d.ts +23 -5
- package/packages/core/dist/node.js +828 -251
- package/packages/cli/dist/batchProcessors-CUJoQD8a.js.map +0 -1
- package/packages/cli/dist/qtiPackageToLearnosity-FhfNr7gf.js.map +0 -1
- package/packages/cli/dist/qtiToLearnosity-5lQ5f3-t.js.map +0 -1
- package/packages/cli/dist/resolveOptions-lHxSyq9F.js.map +0 -1
- package/packages/cli/dist/table-7b-8MN2z.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,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
|
|
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 |
|
|
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
|
|
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`
|
|
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
|
|
package/docs/GETTING_STARTED.md
CHANGED
|
@@ -231,11 +231,23 @@ This produces URLs like:
|
|
|
231
231
|
/>
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
+
### QTI → Learnosity asset filenames
|
|
235
|
+
|
|
236
|
+
QTI → Learnosity conversion uses deterministic, item-scoped asset filenames by default. For each package-local asset, the final Learnosity item reference and the canonical full QTI href are serialized as the ordered JSON tuple `JSON.stringify([finalItemReference, canonicalQtiAssetHref])`. The generated filename is:
|
|
237
|
+
|
|
238
|
+
```text
|
|
239
|
+
md5hex(JSON.stringify([finalItemReference, canonicalQtiAssetHref])) + sourceExtension
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
`md5hex` is the existing lowercase hexadecimal MD5 helper. `canonicalQtiAssetHref` converts backslashes to `/`, removes leading `./`, resolves safe `.`/`..` segments, and removes query strings and fragments while preserving the complete relative path and case. The original final extension is retained once. Thus, `images/intro/logo.png` and `images/outro/logo.png` produce different `.png` filenames, and the same item reference plus canonical href is repeatable across directory and ZIP inputs.
|
|
243
|
+
|
|
244
|
+
The selected filename is used in both generated Learnosity URLs and package bundle paths (`assets/<selected filename>`). Item JSON filenames remain controlled separately by `itemFilenameSource`. These generated QTI → Learnosity names are distinct from pre-existing Learnosity bundle/Data API names such as `<md5_hash>_<original_filename>`; this option does not rename assets during Learnosity → QTI conversion.
|
|
245
|
+
|
|
234
246
|
### `--custom-asset-url`
|
|
235
247
|
|
|
236
248
|
_Available for: `qti-to-learnosity`, `qti-package-to-learnosity`, `learnosity-to-qti`, `learnosity-to-qti-package`_
|
|
237
249
|
|
|
238
|
-
Specify a custom base URL/prefix for asset references (images, audio, video).
|
|
250
|
+
Specify a custom base URL/prefix for asset references (images, audio, video). For QTI → Learnosity, the value replaces the CDN base while the converter-generated deterministic asset filename is preserved. For Learnosity → QTI, the value replaces the reference prefix up to the existing asset filename.
|
|
239
251
|
|
|
240
252
|
**QTI → Learnosity** (`qti-to-learnosity`, `qti-package-to-learnosity`) — use a custom base instead of the default Learnosity CDN:
|
|
241
253
|
|
|
@@ -243,13 +255,29 @@ Specify a custom base URL/prefix for asset references (images, audio, video). Th
|
|
|
243
255
|
lcon qti-to-learnosity --in item.xml --out item.json --organisation_id 12345 --custom-asset-url "https://my-cdn.example.com/assets"
|
|
244
256
|
```
|
|
245
257
|
|
|
246
|
-
This produces
|
|
258
|
+
This produces a URL with your custom prefix and the deterministic generated asset filename:
|
|
247
259
|
|
|
248
260
|
```html
|
|
249
|
-
<img
|
|
261
|
+
<img
|
|
262
|
+
src="https://my-cdn.example.com/assets/<md5hex(JSON.stringify([itemReference, canonicalQtiAssetHref]))>.png"
|
|
263
|
+
/>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
The hash input is the ordered JSON tuple `[finalItemReference, canonicalQtiAssetHref]`, where the asset href retains its full package-relative path after canonicalization. The original basename is not used by itself, so `images/intro/logo.png` and `images/outro/logo.png` cannot collide merely because both are named `logo.png`.
|
|
267
|
+
|
|
268
|
+
**Note:** In this direction, when `--custom-asset-url` is provided it overrides both the default Learnosity CDN and the `--mediavault` flag, but it does not change the generated filename or the physical bundle path.
|
|
269
|
+
|
|
270
|
+
By default, QTI → Learnosity uses the deterministic hashed filename above. To opt out for compatibility with existing basename-based CDN uploads, pass:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
lcon qti-to-learnosity \
|
|
274
|
+
--in item.xml \
|
|
275
|
+
--out item.json \
|
|
276
|
+
--organisation_id 12345 \
|
|
277
|
+
--preserve-asset-filenames
|
|
250
278
|
```
|
|
251
279
|
|
|
252
|
-
|
|
280
|
+
The library equivalent is `{ preserveAssetFilenames: true }`. The `--preserve-asset-filenames` flag is available on both `qti-to-learnosity` and `qti-package-to-learnosity`; the API option applies to both corresponding library conversions. This restores the original final QTI basename, such as `logo.png`, in both JSON URLs and bundle paths. It is compatibility behavior: if different QTI assets request the same basename, conversion reports a collision instead of silently overwriting an asset.
|
|
253
281
|
|
|
254
282
|
**Learnosity → QTI** (`learnosity-to-qti`, `learnosity-to-qti-package`) — rewrite the asset prefix in the generated QTI. When omitted, the default prefix is `./assets`, so a reference resolves to `./assets/<filename>` (matching the packaged `assets/` folder):
|
|
255
283
|
|
|
@@ -265,44 +293,72 @@ Given an input reference of `/vendor/learnosity/itembank/assets/abc123_photo.png
|
|
|
265
293
|
|
|
266
294
|
**Note:** In the Learnosity → QTI direction, `--custom-asset-url` only rewrites the reference strings in the generated XML — it does not relocate or rename the physical asset files copied into the package (those remain under `assets/`). Remote (`http(s)://`), protocol-relative (`//`) and `data:` URIs, and converter-internal references (such as the `lrn-normalize.css` stylesheet) are left untouched.
|
|
267
295
|
|
|
296
|
+
### `--preserve-asset-filenames`
|
|
297
|
+
|
|
298
|
+
_Available for: `qti-to-learnosity`, `qti-package-to-learnosity`_
|
|
299
|
+
|
|
300
|
+
Opt out of deterministic hashed asset filenames and preserve the original final QTI basename. The default is hashed naming based on the item reference and canonical QTI asset path; use this option only when existing CDN uploads require the original names.
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
lcon qti-package-to-learnosity \
|
|
304
|
+
--in ./qti-package \
|
|
305
|
+
--out ./output \
|
|
306
|
+
--organisation_id 12345 \
|
|
307
|
+
--preserve-asset-filenames
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
The library equivalent is:
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
{
|
|
314
|
+
preserveAssetFilenames: true;
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
The selected basename is used consistently in generated JSON URLs and physical bundle paths. If different item assets use the same basename, conversion reports a collision instead of silently overwriting either asset.
|
|
319
|
+
|
|
268
320
|
### `--item-reference-source`
|
|
269
321
|
|
|
270
322
|
_Available for: `qti-to-learnosity`, `qti-package-to-learnosity`_
|
|
271
323
|
|
|
272
|
-
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`.
|
|
273
325
|
|
|
274
|
-
**Default (`
|
|
326
|
+
**Default (`itemIdentifier`)**: Uses the QTI `identifier` attribute from the XML (ignores the filename).
|
|
275
327
|
|
|
276
328
|
```bash
|
|
277
329
|
lcon qti-to-learnosity --in Items/my-item.xml --out item.json
|
|
278
|
-
#
|
|
330
|
+
# If the XML has identifier="item-001", item reference will be: "item-001"
|
|
279
331
|
```
|
|
280
332
|
|
|
281
|
-
|
|
333
|
+
**`--item-reference-source sourceFilename`**: Uses the source filename without the `.xml` extension for human-readable references (this was the default in earlier versions).
|
|
282
334
|
|
|
283
335
|
```bash
|
|
284
|
-
lcon qti-to-learnosity --in Items/my-item.xml --out item.json --item-reference-source
|
|
285
|
-
#
|
|
336
|
+
lcon qti-to-learnosity --in Items/my-item.xml --out item.json --item-reference-source sourceFilename
|
|
337
|
+
# Item reference will be: "my-item"
|
|
286
338
|
```
|
|
287
339
|
|
|
288
|
-
|
|
340
|
+
**`--item-reference-source qti`**: Deprecated alias of `itemIdentifier`; produces the identical result. New integrations should use `itemIdentifier`.
|
|
289
341
|
|
|
290
|
-
|
|
342
|
+
Use the default (`itemIdentifier`) when:
|
|
343
|
+
|
|
344
|
+
- You want item references to match the QTI `identifier` attribute in the XML
|
|
291
345
|
- The QTI identifiers are more meaningful than the filenames
|
|
292
|
-
|
|
346
|
+
|
|
347
|
+
Use `sourceFilename` when you need the earlier filename-based behaviour.
|
|
293
348
|
|
|
294
349
|
### `--item-filename-source`
|
|
295
350
|
|
|
296
351
|
_Available for: `qti-package-to-learnosity`_
|
|
297
352
|
|
|
298
|
-
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`.
|
|
299
354
|
|
|
300
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`.
|
|
301
356
|
|
|
302
357
|
| Value | Behavior |
|
|
303
358
|
| ---------------- | -------------------------------------------------------------------------- |
|
|
359
|
+
| `itemIdentifier` | Name output files after the QTI `identifier` attribute from the XML |
|
|
360
|
+
| `qti` | Deprecated alias of `itemIdentifier` |
|
|
304
361
|
| `sourceFilename` | Name output files after the source XML filename (without `.xml` extension) |
|
|
305
|
-
| `qti` | Name output files after the QTI `identifier` attribute from the XML |
|
|
306
362
|
|
|
307
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.
|
|
308
364
|
|
|
@@ -517,8 +573,8 @@ Create `lrn-converter.config.json` in your working directory to set default opti
|
|
|
517
573
|
"organisationId": 12345,
|
|
518
574
|
"mediaVault": false,
|
|
519
575
|
"customAssetUrl": "https://my-cdn.example.com/assets",
|
|
520
|
-
"itemReferenceSource": "
|
|
521
|
-
"itemFilenameSource": "
|
|
576
|
+
"itemReferenceSource": "itemIdentifier",
|
|
577
|
+
"itemFilenameSource": "sourceFilename"
|
|
522
578
|
}
|
|
523
579
|
```
|
|
524
580
|
|
|
@@ -526,20 +582,21 @@ Create `lrn-converter.config.json` in your working directory to set default opti
|
|
|
526
582
|
|
|
527
583
|
All options are optional. CLI flags override config file values.
|
|
528
584
|
|
|
529
|
-
| Option
|
|
530
|
-
|
|
|
531
|
-
| `qtiVersion`
|
|
532
|
-
| `outputFormat`
|
|
533
|
-
| `diagnostics`
|
|
534
|
-
| `pretty`
|
|
535
|
-
| `verbose`
|
|
536
|
-
| `output`
|
|
537
|
-
| `organisationId`
|
|
538
|
-
| `mediaVault`
|
|
539
|
-
| `customAssetUrl`
|
|
540
|
-
| `
|
|
541
|
-
| `
|
|
542
|
-
| `
|
|
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"` |
|
|
543
600
|
|
|
544
601
|
### Config File Usage
|
|
545
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": "
|
|
53
|
+
"itemReferenceSource": "itemIdentifier"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"items": ["item_001", "item_002"],
|
|
@@ -106,9 +106,7 @@ The converter emits a **flat** activity object (no `data` wrapper):
|
|
|
106
106
|
{
|
|
107
107
|
"reference": "ACTIVITY_REFERENCE",
|
|
108
108
|
"rendering_type": "assess",
|
|
109
|
-
"items": [
|
|
110
|
-
{ "reference": "<item_reference>", "id": "<item_reference>" }
|
|
111
|
-
],
|
|
109
|
+
"items": [{ "reference": "<item_reference>", "id": "<item_reference>" }],
|
|
112
110
|
"config": {
|
|
113
111
|
"navigation": {
|
|
114
112
|
"show_intro": true,
|
|
@@ -237,12 +235,28 @@ Common feature types in `features[].data.type`:
|
|
|
237
235
|
|
|
238
236
|
## assets/ Folder
|
|
239
237
|
|
|
240
|
-
Contains binary media files referenced by items and activities.
|
|
238
|
+
Contains binary media files referenced by items and activities. Existing Learnosity/Data API bundles may use the legacy pattern:
|
|
241
239
|
|
|
242
240
|
```
|
|
243
241
|
<md5_hash>_<original_filename>
|
|
244
242
|
```
|
|
245
243
|
|
|
244
|
+
### QTI → Learnosity generated asset names
|
|
245
|
+
|
|
246
|
+
When QTI is converted to Learnosity JSON, local asset filenames use an item-scoped deterministic hash so that equal basenames from different QTI paths or items cannot overwrite one another on the CDN. The generated filename is:
|
|
247
|
+
|
|
248
|
+
```text
|
|
249
|
+
md5hex(JSON.stringify([finalItemReference, canonicalQtiAssetHref])) + sourceExtension
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`canonicalQtiAssetHref` is the full package-relative QTI href after converting separators to `/`, removing leading `./`, resolving safe `.`/`..` segments, and removing query strings/fragments. Bare filenames such as `745852.gif` are resolved relative to the item XML directory; explicit paths such as `assets/image.png` remain package-root-relative for compatibility. The source extension is retained; the original basename and directories are represented by the hash input, not copied into the output filename.
|
|
253
|
+
|
|
254
|
+
For example, `images/intro/logo.png` and `images/outro/logo.png` produce different deterministic `.png` filenames even when they belong to the same item. Only assets referenced by converted item XML or resolved passage HTML are emitted; manifest-only `<file>` entries such as recording controls are ignored when no item content references them. When the same source asset is referenced by multiple items, each item receives a different deterministic filename containing a cloned copy of the same bytes. The same item reference and canonical href always produce the same filename on repeat conversion. `customAssetUrl` changes only the URL base; it does not change the hash, selected filename, or physical file below `assets/`.
|
|
255
|
+
|
|
256
|
+
The bundle writer stores the selected key relative to the `assets/` root and adds that prefix exactly once, so the invariant is `generated URL basename == bundle path relative to assets/`. This generated QTI→Learnosity naming contract is distinct from pre-existing Learnosity bundle/Data API files that use `<md5_hash>_<original_filename>`; those existing names are read as-is for Learnosity → QTI conversion and are not renamed by this option.
|
|
257
|
+
|
|
258
|
+
For compatibility with existing basename-based CDN uploads, QTI → Learnosity conversion accepts `preserveAssetFilenames: true` in the library API or `--preserve-asset-filenames` in the CLI. That opt-out uses the original final QTI basename in both the generated URL and the physical `assets/` path. It is not collision-safe: when two different asset identities request the same basename, conversion reports an error rather than overwriting either file. The default hashed mode should be used for new conversions.
|
|
259
|
+
|
|
246
260
|
### Asset Types
|
|
247
261
|
|
|
248
262
|
| Extension | Description |
|
|
@@ -258,14 +272,16 @@ Contains binary media files referenced by items and activities. File names follo
|
|
|
258
272
|
Assets are referenced in HTML content using local paths:
|
|
259
273
|
|
|
260
274
|
```html
|
|
261
|
-
<!-- Image -->
|
|
262
|
-
<img
|
|
275
|
+
<!-- Image: generated QTI → Learnosity asset filename -->
|
|
276
|
+
<img
|
|
277
|
+
src="/vendor/learnosity/itembank/assets/<md5hex(JSON.stringify([itemReference, canonicalQtiAssetHref]))>.png"
|
|
278
|
+
/>
|
|
263
279
|
|
|
264
280
|
<!-- Audio player -->
|
|
265
281
|
<span
|
|
266
282
|
class="learnosity-feature"
|
|
267
283
|
data-type="audioplayer"
|
|
268
|
-
data-src="/vendor/learnosity/itembank/assets
|
|
284
|
+
data-src="/vendor/learnosity/itembank/assets/<md5_hash>_m157700"
|
|
269
285
|
>
|
|
270
286
|
</span>
|
|
271
287
|
```
|