@learnosity/lib-qti-converter 0.12.1 → 0.12.2
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 +9 -3
- package/docs/GETTING_STARTED.md +10 -4
- package/docs/TAGS_TO_QTI_METADATA.md +291 -0
- package/docs/_sidebar.md +10 -9
- package/package.json +1 -1
- package/packages/cli/dist/batchProcessors-BfmvnTQ5.js +215 -0
- package/packages/cli/dist/batchProcessors-BfmvnTQ5.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/configOutput-FwkFyQmk.js +399 -0
- package/packages/cli/dist/configOutput-FwkFyQmk.js.map +1 -0
- package/packages/cli/dist/create-prompt-COXnAzFl.js +1387 -0
- package/packages/cli/dist/create-prompt-COXnAzFl.js.map +1 -0
- package/packages/cli/dist/dist-CVD-X-DZ.js +278 -0
- package/packages/cli/dist/dist-CVD-X-DZ.js.map +1 -0
- package/packages/cli/dist/learnosityToQti-sKxcj5Hi.js +102 -0
- package/packages/cli/dist/learnosityToQti-sKxcj5Hi.js.map +1 -0
- package/packages/cli/dist/learnosityToQtiPackage-Ij4cM39M.js +632 -0
- package/packages/cli/dist/learnosityToQtiPackage-Ij4cM39M.js.map +1 -0
- package/packages/cli/dist/main.js +32 -37131
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/pathUtils-Cz2GpPEb.js +2386 -0
- package/packages/cli/dist/pathUtils-Cz2GpPEb.js.map +1 -0
- package/packages/cli/dist/qtiPackageToLearnosity-CvXdmwsb.js +354 -0
- package/packages/cli/dist/qtiPackageToLearnosity-CvXdmwsb.js.map +1 -0
- package/packages/cli/dist/qtiToLearnosity-CkD0r1q0.js +97 -0
- package/packages/cli/dist/qtiToLearnosity-CkD0r1q0.js.map +1 -0
- package/packages/cli/dist/resolveOptions-CfXUqGkd.js +31562 -0
- package/packages/cli/dist/resolveOptions-CfXUqGkd.js.map +1 -0
- package/packages/cli/dist/rolldown-runtime-B4iAMlE-.js +35 -0
- package/packages/cli/dist/{batchProcessors-B8EQvMbH.js → table-DYcNeyJ_.js} +906 -1150
- package/packages/cli/dist/table-DYcNeyJ_.js.map +1 -0
- package/packages/core/dist/index.js +3 -1
- package/packages/core/dist/node.js +3 -1
- package/packages/cli/dist/batchProcessors-B8EQvMbH.js.map +0 -1
package/README.md
CHANGED
|
@@ -36,6 +36,12 @@ pnpm install
|
|
|
36
36
|
pnpm run build
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
After building, run the CLI directly via the local wrapper (no `npx` overhead):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
node bin/lcon.js -i
|
|
43
|
+
```
|
|
44
|
+
|
|
39
45
|
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
46
|
|
|
41
47
|
## Quick Start
|
|
@@ -44,10 +50,10 @@ Some development tasks need tools that are not npm dependencies: Python 3 with `
|
|
|
44
50
|
|
|
45
51
|
```bash
|
|
46
52
|
# Convert single QTI item to Learnosity
|
|
47
|
-
|
|
53
|
+
npm run lcon qti-to-learnosity --in item.xml --out item.json --pretty
|
|
48
54
|
|
|
49
55
|
# Convert single Learnosity item to QTI
|
|
50
|
-
|
|
56
|
+
npm run lcon learnosity-to-qti --in item.json --out item.xml
|
|
51
57
|
```
|
|
52
58
|
|
|
53
59
|
### Library Usage
|
|
@@ -132,7 +138,7 @@ The CLI provides four main conversion commands:
|
|
|
132
138
|
|
|
133
139
|
**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.
|
|
134
140
|
|
|
135
|
-
Run `
|
|
141
|
+
Run `lcon <command> --help` for detailed options, or see [Examples](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES) for usage scenarios.
|
|
136
142
|
|
|
137
143
|
## QTI Validation (not bundled)
|
|
138
144
|
|
package/docs/GETTING_STARTED.md
CHANGED
|
@@ -24,12 +24,18 @@ pnpm install
|
|
|
24
24
|
pnpm run build
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
After building, you can run the CLI directly via the local wrapper (no `npx` overhead):
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
node bin/lcon.js -i
|
|
31
|
+
```
|
|
32
|
+
|
|
27
33
|
## Quick Start — CLI
|
|
28
34
|
|
|
29
35
|
### Convert a Single QTI Item to Learnosity
|
|
30
36
|
|
|
31
37
|
```bash
|
|
32
|
-
|
|
38
|
+
lcon qti-to-learnosity \
|
|
33
39
|
--in path/to/item.xml \
|
|
34
40
|
--out path/to/output.json \
|
|
35
41
|
--pretty
|
|
@@ -38,7 +44,7 @@ npx lcon qti-to-learnosity \
|
|
|
38
44
|
### Convert a Learnosity Item to QTI
|
|
39
45
|
|
|
40
46
|
```bash
|
|
41
|
-
|
|
47
|
+
lcon learnosity-to-qti \
|
|
42
48
|
--in path/to/item.json \
|
|
43
49
|
--out path/to/output.xml \
|
|
44
50
|
--qti-version 2.2
|
|
@@ -49,9 +55,9 @@ npx lcon learnosity-to-qti \
|
|
|
49
55
|
If you prefer prompts for options:
|
|
50
56
|
|
|
51
57
|
```bash
|
|
52
|
-
|
|
58
|
+
lcon qti-to-learnosity --interactive
|
|
53
59
|
# or
|
|
54
|
-
|
|
60
|
+
lcon -i
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
Interactive mode will prompt you for:
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Learnosity Tags to QTI Metadata
|
|
2
|
+
|
|
3
|
+
When converting Learnosity bundles to QTI Content Packages, the converter automatically converts Learnosity tags to IMS LOM (Learning Object Metadata) XML files.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The converter supports one metadata output format:
|
|
8
|
+
|
|
9
|
+
- **LOM (Learning Object Metadata)** - IMS standard metadata format (v1.2)
|
|
10
|
+
|
|
11
|
+
Each Learnosity item's `tags` object is converted to a standalone `.lom.xml` file included in the output package.
|
|
12
|
+
|
|
13
|
+
> **Note:** Common Cartridge Curriculum Standards Metadata is **not** generated in the export direction. Tags are only serialized as LOM classifications.
|
|
14
|
+
|
|
15
|
+
## Tag Input Format
|
|
16
|
+
|
|
17
|
+
The converter accepts Learnosity tags in the **object format** — a JSON object where keys are tag types and values are arrays of tag names:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"reference": "item_001",
|
|
22
|
+
"tags": {
|
|
23
|
+
"subject": ["Mathematics", "Algebra"],
|
|
24
|
+
"grade-level": ["Grade 5"],
|
|
25
|
+
"difficulty": ["Easy"]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Tag Normalization
|
|
31
|
+
|
|
32
|
+
During parsing, the following normalization is applied:
|
|
33
|
+
|
|
34
|
+
- Empty or whitespace-only tag names are filtered out
|
|
35
|
+
- Tag names are trimmed of leading/trailing whitespace
|
|
36
|
+
- Tag names are **de-duplicated** within each type
|
|
37
|
+
- Tag types with no valid tag names after filtering are omitted
|
|
38
|
+
|
|
39
|
+
## LOM Output Format
|
|
40
|
+
|
|
41
|
+
### Standalone LOM File
|
|
42
|
+
|
|
43
|
+
For each item with tags, a standalone file is generated at `metadata/<item-reference>.lom.xml`:
|
|
44
|
+
|
|
45
|
+
```xml
|
|
46
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
47
|
+
<imsmd:lom
|
|
48
|
+
xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
|
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
50
|
+
|
|
51
|
+
<imsmd:general>
|
|
52
|
+
<imsmd:catalogentry>
|
|
53
|
+
<imsmd:catalog>learnosity</imsmd:catalog>
|
|
54
|
+
<imsmd:entry>
|
|
55
|
+
<imsmd:langstring xml:lang="en">item_001</imsmd:langstring>
|
|
56
|
+
</imsmd:entry>
|
|
57
|
+
</imsmd:catalogentry>
|
|
58
|
+
</imsmd:general>
|
|
59
|
+
|
|
60
|
+
<imsmd:classification>
|
|
61
|
+
<imsmd:taxonpath>
|
|
62
|
+
<imsmd:source>
|
|
63
|
+
<imsmd:langstring xml:lang="en">difficulty</imsmd:langstring>
|
|
64
|
+
</imsmd:source>
|
|
65
|
+
<imsmd:taxon>
|
|
66
|
+
<imsmd:entry>
|
|
67
|
+
<imsmd:langstring xml:lang="en">Easy</imsmd:langstring>
|
|
68
|
+
</imsmd:entry>
|
|
69
|
+
</imsmd:taxon>
|
|
70
|
+
</imsmd:taxonpath>
|
|
71
|
+
</imsmd:classification>
|
|
72
|
+
|
|
73
|
+
<imsmd:classification>
|
|
74
|
+
<imsmd:taxonpath>
|
|
75
|
+
<imsmd:source>
|
|
76
|
+
<imsmd:langstring xml:lang="en">grade-level</imsmd:langstring>
|
|
77
|
+
</imsmd:source>
|
|
78
|
+
<imsmd:taxon>
|
|
79
|
+
<imsmd:entry>
|
|
80
|
+
<imsmd:langstring xml:lang="en">Grade 5</imsmd:langstring>
|
|
81
|
+
</imsmd:entry>
|
|
82
|
+
</imsmd:taxon>
|
|
83
|
+
</imsmd:taxonpath>
|
|
84
|
+
</imsmd:classification>
|
|
85
|
+
|
|
86
|
+
<imsmd:classification>
|
|
87
|
+
<imsmd:taxonpath>
|
|
88
|
+
<imsmd:source>
|
|
89
|
+
<imsmd:langstring xml:lang="en">subject</imsmd:langstring>
|
|
90
|
+
</imsmd:source>
|
|
91
|
+
<imsmd:taxon>
|
|
92
|
+
<imsmd:entry>
|
|
93
|
+
<imsmd:langstring xml:lang="en">Algebra</imsmd:langstring>
|
|
94
|
+
</imsmd:entry>
|
|
95
|
+
</imsmd:taxon>
|
|
96
|
+
<imsmd:taxon>
|
|
97
|
+
<imsmd:entry>
|
|
98
|
+
<imsmd:langstring xml:lang="en">Mathematics</imsmd:langstring>
|
|
99
|
+
</imsmd:entry>
|
|
100
|
+
</imsmd:taxon>
|
|
101
|
+
</imsmd:taxonpath>
|
|
102
|
+
</imsmd:classification>
|
|
103
|
+
|
|
104
|
+
</imsmd:lom>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Manifest Reference
|
|
108
|
+
|
|
109
|
+
The LOM file is referenced in `imsmanifest.xml` within the item's `<resource>` element:
|
|
110
|
+
|
|
111
|
+
```xml
|
|
112
|
+
<resource identifier="item_item_001" type="imsqti_item_xmlv2p2" href="items/item_001.xml">
|
|
113
|
+
<file href="items/item_001.xml"/>
|
|
114
|
+
<file href="metadata/item_001.lom.xml"/>
|
|
115
|
+
</resource>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The LOM content is **not** embedded inline in the manifest — it is stored as a separate file.
|
|
119
|
+
|
|
120
|
+
## Mapping
|
|
121
|
+
|
|
122
|
+
| Learnosity | QTI LOM |
|
|
123
|
+
| ---------------------- | ----------------------------------------------------------------------- |
|
|
124
|
+
| Tag type (object key) | `<imsmd:source>/<imsmd:langstring>` |
|
|
125
|
+
| Tag name (array value) | `<imsmd:taxon>/<imsmd:entry>/<imsmd:langstring>` |
|
|
126
|
+
| Item reference | `<imsmd:general>/<imsmd:catalogentry>/<imsmd:entry>/<imsmd:langstring>` |
|
|
127
|
+
|
|
128
|
+
### Structure
|
|
129
|
+
|
|
130
|
+
- One `<imsmd:classification>` element per tag type
|
|
131
|
+
- One `<imsmd:taxon>` element per tag name within a classification
|
|
132
|
+
- The `<imsmd:general>` section identifies the item via a `<imsmd:catalogentry>` with catalog `learnosity`
|
|
133
|
+
|
|
134
|
+
## Sorting and Determinism
|
|
135
|
+
|
|
136
|
+
The converter produces **deterministic output** by sorting:
|
|
137
|
+
|
|
138
|
+
- **Tag types** are sorted lexicographically (e.g., `difficulty` before `grade-level` before `subject`)
|
|
139
|
+
- **Tag names** within each type are sorted alphabetically (e.g., `Algebra` before `Mathematics`)
|
|
140
|
+
|
|
141
|
+
This ensures that the same input always produces identical output, regardless of the original key order in the JSON.
|
|
142
|
+
|
|
143
|
+
## XML Formatting
|
|
144
|
+
|
|
145
|
+
- Uses IMS Metadata v1.2 namespace (`http://www.imsglobal.org/xsd/imsmd_v1p2`)
|
|
146
|
+
- Uses **lowercase** IMS MD v1.2 element names: `imsmd:taxonpath`, `imsmd:langstring`
|
|
147
|
+
- All `<imsmd:langstring>` elements include `xml:lang="en"`
|
|
148
|
+
- XML special characters in tag types and tag names are escaped (`&`, `<`, `>`, `"`, `'`)
|
|
149
|
+
|
|
150
|
+
## Items Without Tags
|
|
151
|
+
|
|
152
|
+
If an item has no `tags` property, an empty tags object, or all tag names are empty/whitespace, **no LOM metadata file is generated** for that item and no metadata file reference appears in the manifest.
|
|
153
|
+
|
|
154
|
+
## Tag Validation
|
|
155
|
+
|
|
156
|
+
Unlike the QTI-to-Learnosity direction, the Learnosity-to-QTI export does **not** enforce a maximum tag length or provide a truncation option. All tag types and tag names are written to LOM as-is (after trimming and de-duplication).
|
|
157
|
+
|
|
158
|
+
## Complete Example
|
|
159
|
+
|
|
160
|
+
### Input (Learnosity JSON)
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"reference": "math_q1",
|
|
165
|
+
"tags": {
|
|
166
|
+
"standard": ["CCSS.MATH.CONTENT.HSA.REI.A.1", "CCSS.MATH.CONTENT.HSA.REI.B.3"],
|
|
167
|
+
"subject": ["Mathematics"],
|
|
168
|
+
"grade-level": ["Grade 9", "Grade 10"]
|
|
169
|
+
},
|
|
170
|
+
"questions": [...]
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Output: `metadata/math_q1.lom.xml`
|
|
175
|
+
|
|
176
|
+
```xml
|
|
177
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
178
|
+
<imsmd:lom
|
|
179
|
+
xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
|
|
180
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
181
|
+
|
|
182
|
+
<imsmd:general>
|
|
183
|
+
<imsmd:catalogentry>
|
|
184
|
+
<imsmd:catalog>learnosity</imsmd:catalog>
|
|
185
|
+
<imsmd:entry>
|
|
186
|
+
<imsmd:langstring xml:lang="en">math_q1</imsmd:langstring>
|
|
187
|
+
</imsmd:entry>
|
|
188
|
+
</imsmd:catalogentry>
|
|
189
|
+
</imsmd:general>
|
|
190
|
+
|
|
191
|
+
<imsmd:classification>
|
|
192
|
+
<imsmd:taxonpath>
|
|
193
|
+
<imsmd:source>
|
|
194
|
+
<imsmd:langstring xml:lang="en">grade-level</imsmd:langstring>
|
|
195
|
+
</imsmd:source>
|
|
196
|
+
<imsmd:taxon>
|
|
197
|
+
<imsmd:entry>
|
|
198
|
+
<imsmd:langstring xml:lang="en">Grade 10</imsmd:langstring>
|
|
199
|
+
</imsmd:entry>
|
|
200
|
+
</imsmd:taxon>
|
|
201
|
+
<imsmd:taxon>
|
|
202
|
+
<imsmd:entry>
|
|
203
|
+
<imsmd:langstring xml:lang="en">Grade 9</imsmd:langstring>
|
|
204
|
+
</imsmd:entry>
|
|
205
|
+
</imsmd:taxon>
|
|
206
|
+
</imsmd:taxonpath>
|
|
207
|
+
</imsmd:classification>
|
|
208
|
+
|
|
209
|
+
<imsmd:classification>
|
|
210
|
+
<imsmd:taxonpath>
|
|
211
|
+
<imsmd:source>
|
|
212
|
+
<imsmd:langstring xml:lang="en">standard</imsmd:langstring>
|
|
213
|
+
</imsmd:source>
|
|
214
|
+
<imsmd:taxon>
|
|
215
|
+
<imsmd:entry>
|
|
216
|
+
<imsmd:langstring xml:lang="en">CCSS.MATH.CONTENT.HSA.REI.A.1</imsmd:langstring>
|
|
217
|
+
</imsmd:entry>
|
|
218
|
+
</imsmd:taxon>
|
|
219
|
+
<imsmd:taxon>
|
|
220
|
+
<imsmd:entry>
|
|
221
|
+
<imsmd:langstring xml:lang="en">CCSS.MATH.CONTENT.HSA.REI.B.3</imsmd:langstring>
|
|
222
|
+
</imsmd:entry>
|
|
223
|
+
</imsmd:taxon>
|
|
224
|
+
</imsmd:taxonpath>
|
|
225
|
+
</imsmd:classification>
|
|
226
|
+
|
|
227
|
+
<imsmd:classification>
|
|
228
|
+
<imsmd:taxonpath>
|
|
229
|
+
<imsmd:source>
|
|
230
|
+
<imsmd:langstring xml:lang="en">subject</imsmd:langstring>
|
|
231
|
+
</imsmd:source>
|
|
232
|
+
<imsmd:taxon>
|
|
233
|
+
<imsmd:entry>
|
|
234
|
+
<imsmd:langstring xml:lang="en">Mathematics</imsmd:langstring>
|
|
235
|
+
</imsmd:entry>
|
|
236
|
+
</imsmd:taxon>
|
|
237
|
+
</imsmd:taxonpath>
|
|
238
|
+
</imsmd:classification>
|
|
239
|
+
|
|
240
|
+
</imsmd:lom>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Output: `imsmanifest.xml` (resource entry)
|
|
244
|
+
|
|
245
|
+
```xml
|
|
246
|
+
<resource identifier="item_math_q1" type="imsqti_item_xmlv2p2" href="items/math_q1.xml">
|
|
247
|
+
<file href="items/math_q1.xml"/>
|
|
248
|
+
<file href="metadata/math_q1.lom.xml"/>
|
|
249
|
+
</resource>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Package Structure
|
|
253
|
+
|
|
254
|
+
A typical output package contains:
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
output.zip/
|
|
258
|
+
imsmanifest.xml
|
|
259
|
+
assessmentTest.xml
|
|
260
|
+
items/
|
|
261
|
+
item_001.xml
|
|
262
|
+
item_002.xml
|
|
263
|
+
metadata/
|
|
264
|
+
item_001.lom.xml
|
|
265
|
+
item_002.lom.xml
|
|
266
|
+
assets/
|
|
267
|
+
image1.png
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
The `metadata/` folder is only present when at least one item has tags.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Differences from QTI-to-Learnosity Direction
|
|
275
|
+
|
|
276
|
+
| Aspect | QTI → Learnosity | Learnosity → QTI |
|
|
277
|
+
| --------------------- | ---------------------------------- | --------------------- |
|
|
278
|
+
| Formats supported | LOM + Common Cartridge | LOM only |
|
|
279
|
+
| Metadata location | Manifest inline + standalone files | Standalone files only |
|
|
280
|
+
| Tag length validation | 255-char limit enforced | No length validation |
|
|
281
|
+
| Truncation option | `--truncate-tags` available | Not applicable |
|
|
282
|
+
| Merge behavior | Manifest tags take priority | N/A (single source) |
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## See Also
|
|
287
|
+
|
|
288
|
+
- [QTI Metadata to Learnosity Tags](./QTI_METADATA_TO_TAGS.md) - The reverse direction (QTI → Learnosity)
|
|
289
|
+
- [Supported Interactions](https://learnosity.github.io/lib-qti-converter/#/SUPPORTED_INTERACTIONS) - Complete list of QTI ↔ Learnosity interaction mappings
|
|
290
|
+
- [Getting Started](https://learnosity.github.io/lib-qti-converter/#/GETTING_STARTED) - Installation and basic usage
|
|
291
|
+
- [Examples](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES) - Conversion examples
|
package/docs/_sidebar.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
- **Getting Started**
|
|
2
|
-
|
|
2
|
+
- [Installation & Quick Start](GETTING_STARTED.md)
|
|
3
3
|
- **Reference**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
- [Supported Interactions](SUPPORTED_INTERACTIONS.md)
|
|
5
|
+
- [QTI Structure](QTI_STRUCTURE.md)
|
|
6
|
+
- [Learnosity Bundle Format](LEARNOSITY_BUNDLE_FORMAT.md)
|
|
7
|
+
- [Learnosity Sections](LEARNOSITY_SECTIONS.md)
|
|
8
|
+
- [QTI Metadata to Tags](QTI_METADATA_TO_TAGS.md)
|
|
9
|
+
- [Tags to QTI Metadata](TAGS_TO_QTI_METADATA.md)
|
|
10
|
+
- [Diagnostics](DIAGNOSTICS.md)
|
|
10
11
|
- **More**
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
- [Examples](EXAMPLES.md)
|
|
13
|
+
- [FAQ](FAQ.md)
|
package/package.json
CHANGED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { n as formatDiagnosticsSummaryTable, s as writeDiagnostics } from "./table-DYcNeyJ_.js";
|
|
2
|
+
import { buildPackageFromActivity, convertActivity, convertQtiPackageToLearnosityBundle, ensureUniqueFolderName, loadLearnosityBundle, loadPackageDirectory, mergeActivityPackage, nodeFileAccess, sanitizeFolderName, saveQtiContentPackage, writeLearnosityBundle } from "@learnosity/converter-core/node";
|
|
3
|
+
//#region src/utils/batchProcessors.ts
|
|
4
|
+
/**
|
|
5
|
+
* Per-package conversion tasks, shared by the serial batch path
|
|
6
|
+
* (`processBatch`) and the parallel worker path (`processBatchParallel` via
|
|
7
|
+
* `batchWorker`). Extracting them here keeps a single implementation per
|
|
8
|
+
* direction — the same code runs inline or inside a worker thread.
|
|
9
|
+
*/
|
|
10
|
+
/** Run one batch task in-process (used by the worker and directly in tests). */
|
|
11
|
+
async function runBatchTask(task, quiet = true) {
|
|
12
|
+
if (task.direction === "qti-to-learnosity") return processQtiPackageToLearnosity(task.pkg, task.packageOutputPath, task.options, quiet);
|
|
13
|
+
return processLearnosityToQtiPackage(task.pkg, task.packageOutputPath, task.options, quiet);
|
|
14
|
+
}
|
|
15
|
+
function displayDiagnosticsSummary(diagnostics, quiet) {
|
|
16
|
+
if (quiet) return;
|
|
17
|
+
const summaryTable = formatDiagnosticsSummaryTable(diagnostics);
|
|
18
|
+
if (summaryTable) {
|
|
19
|
+
console.log(" Diagnostics:");
|
|
20
|
+
console.log(summaryTable.split("\n").map((line) => " " + line).join("\n"));
|
|
21
|
+
console.log("");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Convert one QTI Content Package directory to a Learnosity bundle on disk. */
|
|
25
|
+
async function processQtiPackageToLearnosity(pkg, packageOutputPath, options, quiet) {
|
|
26
|
+
const loaded = loadPackageDirectory(pkg.path);
|
|
27
|
+
const convertResult = loaded.entries ? convertQtiPackageToLearnosityBundle({ entries: loaded.entries }, {
|
|
28
|
+
organisationId: options.organisationId,
|
|
29
|
+
mediaVault: options.mediaVault,
|
|
30
|
+
customAssetUrl: options.customAssetUrl,
|
|
31
|
+
itemReferenceSource: options.itemReferenceSource,
|
|
32
|
+
itemFilenameSource: options.itemFilenameSource,
|
|
33
|
+
truncateTags: options.truncateTags,
|
|
34
|
+
packageVersion: options.version,
|
|
35
|
+
sourceDir: pkg.path,
|
|
36
|
+
fileAccess: nodeFileAccess
|
|
37
|
+
}) : { diagnostics: loaded.diagnostics };
|
|
38
|
+
const errors = convertResult.diagnostics.filter((d) => d.level === "error");
|
|
39
|
+
const warnings = convertResult.diagnostics.filter((d) => d.level === "warning");
|
|
40
|
+
const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;
|
|
41
|
+
const convertedFiles = convertResult.convertedSourceFiles || [];
|
|
42
|
+
const failedFiles = convertResult.failedSourceFiles || [];
|
|
43
|
+
const filesWithErrors = /* @__PURE__ */ new Set();
|
|
44
|
+
for (const d of convertResult.diagnostics) if (d.level === "error" && d.file) filesWithErrors.add(d.file);
|
|
45
|
+
const convertedWithErrors = convertedFiles.filter((f) => filesWithErrors.has(f)).length;
|
|
46
|
+
const erroredItemCount = failedFiles.length + convertedWithErrors;
|
|
47
|
+
const cleanItemCount = convertedFiles.length - convertedWithErrors;
|
|
48
|
+
if (errors.length > 0 && !hasValidBundle) return {
|
|
49
|
+
success: false,
|
|
50
|
+
errorCount: errors.length,
|
|
51
|
+
warningCount: warnings.length,
|
|
52
|
+
convertedItemCount: cleanItemCount,
|
|
53
|
+
failedItemCount: erroredItemCount,
|
|
54
|
+
message: "Conversion failed"
|
|
55
|
+
};
|
|
56
|
+
const writeResult = await writeLearnosityBundle(convertResult.bundle, {
|
|
57
|
+
outDir: packageOutputPath,
|
|
58
|
+
isZipOutput: false
|
|
59
|
+
});
|
|
60
|
+
const writeErrors = writeResult.diagnostics.filter((d) => d.level === "error");
|
|
61
|
+
if (writeErrors.length > 0) return {
|
|
62
|
+
success: false,
|
|
63
|
+
errorCount: errors.length + writeErrors.length,
|
|
64
|
+
warningCount: warnings.length,
|
|
65
|
+
convertedItemCount: cleanItemCount,
|
|
66
|
+
failedItemCount: erroredItemCount,
|
|
67
|
+
message: "Write failed"
|
|
68
|
+
};
|
|
69
|
+
const diagnosticsPath = `${packageOutputPath}/diagnostics.json`;
|
|
70
|
+
const allDiagnostics = [...convertResult.diagnostics, ...writeResult.diagnostics];
|
|
71
|
+
const convertedActivityFiles = convertResult.convertedActivityFiles || [];
|
|
72
|
+
await writeDiagnostics(allDiagnostics, "file", diagnosticsPath, packageOutputPath, false, {
|
|
73
|
+
inputPath: pkg.path,
|
|
74
|
+
outputPath: packageOutputPath,
|
|
75
|
+
totalItemsFound: convertedFiles.length + failedFiles.length,
|
|
76
|
+
totalActivitiesFound: convertedActivityFiles.length,
|
|
77
|
+
convertedFiles,
|
|
78
|
+
failedFiles,
|
|
79
|
+
convertedActivities: convertedActivityFiles
|
|
80
|
+
});
|
|
81
|
+
if (!quiet) {
|
|
82
|
+
const summaryTable = formatDiagnosticsSummaryTable(allDiagnostics);
|
|
83
|
+
if (summaryTable) {
|
|
84
|
+
console.log(" Diagnostics:");
|
|
85
|
+
console.log(summaryTable.split("\n").map((line) => " " + line).join("\n"));
|
|
86
|
+
console.log("");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
errorCount: errors.length,
|
|
92
|
+
warningCount: warnings.length,
|
|
93
|
+
convertedItemCount: cleanItemCount,
|
|
94
|
+
failedItemCount: erroredItemCount
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Convert one Learnosity bundle directory to a QTI Content Package on disk. */
|
|
98
|
+
async function processLearnosityToQtiPackage(pkg, packageOutputPath, options, quiet) {
|
|
99
|
+
const loadResult = loadLearnosityBundle(pkg.path);
|
|
100
|
+
if (!loadResult.bundle) {
|
|
101
|
+
const errorCount = loadResult.diagnostics.filter((d) => d.level === "error").length;
|
|
102
|
+
displayDiagnosticsSummary(loadResult.diagnostics, quiet);
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
errorCount,
|
|
106
|
+
warningCount: 0,
|
|
107
|
+
message: "Bundle load error"
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const bundle = loadResult.bundle;
|
|
111
|
+
const allDiagnostics = [...loadResult.diagnostics];
|
|
112
|
+
const allConvertedActivities = [];
|
|
113
|
+
const usedFolderNames = /* @__PURE__ */ new Set();
|
|
114
|
+
const convertedItemRefs = /* @__PURE__ */ new Set();
|
|
115
|
+
const failedItemRefs = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const activityRef of bundle.activityRefs) {
|
|
117
|
+
const convertResult = convertActivity(bundle, activityRef, {
|
|
118
|
+
pretty: options.pretty,
|
|
119
|
+
version: options.qtiVersion
|
|
120
|
+
});
|
|
121
|
+
allDiagnostics.push(...convertResult.diagnostics);
|
|
122
|
+
const itemRefs = bundle.activityItemRefs.get(activityRef) ?? [];
|
|
123
|
+
const successfulItemRefs = new Set(convertResult.items.map((item) => item.reference));
|
|
124
|
+
for (const itemRef of itemRefs) if (successfulItemRefs.has(itemRef)) convertedItemRefs.add(itemRef);
|
|
125
|
+
else failedItemRefs.add(itemRef);
|
|
126
|
+
if (convertResult.items.length > 0) {
|
|
127
|
+
const sanitizedName = sanitizeFolderName(activityRef, `activity_${allConvertedActivities.length + 1}`);
|
|
128
|
+
const folderName = ensureUniqueFolderName(sanitizedName, usedFolderNames);
|
|
129
|
+
allConvertedActivities.push({
|
|
130
|
+
activityRef,
|
|
131
|
+
folderName,
|
|
132
|
+
conversion: convertResult
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const itemRef of convertedItemRefs) failedItemRefs.delete(itemRef);
|
|
137
|
+
const convertedFiles = itemRefsToFilenames(bundle, convertedItemRefs);
|
|
138
|
+
const failedFiles = itemRefsToFilenames(bundle, failedItemRefs);
|
|
139
|
+
const convertedActivityFiles = allConvertedActivities.map(({ activityRef }) => `activities/${activityRef}.json`);
|
|
140
|
+
const failedActivityFiles = bundle.activityRefs.filter((ref) => !allConvertedActivities.some((a) => a.activityRef === ref)).map((ref) => `activities/${ref}.json`);
|
|
141
|
+
const totalItemsConverted = convertedItemRefs.size;
|
|
142
|
+
const totalItemsFailed = failedItemRefs.size;
|
|
143
|
+
const writePackageDiagnostics = () => writeDiagnostics(allDiagnostics, "file", `${packageOutputPath}/diagnostics.json`, packageOutputPath, false, {
|
|
144
|
+
inputPath: pkg.path,
|
|
145
|
+
outputPath: packageOutputPath,
|
|
146
|
+
totalItemsFound: totalItemsConverted + totalItemsFailed,
|
|
147
|
+
totalActivitiesFound: bundle.activityRefs.length,
|
|
148
|
+
convertedFiles,
|
|
149
|
+
failedFiles,
|
|
150
|
+
convertedActivities: convertedActivityFiles,
|
|
151
|
+
failedActivities: failedActivityFiles
|
|
152
|
+
});
|
|
153
|
+
if (allConvertedActivities.length === 0) {
|
|
154
|
+
const errorCount = allDiagnostics.filter((d) => d.level === "error").length;
|
|
155
|
+
await writePackageDiagnostics();
|
|
156
|
+
return {
|
|
157
|
+
success: false,
|
|
158
|
+
errorCount,
|
|
159
|
+
warningCount: allDiagnostics.filter((d) => d.level === "warning").length,
|
|
160
|
+
convertedItemCount: 0,
|
|
161
|
+
failedItemCount: totalItemsFailed,
|
|
162
|
+
message: "No activities converted"
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const pkgData = {
|
|
166
|
+
zipPath: "",
|
|
167
|
+
resources: [],
|
|
168
|
+
entries: /* @__PURE__ */ new Map(),
|
|
169
|
+
items: [],
|
|
170
|
+
assets: []
|
|
171
|
+
};
|
|
172
|
+
const addedResourceIds = /* @__PURE__ */ new Set();
|
|
173
|
+
for (const { activityRef, folderName, conversion } of allConvertedActivities) {
|
|
174
|
+
const packageResult = buildPackageFromActivity(conversion, {
|
|
175
|
+
bundleDir: pkg.path,
|
|
176
|
+
activityRef,
|
|
177
|
+
version: options.qtiVersion
|
|
178
|
+
});
|
|
179
|
+
allDiagnostics.push(...packageResult.diagnostics);
|
|
180
|
+
mergeActivityPackage(pkgData, folderName, packageResult, addedResourceIds);
|
|
181
|
+
}
|
|
182
|
+
const saveResult = saveQtiContentPackage(pkgData, packageOutputPath);
|
|
183
|
+
allDiagnostics.push(...saveResult.diagnostics);
|
|
184
|
+
const errors = allDiagnostics.filter((d) => d.level === "error");
|
|
185
|
+
const warnings = allDiagnostics.filter((d) => d.level === "warning");
|
|
186
|
+
await writePackageDiagnostics();
|
|
187
|
+
displayDiagnosticsSummary(allDiagnostics, quiet);
|
|
188
|
+
if (errors.length > 0) return {
|
|
189
|
+
success: false,
|
|
190
|
+
errorCount: errors.length,
|
|
191
|
+
warningCount: warnings.length,
|
|
192
|
+
convertedItemCount: totalItemsConverted,
|
|
193
|
+
failedItemCount: totalItemsFailed,
|
|
194
|
+
message: "Conversion failed"
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
success: true,
|
|
198
|
+
errorCount: 0,
|
|
199
|
+
warningCount: warnings.length,
|
|
200
|
+
convertedItemCount: totalItemsConverted,
|
|
201
|
+
failedItemCount: totalItemsFailed
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Map item references to the filenames they were loaded from, for the
|
|
206
|
+
* diagnostics report. Falls back to the reference when the bundle has no
|
|
207
|
+
* filename recorded, so counts always match the listed items.
|
|
208
|
+
*/
|
|
209
|
+
function itemRefsToFilenames(bundle, itemRefs) {
|
|
210
|
+
return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
213
|
+
export { processQtiPackageToLearnosity as n, runBatchTask as r, processLearnosityToQtiPackage as t };
|
|
214
|
+
|
|
215
|
+
//# sourceMappingURL=batchProcessors-BfmvnTQ5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batchProcessors-BfmvnTQ5.js","names":[],"sources":["../src/utils/batchProcessors.ts"],"sourcesContent":["/**\n * Per-package conversion tasks, shared by the serial batch path\n * (`processBatch`) and the parallel worker path (`processBatchParallel` via\n * `batchWorker`). Extracting them here keeps a single implementation per\n * direction — the same code runs inline or inside a worker thread.\n */\n\nimport {\n loadPackageDirectory,\n convertQtiPackageToLearnosityBundle,\n writeLearnosityBundle,\n loadLearnosityBundle,\n convertActivity,\n buildPackageFromActivity,\n mergeActivityPackage,\n sanitizeFolderName,\n ensureUniqueFolderName,\n saveQtiContentPackage,\n nodeFileAccess,\n type Diagnostic,\n type ItemFilenameSource,\n type ItemReferenceSource,\n type LearnosityBundleModel,\n type QtiContentPackage,\n} from '@learnosity/converter-core/node';\nimport type { DetectedPackage } from './packageScanner.js';\nimport { writeDiagnostics } from '../io/writeDiagnostics.js';\nimport { formatDiagnosticsSummaryTable } from '../ux/table.js';\n\n/** Options accepted by the per-package processors (subset of resolved CLI options). */\nexport interface BatchPackageOptions {\n organisationId?: number;\n mediaVault?: boolean;\n customAssetUrl?: string;\n itemReferenceSource?: ItemReferenceSource;\n itemFilenameSource?: ItemFilenameSource;\n truncateTags?: boolean;\n version?: string;\n pretty?: boolean;\n qtiVersion?: '2.1' | '2.2';\n}\n\n/** Result of processing one package (matches PackageProcessor's return shape). */\nexport interface PackageResult {\n success: boolean;\n errorCount: number;\n warningCount: number;\n convertedItemCount?: number;\n failedItemCount?: number;\n message?: string;\n}\n\n/** A single package conversion task dispatched to a worker. */\nexport interface BatchTask {\n direction: 'qti-to-learnosity' | 'learnosity-to-qti';\n pkg: DetectedPackage;\n packageOutputPath: string;\n options: BatchPackageOptions;\n}\n\n/** Run one batch task in-process (used by the worker and directly in tests). */\nexport async function runBatchTask(task: BatchTask, quiet = true): Promise<PackageResult> {\n if (task.direction === 'qti-to-learnosity') {\n return processQtiPackageToLearnosity(task.pkg, task.packageOutputPath, task.options, quiet);\n }\n\n return processLearnosityToQtiPackage(task.pkg, task.packageOutputPath, task.options, quiet);\n}\n\nfunction displayDiagnosticsSummary(diagnostics: Diagnostic[], quiet: boolean): void {\n if (quiet) {\n return;\n }\n\n const summaryTable = formatDiagnosticsSummaryTable(diagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n}\n\n/** Convert one QTI Content Package directory to a Learnosity bundle on disk. */\nexport async function processQtiPackageToLearnosity(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Convert the package\n const loaded = loadPackageDirectory(pkg.path);\n const convertResult = loaded.entries\n ? convertQtiPackageToLearnosityBundle(\n { entries: loaded.entries },\n {\n organisationId: options.organisationId,\n mediaVault: options.mediaVault,\n customAssetUrl: options.customAssetUrl,\n itemReferenceSource: options.itemReferenceSource,\n itemFilenameSource: options.itemFilenameSource,\n truncateTags: options.truncateTags,\n packageVersion: options.version,\n sourceDir: pkg.path,\n fileAccess: nodeFileAccess,\n }\n )\n : { diagnostics: loaded.diagnostics };\n\n const errors = convertResult.diagnostics.filter((d) => d.level === 'error');\n const warnings = convertResult.diagnostics.filter((d) => d.level === 'warning');\n const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;\n\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n\n // Count items that have error-level diagnostics (includes both\n // completely failed items and items that converted with errors)\n const filesWithErrors = new Set<string>();\n\n for (const d of convertResult.diagnostics) {\n if (d.level === 'error' && d.file) {\n filesWithErrors.add(d.file);\n }\n }\n\n const convertedWithErrors = convertedFiles.filter((f) => filesWithErrors.has(f)).length;\n const erroredItemCount = failedFiles.length + convertedWithErrors;\n const cleanItemCount = convertedFiles.length - convertedWithErrors;\n\n if (errors.length > 0 && !hasValidBundle) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Conversion failed',\n };\n }\n\n // Write the bundle\n const writeResult = await writeLearnosityBundle(convertResult.bundle!, {\n outDir: packageOutputPath,\n isZipOutput: false,\n });\n\n const writeErrors = writeResult.diagnostics.filter((d) => d.level === 'error');\n\n if (writeErrors.length > 0) {\n return {\n success: false,\n errorCount: errors.length + writeErrors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Write failed',\n };\n }\n\n // In batch mode, always write diagnostics.json to each package directory\n const diagnosticsPath = `${packageOutputPath}/diagnostics.json`;\n const allDiagnostics = [...convertResult.diagnostics, ...writeResult.diagnostics];\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n\n await writeDiagnostics(allDiagnostics, 'file', diagnosticsPath, packageOutputPath, false, {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: convertedFiles.length + failedFiles.length,\n totalActivitiesFound: convertedActivityFiles.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n });\n\n // Show condensed diagnostics summary\n if (!quiet) {\n const summaryTable = formatDiagnosticsSummaryTable(allDiagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n }\n\n return {\n success: true,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n };\n}\n\n/** Convert one Learnosity bundle directory to a QTI Content Package on disk. */\nexport async function processLearnosityToQtiPackage(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Load the bundle\n const loadResult = loadLearnosityBundle(pkg.path);\n\n if (!loadResult.bundle) {\n const errorCount = loadResult.diagnostics.filter((d) => d.level === 'error').length;\n\n displayDiagnosticsSummary(loadResult.diagnostics, quiet);\n\n return {\n success: false,\n errorCount,\n warningCount: 0,\n message: 'Bundle load error',\n };\n }\n\n const bundle = loadResult.bundle;\n const allDiagnostics: Diagnostic[] = [...loadResult.diagnostics];\n\n // Convert all activities in the bundle\n const allConvertedActivities: {\n activityRef: string;\n folderName: string;\n conversion: ReturnType<typeof convertActivity>;\n }[] = [];\n\n // Folder names for tests/<folderName>/assessmentTest.xml must be unique per package\n const usedFolderNames = new Set<string>();\n\n // Track item outcomes for the diagnostics report. Items shared by several\n // activities are counted once, hence the sets.\n const convertedItemRefs = new Set<string>();\n const failedItemRefs = new Set<string>();\n\n for (const activityRef of bundle.activityRefs) {\n const convertResult = convertActivity(bundle, activityRef, {\n pretty: options.pretty,\n version: options.qtiVersion,\n });\n\n allDiagnostics.push(...convertResult.diagnostics);\n\n const itemRefs = bundle.activityItemRefs.get(activityRef) ?? [];\n const successfulItemRefs = new Set(convertResult.items.map((item) => item.reference));\n\n for (const itemRef of itemRefs) {\n if (successfulItemRefs.has(itemRef)) {\n convertedItemRefs.add(itemRef);\n } else {\n failedItemRefs.add(itemRef);\n }\n }\n\n if (convertResult.items.length > 0) {\n const sanitizedName = sanitizeFolderName(\n activityRef,\n `activity_${allConvertedActivities.length + 1}`\n );\n const folderName = ensureUniqueFolderName(sanitizedName, usedFolderNames);\n\n allConvertedActivities.push({ activityRef, folderName, conversion: convertResult });\n }\n }\n\n // An item that converted in one activity is not a failure elsewhere.\n for (const itemRef of convertedItemRefs) {\n failedItemRefs.delete(itemRef);\n }\n\n const convertedFiles = itemRefsToFilenames(bundle, convertedItemRefs);\n const failedFiles = itemRefsToFilenames(bundle, failedItemRefs);\n const convertedActivityFiles = allConvertedActivities.map(\n ({ activityRef }) => `activities/${activityRef}.json`\n );\n const failedActivityFiles = bundle.activityRefs\n .filter((ref) => !allConvertedActivities.some((a) => a.activityRef === ref))\n .map((ref) => `activities/${ref}.json`);\n const totalItemsConverted = convertedItemRefs.size;\n const totalItemsFailed = failedItemRefs.size;\n\n // In batch mode, always write diagnostics.json to each package directory,\n // including when the package fails, so the report explains what happened.\n // Reads allDiagnostics when called, so later diagnostics are included.\n const writePackageDiagnostics = () =>\n writeDiagnostics(\n allDiagnostics,\n 'file',\n `${packageOutputPath}/diagnostics.json`,\n packageOutputPath,\n false,\n {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: totalItemsConverted + totalItemsFailed,\n totalActivitiesFound: bundle.activityRefs.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n failedActivities: failedActivityFiles,\n }\n );\n\n if (allConvertedActivities.length === 0) {\n const errorCount = allDiagnostics.filter((d) => d.level === 'error').length;\n\n await writePackageDiagnostics();\n\n return {\n success: false,\n errorCount,\n warningCount: allDiagnostics.filter((d) => d.level === 'warning').length,\n convertedItemCount: 0,\n failedItemCount: totalItemsFailed,\n message: 'No activities converted',\n };\n }\n\n // Build package with all activities\n const pkgData: QtiContentPackage = {\n zipPath: '',\n resources: [],\n entries: new Map(),\n items: [],\n assets: [],\n };\n\n const addedResourceIds = new Set<string>();\n\n for (const { activityRef, folderName, conversion } of allConvertedActivities) {\n const packageResult = buildPackageFromActivity(conversion, {\n bundleDir: pkg.path,\n activityRef,\n version: options.qtiVersion,\n });\n\n allDiagnostics.push(...packageResult.diagnostics);\n\n // Relocates the assessmentTest to tests/<folderName>/assessmentTest.xml and\n // wires manifest dependencies, matching the single-package output layout.\n mergeActivityPackage(pkgData, folderName, packageResult, addedResourceIds);\n }\n\n // Save the package\n const saveResult = saveQtiContentPackage(pkgData, packageOutputPath);\n\n allDiagnostics.push(...saveResult.diagnostics);\n\n const errors = allDiagnostics.filter((d) => d.level === 'error');\n const warnings = allDiagnostics.filter((d) => d.level === 'warning');\n\n await writePackageDiagnostics();\n\n displayDiagnosticsSummary(allDiagnostics, quiet);\n\n if (errors.length > 0) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n message: 'Conversion failed',\n };\n }\n\n return {\n success: true,\n errorCount: 0,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n };\n}\n\n/**\n * Map item references to the filenames they were loaded from, for the\n * diagnostics report. Falls back to the reference when the bundle has no\n * filename recorded, so counts always match the listed items.\n */\nfunction itemRefsToFilenames(bundle: LearnosityBundleModel, itemRefs: Set<string>): string[] {\n return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);\n}\n"],"mappings":";;;;;;;;;;AA6DA,eAAsB,aAAa,MAAiB,QAAQ,MAA8B;CACtF,IAAI,KAAK,cAAc,qBACnB,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;CAG9F,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;AAC9F;AAEA,SAAS,0BAA0B,aAA2B,OAAsB;CAChF,IAAI,OACA;CAGJ,MAAM,eAAe,8BAA8B,WAAW;CAE9D,IAAI,cAAc;EACd,QAAQ,IAAI,gBAAgB;EAC5B,QAAQ,IACJ,aACK,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,OAAO,IAAI,CAAC,CAC1B,KAAK,IAAI,CAClB;EACA,QAAQ,IAAI,EAAE;CAClB;AACJ;;AAGA,eAAsB,8BAClB,KACA,mBACA,SACA,OACsB;CAEtB,MAAM,SAAS,qBAAqB,IAAI,IAAI;CAC5C,MAAM,gBAAgB,OAAO,UACvB,oCACI,EAAE,SAAS,OAAO,QAAQ,GAC1B;EACI,gBAAgB,QAAQ;EACxB,YA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