@learnosity/lib-qti-converter 0.10.4 → 0.12.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/README.md CHANGED
@@ -4,6 +4,8 @@ A TypeScript tool for converting between QTI (Question & Test Interoperability)
4
4
 
5
5
  ## Documentation
6
6
 
7
+ > **Note:** This project was renamed from `learnosity-qti-converter` to `lib-qti-converter`. If you are visiting from [https://www.npmjs.com/package/@learnosity/learnosity-qti-converter](https://www.npmjs.com/package/@learnosity/learnosity-qti-converter), please switch to [https://www.npmjs.com/package/@learnosity/lib-qti-converter](https://www.npmjs.com/package/@learnosity/lib-qti-converter) or the documentation links below won't work.
8
+
7
9
  - **[Getting Started](https://learnosity.github.io/lib-qti-converter/#/GETTING_STARTED)** - Installation, quick start (CLI and library), and basic workflow
8
10
  - **[QTI Structure](https://learnosity.github.io/lib-qti-converter/#/QTI_STRUCTURE)** - Support for QTI structural elements (assessmentItem, assessmentTest, assessmentSection, testPart)
9
11
  - **[Diagnostics](https://learnosity.github.io/lib-qti-converter/#/DIAGNOSTICS)** - Understanding diagnostic messages and the diagnostics file
@@ -34,38 +36,89 @@ pnpm install
34
36
  pnpm run build
35
37
  ```
36
38
 
39
+ Some development tasks need tools that are not npm dependencies: Python 3 with `lxml` for [QTI validation](#qti-validation-not-bundled), and the Trivy and Semgrep CLIs for [security scanning](#security-scanning-external-tools-required).
40
+
37
41
  ## Quick Start
38
42
 
39
43
  ### CLI Usage
40
44
 
41
45
  ```bash
42
- # Install globally for CLI access
43
- npm install -g @learnosity/lib-qti-converter
44
-
45
- # Convert QTI to Learnosity
46
- lcon qti-to-learnosity --in item.xml --out item.json --pretty
46
+ # Convert single QTI item to Learnosity
47
+ npx lcon qti-to-learnosity --in item.xml --out item.json --pretty
47
48
 
48
- # Convert Learnosity to QTI
49
- lcon learnosity-to-qti --in item.json --out item.xml
49
+ # Convert single Learnosity item to QTI
50
+ npx lcon learnosity-to-qti --in item.json --out item.xml
50
51
  ```
51
52
 
52
53
  ### Library Usage
53
54
 
55
+ The package ships **two entry points**:
56
+
57
+ | Import | Runs in | Contains |
58
+ | ------------------------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------- |
59
+ | `@learnosity/lib-qti-converter` | Browser **and** Node | In-memory conversion (strings / JSON) — no filesystem access |
60
+ | `@learnosity/lib-qti-converter/node` | Node only | Everything above **plus** filesystem/ZIP helpers: package & bundle load/save and disk-based package conversion |
61
+
62
+ The root entry is **browser-safe** — it has no `node:*` dependencies and bundles for the browser with no polyfills.
63
+
64
+ #### In-memory conversion (browser or Node)
65
+
66
+ ```typescript
67
+ import { convertQtiToLearnosity, convertLearnosityToQti } from '@learnosity/lib-qti-converter';
68
+
69
+ // QTI XML string → Learnosity item JSON
70
+ const { output, diagnostics } = await convertQtiToLearnosity(qtiXmlString, { qtiVersion: '2.2' });
71
+
72
+ // Learnosity item JSON → QTI XML string
73
+ const roundTripped = await convertLearnosityToQti(output, { qtiVersion: '2.2' });
74
+ ```
75
+
76
+ These functions operate purely on strings and objects in memory — ideal for a browser app or a request handler. Disk lookups for external passage HTML and LOM metadata are **opt-in** (see below); without them an external `<object>` passage reference is left in place.
77
+
78
+ #### Node.js — filesystem & packages
79
+
80
+ Package- and bundle-level conversions read and write the filesystem (and ZIP archives), so they live in the `/node` entry point:
81
+
82
+ ```typescript
83
+ import {
84
+ convertQtiPackageToLearnosity, // QTI Content Package (dir or .zip) → Learnosity bundle
85
+ convertLearnosityToQtiPackage, // Learnosity bundle → QTI Content Package
86
+ loadLearnosityBundle,
87
+ writeLearnosityBundle,
88
+ nodeFileAccess,
89
+ } from '@learnosity/lib-qti-converter/node';
90
+
91
+ // Convert a QTI package on disk to an in-memory Learnosity bundle
92
+ const { bundle, diagnostics } = await convertQtiPackageToLearnosity({ inputPath: './qti-package' });
93
+
94
+ // Convert a Learnosity bundle directory to a QTI package written to disk
95
+ const result = convertLearnosityToQtiPackage({ inputPath: './bundle', outputPath: './out.zip' });
96
+ ```
97
+
98
+ To resolve external passage HTML and sibling LOM metadata files **from disk** during single-item conversion, inject `nodeFileAccess`:
99
+
54
100
  ```typescript
55
101
  import { convertQtiToLearnosity } from '@learnosity/lib-qti-converter';
102
+ import { nodeFileAccess } from '@learnosity/lib-qti-converter/node';
56
103
 
57
- const result = await convertQtiToLearnosity(qtiXmlString, {
104
+ const { output } = await convertQtiToLearnosity(qtiXml, {
58
105
  qtiVersion: '2.2',
59
- outputFormat: 'dir',
60
- diagnostics: 'none',
61
- verbose: false,
62
- pretty: true,
106
+ inputPath: './items/item.xml', // used to locate the sibling LOM file
107
+ fileAccess: nodeFileAccess, // enables disk reads for passages/LOM
63
108
  });
109
+ ```
110
+
111
+ #### Browser / bundlers
112
+
113
+ Importing from `@learnosity/lib-qti-converter` pulls in no Node built-ins, so it bundles for the browser with an empty polyfill/externals config:
64
114
 
65
- console.log(result.output); // Converted Learnosity JSON
66
- console.log(result.diagnostics); // Array of diagnostic messages
115
+ ```typescript
116
+ // Runs in the browser — strings in, JSON out
117
+ import { convertQtiToLearnosity, convertLearnosityToQti } from '@learnosity/lib-qti-converter';
67
118
  ```
68
119
 
120
+ Filesystem and ZIP‑package operations are Node‑only and are **not** part of the browser entry — importing `@learnosity/lib-qti-converter/node` in a browser bundle will (correctly) fail to resolve `node:fs`/`node:path`.
121
+
69
122
  See [Getting Started](https://learnosity.github.io/lib-qti-converter/#/GETTING_STARTED) for detailed instructions and [Examples](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES) for more usage scenarios.
70
123
 
71
124
  ## Available Commands (CLI)
@@ -77,9 +130,9 @@ The CLI provides four main conversion commands:
77
130
  - **`learnosity-to-qti`** - Convert Learnosity JSON to QTI XML
78
131
  - **`learnosity-to-qti-package`** - Convert Learnosity bundle to QTI Content Package
79
132
 
80
- **Batch Processing:** The package conversion commands (`qti-package-to-learnosity` and `learnosity-to-qti-package`) support a `--recursive` flag to convert multiple packages in subdirectories with a single command. See [Examples - Batch Processing](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES?id=10-batch-processing-with-recursive-flag) for details.
133
+ **Batch Processing:** The package conversion commands (`qti-package-to-learnosity` and `learnosity-to-qti-package`) support a `--recursive` flag to convert multiple packages in subdirectories with a single command, plus an opt-in `--concurrency <n>` flag to convert them in parallel across worker threads (default `1` = serial). See [Examples - Batch Processing](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES?id=10-batch-processing-with-recursive-flag) for details.
81
134
 
82
- Run `lcon <command> --help` for detailed options, or see [Examples](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES) for usage scenarios.
135
+ Run `npx lcon <command> --help` for detailed options, or see [Examples](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES) for usage scenarios.
83
136
 
84
137
  ## QTI Validation (not bundled)
85
138
 
@@ -87,20 +140,20 @@ After converting Learnosity to QTI, you can validate the generated QTI XML again
87
140
 
88
141
  ```bash
89
142
  # Validate all QTI XML files in a directory
90
- npm run validate:qti output/qti/
143
+ npm run validate:qti -- output/qti/
91
144
 
92
145
  # Validate a specific file
93
- npm run validate:qti output/qti/item.xml
146
+ npm run validate:qti -- output/qti/item.xml
94
147
 
95
148
  # Debug mode to see schema resolution details
96
- npm run validate:qti:debug output/qti/
149
+ npm run validate:qti:debug -- output/qti/
97
150
  ```
98
151
 
99
152
  Note: the validation script requires Python and lxml library to be installed.
100
153
 
101
154
  ```bash
102
155
  npm run setup:python
103
- npm run validate:qti output/qti/
156
+ npm run validate:qti -- output/qti/
104
157
  ```
105
158
 
106
159
  **Features:**
@@ -158,13 +211,13 @@ After converting QTI to Learnosity (or to validate existing Learnosity JSON file
158
211
 
159
212
  ```bash
160
213
  # Validate all Learnosity JSON files in items/ and activities/ subdirectories
161
- npm run validate:learnosity output/learnosity/
214
+ npm run validate:learnosity -- output/learnosity/
162
215
 
163
216
  # Validate all JSON files recursively in a directory
164
- npm run validate:learnosity output/learnosity/ --recursive
217
+ npm run validate:learnosity -- output/learnosity/ --recursive
165
218
 
166
219
  # Validate a specific file
167
- npm run validate:learnosity output/learnosity/items/item.json
220
+ npm run validate:learnosity -- output/learnosity/items/item.json
168
221
  ```
169
222
 
170
223
  **Note:** When validating a directory without `--recursive`, the script only looks in `./items` and `./activities` subdirectories. Use `--recursive` to validate all JSON files in the directory tree.
@@ -218,6 +271,9 @@ pnpm run coverage:cli # Run CLI tests with coverage
218
271
  pnpm run coverage:core # Run core tests with coverage
219
272
  pnpm run lint # Check code quality
220
273
  pnpm run lint:fix # Auto-fix linting issues
274
+ pnpm run security # Run both security scans (see Security Scanning section)
275
+ pnpm run security:semgrep # Semgrep SAST scan (requires semgrep on your PATH)
276
+ pnpm run security:trivy # Trivy vuln/secret/misconfig scan (requires trivy on your PATH)
221
277
  pnpm run test # Run all tests (core + cli)
222
278
  pnpm run test:cli # Run CLI package tests only
223
279
  pnpm run test:core # Run core package tests only
@@ -237,6 +293,37 @@ pnpm run build
237
293
  npm run lcon -- --help
238
294
  ```
239
295
 
296
+ ### Security Scanning (external tools required)
297
+
298
+ `pnpm run security` runs [Trivy](https://trivy.dev/) (vulnerabilities, secrets, misconfigurations) and [Semgrep](https://semgrep.dev/) (static analysis). Neither is an npm dependency, so `pnpm install` does **not** provide them — install them yourself before running the scans, otherwise the scripts fail with `command not found`.
299
+
300
+ ```bash
301
+ # macOS (Homebrew)
302
+ brew install trivy
303
+ brew install semgrep
304
+
305
+ # Verify both are on your PATH
306
+ trivy --version
307
+ semgrep --version
308
+ ```
309
+
310
+ Alternatives if you don't use Homebrew:
311
+
312
+ - **Trivy** - see the [installation guide](https://trivy.dev/latest/getting-started/installation/) for Linux packages, the install script, and the Docker image.
313
+ - **Semgrep** - `pipx install semgrep` or `python3 -m pip install semgrep` (needs Python 3.10+), or run it via Docker: `docker run --rm -v "${PWD}:/src" semgrep/semgrep semgrep scan --config auto`.
314
+
315
+ ```bash
316
+ pnpm run security # Trivy, then Semgrep
317
+ pnpm run security:trivy # Trivy only
318
+ pnpm run security:semgrep # Semgrep only
319
+ ```
320
+
321
+ Notes:
322
+
323
+ - Semgrep runs with `--config auto`, which downloads rules from the Semgrep registry, so the scan needs network access. No account or login is required.
324
+ - Trivy downloads and caches its vulnerability database on first run, so the first scan takes longer than later ones.
325
+ - Findings that are intentional are suppressed inline with `// nosemgrep:` comments plus a note explaining why. Follow that pattern rather than removing rules if you hit a false positive.
326
+
240
327
  ## Project Structure
241
328
 
242
329
  This is a TypeScript monorepo using pnpm workspaces. Both packages are bundled into self-contained files using [tsdown](https://tsdown.dev/), so the published package has zero runtime dependencies.
@@ -54,10 +54,16 @@ After conversion, a `diagnostics.json` file **may be written** depending on your
54
54
  "directory_input": "/path/to/input",
55
55
  "directory_output": "/path/to/output",
56
56
  "total_items_found": 5,
57
+ "total_items_processed": 5,
57
58
  "total_items_converted": 4,
58
59
  "total_items_failed": 1,
60
+ "total_activities_found": 1,
61
+ "total_activities_converted": 1,
62
+ "total_activities_failed": 0,
59
63
  "converted_items": ["item_001.xml", "item_002.xml", "item_003.xml", "item_004.xml"],
60
64
  "failed_items": ["item_005.xml"],
65
+ "converted_activities": ["activity_001.json"],
66
+ "failed_activities": [],
61
67
  "issues": {
62
68
  "errors": [
63
69
  {
@@ -66,12 +72,14 @@ After conversion, a `diagnostics.json` file **may be written** depending on your
66
72
  "file": "item_005.xml"
67
73
  }
68
74
  ],
69
- "warnings": [],
70
- "info": []
75
+ "info": [],
76
+ "warnings": []
71
77
  }
72
78
  }
73
79
  ```
74
80
 
81
+ > **Note:** Errors are de-duplicated by source file — only the first error per unique file path appears in `issues.errors`, so a file that fails is reported once.
82
+
75
83
  ---
76
84
 
77
85
  ## Severity Levels
@@ -95,6 +103,7 @@ After conversion, a `diagnostics.json` file **may be written** depending on your
95
103
  | `QTI_CHOICE_NO_TEXT` | Warning | A choice element has no text content |
96
104
  | `QTI_DTD_NOT_ALLOWED` | Error | QTI XML contains a DTD (Document Type Definition) which is not allowed for security |
97
105
  | `QTI_ALT_RESPONSES_TRIMMED` | Warning | Alternate responses were limited to 10 items due to excessive QTI mapping rules or Cartesian product combinations |
106
+ | `QTI_SHUFFLE_NOT_SUPPORTED` | Warning | `@shuffle="true"` was dropped because the target Learnosity question type has no `shuffle_options` attribute |
98
107
 
99
108
  #### Learnosity → QTI
100
109
 
@@ -117,12 +126,14 @@ The `--diagnostics` flag accepts either a **mode** or a **file path**:
117
126
 
118
127
  #### Modes
119
128
 
120
- | Mode | Description |
121
- | -------- | --------------------------------------------------------------- |
122
- | `file` | Write diagnostics to `diagnostics.json` in the output directory |
123
- | `stderr` | Write diagnostics to stderr/console |
124
- | `both` | Write diagnostics to both `diagnostics.json` and stderr |
125
- | `none` | Suppress diagnostic output |
129
+ | Mode | Description |
130
+ | -------- | ------------------------------------------------------------------------------------- |
131
+ | `file` | Write diagnostics to `diagnostics.json` in the output directory |
132
+ | `stderr` | Write the diagnostics JSON dump to stderr — only when `--verbose` is also set |
133
+ | `both` | Always write `diagnostics.json`; also dump the JSON to stderr when `--verbose` is set |
134
+ | `none` | Suppress diagnostic output |
135
+
136
+ > **Note:** The diagnostics JSON dump to stderr is gated on `--verbose`. `--diagnostics stderr` (or `both`) writes nothing to stderr on its own — you must also pass `--verbose` to see the JSON dump there. The `file` output is not affected by `--verbose`.
126
137
 
127
138
  **Default Behavior:**
128
139
 
@@ -170,7 +181,7 @@ $ lcon qti-to-learnosity --in item.xml --out item.json --diagnostics stderr
170
181
 
171
182
  [INFO] Converting QTI item: item.xml
172
183
  [WARNING] QTI_MISSING_RESPONSE_DECLARATION: Response declaration missing for RESPONSE_1
173
- [INFO] QTI_COORDINATE_CONVERSION: Converted hotspot coordinates from pixels to percentages
184
+ [INFO] CONTENT_EDITOR_ARTEFACT_STRIPPED: Removed document metadata tags from item content
174
185
  [INFO] Conversion complete: item.json
175
186
  ```
176
187
 
@@ -183,13 +194,13 @@ When using the library API, every conversion function returns a `diagnostics` ar
183
194
  ```typescript
184
195
  import {
185
196
  convertQtiToLearnosity,
186
- convertQtiPackageToLearnosity,
187
197
  hasErrors,
188
198
  filterByLevel,
189
199
  countByLevel,
190
200
  formatDiagnosticsReport,
191
201
  type Diagnostic,
192
202
  } from '@learnosity/lib-qti-converter';
203
+ import { convertQtiPackageToLearnosity } from '@learnosity/lib-qti-converter/node';
193
204
 
194
205
  // Single-item conversion
195
206
  const result = await convertQtiToLearnosity(qtiXml, {
@@ -204,12 +215,19 @@ if (hasErrors(result.diagnostics)) {
204
215
  }
205
216
 
206
217
  // Count by level
207
- const { error, warning, info } = countByLevel(result.diagnostics);
208
- console.log(`Errors: ${error}, Warnings: ${warning}, Info: ${info}`);
209
-
210
- // Format a human-readable report
211
- const report = formatDiagnosticsReport(result.diagnostics);
212
- console.log(report);
218
+ const { errors, warnings, info } = countByLevel(result.diagnostics);
219
+ console.log(`Errors: ${errors}, Warnings: ${warnings}, Info: ${info}`);
220
+
221
+ // Build a structured diagnostics report (returns a DiagnosticsReport object, not a string)
222
+ const report = formatDiagnosticsReport(result.diagnostics, {
223
+ inputPath: '/path/to/input',
224
+ outputPath: '/path/to/output',
225
+ totalItemsFound: 5,
226
+ convertedFiles: ['item_001.xml', 'item_002.xml'],
227
+ failedFiles: ['item_005.xml'],
228
+ });
229
+ console.log(`Converted ${report.total_items_converted} of ${report.total_items_found} items`);
230
+ console.log(JSON.stringify(report, null, 2));
213
231
  ```
214
232
 
215
233
  ### Package Conversion Diagnostics
@@ -238,19 +256,20 @@ interface Diagnostic {
238
256
  level: 'error' | 'warning' | 'info';
239
257
  code: string; // e.g. 'QTI_UNSUPPORTED_INTERACTION'
240
258
  message: string; // Human-readable description
241
- file?: string; // Source file (if applicable)
259
+ file: string; // Source file the diagnostic relates to
260
+ context?: Record<string, unknown>; // Optional structured context
242
261
  }
243
262
  ```
244
263
 
245
264
  ### Available Diagnostic Utilities
246
265
 
247
- | Export | Description |
248
- | -------------------------------------- | ---------------------------------------------------- |
249
- | `hasErrors(diagnostics)` | Returns `true` if any diagnostic has level `'error'` |
250
- | `filterByLevel(diagnostics, level)` | Filter diagnostics by severity level |
251
- | `countByLevel(diagnostics)` | Returns `{ error, warning, info }` counts |
252
- | `formatDiagnosticsReport(diagnostics)` | Format as a human-readable string |
253
- | `DiagnosticCode` | Enum of all diagnostic codes for programmatic checks |
266
+ | Export | Description |
267
+ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
268
+ | `hasErrors(diagnostics)` | Returns `true` if any diagnostic has level `'error'` |
269
+ | `filterByLevel(diagnostics, level)` | Filter diagnostics by severity level |
270
+ | `countByLevel(diagnostics)` | Returns `{ errors, warnings, info }` counts |
271
+ | `formatDiagnosticsReport(diagnostics, options)` | Build a structured `DiagnosticsReport` object; `options` is required (`inputPath`, `outputPath`, `totalItemsFound`, `convertedFiles`, `failedFiles`, plus optional activity fields) |
272
+ | `DiagnosticCode` | Curated set of common diagnostic codes for programmatic checks (the tables above show a common subset) |
254
273
 
255
274
  ---
256
275
 
package/docs/EXAMPLES.md CHANGED
@@ -17,18 +17,31 @@ lcon qti-to-learnosity \
17
17
 
18
18
  ```json
19
19
  {
20
- "reference": "mcq-colors",
21
- "type": "mcq",
22
- "data": {
23
- "options": [
24
- { "label": "Red", "value": "A" },
25
- { "label": "Blue", "value": "B" }
26
- ],
27
- "validation": {
28
- "scoring_type": "exactMatch",
29
- "valid_response": { "value": ["B"] }
20
+ "item": {
21
+ "reference": "mcq-colors",
22
+ "definition": {
23
+ "widgets": [{ "reference": "mcq-colors", "widget_type": "response" }]
30
24
  }
31
- }
25
+ },
26
+ "questions": [
27
+ {
28
+ "reference": "mcq-colors",
29
+ "type": "mcq",
30
+ "data": {
31
+ "type": "mcq",
32
+ "stimulus": "<p>What is your favourite colour?</p>",
33
+ "options": [
34
+ { "label": "Red", "value": "A" },
35
+ { "label": "Blue", "value": "B" }
36
+ ],
37
+ "validation": {
38
+ "scoring_type": "exactMatch",
39
+ "valid_response": { "value": ["B"], "score": 1 }
40
+ }
41
+ }
42
+ }
43
+ ],
44
+ "features": []
32
45
  }
33
46
  ```
34
47
 
@@ -176,9 +189,9 @@ When converting QTI to Learnosity, `<rubricBlock view="scorer">` elements are au
176
189
 
177
190
  ### 5. Control Item Reference Generation
178
191
 
179
- **Default behavior (hashed references):**
192
+ **Default behavior (source-filename references):**
180
193
 
181
- By default, the converter generates MD5 hashes of the QTI identifier to prevent collisions:
194
+ By default (`--item-reference-source sourceFilename`), the converter derives each item reference from the source XML filename with the `.xml` extension removed:
182
195
 
183
196
  ```bash
184
197
  lcon qti-to-learnosity \
@@ -186,7 +199,20 @@ lcon qti-to-learnosity \
186
199
  --out item.json
187
200
  ```
188
201
 
189
- This generates a deterministic MD5 hash for each item reference (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.
202
+ 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.
203
+
204
+ **Generate hashed references to avoid collisions:**
205
+
206
+ Use `--item-reference-source uuid` to generate a deterministic MD5 hash of the QTI identifier for each item reference:
207
+
208
+ ```bash
209
+ lcon qti-to-learnosity \
210
+ --in item.xml \
211
+ --out item.json \
212
+ --item-reference-source uuid
213
+ ```
214
+
215
+ 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.
190
216
 
191
217
  **Use QTI identifier for human-readable references:**
192
218
 
@@ -308,7 +334,7 @@ lcon learnosity-to-qti-package \
308
334
  --in ./bundle-directory \
309
335
  --out output-package.zip \
310
336
  --activity activity_001 \
311
- --output-format zip
337
+ --format zip
312
338
  ```
313
339
 
314
340
  ### 9. Include Learnosity Source in QTI Output
@@ -388,6 +414,21 @@ learnosity-bundles/
388
414
  └── items/
389
415
  ```
390
416
 
417
+ **Nested input structure:**
418
+
419
+ Packages can sit at any depth. Scanning stops at the first directory that is a package (one containing `imsmanifest.xml` or `manifest.json`), and each package is written to the same relative path under `--out`, so intermediate folders are preserved and same-named packages in different subtrees don't overwrite each other:
420
+
421
+ ```
422
+ qti-packages/ learnosity-bundles/
423
+ ├── grade-3/ ├── grade-3/
424
+ │ └── maths/ │ └── maths/
425
+ │ └── package-a/ ─────▶ │ └── package-a/
426
+ ├── grade-4/ ├── grade-4/
427
+ │ └── science/ │ └── science/
428
+ │ └── package-a/ ─────▶ │ └── package-a/
429
+ └── package-b/ ─────▶ └── package-b/
430
+ ```
431
+
391
432
  **Convert multiple Learnosity bundles to QTI packages:**
392
433
 
393
434
  ```bash
@@ -401,7 +442,7 @@ lcon learnosity-to-qti-package \
401
442
  **Features:**
402
443
 
403
444
  - ✅ Automatically detects package types in subdirectories
404
- - ✅ Preserves folder structure (output mirrors input folder names)
445
+ - ✅ Preserves folder structure (output mirrors the input tree, including nested subdirectories)
405
446
  - ✅ Shows progress for each package
406
447
  - ✅ Continues processing even if individual packages fail
407
448
  - ✅ Displays summary report at the end
@@ -443,13 +484,20 @@ Batch Conversion Summary
443
484
  Total packages: 3
444
485
  ✓ Succeeded: 3
445
486
  ✗ Failed: 0
446
- Time elapsed: 12.3s
487
+ ⊘ Skipped: 0
488
+ ------------------------------------------------------------
489
+ Total items: 35
490
+ ✓ Converted: 35
491
+ ✗ Errored: 0
447
492
  ============================================================
493
+
494
+ Completed in 12.3s
448
495
  ```
449
496
 
450
497
  **Notes:**
451
498
 
452
- - The `--recursive` flag only processes immediate subdirectories (not nested subdirectories)
499
+ - The `--recursive` flag scans the whole directory tree, not just immediate subdirectories. Nested packages are written to the matching nested path under `--out` (see "Nested input structure" below)
500
+ - Add `--concurrency <n>` (default `1` = serial) to convert packages in parallel across worker threads — useful for large batches on multi-core machines. The summary is aggregated in package order (identical to serial); only per-package progress lines may appear out of order as workers finish.
453
501
  - Each subdirectory must be a valid package (QTI with `imsmanifest.xml` or Learnosity with `manifest.json`)
454
502
  - Files in the root directory are ignored
455
503
  - Cannot be used with ZIP input (only directory input)
@@ -468,6 +516,8 @@ cat input.json | lcon learnosity-to-qti --in - --out - | xmllint --format -
468
516
 
469
517
  Create `lrn-converter.config.json` to set project defaults:
470
518
 
519
+ > **Note:** All four commands load the config file (and honour `--config` / `--no-config`). Each applies only the keys relevant to its conversion direction and ignores the rest.
520
+
471
521
  ```json
472
522
  {
473
523
  "qtiVersion": "2.2",
@@ -489,7 +539,7 @@ Then run commands without specifying all flags:
489
539
  lcon qti-to-learnosity --in input.xml --out output.json
490
540
 
491
541
  # CLI flags override config file values
492
- lcon qti-to-learnosity --in input.xml --out output.json --verbose false
542
+ lcon qti-to-learnosity --in input.xml --out output.json --qti-version 2.1
493
543
 
494
544
  # Use custom config file location
495
545
  lcon qti-to-learnosity --in input.xml --out output.json --config /path/to/config.json
@@ -506,6 +556,10 @@ You can import the converter into your own Node.js or TypeScript project instead
506
556
  import { convertQtiToLearnosity, convertLearnosityToQti } from '@learnosity/lib-qti-converter';
507
557
  ```
508
558
 
559
+ **Two entry points:** in-memory conversions (`convertQtiToLearnosity`, `convertLearnosityToQti`, and the model/serializer/mapper helpers) are imported from `@learnosity/lib-qti-converter` and are **browser-safe** (no `node:*` dependencies). The filesystem/ZIP package conversions below (`convertQtiPackageToLearnosity`, `convertLearnosityToQtiPackage`) and `nodeFileAccess` are Node-only and are imported from `@learnosity/lib-qti-converter/node`.
560
+
561
+ **Note:** The library API accepts the same `ConversionOptions` object as the CLI, but the `outputFormat`, `diagnostics`, and `verbose` options are CLI-only and are ignored when calling the functions directly — control diagnostics using the returned `diagnostics` array instead.
562
+
509
563
  ### Convert QTI XML to Learnosity JSON
510
564
 
511
565
  ```typescript
@@ -566,9 +620,6 @@ const learnosityItem = {
566
620
 
567
621
  const result = await convertLearnosityToQti(learnosityItem, {
568
622
  qtiVersion: '2.2',
569
- outputFormat: 'dir',
570
- diagnostics: 'none',
571
- verbose: false,
572
623
  pretty: true,
573
624
  });
574
625
 
@@ -590,9 +641,6 @@ import {
590
641
 
591
642
  const result = await convertQtiToLearnosity(qtiXml, {
592
643
  qtiVersion: '2.2',
593
- outputFormat: 'dir',
594
- diagnostics: 'none',
595
- verbose: false,
596
644
  pretty: true,
597
645
  });
598
646
 
@@ -618,7 +666,7 @@ if (warnings.length > 0) {
618
666
  Convert an entire QTI Content Package (directory or ZIP) to a Learnosity bundle. Optionally write the result to disk:
619
667
 
620
668
  ```typescript
621
- import { convertQtiPackageToLearnosity } from '@learnosity/lib-qti-converter';
669
+ import { convertQtiPackageToLearnosity } from '@learnosity/lib-qti-converter/node';
622
670
 
623
671
  // Convert and write to disk
624
672
  // Note: bundle is NOT returned when outputPath is provided — only diagnostics and summary are.
@@ -653,7 +701,7 @@ console.log(zipResult.bundle); // In-memory Learnosity bundle
653
701
  Convert a Learnosity bundle to a QTI Content Package. Specify which activities to convert, or omit to convert all:
654
702
 
655
703
  ```typescript
656
- import { convertLearnosityToQtiPackage } from '@learnosity/lib-qti-converter';
704
+ import { convertLearnosityToQtiPackage } from '@learnosity/lib-qti-converter/node';
657
705
 
658
706
  // Convert all activities and write to a ZIP
659
707
  const result = convertLearnosityToQtiPackage({
@@ -708,16 +756,18 @@ The package exports the following for library consumers:
708
756
  | Option | Type | Required | CLI Equivalent | Description |
709
757
  | --------------------- | ---------------------------------------------- | -------- | ------------------------- | ------------------------------------------------------------------------------ |
710
758
  | `qtiVersion` | `'2.1'` \| `'2.2'` | Yes | `--qti-version` | QTI version to use for conversion |
711
- | `outputFormat` | `'dir'` \| `'zip'` \| `'stdout'` | Yes | `--output-format` | Output format |
712
- | `diagnostics` | `'stderr'` \| `'file'` \| `'both'` \| `'none'` | Yes | `--diagnostics` | Where to write diagnostic messages. Use `'none'` when using as a library |
713
- | `verbose` | `boolean` | Yes | `--verbose` | Include INFO-level diagnostics in the result |
714
- | `pretty` | `boolean` | Yes | `--pretty` | Pretty-print JSON/XML output |
759
+ | `outputFormat` | `'dir'` \| `'zip'` \| `'stdout'` | No | `--output-format` | Output format |
760
+ | `diagnostics` | `'stderr'` \| `'file'` \| `'both'` \| `'none'` | No | `--diagnostics` | Where to write diagnostic messages. Use `'none'` when using as a library |
761
+ | `verbose` | `boolean` | No | `--verbose` | Include INFO-level diagnostics in the result |
762
+ | `pretty` | `boolean` | No | `--pretty` | Pretty-print JSON/XML output |
715
763
  | `inputPath` | `string` | No | `--in` | Path to input file (used for LOM metadata lookup) |
716
764
  | `organisationId` | `number` | No | `--organisation_id` | Organisation ID for Learnosity CDN asset URLs |
717
765
  | `mediaVault` | `boolean` | No | `--mediavault` | Use `media-vault` subdomain instead of `assets` for CDN URLs |
718
766
  | `customAssetUrl` | `string` | No | `--custom-asset-url` | Custom base URL for assets (overrides default Learnosity CDN and `mediaVault`) |
719
767
  | `itemReferenceSource` | `'sourceFilename'` \| `'qti'` \| `'uuid'` | No | `--item-reference-source` | How to generate item references. Default: `'sourceFilename'` |
720
- | `truncateTags` | `boolean` | No | N/A | Truncate tag types and names to 255 characters instead of failing |
768
+ | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
769
+
770
+ **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.
721
771
 
722
772
  ### ConvertQtiPackageToLearnosityOptions Reference (package conversion)
723
773
 
@@ -733,7 +783,7 @@ The package exports the following for library consumers:
733
783
  | `customAssetUrl` | `string` | No | `--custom-asset-url` | Custom base URL for assets (overrides default Learnosity CDN and `mediaVault`) |
734
784
  | `itemReferenceSource` | `'sourceFilename'` \| `'qti'` \| `'uuid'` | No | `--item-reference-source` | How to generate item references. Default: `'sourceFilename'` |
735
785
  | `itemFilenameSource` | `'sourceFilename'` \| `'qti'` | No | `--item-filename-source` | How to name output files |
736
- | `truncateTags` | `boolean` | No | N/A | Truncate tag types and names to 255 characters instead of failing |
786
+ | `truncateTags` | `boolean` | No | `--truncate-tags` | Truncate tag types and names to 255 characters instead of failing |
737
787
 
738
788
  \* Either `inputPath` or `zipBytes` must be provided.
739
789
 
@@ -823,7 +873,7 @@ The validation script validates XML files using **local XSD schemas** (not remot
823
873
  - **Manifest files** (`imsmanifest.xml`) - Validated against IMS Content Packaging schema (`imscp_v1p1.xsd`)
824
874
  - **LOM metadata files** (`*.lom.xml`) - Validated against IMS Learning Resource Metadata schema (`imsmd_v1p2p4.xsd`)
825
875
 
826
- Schema URLs are resolved to local files using the XML catalog (`schemas/qti/catalog.xml`).
876
+ Schema URLs are resolved to local files using the XML catalog (`schemas/catalog.xml`).
827
877
 
828
878
  ```bash
829
879
  pnpm run validate:qti ./output/qti-items
package/docs/FAQ.md CHANGED
@@ -162,7 +162,7 @@ lcon learnosity-to-qti-package --in ./bundle --out package.zip
162
162
  lcon qti-package-to-learnosity --in package.zip --out ./output
163
163
  ```
164
164
 
165
- For individual files, use shell scripting (see [EXAMPLES.md](./EXAMPLES.md#7-batch-conversion)).
165
+ For individual files, use shell scripting (see [EXAMPLES.md](./EXAMPLES.md#10-batch-processing-with-recursive-flag)).
166
166
 
167
167
  ## Diagnostics & Errors
168
168
 
@@ -202,7 +202,7 @@ Override with `--diagnostics <stderr|file|both|none>`.
202
202
 
203
203
  | QTI Interaction | Learnosity Type |
204
204
  | -------------------------- | ----------------------- |
205
- | associateInteraction | classificaiton |
205
+ | associateInteraction | classification |
206
206
  | choiceInteraction | mcq |
207
207
  | textEntryInteraction | clozetext, shorttext |
208
208
  | extendedTextInteraction | longtextV2 |
@@ -245,7 +245,7 @@ lcon learnosity-to-qti --in item.json --out item.xml --qti-version 2.1
245
245
 
246
246
  ### Q: What features are lost when downgrading to QTI 2.1?
247
247
 
248
- **A:** Features introduced in QTI 2.2 may be omitted or degraded. Check diagnostics for `QTI_VERSION_DOWNGRADE` warnings.
248
+ **A:** Features introduced in QTI 2.2 may be omitted or degraded. Check diagnostics for the downgrade codes `QTI_DOWNGRADE_NAMESPACE`, `QTI_DOWNGRADE_SCHEMA_LOCATION`, and `QTI_DOWNGRADE_IDENTIFIER_SANITIZED`.
249
249
 
250
250
  ## Validation
251
251
 
@@ -263,7 +263,7 @@ This validates all XML files in the directory using **local XSD schemas** (not r
263
263
  - **Manifest files** (`imsmanifest.xml`) - Validated against IMS Content Packaging schema
264
264
  - **LOM metadata files** (`*.lom.xml`) - Validated against IMS Learning Resource Metadata schema
265
265
 
266
- Schema URLs are resolved to local files using the XML catalog (`schemas/qti/catalog.xml`).
266
+ Schema URLs are resolved to local files using the XML catalog (`schemas/catalog.xml`).
267
267
 
268
268
  ### Q: Why does validation fail but conversion succeeds?
269
269
 
@@ -291,7 +291,7 @@ This shows schema loading and resolution details.
291
291
 
292
292
  ### Q: How do I set default options?
293
293
 
294
- **A:** Create `lrn-converter.config.json` in your working directory:
294
+ **A:** Create `lrn-converter.config.json` in your working directory (all four commands load it and apply the keys relevant to their conversion direction):
295
295
 
296
296
  ```json
297
297
  {
@@ -333,7 +333,7 @@ See [Getting Started](https://learnosity.github.io/lib-qti-converter/#/GETTING_S
333
333
  pnpm test
334
334
  ```
335
335
 
336
- This runs all 407 tests across the workspace.
336
+ This runs all tests across the workspace (~1,800+ tests: roughly 1,538 in core and 328 in the CLI).
337
337
 
338
338
  ### Q: Why are tests failing?
339
339