@timeback/qti 0.1.2 → 0.1.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,570 @@
1
+ /**
2
+ * QTI Primitives
3
+ *
4
+ * Enums and literal types specific to the QTI protocol.
5
+ * For shared Timeback primitives (TimebackGrade, TimebackSubject), see `@timeback/types`.
6
+ */
7
+
8
+ /**
9
+ * Lesson types for PowerPath integration.
10
+ * Used to categorize assessment content by delivery mode.
11
+ */
12
+ type LessonType =
13
+ | 'powerpath-100'
14
+ | 'quiz'
15
+ | 'test-out'
16
+ | 'placement'
17
+ | 'unit-test'
18
+ | 'alpha-read-article'
19
+ | null
20
+
21
+ /**
22
+ * API Response Types
23
+ *
24
+ * Types for QTI API responses.
25
+ */
26
+
27
+ // ═══════════════════════════════════════════════════════════════════════════════
28
+ // LIST RESPONSE
29
+ // ═══════════════════════════════════════════════════════════════════════════════
30
+
31
+ /**
32
+ * Paginated list response from QTI API.
33
+ *
34
+ * QTI returns pagination metadata directly in the response body alongside items.
35
+ */
36
+ interface ListResponse<T> {
37
+ /** Array of items in this page */
38
+ items: T[]
39
+ /** Total items across all pages */
40
+ total: number
41
+ /** Current page number (1-indexed) */
42
+ page: number
43
+ /** Total number of pages */
44
+ pages: number
45
+ /** Items per page */
46
+ limit: number
47
+ /** Sort field */
48
+ sort: string
49
+ /** Sort order */
50
+ order: 'asc' | 'desc'
51
+ }
52
+
53
+ /**
54
+ * Raw paginated response shape from QTI API (alias for internal use).
55
+ */
56
+ type RawPaginatedResponse<T> = ListResponse<T>
57
+
58
+ // ═══════════════════════════════════════════════════════════════════════════════
59
+ // DELETE RESPONSE
60
+ // ═══════════════════════════════════════════════════════════════════════════════
61
+
62
+ /**
63
+ * Response from DELETE operations.
64
+ */
65
+ interface DeleteResponse {
66
+ message: string
67
+ }
68
+
69
+ /**
70
+ * Base Types
71
+ *
72
+ * Common types shared across QTI resources.
73
+ */
74
+
75
+ // ═══════════════════════════════════════════════════════════════════════════════
76
+ // ENUMS
77
+ // ═══════════════════════════════════════════════════════════════════════════════
78
+
79
+ /**
80
+ * Assessment item interaction types.
81
+ */
82
+ type AssessmentItemType =
83
+ | 'choice'
84
+ | 'text-entry'
85
+ | 'extended-text'
86
+ | 'inline-choice'
87
+ | 'match'
88
+ | 'order'
89
+ | 'associate'
90
+ | 'select-point'
91
+ | 'graphic-order'
92
+ | 'graphic-associate'
93
+ | 'graphic-gap-match'
94
+ | 'hotspot'
95
+ | 'hottext'
96
+ | 'slider'
97
+ | 'drawing'
98
+ | 'media'
99
+ | 'upload'
100
+
101
+ /**
102
+ * Cardinality of a response or outcome variable.
103
+ */
104
+ type Cardinality = 'single' | 'multiple' | 'ordered' | 'record'
105
+
106
+ /**
107
+ * Base type of a response or outcome variable.
108
+ */
109
+ type BaseType =
110
+ | 'identifier'
111
+ | 'boolean'
112
+ | 'integer'
113
+ | 'float'
114
+ | 'string'
115
+ | 'point'
116
+ | 'pair'
117
+ | 'directedPair'
118
+ | 'duration'
119
+ | 'file'
120
+ | 'uri'
121
+
122
+ /**
123
+ * Difficulty level for assessment items.
124
+ */
125
+ type Difficulty = 'easy' | 'medium' | 'hard'
126
+
127
+ /**
128
+ * Grade level (K-12 + pre-K as -1).
129
+ */
130
+ type Grade = -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
131
+
132
+ /**
133
+ * Navigation mode for test parts.
134
+ */
135
+ type NavigationMode = 'linear' | 'nonlinear'
136
+
137
+ /**
138
+ * Submission mode for test parts.
139
+ */
140
+ type SubmissionMode = 'individual' | 'simultaneous'
141
+
142
+ /**
143
+ * Show/hide indicator for feedback.
144
+ */
145
+ type ShowHide = 'show' | 'hide'
146
+
147
+ /**
148
+ * Schema type for validation.
149
+ */
150
+ type ValidationSchema = 'test' | 'item' | 'stimulus'
151
+
152
+ /**
153
+ * Sort order for list responses.
154
+ */
155
+ type SortOrder = 'asc' | 'desc'
156
+
157
+ /**
158
+ * Feedback type.
159
+ */
160
+ type FeedbackType = 'QUESTION' | 'LESSON'
161
+
162
+ // ═══════════════════════════════════════════════════════════════════════════════
163
+ // COMMON STRUCTURES
164
+ // ═══════════════════════════════════════════════════════════════════════════════
165
+
166
+ /**
167
+ * Correct response value.
168
+ */
169
+ interface CorrectResponse {
170
+ value: string[]
171
+ }
172
+
173
+ /**
174
+ * Response declaration for assessment items.
175
+ */
176
+ interface ResponseDeclaration {
177
+ identifier: string
178
+ cardinality: Cardinality
179
+ baseType?: BaseType
180
+ correctResponse: CorrectResponse
181
+ }
182
+
183
+ /**
184
+ * Outcome declaration for items and tests.
185
+ */
186
+ interface OutcomeDeclaration {
187
+ identifier: string
188
+ cardinality: Cardinality
189
+ baseType?: BaseType
190
+ }
191
+
192
+ /**
193
+ * Test outcome declaration with additional properties.
194
+ */
195
+ interface TestOutcomeDeclaration {
196
+ identifier: string
197
+ cardinality?: Cardinality
198
+ baseType: BaseType
199
+ normalMaximum?: number
200
+ normalMinimum?: number
201
+ defaultValue?: {
202
+ value?: unknown
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Inline feedback configuration.
208
+ */
209
+ interface InlineFeedback {
210
+ outcomeIdentifier: string
211
+ variableIdentifier: string
212
+ }
213
+
214
+ /**
215
+ * Response processing configuration.
216
+ */
217
+ interface ResponseProcessing {
218
+ templateType: 'match_correct' | 'map_response'
219
+ responseDeclarationIdentifier: string
220
+ outcomeIdentifier: string
221
+ correctResponseIdentifier: string
222
+ incorrectResponseIdentifier: string
223
+ inlineFeedback?: InlineFeedback
224
+ }
225
+
226
+ /**
227
+ * Learning objective set for metadata.
228
+ */
229
+ interface LearningObjectiveSet {
230
+ source: string
231
+ learningObjectiveIds: string[]
232
+ }
233
+
234
+ /**
235
+ * Item metadata.
236
+ */
237
+ interface ItemMetadata {
238
+ subject?: string
239
+ grade?: Grade
240
+ difficulty?: Difficulty
241
+ learningObjectiveSet?: LearningObjectiveSet[]
242
+ }
243
+
244
+ /**
245
+ * Modal feedback element.
246
+ */
247
+ interface ModalFeedback {
248
+ outcomeIdentifier: string
249
+ identifier: string
250
+ showHide: ShowHide
251
+ content: string
252
+ title: string
253
+ }
254
+
255
+ /**
256
+ * Inline feedback element.
257
+ */
258
+ interface FeedbackInline {
259
+ outcomeIdentifier: string
260
+ identifier: string
261
+ showHide: ShowHide
262
+ content: string
263
+ class: string[]
264
+ }
265
+
266
+ /**
267
+ * Block feedback element.
268
+ */
269
+ interface FeedbackBlock {
270
+ outcomeIdentifier: string
271
+ identifier: string
272
+ showHide: ShowHide
273
+ content: string
274
+ class: string[]
275
+ }
276
+
277
+ /**
278
+ * Stylesheet reference.
279
+ */
280
+ interface Stylesheet {
281
+ href: string
282
+ type: string
283
+ }
284
+
285
+ /**
286
+ * Catalog info entry.
287
+ */
288
+ interface CatalogInfo {
289
+ id: string
290
+ support: string
291
+ content: string
292
+ }
293
+
294
+ // ═══════════════════════════════════════════════════════════════════════════════
295
+ // PAGINATION
296
+ // ═══════════════════════════════════════════════════════════════════════════════
297
+
298
+ /**
299
+ * Pagination metadata from QTI list responses.
300
+ */
301
+ interface PaginationMeta {
302
+ /** Total items across all pages */
303
+ total: number
304
+ /** Current page number (1-indexed) */
305
+ page: number
306
+ /** Total number of pages */
307
+ pages: number
308
+ /** Items per page */
309
+ limit: number
310
+ /** Sort field */
311
+ sort: string
312
+ /** Sort order */
313
+ order: SortOrder
314
+ }
315
+
316
+ /**
317
+ * Assessment Items Types
318
+ *
319
+ * Types for QTI assessment item resources.
320
+ */
321
+
322
+
323
+
324
+ // ═══════════════════════════════════════════════════════════════════════════════
325
+ // ASSESSMENT ITEM
326
+ // ═══════════════════════════════════════════════════════════════════════════════
327
+
328
+ /**
329
+ * Assessment item entity.
330
+ */
331
+ interface AssessmentItem {
332
+ identifier: string
333
+ title: string
334
+ type: AssessmentItemType
335
+ qtiVersion: string
336
+ timeDependent: boolean
337
+ adaptive: boolean
338
+ responseDeclarations?: ResponseDeclaration[]
339
+ outcomeDeclarations?: OutcomeDeclaration[]
340
+ responseProcessing?: ResponseProcessing
341
+ metadata?: ItemMetadata
342
+ /** Raw QTI XML string */
343
+ rawXml: string
344
+ /**
345
+ * Parsed XML→JSON content.
346
+ * Structure varies by item type.
347
+ */
348
+ content: Record<string, unknown>
349
+ modalFeedback?: ModalFeedback[]
350
+ feedbackInline?: FeedbackInline[]
351
+ feedbackBlock?: FeedbackBlock[]
352
+ createdAt: string
353
+ updatedAt: string
354
+ __v?: number
355
+ }
356
+
357
+ /**
358
+ * Result of processing a response.
359
+ */
360
+ interface ProcessResponseResult {
361
+ score: number
362
+ feedback: {
363
+ identifier: string
364
+ value: string
365
+ }
366
+ }
367
+
368
+ // ═══════════════════════════════════════════════════════════════════════════════
369
+ // SECTION ITEM REFERENCE
370
+ // ═══════════════════════════════════════════════════════════════════════════════
371
+
372
+ /**
373
+ * Reference to an assessment item within a section.
374
+ */
375
+ interface AssessmentItemRef {
376
+ identifier: string
377
+ /**
378
+ * Item reference href.
379
+ *
380
+ * The QTI docs show this field as `string` in most responses, but it can also
381
+ * appear as an array (and in one place, a nested array) in request/response
382
+ * examples for test-part payloads.
383
+ */
384
+ href?: string | string[] | string[][]
385
+ sequence?: number
386
+ }
387
+
388
+ // ═══════════════════════════════════════════════════════════════════════════════
389
+ // SECTION
390
+ // ═══════════════════════════════════════════════════════════════════════════════
391
+
392
+ /**
393
+ * Assessment section within a test part.
394
+ */
395
+ interface AssessmentSection {
396
+ identifier: string
397
+ title: string
398
+ visible: boolean
399
+ required?: boolean
400
+ fixed?: boolean
401
+ sequence?: number
402
+ 'qti-assessment-item-ref'?: AssessmentItemRef[]
403
+ }
404
+
405
+ // ═══════════════════════════════════════════════════════════════════════════════
406
+ // TEST PART
407
+ // ═══════════════════════════════════════════════════════════════════════════════
408
+
409
+ /**
410
+ * Test part within an assessment test.
411
+ */
412
+ interface TestPart {
413
+ identifier: string
414
+ navigationMode: NavigationMode
415
+ submissionMode: SubmissionMode
416
+ 'qti-assessment-section': AssessmentSection | AssessmentSection[]
417
+ }
418
+
419
+ // ═══════════════════════════════════════════════════════════════════════════════
420
+ // ASSESSMENT TEST
421
+ // ═══════════════════════════════════════════════════════════════════════════════
422
+
423
+ /**
424
+ * Assessment test entity.
425
+ */
426
+ interface AssessmentTest {
427
+ identifier: string
428
+ title: string
429
+ qtiVersion: string
430
+ 'qti-test-part': TestPart[]
431
+ 'qti-outcome-declaration': TestOutcomeDeclaration[]
432
+ timeLimit?: number
433
+ maxAttempts?: number
434
+ toolsEnabled?: Record<string, boolean>
435
+ metadata?: Record<string, unknown>
436
+ /** Raw QTI XML string */
437
+ rawXml: string
438
+ /**
439
+ * Parsed XML→JSON content.
440
+ * Structure varies by test.
441
+ */
442
+ content: Record<string, unknown>
443
+ createdAt: string
444
+ updatedAt: string
445
+ __v?: number
446
+ isValidXml?: boolean
447
+ }
448
+
449
+ // ═══════════════════════════════════════════════════════════════════════════════
450
+ // QUESTIONS RESPONSE
451
+ // ═══════════════════════════════════════════════════════════════════════════════
452
+
453
+ /**
454
+ * Question reference within a test.
455
+ */
456
+ interface QuestionReference {
457
+ identifier: string
458
+ href: string
459
+ testPart: string
460
+ section: string
461
+ }
462
+
463
+ /**
464
+ * Question with full item details.
465
+ */
466
+ interface QuestionWithItem {
467
+ reference: QuestionReference
468
+ question: AssessmentItem
469
+ }
470
+
471
+ /**
472
+ * Response from GET /assessment-tests/{identifier}/questions.
473
+ */
474
+ interface QuestionsResponse {
475
+ assessmentTest: string
476
+ title: string
477
+ totalQuestions: number
478
+ questions: QuestionWithItem[]
479
+ }
480
+
481
+ /**
482
+ * Lesson Types
483
+ *
484
+ * Types for QTI lesson and question feedback resources.
485
+ */
486
+
487
+
488
+
489
+ // ═══════════════════════════════════════════════════════════════════════════════
490
+ // LESSON FEEDBACK
491
+ // ═══════════════════════════════════════════════════════════════════════════════
492
+
493
+ /**
494
+ * Lesson feedback entity.
495
+ */
496
+ interface LessonFeedback {
497
+ questionId?: string
498
+ userId: string
499
+ feedback: string
500
+ type: FeedbackType
501
+ lessonId: string
502
+ humanApproved?: boolean | boolean[]
503
+ }
504
+
505
+ /**
506
+ * Stimuli Types
507
+ *
508
+ * Types for QTI stimulus resources.
509
+ */
510
+
511
+
512
+
513
+ // ═══════════════════════════════════════════════════════════════════════════════
514
+ // STIMULUS
515
+ // ═══════════════════════════════════════════════════════════════════════════════
516
+
517
+ /**
518
+ * Stimulus entity.
519
+ */
520
+ interface Stimulus {
521
+ identifier: string
522
+ title: string
523
+ label?: string
524
+ language?: string
525
+ stylesheet?: Stylesheet
526
+ catalogInfo: CatalogInfo[]
527
+ toolName?: string
528
+ toolVersion?: string
529
+ metadata?: Record<string, unknown>
530
+ /** Raw QTI XML string */
531
+ rawXml: string
532
+ /**
533
+ * Parsed XML→JSON content.
534
+ * Structure varies.
535
+ */
536
+ content: Record<string, unknown>
537
+ createdAt: string
538
+ updatedAt: string
539
+ __v?: number
540
+ }
541
+
542
+ /**
543
+ * Validation Types
544
+ *
545
+ * Types for QTI XML validation resources.
546
+ */
547
+
548
+ // ═══════════════════════════════════════════════════════════════════════════════
549
+ // VALIDATION
550
+ // ═══════════════════════════════════════════════════════════════════════════════
551
+
552
+ /**
553
+ * Single validation result.
554
+ */
555
+ interface ValidationResult {
556
+ success: boolean
557
+ entityId: string
558
+ xmlContent: string
559
+ validationErrors: string[]
560
+ message: string
561
+ }
562
+
563
+ /**
564
+ * Batch validation result.
565
+ */
566
+ interface BatchValidationResult {
567
+ results: ValidationResult[]
568
+ }
569
+
570
+ export type { AssessmentItem, AssessmentItemRef, AssessmentItemType, AssessmentSection, AssessmentTest, BaseType, BatchValidationResult, Cardinality, CatalogInfo, CorrectResponse, DeleteResponse, Difficulty, FeedbackBlock, FeedbackInline, FeedbackType, Grade, InlineFeedback, ItemMetadata, LearningObjectiveSet, LessonFeedback, LessonType, ListResponse, ModalFeedback, NavigationMode, OutcomeDeclaration, PaginationMeta, ProcessResponseResult, QuestionReference, QuestionWithItem, QuestionsResponse, RawPaginatedResponse, ResponseDeclaration, ResponseProcessing, ShowHide, SortOrder, Stimulus, Stylesheet, SubmissionMode, TestOutcomeDeclaration, TestPart, ValidationResult, ValidationSchema };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-types.d.ts","sourceRoot":"","sources":["../src/public-types.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timeback/qti",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -12,8 +12,8 @@
12
12
  "import": "./dist/errors.js"
13
13
  },
14
14
  "./types": {
15
- "types": "./dist/types.d.ts",
16
- "import": "./dist/types.js"
15
+ "types": "./dist/public-types.d.ts",
16
+ "import": "./dist/public-types.js"
17
17
  }
18
18
  },
19
19
  "main": "dist/index.js",
@@ -35,7 +35,8 @@
35
35
  "@timeback/internal-test": "0.0.0",
36
36
  "@timeback/internal-utils": "0.0.0",
37
37
  "@timeback/types": "0.0.0",
38
- "@types/bun": "latest"
38
+ "@types/bun": "latest",
39
+ "esbuild": "^0.27.3"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "typescript": "^5"
File without changes