@learnosity/lib-qti-converter 0.10.4

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.
@@ -0,0 +1,384 @@
1
+ # Learnosity Sections → QTI Mapping
2
+
3
+ This document describes how Learnosity Activities with **sections** are converted to QTI `<assessmentTest>` structures with multiple `<assessmentSection>` elements.
4
+
5
+ ## Overview
6
+
7
+ Learnosity Activities can organize items into **sections**, which are logical groupings with their own configuration for:
8
+
9
+ - **Navigation rules** (linear vs. nonlinear)
10
+ - **Time limits** (hard or soft)
11
+ - **Item shuffling**
12
+
13
+ When converting to QTI, these sections map to:
14
+
15
+ - **`<testPart>`** - Container for all sections (navigation mode determined by section configs)
16
+ - **`<assessmentSection>`** - Individual sections with their own settings
17
+
18
+ ## Mapping Rules
19
+
20
+ | Learnosity Section Config | QTI Equivalent | Notes |
21
+ | ------------------------------------------ | --------------------------------------- | ----------------------------------------------------------------------------- |
22
+ | `config.navigation.allow_backward: false` | `<testPart navigationMode="linear">` | If **any** section has `allow_backward: false`, the entire testPart is linear |
23
+ | `config.navigation.allow_backward: true` | `<testPart navigationMode="nonlinear">` | Only if **all** sections allow backward navigation |
24
+ | `config.configuration.shuffle_items: true` | `<assessmentSection shuffle="true">` | Per-section attribute |
25
+ | `config.time.max_time` | `<timeLimits maxTime="...">` | Time in seconds, applied to the section |
26
+ | `config.time.limit_type: "hard"` | `allowLateSubmission="false"` | Hard time limit prevents late submission |
27
+ | `config.time.limit_type: "soft"` | `allowLateSubmission="true"` | Soft time limit allows late submission |
28
+
29
+ ## Learnosity JSON Example
30
+
31
+ ### Activity with Sections
32
+
33
+ ```json
34
+ {
35
+ "activity_id": "demo-activity-sections",
36
+ "name": "Multi-Section Assessment",
37
+ "rendering_type": "assess",
38
+ "type": "submit_practice",
39
+ "data": {
40
+ "config": {
41
+ "title": "Multi-Section Assessment"
42
+ },
43
+ "sections": [
44
+ {
45
+ "items": [
46
+ {
47
+ "id": "item_001",
48
+ "reference": "item_001"
49
+ },
50
+ {
51
+ "id": "item_002",
52
+ "reference": "item_002"
53
+ }
54
+ ],
55
+ "config": {
56
+ "navigation": {
57
+ "allow_backward": true
58
+ }
59
+ }
60
+ },
61
+ {
62
+ "items": [
63
+ {
64
+ "id": "item_003",
65
+ "reference": "item_003"
66
+ },
67
+ {
68
+ "id": "item_004",
69
+ "reference": "item_004"
70
+ }
71
+ ],
72
+ "config": {
73
+ "configuration": {
74
+ "shuffle_items": true
75
+ },
76
+ "time": {
77
+ "max_time": 300,
78
+ "limit_type": "hard"
79
+ }
80
+ }
81
+ },
82
+ {
83
+ "items": [
84
+ {
85
+ "id": "item_005",
86
+ "reference": "item_005"
87
+ }
88
+ ],
89
+ "config": {
90
+ "time": {
91
+ "max_time": 600,
92
+ "limit_type": "soft"
93
+ }
94
+ }
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ ```
100
+
101
+ ## QTI Output Example
102
+
103
+ The above Learnosity activity converts to the following QTI structure:
104
+
105
+ ```xml
106
+ <?xml version="1.0" encoding="UTF-8"?>
107
+ <assessmentTest xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2"
108
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
109
+ xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p2
110
+ http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd"
111
+ identifier="demo-activity-sections"
112
+ title="Multi-Section Assessment">
113
+
114
+ <testPart identifier="testPart_1"
115
+ navigationMode="nonlinear"
116
+ submissionMode="simultaneous">
117
+
118
+ <!-- Section 1: No special settings -->
119
+ <assessmentSection identifier="section_1"
120
+ title="Multi-Section Assessment - Section 1"
121
+ visible="true">
122
+ <assessmentItemRef identifier="item_001" href="items/item_001.xml"/>
123
+ <assessmentItemRef identifier="item_002" href="items/item_002.xml"/>
124
+ </assessmentSection>
125
+
126
+ <!-- Section 2: Shuffled items with hard time limit -->
127
+ <assessmentSection identifier="section_2"
128
+ title="Multi-Section Assessment - Section 2"
129
+ visible="true"
130
+ shuffle="true">
131
+ <timeLimits maxTime="300" allowLateSubmission="false"/>
132
+ <assessmentItemRef identifier="item_003" href="items/item_003.xml"/>
133
+ <assessmentItemRef identifier="item_004" href="items/item_004.xml"/>
134
+ </assessmentSection>
135
+
136
+ <!-- Section 3: Soft time limit -->
137
+ <assessmentSection identifier="section_3"
138
+ title="Multi-Section Assessment - Section 3"
139
+ visible="true">
140
+ <timeLimits maxTime="600" allowLateSubmission="true"/>
141
+ <assessmentItemRef identifier="item_005" href="items/item_005.xml"/>
142
+ </assessmentSection>
143
+
144
+ </testPart>
145
+ </assessmentTest>
146
+ ```
147
+
148
+ ## Navigation Mode Resolution
149
+
150
+ The `navigationMode` attribute on `<testPart>` is determined by examining **all** sections in the activity:
151
+
152
+ - **Linear** (`navigationMode="linear"`): Set if **any** section has `config.navigation.allow_backward: false`
153
+ - Prevents students from navigating backward to previous items
154
+ - Enforces sequential progression through the test
155
+
156
+ - **Nonlinear** (`navigationMode="nonlinear"`): Set only if **all** sections have `config.navigation.allow_backward: true` (or no navigation config)
157
+ - Allows free navigation between items
158
+ - Students can review and change answers
159
+
160
+ ### Example: Mixed Navigation Settings
161
+
162
+ ```json
163
+ {
164
+ "sections": [
165
+ {
166
+ "items": ["item_001"],
167
+ "config": {
168
+ "navigation": {
169
+ "allow_backward": true // This section allows backward
170
+ }
171
+ }
172
+ },
173
+ {
174
+ "items": ["item_002"],
175
+ "config": {
176
+ "navigation": {
177
+ "allow_backward": false // This section is linear
178
+ }
179
+ }
180
+ }
181
+ ]
182
+ }
183
+ ```
184
+
185
+ **Result**: `<testPart navigationMode="linear">` because at least one section has `allow_backward: false`.
186
+
187
+ ## Section Identifiers and Titles
188
+
189
+ - **Section identifiers**: Auto-generated as `section_1`, `section_2`, etc.
190
+ - **Section titles**: Derived from the activity title with section number appended
191
+ - Format: `"{activity_title} - Section {n}"`
192
+ - Example: `"Math Quiz - Section 1"`
193
+
194
+ ## Time Limits
195
+
196
+ Time limits in Learnosity are specified in **seconds** and map directly to QTI's `maxTime` attribute.
197
+
198
+ ### Hard vs. Soft Limits
199
+
200
+ | Learnosity `limit_type` | QTI `allowLateSubmission` | Behavior |
201
+ | ----------------------- | ------------------------- | ------------------------------------------------------- |
202
+ | `"hard"` | `false` | Timer expires → automatic submission, no late answers |
203
+ | `"soft"` | `true` | Timer expires → warning shown, but student can continue |
204
+
205
+ ### Example: Section with Hard Time Limit
206
+
207
+ ```json
208
+ {
209
+ "config": {
210
+ "time": {
211
+ "max_time": 1800, // 30 minutes
212
+ "limit_type": "hard"
213
+ }
214
+ }
215
+ }
216
+ ```
217
+
218
+ Converts to:
219
+
220
+ ```xml
221
+ <timeLimits maxTime="1800" allowLateSubmission="false"/>
222
+ ```
223
+
224
+ ## Item Shuffling
225
+
226
+ The `shuffle_items` configuration controls whether items within a section are presented in random order.
227
+
228
+ ```json
229
+ {
230
+ "config": {
231
+ "configuration": {
232
+ "shuffle_items": true
233
+ }
234
+ }
235
+ }
236
+ ```
237
+
238
+ Converts to:
239
+
240
+ ```xml
241
+ <assessmentSection shuffle="true">
242
+ <!-- items will be shuffled when presented -->
243
+ </assessmentSection>
244
+ ```
245
+
246
+ **Note**: If `shuffle_items` is `false` or not specified, the `shuffle` attribute is omitted (defaults to `false` in QTI).
247
+
248
+ ## Bundle File Structure
249
+
250
+ When exporting Learnosity activities with sections, the bundle structure includes:
251
+
252
+ ```
253
+ learnosity-bundle/
254
+ ├── manifest.json # Contains activity and item metadata
255
+ ├── activities/
256
+ │ └── {activity_id}.json # Activity JSON with sections array
257
+ └── items/
258
+ ├── {item_hash}.json # Item files (MD5 hash of item ID)
259
+ └── ...
260
+ ```
261
+
262
+ ### Important: Item File Naming
263
+
264
+ Item files are named using the **MD5 hash of the item reference** (without organization prefix):
265
+
266
+ - Item reference: `"item_001"`
267
+ - Filename: `md5("item_001").json` → `a1b2c3d4e5f6...json`
268
+
269
+ **Note**: Even though the manifest may include a full item ID with an organization prefix (e.g., `"1::item_001"`), the filename is always based on the `reference` field only.
270
+
271
+ The converter automatically handles this by:
272
+
273
+ 1. Extracting item references from activity sections or manifest
274
+ 2. Using the reference for MD5 hashing when locating files
275
+ 3. Falling back to direct filename match if MD5 file doesn't exist
276
+
277
+ ## Conversion Behavior
278
+
279
+ ### Empty Sections
280
+
281
+ Sections with no items (or all items filtered out) are **skipped** in the QTI output.
282
+
283
+ ### Missing Items
284
+
285
+ If an item referenced in a section is not found in the bundle:
286
+
287
+ - The item is **skipped** (not included in the section)
288
+ - A diagnostic warning is generated
289
+ - Conversion continues with remaining items
290
+
291
+ ### Flat vs. Section-Based Activities
292
+
293
+ The converter supports both formats:
294
+
295
+ **Flat format (legacy)** - Array of strings:
296
+
297
+ ```json
298
+ {
299
+ "data": {
300
+ "items": ["item_001", "item_002", "item_003"]
301
+ }
302
+ }
303
+ ```
304
+
305
+ → Converts to a single `<assessmentSection>` with all items
306
+
307
+ **Flat format (official)** - Array of objects:
308
+
309
+ ```json
310
+ {
311
+ "data": {
312
+ "items": [
313
+ {
314
+ "id": "1::item_001",
315
+ "reference": "item_001"
316
+ },
317
+ {
318
+ "id": "1::item_002",
319
+ "reference": "item_002"
320
+ },
321
+ {
322
+ "id": "1::item_003",
323
+ "reference": "item_003"
324
+ }
325
+ ]
326
+ }
327
+ }
328
+ ```
329
+
330
+ → Converts to a single `<assessmentSection>` with all items
331
+
332
+ **Section-based format** - Array of sections with item objects:
333
+
334
+ ```json
335
+ {
336
+ "data": {
337
+ "sections": [
338
+ {
339
+ "items": [
340
+ {
341
+ "id": "1::item_001",
342
+ "reference": "item_001"
343
+ },
344
+ {
345
+ "id": "1::item_002",
346
+ "reference": "item_002"
347
+ }
348
+ ]
349
+ },
350
+ {
351
+ "items": [
352
+ {
353
+ "id": "1::item_003",
354
+ "reference": "item_003"
355
+ }
356
+ ]
357
+ }
358
+ ]
359
+ }
360
+ }
361
+ ```
362
+
363
+ → Converts to multiple `<assessmentSection>` elements
364
+
365
+ ## QTI Compatibility
366
+
367
+ The generated QTI is compatible with:
368
+
369
+ - **QTI 2.1** - All features supported
370
+ - **QTI 2.2** - All features supported (default output version)
371
+
372
+ Both versions support:
373
+
374
+ - Multiple `<assessmentSection>` elements
375
+ - Section-level `shuffle` attribute
376
+ - Section-level `<timeLimits>` elements
377
+ - `navigationMode` on `<testPart>`
378
+
379
+ ## See Also
380
+
381
+ - [Learnosity Bundle Format](https://learnosity.github.io/lib-qti-converter/#/LEARNOSITY_BUNDLE_FORMAT) - Complete bundle structure documentation
382
+ - [Diagnostics](https://learnosity.github.io/lib-qti-converter/#/DIAGNOSTICS) - Understanding diagnostics metadata and conversion messages
383
+ - [Supported Interactions](https://learnosity.github.io/lib-qti-converter/#/SUPPORTED_INTERACTIONS) - Item-level conversion mappings
384
+ - [Examples](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES) - CLI and library usage examples
@@ -0,0 +1,266 @@
1
+ # QTI Metadata to Learnosity Tags
2
+
3
+ When converting QTI packages to Learnosity, the converter automatically extracts metadata and converts it to Learnosity tags.
4
+
5
+ ## Overview
6
+
7
+ The converter supports two metadata formats:
8
+
9
+ 1. **LOM (Learning Object Metadata)** - IMS standard metadata format
10
+ 2. **Common Cartridge Curriculum Standards Metadata** - Common Cartridge-specific metadata format
11
+
12
+ Both formats can be present in the same QTI package, and tags from both sources are automatically merged.
13
+
14
+ ## Metadata Sources
15
+
16
+ The converter searches for metadata in two locations:
17
+
18
+ 1. **Manifest metadata** - `<metadata>` blocks within each `<resource>` element in `imsmanifest.xml`
19
+ 2. **Standalone LOM files** - Files named `*.lom.xml` located alongside the item XML files
20
+
21
+ ## LOM (Learning Object Metadata)
22
+
23
+ ### QTI Metadata Format (imsmanifest.xml)
24
+
25
+ ```xml
26
+ <resource identifier="item_001" type="imsqti_item_xmlv2p1" href="./items/item_001.xml">
27
+ <metadata>
28
+ <imsmd:lom xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2">
29
+ <imsmd:classification>
30
+ <imsmd:taxonPath>
31
+ <imsmd:source>
32
+ <imsmd:string>subject</imsmd:string>
33
+ </imsmd:source>
34
+ <imsmd:taxon>
35
+ <imsmd:entry>
36
+ <imsmd:string>Mathematics</imsmd:string>
37
+ </imsmd:entry>
38
+ </imsmd:taxon>
39
+ </imsmd:taxonPath>
40
+ <imsmd:taxonPath>
41
+ <imsmd:source>
42
+ <imsmd:string>grade-level</imsmd:string>
43
+ </imsmd:source>
44
+ <imsmd:taxon>
45
+ <imsmd:entry>
46
+ <imsmd:string>Grade 5</imsmd:string>
47
+ </imsmd:entry>
48
+ </imsmd:taxon>
49
+ </imsmd:taxonPath>
50
+ </imsmd:classification>
51
+ </imsmd:lom>
52
+ </metadata>
53
+ <file href="./items/item_001.xml"/>
54
+ </resource>
55
+ ```
56
+
57
+ ### Learnosity Tags Output
58
+
59
+ ```json
60
+ {
61
+ "reference": "item_001",
62
+ "tags": {
63
+ "subject": ["Mathematics"],
64
+ "grade-level": ["Grade 5"]
65
+ },
66
+ "questions": [...]
67
+ }
68
+ ```
69
+
70
+ ### Mapping
71
+
72
+ - `<imsmd:source>` → tag type
73
+ - `<imsmd:taxon>/<imsmd:entry>` → tag value
74
+
75
+ ### Features
76
+
77
+ - Supports both `<imsmd:langstring>` and `<imsmd:string>` elements
78
+ - Multiple taxonomy paths are combined into a single tags object
79
+ - Multiple values for the same tag type are merged into an array
80
+ - Tags from manifest metadata are merged with tags from standalone LOM files
81
+ - Tag type names come from `<imsmd:source>` elements
82
+ - Tag values come from `<imsmd:taxon>/<imsmd:entry>` elements
83
+
84
+ ## Common Cartridge Curriculum Standards Metadata
85
+
86
+ In addition to LOM metadata, the converter also supports **Common Cartridge curriculum standards metadata** found in `<metadata>` blocks within `imsmanifest.xml`.
87
+
88
+ ### Common Cartridge Metadata Format
89
+
90
+ ```xml
91
+ <resource identifier="item_001" type="imsqti_item_xmlv2p1" href="./items/item_001.xml">
92
+ <metadata>
93
+ <csm:curriculumStandardsMetadataSet xmlns:csm="http://www.imsglobal.org/xsd/imscsmd_v1p0">
94
+ <csm:curriculumStandardsMetadata>
95
+ <csm:setOfGUIDs>
96
+ <csm:labelledGUID>
97
+ <csm:label>goalKeywords</csm:label>
98
+ <csm:GUID>enVAGA_NATA2\AGA\MTH.4483</csm:GUID>
99
+ </csm:labelledGUID>
100
+ <csm:labelledGUID>
101
+ <csm:label>standard</csm:label>
102
+ <csm:GUID>CCSS.MATH.CONTENT.HSA.REI.A.1</csm:GUID>
103
+ </csm:labelledGUID>
104
+ </csm:setOfGUIDs>
105
+ </csm:curriculumStandardsMetadata>
106
+ </csm:curriculumStandardsMetadataSet>
107
+ </metadata>
108
+ <file href="./items/item_001.xml"/>
109
+ </resource>
110
+ ```
111
+
112
+ ### Learnosity Tags Output
113
+
114
+ ```json
115
+ {
116
+ "reference": "item_001",
117
+ "tags": {
118
+ "goalKeywords": ["enVAGA_NATA2\\AGA\\MTH.4483"],
119
+ "standard": ["CCSS.MATH.CONTENT.HSA.REI.A.1"]
120
+ },
121
+ "questions": [...]
122
+ }
123
+ ```
124
+
125
+ ### Mapping
126
+
127
+ - `<csm:label>` → tag type
128
+ - `<csm:GUID>` → tag name
129
+
130
+ ### Features
131
+
132
+ - Namespace-aware parsing (works with any XML prefix bound to the Common Cartridge namespace)
133
+ - Automatic deduplication of duplicate entries
134
+ - Incomplete entries (missing label or GUID) are safely skipped
135
+ - Whitespace is automatically trimmed from both label and GUID values
136
+ - Common Cartridge tags are merged with LOM tags when both are present
137
+ - Backslashes and special characters in GUID values are preserved
138
+
139
+ ## Combined LOM and Common Cartridge Example
140
+
141
+ When both LOM and Common Cartridge metadata are present in the same resource, they are merged:
142
+
143
+ ```xml
144
+ <metadata>
145
+ <imsmd:lom xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2">
146
+ <imsmd:classification>
147
+ <imsmd:taxonPath>
148
+ <imsmd:source><imsmd:string>subject</imsmd:string></imsmd:source>
149
+ <imsmd:taxon><imsmd:entry><imsmd:string>Mathematics</imsmd:string></imsmd:entry></imsmd:taxon>
150
+ </imsmd:taxonPath>
151
+ </imsmd:classification>
152
+ </imsmd:lom>
153
+ <csm:curriculumStandardsMetadataSet xmlns:csm="http://www.imsglobal.org/xsd/imscsmd_v1p0">
154
+ <csm:curriculumStandardsMetadata>
155
+ <csm:setOfGUIDs>
156
+ <csm:labelledGUID>
157
+ <csm:label>standard</csm:label>
158
+ <csm:GUID>CCSS.MATH.CONTENT.HSA.REI.A.1</csm:GUID>
159
+ </csm:labelledGUID>
160
+ </csm:setOfGUIDs>
161
+ </csm:curriculumStandardsMetadata>
162
+ </csm:curriculumStandardsMetadataSet>
163
+ </metadata>
164
+ ```
165
+
166
+ **Combined Output:**
167
+
168
+ ```json
169
+ {
170
+ "tags": {
171
+ "subject": ["Mathematics"],
172
+ "standard": ["CCSS.MATH.CONTENT.HSA.REI.A.1"]
173
+ }
174
+ }
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Tag Validation and Length Limits
180
+
181
+ ### Maximum Tag Length
182
+
183
+ Learnosity enforces a **maximum length of 255 characters** for both tag types and tag names. The converter validates all tags during conversion to ensure they comply with this limit.
184
+
185
+ ### Default Behavior (Strict Mode)
186
+
187
+ By default, the converter will **fail with an error** if any tag type or tag name exceeds 255 characters:
188
+
189
+ ```
190
+ Error: Tag type "very-long-taxonomy-name..." exceeds maximum length of 255 characters (length: 300).
191
+ Use --truncate-tags to automatically truncate tags instead of failing.
192
+ ```
193
+
194
+ This ensures you are aware of any metadata that doesn't meet Learnosity's requirements.
195
+
196
+ ### Truncation Mode
197
+
198
+ You can enable automatic truncation using the `--truncate-tags` CLI option or `truncateTags` library option:
199
+
200
+ **CLI:**
201
+
202
+ ```bash
203
+ # Single file conversion
204
+ qti-to-learnosity --in item.xml --out item.json --truncate-tags
205
+
206
+ # Package conversion
207
+ qti-package-to-learnosity --in package.zip --out bundle.zip --truncate-tags
208
+ ```
209
+
210
+ **Library:**
211
+
212
+ ```typescript
213
+ import {
214
+ convertQtiToLearnosity,
215
+ convertQtiPackageToLearnosity,
216
+ } from '@learnosity/lib-qti-converter';
217
+
218
+ // Single-item conversion
219
+ const result = await convertQtiToLearnosity(qtiXml, {
220
+ truncateTags: true,
221
+ // ...other required options
222
+ });
223
+
224
+ // Package conversion
225
+ const pkgResult = await convertQtiPackageToLearnosity({
226
+ inputPath: 'package.zip',
227
+ truncateTags: true,
228
+ });
229
+ ```
230
+
231
+ When truncation is enabled:
232
+
233
+ - Tag types and tag names that exceed 255 characters are automatically truncated
234
+ - A **warning** diagnostic is generated for each truncated tag
235
+ - The conversion continues successfully
236
+
237
+ **Example warning:**
238
+
239
+ ```
240
+ Warning: Tag value "Common Core State Standards for Mathematics - High School Algebra - Reasoning with Equations and Inequalities - Understand solving equations as a process of reasoning and explain the reasoning - Explain each step in solving a simple equation..." for type "standard" exceeds 255 characters and was truncated
241
+ ```
242
+
243
+ ### Configuration File
244
+
245
+ You can also enable truncation in your configuration file:
246
+
247
+ ```json
248
+ {
249
+ "truncateTags": true
250
+ }
251
+ ```
252
+
253
+ ### Recommendations
254
+
255
+ - **Development/Testing**: Use strict mode (default) to identify problematic metadata early
256
+ - **Production**: Consider using `--truncate-tags` if you have legacy content with long taxonomy names
257
+ - **Best Practice**: Review truncation warnings to ensure important information isn't lost
258
+
259
+ ---
260
+
261
+ ## See Also
262
+
263
+ - [Supported Interactions](https://learnosity.github.io/lib-qti-converter/#/SUPPORTED_INTERACTIONS) - Complete list of QTI ↔ Learnosity interaction mappings
264
+ - [Getting Started](https://learnosity.github.io/lib-qti-converter/#/GETTING_STARTED) - Installation and basic usage
265
+ - [Examples](https://learnosity.github.io/lib-qti-converter/#/EXAMPLES) - Conversion examples
266
+ - [FAQ](https://learnosity.github.io/lib-qti-converter/#/FAQ) - Common questions