@pie-qti/qti-common 0.1.11 → 0.1.12
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 +16 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -276,15 +276,21 @@ console.log(`Playing ${version} content`);
|
|
|
276
276
|
### Transform Integration
|
|
277
277
|
|
|
278
278
|
```typescript
|
|
279
|
-
import {
|
|
279
|
+
import { TransformEngine } from '@pie-qti/transform-core';
|
|
280
|
+
import { QtiToPiePlugin } from '@pie-qti/to-pie';
|
|
280
281
|
import { createQtiParser } from '@pie-qti/qti-common';
|
|
281
282
|
|
|
282
283
|
const xml = `...(QTI 2.x or 3.0)...`;
|
|
283
|
-
const {
|
|
284
|
+
const { version } = createQtiParser(xml);
|
|
285
|
+
|
|
286
|
+
const engine = new TransformEngine();
|
|
287
|
+
engine.use(new QtiToPiePlugin());
|
|
284
288
|
|
|
285
|
-
const
|
|
286
|
-
|
|
289
|
+
const handle = await engine.transform(xml, {
|
|
290
|
+
sourceFormat: version.startsWith('3') ? 'qti30' : 'qti22',
|
|
291
|
+
targetFormat: 'pie'
|
|
287
292
|
});
|
|
293
|
+
const result = await handle.result();
|
|
288
294
|
```
|
|
289
295
|
|
|
290
296
|
## Migration Guide
|
|
@@ -292,11 +298,13 @@ const pieItem = await transformQtiToPie(xml, {
|
|
|
292
298
|
### From QTI 2.x-only Code
|
|
293
299
|
|
|
294
300
|
**Before** (QTI 2.x only):
|
|
301
|
+
|
|
295
302
|
```typescript
|
|
296
303
|
const elements = doc.getElementsByTagName('choiceInteraction');
|
|
297
304
|
```
|
|
298
305
|
|
|
299
306
|
**After** (QTI 2.x + 3.0):
|
|
307
|
+
|
|
300
308
|
```typescript
|
|
301
309
|
import { createQtiParser } from '@pie-qti/qti-common';
|
|
302
310
|
|
|
@@ -306,6 +314,7 @@ const elements = doc.getElementsByTagName(tagName);
|
|
|
306
314
|
```
|
|
307
315
|
|
|
308
316
|
**Even Better** (using existing extraction layer):
|
|
317
|
+
|
|
309
318
|
```typescript
|
|
310
319
|
// No changes needed! Extraction layer already uses mappers internally
|
|
311
320
|
const player = new Player(xml); // Works with both QTI 2.x and 3.0
|
|
@@ -314,11 +323,13 @@ const player = new Player(xml); // Works with both QTI 2.x and 3.0
|
|
|
314
323
|
### Attribute Handling Migration
|
|
315
324
|
|
|
316
325
|
**Before** (QTI 2.x only):
|
|
326
|
+
|
|
317
327
|
```typescript
|
|
318
328
|
const baseType = element.getAttribute('baseType');
|
|
319
329
|
```
|
|
320
330
|
|
|
321
331
|
**After** (QTI 2.x + 3.0):
|
|
332
|
+
|
|
322
333
|
```typescript
|
|
323
334
|
import { getAttribute } from '@pie-qti/qti-common';
|
|
324
335
|
|
|
@@ -336,6 +347,7 @@ bun test --coverage
|
|
|
336
347
|
```
|
|
337
348
|
|
|
338
349
|
Test fixtures are available in `src/__tests__/fixtures/`:
|
|
350
|
+
|
|
339
351
|
- `qti3-choice-single.xml` — Single-selection choice
|
|
340
352
|
- `qti3-choice-multiple.xml` — Multiple-selection choice
|
|
341
353
|
- `qti3-match-interaction.xml` — Match interaction
|