@qti-components/test 2.0.0-next.23 → 2.0.0-next.24
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/dist/components/test-navigation/test-navigation.js +36 -265
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/internal/derive-computed-context.d.ts +86 -0
- package/dist/internal/derive-computed-context.js +213 -0
- package/dist/internal/derive-computed-context.js.map +1 -0
- package/package.json +2 -2
|
@@ -8,11 +8,12 @@ import { ContextConsumer, consume, provide } from '@lit/context';
|
|
|
8
8
|
import { html, LitElement } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import { computedContext } from '@qti-components/base';
|
|
11
|
-
import { buildTestModel
|
|
11
|
+
import { buildTestModel } from '@qti-components/delivery';
|
|
12
12
|
import { configContext } from '@qti-components/base';
|
|
13
13
|
import { testContext } from '@qti-components/base';
|
|
14
14
|
import { sessionContext } from '@qti-components/base';
|
|
15
15
|
import { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';
|
|
16
|
+
import { assessOptimality, deriveComputedContext, isItemDone } from '../../internal/derive-computed-context';
|
|
16
17
|
import { itemFactsContext } from '../../internal/item-facts.context';
|
|
17
18
|
import { renderedMarkup } from '../../internal/rendered-markup';
|
|
18
19
|
import { testHostContext } from '../../internal/test-host.context';
|
|
@@ -98,13 +99,6 @@ export class TestNavigation extends LitElement {
|
|
|
98
99
|
this.#optimality = new Map();
|
|
99
100
|
/** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
|
|
100
101
|
this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
|
|
101
|
-
/**
|
|
102
|
-
* The item-refs of each section, its subsections' included, by section identifier: a section that
|
|
103
|
-
* only holds subsections is completed when theirs are.
|
|
104
|
-
*/
|
|
105
|
-
this.#sectionItems = new Map();
|
|
106
|
-
/** Every item-ref of the test in document order, which item numbers follow. */
|
|
107
|
-
this.#itemOrder = [];
|
|
108
102
|
/** The items this navigation disabled because their attempts are used, so it releases only those. */
|
|
109
103
|
this.#lockedItems = new WeakSet();
|
|
110
104
|
listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));
|
|
@@ -126,12 +120,12 @@ export class TestNavigation extends LitElement {
|
|
|
126
120
|
const itemContext = event.detail.itemContext;
|
|
127
121
|
if (!itemContext?.identifier)
|
|
128
122
|
return;
|
|
129
|
-
const optimality =
|
|
123
|
+
const optimality = assessOptimality(itemContext);
|
|
130
124
|
this.#optimality.set(itemContext.identifier, optimality);
|
|
131
125
|
const computedItem = this.computedItemFor(itemContext.identifier);
|
|
132
126
|
const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;
|
|
133
127
|
const completionStatus = itemContext.variables?.find(v => v.identifier === 'completionStatus')?.value;
|
|
134
|
-
this.afterAttemptEnded(event.composedPath()[0]?.closest('qti-assessment-item'), computedItem,
|
|
128
|
+
this.afterAttemptEnded(event.composedPath()[0]?.closest('qti-assessment-item'), computedItem, isItemDone(numAttempts, optimality, computedItem?.sessionControl?.maxAttempts, computedItem?.adaptive, completionStatus));
|
|
135
129
|
}
|
|
136
130
|
/**
|
|
137
131
|
* Extension point for presentation packages reacting to an ended attempt.
|
|
@@ -235,57 +229,38 @@ export class TestNavigation extends LitElement {
|
|
|
235
229
|
});
|
|
236
230
|
// The structure and the session-control cascade come from the test's markup, not from upgraded
|
|
237
231
|
// properties, so they do not depend on registration or render timing.
|
|
238
|
-
|
|
239
|
-
this
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// document order; `index` is.
|
|
257
|
-
sections: sectionsInOrder(testPart.sections).map(section => ({
|
|
258
|
-
active: false,
|
|
259
|
-
identifier: section.identifier,
|
|
260
|
-
title: section.title,
|
|
261
|
-
allowSkipping: section.sessionControl.allowSkipping,
|
|
262
|
-
items: ownItemRefs(section).map(item => ({
|
|
263
|
-
...this.initContext?.find(i => i.identifier === item.identifier),
|
|
264
|
-
active: false,
|
|
265
|
-
identifier: item.identifier,
|
|
266
|
-
categories: item.categories,
|
|
267
|
-
href: item.href,
|
|
268
|
-
variables: [],
|
|
269
|
-
sessionControl: { ...item.sessionControl }
|
|
270
|
-
}))
|
|
271
|
-
}))
|
|
272
|
-
}))
|
|
273
|
-
};
|
|
232
|
+
this.#model = buildTestModel(renderedMarkup(this.#testElement));
|
|
233
|
+
this.computedContext = this.#derive();
|
|
234
|
+
}
|
|
235
|
+
/** The test's structure and resolved session control, read from its markup when it is connected. */
|
|
236
|
+
#model;
|
|
237
|
+
/** `computedContext`, derived anew from its inputs (`deriveComputedContext`), never from the previous one. */
|
|
238
|
+
#derive() {
|
|
239
|
+
this.#seedOptimality();
|
|
240
|
+
return deriveComputedContext({
|
|
241
|
+
model: this.#model,
|
|
242
|
+
itemFacts: this._itemFacts,
|
|
243
|
+
testContext: this._testContext,
|
|
244
|
+
sessionContext: this._sessionContext,
|
|
245
|
+
infoItemCategory: this.configContext?.infoItemCategory,
|
|
246
|
+
itemData: this.initContext,
|
|
247
|
+
optimality: this.#optimality,
|
|
248
|
+
itemElement: this.#itemElement
|
|
249
|
+
});
|
|
274
250
|
}
|
|
275
251
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
252
|
+
* On a restored session no attempt is ended this run, so the latch is seeded once from the
|
|
253
|
+
* persisted context, which still holds the submitted response. A later change of the answer
|
|
254
|
+
* leaves the seeded value alone.
|
|
278
255
|
*/
|
|
279
|
-
#
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
item.categories.includes(this.configContext?.infoItemCategory) ? null : index++
|
|
288
|
-
]));
|
|
256
|
+
#seedOptimality() {
|
|
257
|
+
for (const itemContext of this._testContext?.items ?? []) {
|
|
258
|
+
if (!itemContext.identifier || this.#optimality.has(itemContext.identifier))
|
|
259
|
+
continue;
|
|
260
|
+
const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;
|
|
261
|
+
if (numAttempts > 0)
|
|
262
|
+
this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));
|
|
263
|
+
}
|
|
289
264
|
}
|
|
290
265
|
/**
|
|
291
266
|
* Extract default values from a qti-context-declaration element
|
|
@@ -325,131 +300,11 @@ export class TestNavigation extends LitElement {
|
|
|
325
300
|
});
|
|
326
301
|
return defaultValues;
|
|
327
302
|
}
|
|
328
|
-
|
|
329
|
-
#factsFor(identifier) {
|
|
330
|
-
const facts = this._itemFacts?.get(identifier);
|
|
331
|
-
if (!facts)
|
|
332
|
-
return {};
|
|
333
|
-
const { identifier: assessmentItemIdentifier, ...rest } = facts;
|
|
334
|
-
return { ...rest, assessmentItemIdentifier };
|
|
335
|
-
}
|
|
336
|
-
/* PK: on every change of the candidate we will recomputed the computedContext */
|
|
303
|
+
/* On every change of the candidate's state, the context is derived again. */
|
|
337
304
|
willUpdate(_changedProperties) {
|
|
338
|
-
if (!this
|
|
305
|
+
if (!this.#model)
|
|
339
306
|
return;
|
|
340
|
-
|
|
341
|
-
this.computedContext = {
|
|
342
|
-
...this.computedContext,
|
|
343
|
-
view: this._sessionContext?.view,
|
|
344
|
-
plugins: this._sessionContext?.plugins ?? {},
|
|
345
|
-
testParts: this.computedContext.testParts.map(testPart => {
|
|
346
|
-
return {
|
|
347
|
-
...testPart,
|
|
348
|
-
active: this._sessionContext?.navPartId === testPart.identifier || false,
|
|
349
|
-
sections: testPart.sections.map(section => {
|
|
350
|
-
return {
|
|
351
|
-
...section,
|
|
352
|
-
active: this._sessionContext?.navSectionId === section.identifier || false,
|
|
353
|
-
completed: (this.#sectionItems.get(section.identifier) ?? section.items.map(i => i.identifier)).every(identifier => this._testContext.items
|
|
354
|
-
.find(i => i.identifier === identifier)
|
|
355
|
-
?.variables.find(v => v.identifier === 'completionStatus')?.value === 'completed'),
|
|
356
|
-
items: section.items.map(item => {
|
|
357
|
-
const itemContext = this._testContext?.items.find(i => i.identifier === item.identifier);
|
|
358
|
-
const computedItem = {
|
|
359
|
-
...item,
|
|
360
|
-
...this.#factsFor(item.identifier),
|
|
361
|
-
...itemContext,
|
|
362
|
-
...this.initContext?.find(i => i.identifier === item.identifier)
|
|
363
|
-
};
|
|
364
|
-
const rawscore = computedItem.variables?.find(vr => vr.identifier == 'SCORE')?.value;
|
|
365
|
-
const score = rawscore === undefined || rawscore === null ? null : parseFloat(rawscore?.toString());
|
|
366
|
-
const completionStatus = computedItem.variables?.find(v => v.identifier === 'completionStatus')
|
|
367
|
-
?.value;
|
|
368
|
-
const response = computedItem.variables?.find(v => v.identifier === 'RESPONSE')?.value || '';
|
|
369
|
-
const numAttempts = Number(computedItem.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;
|
|
370
|
-
const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
|
|
371
|
-
// Published by the item. One that is not on screen has nothing to be invalid.
|
|
372
|
-
const valid = itemContext?.valid ?? true;
|
|
373
|
-
const responseVars = itemContext?.variables?.filter(v => v.type === 'response' && v.identifier !== 'numAttempts') || [];
|
|
374
|
-
const isDefaultResponse = responseVars.every(v => {
|
|
375
|
-
if (v.value === undefined || v.value === null) {
|
|
376
|
-
return true;
|
|
377
|
-
}
|
|
378
|
-
let fallbackValue;
|
|
379
|
-
switch (v.baseType) {
|
|
380
|
-
case 'integer':
|
|
381
|
-
case 'float':
|
|
382
|
-
case 'duration':
|
|
383
|
-
fallbackValue = '0';
|
|
384
|
-
break;
|
|
385
|
-
case 'boolean':
|
|
386
|
-
fallbackValue = 'false';
|
|
387
|
-
break;
|
|
388
|
-
case 'string':
|
|
389
|
-
case 'directedPair':
|
|
390
|
-
case 'identifier':
|
|
391
|
-
case 'pair':
|
|
392
|
-
case 'record':
|
|
393
|
-
default:
|
|
394
|
-
fallbackValue = '';
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
const defaultValue = v.defaultValue ?? fallbackValue;
|
|
398
|
-
if (Array.isArray(v.value)) {
|
|
399
|
-
const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
400
|
-
return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
|
|
401
|
-
}
|
|
402
|
-
return v.value === defaultValue;
|
|
403
|
-
});
|
|
404
|
-
// Computed and opiniated
|
|
405
|
-
// const type = item.categories.includes(this.configContext?.infoItemCategory) ? 'info' : 'regular';
|
|
406
|
-
// const correct = (type == 'regular' && score !== undefined && !isNaN(score) && score > 0) || false;
|
|
407
|
-
// const incorrect = (type == 'regular' && score !== undefined && !isNaN(score) && score <= 0) || false;
|
|
408
|
-
// const completed = completionStatus === 'completed';
|
|
409
|
-
const index = itemIndexes.get(item.identifier) ?? null;
|
|
410
|
-
const rawMaxScore = item.variables?.find(vr => vr.identifier == 'MAXSCORE')?.value;
|
|
411
|
-
const maxScore = rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
|
|
412
|
-
// Optimality comes from the last *ended attempt* (#optimality),
|
|
413
|
-
// latched in #handleItemContextUpdated — never from a live
|
|
414
|
-
// mid-attempt selection. On a restored session no attempt is ended
|
|
415
|
-
// this run, so seed it once from the persisted context, which still
|
|
416
|
-
// holds the submitted response.
|
|
417
|
-
let optimality = this.#optimality.get(computedItem.identifier);
|
|
418
|
-
if (optimality === undefined) {
|
|
419
|
-
optimality = itemContext ? this.#assessOptimality(itemContext) : 'unscored';
|
|
420
|
-
if (numAttempts > 0)
|
|
421
|
-
this.#optimality.set(computedItem.identifier, optimality);
|
|
422
|
-
}
|
|
423
|
-
const done = this.#isItemDone(numAttempts, optimality, computedItem.sessionControl?.maxAttempts, computedItem.adaptive, completionStatus);
|
|
424
|
-
return {
|
|
425
|
-
...computedItem,
|
|
426
|
-
completionStatus,
|
|
427
|
-
numAttempts,
|
|
428
|
-
score,
|
|
429
|
-
response,
|
|
430
|
-
index,
|
|
431
|
-
active,
|
|
432
|
-
valid,
|
|
433
|
-
isDefaultResponse,
|
|
434
|
-
maxScore,
|
|
435
|
-
done,
|
|
436
|
-
// Reflects the last *ended* attempt only. Read the latch directly
|
|
437
|
-
// (not the `optimality` local) — the latch is written solely on
|
|
438
|
-
// responseProcessed / restore-seed (line above, guarded by
|
|
439
|
-
// numAttempts > 0), so a freshly-picked mid-attempt selection
|
|
440
|
-
// computed live is never stored and never counts as optimal.
|
|
441
|
-
optimal: this.#optimality.get(computedItem.identifier) === 'optimal'
|
|
442
|
-
// type,
|
|
443
|
-
// correct,
|
|
444
|
-
// incorrect,
|
|
445
|
-
// completed
|
|
446
|
-
};
|
|
447
|
-
})
|
|
448
|
-
};
|
|
449
|
-
})
|
|
450
|
-
};
|
|
451
|
-
})
|
|
452
|
-
};
|
|
307
|
+
this.computedContext = this.#derive();
|
|
453
308
|
this.dispatchEvent(new CustomEvent('qti-computed-context-updated', {
|
|
454
309
|
detail: this.computedContext,
|
|
455
310
|
bubbles: true
|
|
@@ -507,90 +362,6 @@ export class TestNavigation extends LitElement {
|
|
|
507
362
|
const maxAttempts = item.sessionControl?.maxAttempts ?? 1;
|
|
508
363
|
return maxAttempts > 0 && (item.numAttempts ?? 0) >= maxAttempts;
|
|
509
364
|
}
|
|
510
|
-
/**
|
|
511
|
-
* Decide whether an item should be treated as "the candidate is done with it"
|
|
512
|
-
* for the purpose of gating forward navigation and further attempts.
|
|
513
|
-
*
|
|
514
|
-
* - The candidate must have actually ended an attempt (numAttempts > 0).
|
|
515
|
-
* - Once attempted, the item is done if they reached the optimal outcome
|
|
516
|
-
* ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
|
|
517
|
-
* done while a better attempt is still possible ('suboptimal') and attempts
|
|
518
|
-
* remain — see #assessOptimality for how "optimal" is determined.
|
|
519
|
-
*
|
|
520
|
-
* `optimality` reflects the last *ended attempt* (see #optimality), not the
|
|
521
|
-
* live selection — so a freshly-picked optimal answer doesn't count as done
|
|
522
|
-
* until test-end-attempt evaluates it.
|
|
523
|
-
*
|
|
524
|
-
* Adaptive items decide this themselves: max-attempts does not apply to them
|
|
525
|
-
* (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads
|
|
526
|
-
* on to the next part of the item. They are done once their response
|
|
527
|
-
* processing sets completionStatus to 'completed'.
|
|
528
|
-
*/
|
|
529
|
-
#isItemDone(numAttempts, optimality, maxAttempts, adaptive, completionStatus) {
|
|
530
|
-
if (numAttempts === 0)
|
|
531
|
-
return false;
|
|
532
|
-
if (adaptive)
|
|
533
|
-
return completionStatus === 'completed';
|
|
534
|
-
if (optimality !== 'suboptimal')
|
|
535
|
-
return true;
|
|
536
|
-
const max = maxAttempts ?? 1;
|
|
537
|
-
return max > 0 && numAttempts >= max;
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Decide whether an item's submission is as good as it can get — i.e. the
|
|
541
|
-
* candidate reached the *optimal* outcome, so there's no reason to make them
|
|
542
|
-
* try again. 'optimal' means best achievable, 'suboptimal' means a better
|
|
543
|
-
* attempt is still possible, 'unscored' means there's nothing to judge against.
|
|
544
|
-
* ("optimal" is the spec's own word — a qti-correct-response is defined as
|
|
545
|
-
* "the (or an) optimal value".)
|
|
546
|
-
*
|
|
547
|
-
* Two signals, in order of authority:
|
|
548
|
-
* 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).
|
|
549
|
-
* This correctly handles partial-credit / qti-mapping items, where an exact
|
|
550
|
-
* response match would under- or over-judge.
|
|
551
|
-
* 2. The declared qti-correct-response, for items that aren't scored (no
|
|
552
|
-
* SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping
|
|
553
|
-
* variables like numAttempts can be typed 'response' but never declare a
|
|
554
|
-
* correctResponse, so we filter on a declared correctResponse.
|
|
555
|
-
*
|
|
556
|
-
* Items with neither a comparable score nor a correctResponse (essays, info
|
|
557
|
-
* items, etc.) are 'unscored' — there's no optimal value to require, so one
|
|
558
|
-
* attempt is enough.
|
|
559
|
-
*/
|
|
560
|
-
#assessOptimality(item) {
|
|
561
|
-
const variables = item.variables ?? [];
|
|
562
|
-
const score = this.#numericVariable(variables, 'SCORE');
|
|
563
|
-
const maxScore = this.#numericVariable(variables, 'MAXSCORE');
|
|
564
|
-
if (score !== null && maxScore !== null) {
|
|
565
|
-
return score >= maxScore ? 'optimal' : 'suboptimal';
|
|
566
|
-
}
|
|
567
|
-
const responseVars = variables.filter((v) => v.type === 'response' &&
|
|
568
|
-
v.correctResponse !== undefined &&
|
|
569
|
-
v.correctResponse !== null);
|
|
570
|
-
if (responseVars.length === 0)
|
|
571
|
-
return 'unscored';
|
|
572
|
-
const allMatch = responseVars.every(v => {
|
|
573
|
-
const expected = v.correctResponse;
|
|
574
|
-
const actual = v.value;
|
|
575
|
-
if (actual === undefined || actual === null)
|
|
576
|
-
return false;
|
|
577
|
-
if (Array.isArray(expected) && Array.isArray(actual)) {
|
|
578
|
-
return expected.length === actual.length && expected.every(e => actual.includes(e));
|
|
579
|
-
}
|
|
580
|
-
if (Array.isArray(expected) || Array.isArray(actual))
|
|
581
|
-
return false;
|
|
582
|
-
return expected === actual;
|
|
583
|
-
});
|
|
584
|
-
return allMatch ? 'optimal' : 'suboptimal';
|
|
585
|
-
}
|
|
586
|
-
/** Read a single numeric outcome value, or null when absent / non-numeric. */
|
|
587
|
-
#numericVariable(variables, identifier) {
|
|
588
|
-
const raw = variables?.find(v => v.identifier === identifier)?.value;
|
|
589
|
-
if (raw === undefined || raw === null || Array.isArray(raw))
|
|
590
|
-
return null;
|
|
591
|
-
const parsed = parseFloat(raw.toString());
|
|
592
|
-
return Number.isNaN(parsed) ? null : parsed;
|
|
593
|
-
}
|
|
594
365
|
}
|
|
595
366
|
__decorate([
|
|
596
367
|
property({ type: String })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-navigation.js","s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AAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oDACd;AAI3B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACX;AAKjC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDAClB;AAI5B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;uDACK;AAEiB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;sDAAwB","sourcesContent":["import { ContextConsumer, consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\nimport { buildTestModel, itemRefsInOrder, ownItemRefs, sectionsInOrder } from '@qti-components/delivery';\nimport { configContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\nimport { sessionContext } from '@qti-components/base';\nimport { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';\n\nimport { itemFactsContext } from '../../internal/item-facts.context';\nimport { renderedMarkup } from '../../internal/rendered-markup';\nimport { testHostContext } from '../../internal/test-host.context';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiContext } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { ItemFacts, ItemRefModel } from '@qti-components/delivery';\nimport type { ItemFactsByRef } from '../../internal/item-facts.context';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\nimport type { ResponseVariable } from '@qti-components/base';\n\n/**\n * Whether an item's ended attempt reached the best achievable outcome:\n * 'optimal' (nothing to improve), 'suboptimal' (a better attempt is possible),\n * or 'unscored' (no machine-judgeable optimal value — see #assessOptimality).\n */\ntype ItemOptimality = 'optimal' | 'suboptimal' | 'unscored';\n\n/** A new object each time: a host that mutates the one it read must not change anyone else's. */\nconst newQtiContext = (): QtiContext => ({\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n});\n\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier: string | undefined = undefined;\n\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n /**\n * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the\n * enclosing test's: reading returns it, writing replaces it, so a host that has always set the\n * shuffle seed here keeps working. Removed in the next major.\n *\n * Written before the navigation is inside a test, it waits and is handed over on connect.\n */\n public get qtiContext(): QtiContext {\n return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());\n }\n\n public set qtiContext(value: QtiContext) {\n if (!this.#warnedQtiContext) {\n this.#warnedQtiContext = true;\n console.warn(\n '[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major ' +\n 'release. Set `qtiContext` on `<qti-test>` instead; it is the same value.'\n );\n }\n this.#writeQtiContext(value);\n }\n\n #pendingQtiContext?: QtiContext;\n #warnedQtiContext = false;\n\n /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */\n #writeQtiContext(value: QtiContext): void {\n const owner = this.#owner();\n if (owner) owner.qtiContext = value;\n else this.#pendingQtiContext = value;\n }\n\n /**\n * The `qti-test` this navigation is in, found through context so it works across shadow roots.\n * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.\n */\n #testHost = new ContextConsumer(this, {\n context: testHostContext,\n subscribe: true,\n callback: host => {\n if (host && this.#pendingQtiContext) {\n host.qtiContext = this.#pendingQtiContext;\n this.#pendingQtiContext = undefined;\n }\n }\n });\n\n #owner(): { qtiContext: QtiContext } | null {\n return this.#testHost.value ?? null;\n }\n\n @state()\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n /** Read from each item's XML when `qti-test` fetches it; see `itemFactsContext`. */\n @state()\n @consume({ context: itemFactsContext, subscribe: true })\n protected _itemFacts?: ItemFactsByRef;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n #testElement: QtiAssessmentTest;\n\n /**\n * Whether each item's last *ended attempt* reached the optimal outcome, keyed\n * by item-ref id. Written from #handleItemContextUpdated when processResponse\n * ends an attempt — never on a plain selection. Mirrors how inline feedback\n * only re-evaluates when an attempt is processed, so a freshly-picked answer\n * doesn't flip `done` until the candidate ends the attempt.\n */\n #optimality = new Map<string, ItemOptimality>();\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));\n\n listenItemPublic(this, 'qc-item-response-changed', this.#handleInteractionChanged.bind(this));\n this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));\n\n listenPublic(this, 'qc-test-end-attempt', this.#handleTestEndAttempt.bind(this));\n listenPublic(this, 'qc-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));\n }\n\n /**\n * Latch whether an item reached its optimal outcome whenever it has just ended\n * an attempt. processResponse — fired by test-end-attempt, autoscore, or an\n * in-item end-attempt interaction — flags its context update with\n * `responseProcessed`; a plain selection updates the context without it, so\n * `done` can't flip until the candidate actually ends the attempt.\n */\n #handleItemContextUpdated(event: CustomEvent<{ itemContext: ItemContext; responseProcessed?: boolean }>) {\n if (!event.detail?.responseProcessed) return;\n const itemContext = event.detail.itemContext;\n if (!itemContext?.identifier) return;\n const optimality = this.#assessOptimality(itemContext);\n this.#optimality.set(itemContext.identifier, optimality);\n\n const computedItem = this.computedItemFor(itemContext.identifier);\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n const completionStatus = itemContext.variables?.find(v => v.identifier === 'completionStatus')?.value as string;\n this.afterAttemptEnded(\n (event.composedPath()[0] as HTMLElement)?.closest<QtiAssessmentItem>('qti-assessment-item'),\n computedItem,\n this.#isItemDone(\n numAttempts,\n optimality,\n computedItem?.sessionControl?.maxAttempts,\n computedItem?.adaptive,\n completionStatus\n )\n );\n }\n\n /**\n * Extension point for presentation packages reacting to an ended attempt.\n * `done` is settled here — from the freshly latched optimality and the\n * session-control cascade — because the computed context only catches up on\n * the next update, after this event has finished bubbling.\n */\n protected afterAttemptEnded(\n _assessmentItem: QtiAssessmentItem | undefined,\n _computedItem: ComputedItem | undefined,\n _done: boolean\n ): void {}\n\n /** The computed-context entry for an item, from the session-control cascade. */\n protected computedItemFor(identifier: string): ComputedItem | undefined {\n return this.computedContext?.testParts\n ?.flatMap(part => part.sections)\n .flatMap(section => section.items)\n .find(i => i.identifier === identifier);\n }\n\n /** The assessment item for an item-ref id, if it has been rendered. */\n #assessmentItemFor(identifier: string | undefined): QtiAssessmentItem | undefined {\n if (!identifier) return undefined;\n const itemRef = this.#testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(identifier)}\"]`\n );\n return itemRef?.assessmentItem ?? undefined;\n }\n\n /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */\n #itemElement = (identifier: string): HTMLElement | null => this.#assessmentItemFor(identifier) ?? null;\n\n /** The currently active assessment item, exposed for optional presentation extensions. */\n protected get activeAssessmentItem(): QtiAssessmentItem | undefined {\n if (!this.#testElement || !this._sessionContext?.navItemRefId) return undefined;\n return this.#testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n )?.assessmentItem;\n }\n\n /**\n * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or\n * given an `item`), or else the item on screen.\n */\n #handleTestEndAttempt(event: CustomEvent<{ itemId?: string } | undefined>) {\n const itemId = event.detail?.itemId;\n const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;\n if (!qtiAssessmentItemEl) return;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n #handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);\n if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n #handleInteractionChanged(_event: CustomEvent) {\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest<QtiAssessmentItem>(\n 'qti-assessment-item'\n );\n // Autoscoring resolves the item from the event's own path, so a change\n // raised outside an assessment item has nothing to score.\n if (!assessmentItem) return;\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n #handleTestConnected(event: CustomEvent) {\n this.#testElement = event.detail as QtiAssessmentTest;\n // A fresh test invalidates the per-test optimality latches.\n this.#optimality.clear();\n // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this.#testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n });\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this.#extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n });\n }\n });\n\n // The structure and the session-control cascade come from the test's markup, not from upgraded\n // properties, so they do not depend on registration or render timing.\n const model = buildTestModel(renderedMarkup(this.#testElement));\n this.#sectionItems = new Map(\n model.testParts.flatMap(part =>\n sectionsInOrder(part.sections).map(\n section => [section.identifier, itemRefsInOrder(section.content).map(item => item.identifier)] as const\n )\n )\n );\n this.#itemOrder = model.testParts.flatMap(part => itemRefsInOrder(part.sections));\n this.computedContext = {\n itemElement: this.#itemElement,\n identifier: model.identifier,\n title: model.title,\n view: this._sessionContext?.view,\n plugins: this._sessionContext?.plugins ?? {},\n testParts: model.testParts.map(testPart => ({\n active: false,\n identifier: testPart.identifier,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n allowSkipping: testPart.sessionControl.allowSkipping,\n itemOrder: itemRefsInOrder(testPart.sections).map(item => item.identifier),\n // Flat, depth first: every section once, each with only its own item-refs, so every item is\n // listed once. Where a section's item-refs and subsections interleave, this list is not in\n // document order; `index` is.\n sections: sectionsInOrder(testPart.sections).map(section => ({\n active: false,\n identifier: section.identifier,\n title: section.title,\n allowSkipping: section.sessionControl.allowSkipping,\n items: ownItemRefs(section).map(item => ({\n ...this.initContext?.find(i => i.identifier === item.identifier),\n active: false,\n identifier: item.identifier,\n categories: item.categories,\n href: item.href,\n variables: [] as OutcomeVariable[],\n sessionControl: { ...item.sessionControl }\n }))\n }))\n }))\n };\n }\n\n /**\n * The item-refs of each section, its subsections' included, by section identifier: a section that\n * only holds subsections is completed when theirs are.\n */\n #sectionItems = new Map<string, string[]>();\n\n /** Every item-ref of the test in document order, which item numbers follow. */\n #itemOrder: ItemRefModel[] = [];\n\n /** Item numbers in document order, skipping info items; null for an info item. */\n #itemIndexes(): Map<string, number | null> {\n let index = 1;\n return new Map(\n this.#itemOrder.map(item => [\n item.identifier,\n item.categories.includes(this.configContext?.infoItemCategory) ? null : index++\n ])\n );\n }\n\n /**\n * Extract default values from a qti-context-declaration element\n */\n #extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\n }\n\n /** An item's facts as `computedContext` has carried them; nothing until the item is fetched. */\n #factsFor(identifier: string): Partial<Omit<ItemFacts, 'identifier'>> & { assessmentItemIdentifier?: string } {\n const facts: ItemFacts | undefined = this._itemFacts?.get(identifier);\n if (!facts) return {};\n const { identifier: assessmentItemIdentifier, ...rest } = facts;\n return { ...rest, assessmentItemIdentifier };\n }\n\n /* PK: on every change of the candidate we will recomputed the computedContext */\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) return;\n\n const itemIndexes = this.#itemIndexes();\n this.computedContext = {\n ...this.computedContext,\n view: this._sessionContext?.view,\n plugins: this._sessionContext?.plugins ?? {},\n testParts: this.computedContext.testParts.map(testPart => {\n return {\n ...testPart,\n active: this._sessionContext?.navPartId === testPart.identifier || false,\n sections: testPart.sections.map(section => {\n return {\n ...section,\n active: this._sessionContext?.navSectionId === section.identifier || false,\n completed: (this.#sectionItems.get(section.identifier) ?? section.items.map(i => i.identifier)).every(\n identifier =>\n this._testContext.items\n .find(i => i.identifier === identifier)\n ?.variables.find(v => v.identifier === 'completionStatus')?.value === 'completed'\n ),\n\n items: section.items.map(item => {\n const itemContext = this._testContext?.items.find(i => i.identifier === item.identifier);\n const computedItem = {\n ...item,\n ...this.#factsFor(item.identifier),\n ...itemContext,\n ...this.initContext?.find(i => i.identifier === item.identifier)\n };\n\n const rawscore = computedItem.variables?.find(vr => vr.identifier == 'SCORE')?.value;\n\n const score = rawscore === undefined || rawscore === null ? null : parseFloat(rawscore?.toString());\n\n const completionStatus = computedItem.variables?.find(v => v.identifier === 'completionStatus')\n ?.value as string;\n\n const response = computedItem.variables?.find(v => v.identifier === 'RESPONSE')?.value || '';\n const numAttempts =\n Number(computedItem.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n\n const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;\n\n // Published by the item. One that is not on screen has nothing to be invalid.\n const valid = itemContext?.valid ?? true;\n\n const responseVars =\n itemContext?.variables?.filter(v => v.type === 'response' && v.identifier !== 'numAttempts') || [];\n\n const isDefaultResponse = responseVars.every(v => {\n if (v.value === undefined || v.value === null) {\n return true;\n }\n let fallbackValue: string;\n switch (v.baseType) {\n case 'integer':\n case 'float':\n case 'duration':\n fallbackValue = '0';\n break;\n case 'boolean':\n fallbackValue = 'false';\n break;\n case 'string':\n case 'directedPair':\n case 'identifier':\n case 'pair':\n case 'record':\n default:\n fallbackValue = '';\n break;\n }\n\n const defaultValue = v.defaultValue ?? fallbackValue;\n\n if (Array.isArray(v.value)) {\n const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];\n return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);\n }\n\n return v.value === defaultValue;\n });\n\n // Computed and opiniated\n // const type = item.categories.includes(this.configContext?.infoItemCategory) ? 'info' : 'regular';\n // const correct = (type == 'regular' && score !== undefined && !isNaN(score) && score > 0) || false;\n // const incorrect = (type == 'regular' && score !== undefined && !isNaN(score) && score <= 0) || false;\n // const completed = completionStatus === 'completed';\n\n const index = itemIndexes.get(item.identifier) ?? null;\n const rawMaxScore = item.variables?.find(vr => vr.identifier == 'MAXSCORE')?.value;\n const maxScore =\n rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());\n\n // Optimality comes from the last *ended attempt* (#optimality),\n // latched in #handleItemContextUpdated — never from a live\n // mid-attempt selection. On a restored session no attempt is ended\n // this run, so seed it once from the persisted context, which still\n // holds the submitted response.\n let optimality = this.#optimality.get(computedItem.identifier);\n if (optimality === undefined) {\n optimality = itemContext ? this.#assessOptimality(itemContext) : 'unscored';\n if (numAttempts > 0) this.#optimality.set(computedItem.identifier, optimality);\n }\n\n const done = this.#isItemDone(\n numAttempts,\n optimality,\n computedItem.sessionControl?.maxAttempts,\n computedItem.adaptive,\n completionStatus\n );\n\n return {\n ...computedItem,\n completionStatus,\n numAttempts,\n score,\n response,\n index,\n active,\n valid,\n isDefaultResponse,\n maxScore,\n done,\n // Reflects the last *ended* attempt only. Read the latch directly\n // (not the `optimality` local) — the latch is written solely on\n // responseProcessed / restore-seed (line above, guarded by\n // numAttempts > 0), so a freshly-picked mid-attempt selection\n // computed live is never stored and never counts as optimal.\n optimal: this.#optimality.get(computedItem.identifier) === 'optimal'\n // type,\n // correct,\n // incorrect,\n // completed\n };\n })\n };\n })\n };\n })\n };\n\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n this.#lockUsedItems();\n }\n\n /** The items this navigation disabled because their attempts are used, so it releases only those. */\n #lockedItems = new WeakSet<QtiAssessmentItem>();\n\n /**\n * Disables every rendered item whose attempts are used, from the computed context, so the\n * candidate cannot change the answer once the last attempt is ended. Runs after every update:\n * an item rendered later (another item, a section on screen, a restored state) is locked as it\n * arrives, and one whose attempts are back to zero (a new state) is released.\n *\n * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a\n * host or view that disables or makes an item read-only itself keeps it so.\n */\n #lockUsedItems(): void {\n if (!this.#testElement || !this.computedContext) return;\n // In a simultaneous part every item has one attempt, processed when the part ends (QTI info model\n // §2.8.2), so the candidate may change the answer until then: TAO keeps such an item open too.\n const items = new Map(\n this.computedContext.testParts.flatMap(part =>\n part.submissionMode === 'simultaneous'\n ? []\n : part.sections.flatMap(section => section.items.map(item => [item.identifier, item] as const))\n )\n );\n for (const itemRef of this.#testElement.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')) {\n const element = itemRef.assessmentItem;\n if (!element) continue;\n const used = this.#attemptsUsed(items.get(itemRef.identifier), element);\n if (used && !element.disabled) {\n element.disabled = true;\n this.#lockedItems.add(element);\n } else if (!used && this.#lockedItems.has(element)) {\n this.#lockedItems.delete(element);\n element.disabled = false;\n }\n }\n }\n\n /**\n * The same rule as `test-end-attempt`'s max-attempts guard: a non-adaptive item with a\n * `max-attempts` above 0 whose attempts reached it. Adaptive items end themselves, and 0 is\n * unlimited. With `auto-score-items` every change is scored as an attempt, so the count is not\n * the candidate's and locks nothing.\n */\n #attemptsUsed(item: ComputedItem | undefined, element: QtiAssessmentItem): boolean {\n if (!item || this.autoScoreItems) return false;\n if (item.adaptive || element.adaptive === 'true') return false;\n const maxAttempts = item.sessionControl?.maxAttempts ?? 1;\n return maxAttempts > 0 && (item.numAttempts ?? 0) >= maxAttempts;\n }\n\n /**\n * Decide whether an item should be treated as \"the candidate is done with it\"\n * for the purpose of gating forward navigation and further attempts.\n *\n * - The candidate must have actually ended an attempt (numAttempts > 0).\n * - Once attempted, the item is done if they reached the optimal outcome\n * ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*\n * done while a better attempt is still possible ('suboptimal') and attempts\n * remain — see #assessOptimality for how \"optimal\" is determined.\n *\n * `optimality` reflects the last *ended attempt* (see #optimality), not the\n * live selection — so a freshly-picked optimal answer doesn't count as done\n * until test-end-attempt evaluates it.\n *\n * Adaptive items decide this themselves: max-attempts does not apply to them\n * (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads\n * on to the next part of the item. They are done once their response\n * processing sets completionStatus to 'completed'.\n */\n #isItemDone(\n numAttempts: number,\n optimality: ItemOptimality,\n maxAttempts: number | undefined,\n adaptive?: boolean,\n completionStatus?: string\n ): boolean {\n if (numAttempts === 0) return false;\n if (adaptive) return completionStatus === 'completed';\n if (optimality !== 'suboptimal') return true;\n const max = maxAttempts ?? 1;\n return max > 0 && numAttempts >= max;\n }\n\n /**\n * Decide whether an item's submission is as good as it can get — i.e. the\n * candidate reached the *optimal* outcome, so there's no reason to make them\n * try again. 'optimal' means best achievable, 'suboptimal' means a better\n * attempt is still possible, 'unscored' means there's nothing to judge against.\n * (\"optimal\" is the spec's own word — a qti-correct-response is defined as\n * \"the (or an) optimal value\".)\n *\n * Two signals, in order of authority:\n * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).\n * This correctly handles partial-credit / qti-mapping items, where an exact\n * response match would under- or over-judge.\n * 2. The declared qti-correct-response, for items that aren't scored (no\n * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping\n * variables like numAttempts can be typed 'response' but never declare a\n * correctResponse, so we filter on a declared correctResponse.\n *\n * Items with neither a comparable score nor a correctResponse (essays, info\n * items, etc.) are 'unscored' — there's no optimal value to require, so one\n * attempt is enough.\n */\n #assessOptimality(item: ItemContext): ItemOptimality {\n const variables = item.variables ?? [];\n\n const score = this.#numericVariable(variables, 'SCORE');\n const maxScore = this.#numericVariable(variables, 'MAXSCORE');\n if (score !== null && maxScore !== null) {\n return score >= maxScore ? 'optimal' : 'suboptimal';\n }\n\n const responseVars = variables.filter(\n (v): v is ResponseVariable =>\n v.type === 'response' &&\n (v as ResponseVariable).correctResponse !== undefined &&\n (v as ResponseVariable).correctResponse !== null\n );\n if (responseVars.length === 0) return 'unscored';\n const allMatch = responseVars.every(v => {\n const expected = v.correctResponse;\n const actual = v.value;\n if (actual === undefined || actual === null) return false;\n if (Array.isArray(expected) && Array.isArray(actual)) {\n return expected.length === actual.length && expected.every(e => actual.includes(e));\n }\n if (Array.isArray(expected) || Array.isArray(actual)) return false;\n return expected === actual;\n });\n return allMatch ? 'optimal' : 'suboptimal';\n }\n\n /** Read a single numeric outcome value, or null when absent / non-numeric. */\n #numericVariable(variables: ItemContext['variables'], identifier: string): number | null {\n const raw = variables?.find(v => v.identifier === identifier)?.value;\n if (raw === undefined || raw === null || Array.isArray(raw)) return null;\n const parsed = parseFloat(raw.toString());\n return Number.isNaN(parsed) ? null : parsed;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-navigation': TestNavigation;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test-navigation.js","sourceRoot":"","sources":["../../../src/components/test-navigation/test-navigation.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CA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AE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oDACd;AAI3B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACX;AAKjC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDAClB;AAI5B;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;uDACK;AAEiB;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;sDAAwB","sourcesContent":["import { ContextConsumer, consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\nimport { buildTestModel } from '@qti-components/delivery';\nimport { configContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\nimport { sessionContext } from '@qti-components/base';\nimport { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';\n\nimport { assessOptimality, deriveComputedContext, isItemDone } from '../../internal/derive-computed-context';\nimport { itemFactsContext } from '../../internal/item-facts.context';\nimport { renderedMarkup } from '../../internal/rendered-markup';\nimport { testHostContext } from '../../internal/test-host.context';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiContext } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { TestModel } from '@qti-components/delivery';\nimport type { ItemOptimality } from '../../internal/derive-computed-context';\nimport type { ItemFactsByRef } from '../../internal/item-facts.context';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\n\n/** A new object each time: a host that mutates the one it read must not change anyone else's. */\nconst newQtiContext = (): QtiContext => ({\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n});\n\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier: string | undefined = undefined;\n\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n /**\n * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the\n * enclosing test's: reading returns it, writing replaces it, so a host that has always set the\n * shuffle seed here keeps working. Removed in the next major.\n *\n * Written before the navigation is inside a test, it waits and is handed over on connect.\n */\n public get qtiContext(): QtiContext {\n return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());\n }\n\n public set qtiContext(value: QtiContext) {\n if (!this.#warnedQtiContext) {\n this.#warnedQtiContext = true;\n console.warn(\n '[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major ' +\n 'release. Set `qtiContext` on `<qti-test>` instead; it is the same value.'\n );\n }\n this.#writeQtiContext(value);\n }\n\n #pendingQtiContext?: QtiContext;\n #warnedQtiContext = false;\n\n /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */\n #writeQtiContext(value: QtiContext): void {\n const owner = this.#owner();\n if (owner) owner.qtiContext = value;\n else this.#pendingQtiContext = value;\n }\n\n /**\n * The `qti-test` this navigation is in, found through context so it works across shadow roots.\n * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.\n */\n #testHost = new ContextConsumer(this, {\n context: testHostContext,\n subscribe: true,\n callback: host => {\n if (host && this.#pendingQtiContext) {\n host.qtiContext = this.#pendingQtiContext;\n this.#pendingQtiContext = undefined;\n }\n }\n });\n\n #owner(): { qtiContext: QtiContext } | null {\n return this.#testHost.value ?? null;\n }\n\n @state()\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n /** Read from each item's XML when `qti-test` fetches it; see `itemFactsContext`. */\n @state()\n @consume({ context: itemFactsContext, subscribe: true })\n protected _itemFacts?: ItemFactsByRef;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n #testElement: QtiAssessmentTest;\n\n /**\n * Whether each item's last *ended attempt* reached the optimal outcome, keyed\n * by item-ref id. Written from #handleItemContextUpdated when processResponse\n * ends an attempt — never on a plain selection. Mirrors how inline feedback\n * only re-evaluates when an attempt is processed, so a freshly-picked answer\n * doesn't flip `done` until the candidate ends the attempt.\n */\n #optimality = new Map<string, ItemOptimality>();\n\n constructor() {\n super();\n listenPublic(this, 'qc-test-loaded', this.#handleTestConnected.bind(this));\n\n listenItemPublic(this, 'qc-item-response-changed', this.#handleInteractionChanged.bind(this));\n this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));\n\n listenPublic(this, 'qc-test-end-attempt', this.#handleTestEndAttempt.bind(this));\n listenPublic(this, 'qc-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));\n }\n\n /**\n * Latch whether an item reached its optimal outcome whenever it has just ended\n * an attempt. processResponse — fired by test-end-attempt, autoscore, or an\n * in-item end-attempt interaction — flags its context update with\n * `responseProcessed`; a plain selection updates the context without it, so\n * `done` can't flip until the candidate actually ends the attempt.\n */\n #handleItemContextUpdated(event: CustomEvent<{ itemContext: ItemContext; responseProcessed?: boolean }>) {\n if (!event.detail?.responseProcessed) return;\n const itemContext = event.detail.itemContext;\n if (!itemContext?.identifier) return;\n const optimality = assessOptimality(itemContext);\n this.#optimality.set(itemContext.identifier, optimality);\n\n const computedItem = this.computedItemFor(itemContext.identifier);\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n const completionStatus = itemContext.variables?.find(v => v.identifier === 'completionStatus')?.value as string;\n this.afterAttemptEnded(\n (event.composedPath()[0] as HTMLElement)?.closest<QtiAssessmentItem>('qti-assessment-item'),\n computedItem,\n isItemDone(\n numAttempts,\n optimality,\n computedItem?.sessionControl?.maxAttempts,\n computedItem?.adaptive,\n completionStatus\n )\n );\n }\n\n /**\n * Extension point for presentation packages reacting to an ended attempt.\n * `done` is settled here — from the freshly latched optimality and the\n * session-control cascade — because the computed context only catches up on\n * the next update, after this event has finished bubbling.\n */\n protected afterAttemptEnded(\n _assessmentItem: QtiAssessmentItem | undefined,\n _computedItem: ComputedItem | undefined,\n _done: boolean\n ): void {}\n\n /** The computed-context entry for an item, from the session-control cascade. */\n protected computedItemFor(identifier: string): ComputedItem | undefined {\n return this.computedContext?.testParts\n ?.flatMap(part => part.sections)\n .flatMap(section => section.items)\n .find(i => i.identifier === identifier);\n }\n\n /** The assessment item for an item-ref id, if it has been rendered. */\n #assessmentItemFor(identifier: string | undefined): QtiAssessmentItem | undefined {\n if (!identifier) return undefined;\n const itemRef = this.#testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(identifier)}\"]`\n );\n return itemRef?.assessmentItem ?? undefined;\n }\n\n /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */\n #itemElement = (identifier: string): HTMLElement | null => this.#assessmentItemFor(identifier) ?? null;\n\n /** The currently active assessment item, exposed for optional presentation extensions. */\n protected get activeAssessmentItem(): QtiAssessmentItem | undefined {\n if (!this.#testElement || !this._sessionContext?.navItemRefId) return undefined;\n return this.#testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n )?.assessmentItem;\n }\n\n /**\n * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or\n * given an `item`), or else the item on screen.\n */\n #handleTestEndAttempt(event: CustomEvent<{ itemId?: string } | undefined>) {\n const itemId = event.detail?.itemId;\n const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;\n if (!qtiAssessmentItemEl) return;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n #handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);\n if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n #handleInteractionChanged(_event: CustomEvent) {\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest<QtiAssessmentItem>(\n 'qti-assessment-item'\n );\n // Autoscoring resolves the item from the event's own path, so a change\n // raised outside an assessment item has nothing to score.\n if (!assessmentItem) return;\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n #handleTestConnected(event: CustomEvent) {\n this.#testElement = event.detail as QtiAssessmentTest;\n // A fresh test invalidates the per-test optimality latches.\n this.#optimality.clear();\n // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this.#testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n });\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this.#extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n });\n }\n });\n\n // The structure and the session-control cascade come from the test's markup, not from upgraded\n // properties, so they do not depend on registration or render timing.\n this.#model = buildTestModel(renderedMarkup(this.#testElement));\n this.computedContext = this.#derive();\n }\n\n /** The test's structure and resolved session control, read from its markup when it is connected. */\n #model?: TestModel;\n\n /** `computedContext`, derived anew from its inputs (`deriveComputedContext`), never from the previous one. */\n #derive(): ComputedContext {\n this.#seedOptimality();\n return deriveComputedContext({\n model: this.#model,\n itemFacts: this._itemFacts,\n testContext: this._testContext,\n sessionContext: this._sessionContext,\n infoItemCategory: this.configContext?.infoItemCategory,\n itemData: this.initContext,\n optimality: this.#optimality,\n itemElement: this.#itemElement\n });\n }\n\n /**\n * On a restored session no attempt is ended this run, so the latch is seeded once from the\n * persisted context, which still holds the submitted response. A later change of the answer\n * leaves the seeded value alone.\n */\n #seedOptimality(): void {\n for (const itemContext of this._testContext?.items ?? []) {\n if (!itemContext.identifier || this.#optimality.has(itemContext.identifier)) continue;\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n if (numAttempts > 0) this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));\n }\n }\n\n /**\n * Extract default values from a qti-context-declaration element\n */\n #extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\n }\n\n /* On every change of the candidate's state, the context is derived again. */\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.#model) return;\n this.computedContext = this.#derive();\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n this.#lockUsedItems();\n }\n\n /** The items this navigation disabled because their attempts are used, so it releases only those. */\n #lockedItems = new WeakSet<QtiAssessmentItem>();\n\n /**\n * Disables every rendered item whose attempts are used, from the computed context, so the\n * candidate cannot change the answer once the last attempt is ended. Runs after every update:\n * an item rendered later (another item, a section on screen, a restored state) is locked as it\n * arrives, and one whose attempts are back to zero (a new state) is released.\n *\n * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a\n * host or view that disables or makes an item read-only itself keeps it so.\n */\n #lockUsedItems(): void {\n if (!this.#testElement || !this.computedContext) return;\n // In a simultaneous part every item has one attempt, processed when the part ends (QTI info model\n // §2.8.2), so the candidate may change the answer until then: TAO keeps such an item open too.\n const items = new Map(\n this.computedContext.testParts.flatMap(part =>\n part.submissionMode === 'simultaneous'\n ? []\n : part.sections.flatMap(section => section.items.map(item => [item.identifier, item] as const))\n )\n );\n for (const itemRef of this.#testElement.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')) {\n const element = itemRef.assessmentItem;\n if (!element) continue;\n const used = this.#attemptsUsed(items.get(itemRef.identifier), element);\n if (used && !element.disabled) {\n element.disabled = true;\n this.#lockedItems.add(element);\n } else if (!used && this.#lockedItems.has(element)) {\n this.#lockedItems.delete(element);\n element.disabled = false;\n }\n }\n }\n\n /**\n * The same rule as `test-end-attempt`'s max-attempts guard: a non-adaptive item with a\n * `max-attempts` above 0 whose attempts reached it. Adaptive items end themselves, and 0 is\n * unlimited. With `auto-score-items` every change is scored as an attempt, so the count is not\n * the candidate's and locks nothing.\n */\n #attemptsUsed(item: ComputedItem | undefined, element: QtiAssessmentItem): boolean {\n if (!item || this.autoScoreItems) return false;\n if (item.adaptive || element.adaptive === 'true') return false;\n const maxAttempts = item.sessionControl?.maxAttempts ?? 1;\n return maxAttempts > 0 && (item.numAttempts ?? 0) >= maxAttempts;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-navigation': TestNavigation;\n }\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ComputedContext, ItemContext } from '@qti-components/base';
|
|
2
|
+
import type { SessionContext, TestContext } from '@qti-components/base';
|
|
3
|
+
import type { TestModel } from '@qti-components/delivery';
|
|
4
|
+
import type { ItemFactsByRef } from './item-facts.context';
|
|
5
|
+
/**
|
|
6
|
+
* Whether an item's ended attempt reached the best achievable outcome:
|
|
7
|
+
* 'optimal' (nothing to improve), 'suboptimal' (a better attempt is possible),
|
|
8
|
+
* or 'unscored' (no machine-judgeable optimal value — see `assessOptimality`).
|
|
9
|
+
*/
|
|
10
|
+
export type ItemOptimality = 'optimal' | 'suboptimal' | 'unscored';
|
|
11
|
+
/** Everything `computedContext` is derived from. Nothing here is the previous `computedContext`. */
|
|
12
|
+
export interface ComputedContextInputs {
|
|
13
|
+
/** The test's structure and resolved session control, from its XML (`buildTestModel`). */
|
|
14
|
+
readonly model: TestModel;
|
|
15
|
+
/** The facts of every item fetched so far, by item-ref identifier. */
|
|
16
|
+
readonly itemFacts?: ItemFactsByRef;
|
|
17
|
+
/** The candidate's responses and outcomes, per item. */
|
|
18
|
+
readonly testContext?: Readonly<TestContext>;
|
|
19
|
+
/** Where the candidate is, the view and the plugin state. */
|
|
20
|
+
readonly sessionContext?: Readonly<SessionContext>;
|
|
21
|
+
/** `config.infoItemCategory`: items with it are not numbered. */
|
|
22
|
+
readonly infoItemCategory?: string;
|
|
23
|
+
/** The host's per-item fields (`initContext`). */
|
|
24
|
+
readonly itemData?: readonly {
|
|
25
|
+
identifier: string;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}[];
|
|
28
|
+
/**
|
|
29
|
+
* The optimality of each item's last ended attempt, by item-ref identifier (see `ItemOptimality`).
|
|
30
|
+
* Kept by `test-navigation`, since it is not in the contexts: it is written when an attempt ends,
|
|
31
|
+
* never on a plain change of the answer.
|
|
32
|
+
*/
|
|
33
|
+
readonly optimality: ReadonlyMap<string, ItemOptimality>;
|
|
34
|
+
/** `computedContext.itemElement`, passed through. */
|
|
35
|
+
readonly itemElement?: ComputedContext['itemElement'];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `computedContext`, derived from its inputs alone: built anew on every call, never from the previous
|
|
39
|
+
* context, and never changing an input. The same inputs give an equal context.
|
|
40
|
+
*
|
|
41
|
+
* Roadmap 1, T2c. `DeliveryState` is not live at runtime yet, so the candidate's state comes from
|
|
42
|
+
* `testContext` and `sessionContext`; T3 and T8 move it into `DeliveryState`, and add their fields here.
|
|
43
|
+
*/
|
|
44
|
+
export declare function deriveComputedContext(inputs: ComputedContextInputs): ComputedContext;
|
|
45
|
+
/**
|
|
46
|
+
* Decide whether an item should be treated as "the candidate is done with it"
|
|
47
|
+
* for the purpose of gating forward navigation and further attempts.
|
|
48
|
+
*
|
|
49
|
+
* - The candidate must have actually ended an attempt (numAttempts > 0).
|
|
50
|
+
* - Once attempted, the item is done if they reached the optimal outcome
|
|
51
|
+
* ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
|
|
52
|
+
* done while a better attempt is still possible ('suboptimal') and attempts
|
|
53
|
+
* remain — see `assessOptimality` for how "optimal" is determined.
|
|
54
|
+
*
|
|
55
|
+
* `optimality` reflects the last *ended attempt*, not the live selection — so a
|
|
56
|
+
* freshly-picked optimal answer doesn't count as done until test-end-attempt
|
|
57
|
+
* evaluates it.
|
|
58
|
+
*
|
|
59
|
+
* Adaptive items decide this themselves: max-attempts does not apply to them
|
|
60
|
+
* (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads
|
|
61
|
+
* on to the next part of the item. They are done once their response
|
|
62
|
+
* processing sets completionStatus to 'completed'.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isItemDone(numAttempts: number, optimality: ItemOptimality, maxAttempts: number | undefined, adaptive?: boolean, completionStatus?: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Decide whether an item's submission is as good as it can get — i.e. the
|
|
67
|
+
* candidate reached the *optimal* outcome, so there's no reason to make them
|
|
68
|
+
* try again. 'optimal' means best achievable, 'suboptimal' means a better
|
|
69
|
+
* attempt is still possible, 'unscored' means there's nothing to judge against.
|
|
70
|
+
* ("optimal" is the spec's own word — a qti-correct-response is defined as
|
|
71
|
+
* "the (or an) optimal value".)
|
|
72
|
+
*
|
|
73
|
+
* Two signals, in order of authority:
|
|
74
|
+
* 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).
|
|
75
|
+
* This correctly handles partial-credit / qti-mapping items, where an exact
|
|
76
|
+
* response match would under- or over-judge.
|
|
77
|
+
* 2. The declared qti-correct-response, for items that aren't scored (no
|
|
78
|
+
* SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping
|
|
79
|
+
* variables like numAttempts can be typed 'response' but never declare a
|
|
80
|
+
* correctResponse, so we filter on a declared correctResponse.
|
|
81
|
+
*
|
|
82
|
+
* Items with neither a comparable score nor a correctResponse (essays, info
|
|
83
|
+
* items, etc.) are 'unscored' — there's no optimal value to require, so one
|
|
84
|
+
* attempt is enough.
|
|
85
|
+
*/
|
|
86
|
+
export declare function assessOptimality(item: ItemContext): ItemOptimality;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { itemRefsInOrder, ownItemRefs, sectionsInOrder } from '@qti-components/delivery';
|
|
2
|
+
/**
|
|
3
|
+
* `computedContext`, derived from its inputs alone: built anew on every call, never from the previous
|
|
4
|
+
* context, and never changing an input. The same inputs give an equal context.
|
|
5
|
+
*
|
|
6
|
+
* Roadmap 1, T2c. `DeliveryState` is not live at runtime yet, so the candidate's state comes from
|
|
7
|
+
* `testContext` and `sessionContext`; T3 and T8 move it into `DeliveryState`, and add their fields here.
|
|
8
|
+
*/
|
|
9
|
+
export function deriveComputedContext(inputs) {
|
|
10
|
+
const { model, sessionContext, itemElement } = inputs;
|
|
11
|
+
const itemIndexes = indexesInDocumentOrder(model.testParts.flatMap(part => itemRefsInOrder(part.sections)), inputs.infoItemCategory);
|
|
12
|
+
return {
|
|
13
|
+
itemElement,
|
|
14
|
+
identifier: model.identifier,
|
|
15
|
+
title: model.title,
|
|
16
|
+
view: sessionContext?.view,
|
|
17
|
+
plugins: sessionContext?.plugins ?? {},
|
|
18
|
+
testParts: model.testParts.map(testPart => ({
|
|
19
|
+
active: sessionContext?.navPartId === testPart.identifier,
|
|
20
|
+
identifier: testPart.identifier,
|
|
21
|
+
navigationMode: testPart.navigationMode,
|
|
22
|
+
submissionMode: testPart.submissionMode,
|
|
23
|
+
allowSkipping: testPart.sessionControl.allowSkipping,
|
|
24
|
+
itemOrder: itemRefsInOrder(testPart.sections).map(item => item.identifier),
|
|
25
|
+
// Flat, depth first: every section once, each with only its own item-refs, so every item is
|
|
26
|
+
// listed once. Where a section's item-refs and subsections interleave, this list is not in
|
|
27
|
+
// document order; `index` is.
|
|
28
|
+
sections: sectionsInOrder(testPart.sections).map(section => ({
|
|
29
|
+
active: sessionContext?.navSectionId === section.identifier,
|
|
30
|
+
identifier: section.identifier,
|
|
31
|
+
title: section.title,
|
|
32
|
+
allowSkipping: section.sessionControl.allowSkipping,
|
|
33
|
+
// A section that only holds subsections is completed when theirs are.
|
|
34
|
+
completed: itemRefsInOrder(section.content).every(item => variableValue(itemContextFor(inputs, item.identifier), 'completionStatus') === 'completed'),
|
|
35
|
+
items: ownItemRefs(section).map(item => deriveItem(inputs, item, itemIndexes.get(item.identifier) ?? null))
|
|
36
|
+
}))
|
|
37
|
+
}))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function deriveItem(inputs, item, index) {
|
|
41
|
+
const itemContext = itemContextFor(inputs, item.identifier);
|
|
42
|
+
const computedItem = {
|
|
43
|
+
active: false,
|
|
44
|
+
identifier: item.identifier,
|
|
45
|
+
categories: [...item.categories],
|
|
46
|
+
href: item.href,
|
|
47
|
+
variables: [],
|
|
48
|
+
sessionControl: { ...item.sessionControl },
|
|
49
|
+
...factsFor(inputs.itemFacts, item.identifier),
|
|
50
|
+
...itemContext,
|
|
51
|
+
...inputs.itemData?.find(data => data.identifier === item.identifier)
|
|
52
|
+
};
|
|
53
|
+
const rawScore = variableValue(computedItem, 'SCORE');
|
|
54
|
+
const score = rawScore === undefined || rawScore === null ? null : parseFloat(rawScore.toString());
|
|
55
|
+
const rawMaxScore = variableValue(computedItem, 'MAXSCORE');
|
|
56
|
+
const maxScore = rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(rawMaxScore.toString());
|
|
57
|
+
const completionStatus = variableValue(computedItem, 'completionStatus');
|
|
58
|
+
const response = variableValue(computedItem, 'RESPONSE') || '';
|
|
59
|
+
const numAttempts = Number(variableValue(computedItem, 'numAttempts')) || 0;
|
|
60
|
+
// Optimality comes from the last *ended attempt*, never from a live mid-attempt selection.
|
|
61
|
+
// `test-navigation` seeds the latch once from a restored context, which still holds the submitted
|
|
62
|
+
// response; before that, an item with no ended attempt is assessed on what it holds.
|
|
63
|
+
const latched = inputs.optimality.get(item.identifier);
|
|
64
|
+
const optimality = latched ?? (itemContext ? assessOptimality(itemContext) : 'unscored');
|
|
65
|
+
return {
|
|
66
|
+
...computedItem,
|
|
67
|
+
completionStatus,
|
|
68
|
+
numAttempts,
|
|
69
|
+
score,
|
|
70
|
+
response,
|
|
71
|
+
index,
|
|
72
|
+
active: inputs.sessionContext?.navItemRefId === item.identifier,
|
|
73
|
+
// Published by the item. One that is not on screen has nothing to be invalid.
|
|
74
|
+
valid: itemContext?.valid ?? true,
|
|
75
|
+
isDefaultResponse: isDefaultResponse(itemContext),
|
|
76
|
+
maxScore,
|
|
77
|
+
done: isItemDone(numAttempts, optimality, computedItem.sessionControl?.maxAttempts, computedItem.adaptive, completionStatus),
|
|
78
|
+
// Reflects the last *ended* attempt only: the latch, not the fallback above.
|
|
79
|
+
optimal: latched === 'optimal'
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function itemContextFor(inputs, identifier) {
|
|
83
|
+
return inputs.testContext?.items?.find(item => item.identifier === identifier);
|
|
84
|
+
}
|
|
85
|
+
function variableValue(item, identifier) {
|
|
86
|
+
return item?.variables?.find(variable => variable.identifier === identifier)?.value;
|
|
87
|
+
}
|
|
88
|
+
/** An item's facts as `computedContext` carries them; nothing until the item is fetched. */
|
|
89
|
+
function factsFor(itemFacts, identifier) {
|
|
90
|
+
const facts = itemFacts?.get(identifier);
|
|
91
|
+
if (!facts)
|
|
92
|
+
return {};
|
|
93
|
+
const { identifier: assessmentItemIdentifier, ...rest } = facts;
|
|
94
|
+
return { ...rest, assessmentItemIdentifier };
|
|
95
|
+
}
|
|
96
|
+
/** Item numbers in document order, skipping info items; null for an info item. */
|
|
97
|
+
function indexesInDocumentOrder(items, infoItemCategory) {
|
|
98
|
+
let index = 1;
|
|
99
|
+
return new Map(items.map(item => [item.identifier, item.categories.includes(infoItemCategory) ? null : index++]));
|
|
100
|
+
}
|
|
101
|
+
/** Every response still holds its default (or the base type's empty value): nothing answered. */
|
|
102
|
+
function isDefaultResponse(itemContext) {
|
|
103
|
+
const responseVariables = itemContext?.variables?.filter(v => v.type === 'response' && v.identifier !== 'numAttempts') || [];
|
|
104
|
+
return responseVariables.every(v => {
|
|
105
|
+
if (v.value === undefined || v.value === null)
|
|
106
|
+
return true;
|
|
107
|
+
let fallbackValue;
|
|
108
|
+
switch (v.baseType) {
|
|
109
|
+
case 'integer':
|
|
110
|
+
case 'float':
|
|
111
|
+
case 'duration':
|
|
112
|
+
fallbackValue = '0';
|
|
113
|
+
break;
|
|
114
|
+
case 'boolean':
|
|
115
|
+
fallbackValue = 'false';
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
fallbackValue = '';
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
const defaultValue = v.defaultValue ?? fallbackValue;
|
|
122
|
+
if (Array.isArray(v.value)) {
|
|
123
|
+
const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
124
|
+
return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
|
|
125
|
+
}
|
|
126
|
+
return v.value === defaultValue;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Decide whether an item should be treated as "the candidate is done with it"
|
|
131
|
+
* for the purpose of gating forward navigation and further attempts.
|
|
132
|
+
*
|
|
133
|
+
* - The candidate must have actually ended an attempt (numAttempts > 0).
|
|
134
|
+
* - Once attempted, the item is done if they reached the optimal outcome
|
|
135
|
+
* ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
|
|
136
|
+
* done while a better attempt is still possible ('suboptimal') and attempts
|
|
137
|
+
* remain — see `assessOptimality` for how "optimal" is determined.
|
|
138
|
+
*
|
|
139
|
+
* `optimality` reflects the last *ended attempt*, not the live selection — so a
|
|
140
|
+
* freshly-picked optimal answer doesn't count as done until test-end-attempt
|
|
141
|
+
* evaluates it.
|
|
142
|
+
*
|
|
143
|
+
* Adaptive items decide this themselves: max-attempts does not apply to them
|
|
144
|
+
* (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads
|
|
145
|
+
* on to the next part of the item. They are done once their response
|
|
146
|
+
* processing sets completionStatus to 'completed'.
|
|
147
|
+
*/
|
|
148
|
+
export function isItemDone(numAttempts, optimality, maxAttempts, adaptive, completionStatus) {
|
|
149
|
+
if (numAttempts === 0)
|
|
150
|
+
return false;
|
|
151
|
+
if (adaptive)
|
|
152
|
+
return completionStatus === 'completed';
|
|
153
|
+
if (optimality !== 'suboptimal')
|
|
154
|
+
return true;
|
|
155
|
+
const max = maxAttempts ?? 1;
|
|
156
|
+
return max > 0 && numAttempts >= max;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Decide whether an item's submission is as good as it can get — i.e. the
|
|
160
|
+
* candidate reached the *optimal* outcome, so there's no reason to make them
|
|
161
|
+
* try again. 'optimal' means best achievable, 'suboptimal' means a better
|
|
162
|
+
* attempt is still possible, 'unscored' means there's nothing to judge against.
|
|
163
|
+
* ("optimal" is the spec's own word — a qti-correct-response is defined as
|
|
164
|
+
* "the (or an) optimal value".)
|
|
165
|
+
*
|
|
166
|
+
* Two signals, in order of authority:
|
|
167
|
+
* 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).
|
|
168
|
+
* This correctly handles partial-credit / qti-mapping items, where an exact
|
|
169
|
+
* response match would under- or over-judge.
|
|
170
|
+
* 2. The declared qti-correct-response, for items that aren't scored (no
|
|
171
|
+
* SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping
|
|
172
|
+
* variables like numAttempts can be typed 'response' but never declare a
|
|
173
|
+
* correctResponse, so we filter on a declared correctResponse.
|
|
174
|
+
*
|
|
175
|
+
* Items with neither a comparable score nor a correctResponse (essays, info
|
|
176
|
+
* items, etc.) are 'unscored' — there's no optimal value to require, so one
|
|
177
|
+
* attempt is enough.
|
|
178
|
+
*/
|
|
179
|
+
export function assessOptimality(item) {
|
|
180
|
+
const variables = item.variables ?? [];
|
|
181
|
+
const score = numericVariable(variables, 'SCORE');
|
|
182
|
+
const maxScore = numericVariable(variables, 'MAXSCORE');
|
|
183
|
+
if (score !== null && maxScore !== null) {
|
|
184
|
+
return score >= maxScore ? 'optimal' : 'suboptimal';
|
|
185
|
+
}
|
|
186
|
+
const responseVars = variables.filter((v) => v.type === 'response' &&
|
|
187
|
+
v.correctResponse !== undefined &&
|
|
188
|
+
v.correctResponse !== null);
|
|
189
|
+
if (responseVars.length === 0)
|
|
190
|
+
return 'unscored';
|
|
191
|
+
const allMatch = responseVars.every(v => {
|
|
192
|
+
const expected = v.correctResponse;
|
|
193
|
+
const actual = v.value;
|
|
194
|
+
if (actual === undefined || actual === null)
|
|
195
|
+
return false;
|
|
196
|
+
if (Array.isArray(expected) && Array.isArray(actual)) {
|
|
197
|
+
return expected.length === actual.length && expected.every(e => actual.includes(e));
|
|
198
|
+
}
|
|
199
|
+
if (Array.isArray(expected) || Array.isArray(actual))
|
|
200
|
+
return false;
|
|
201
|
+
return expected === actual;
|
|
202
|
+
});
|
|
203
|
+
return allMatch ? 'optimal' : 'suboptimal';
|
|
204
|
+
}
|
|
205
|
+
/** Read a single numeric outcome value, or null when absent / non-numeric. */
|
|
206
|
+
function numericVariable(variables, identifier) {
|
|
207
|
+
const raw = variables?.find(v => v.identifier === identifier)?.value;
|
|
208
|
+
if (raw === undefined || raw === null || Array.isArray(raw))
|
|
209
|
+
return null;
|
|
210
|
+
const parsed = parseFloat(raw.toString());
|
|
211
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=derive-computed-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-computed-context.js","sourceRoot":"","sources":["../../src/internal/derive-computed-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAsCzF;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA6B;IACjE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,WAAW,GAAG,sBAAsB,CACxC,KAAK,CAAC,SA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AAC,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;QACnE,OAAO,QAAQ,KAAK,MAAM,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;AAC7C,CAAC;AAED,8EAA8E;AAC9E,SAAS,eAAe,CAAC,SAAmC,EAAE,UAAkB;IAC9E,MAAM,GAAG,GAAG,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,EAAE,KAAK,CAAC;IACrE,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC","sourcesContent":["import { itemRefsInOrder, ownItemRefs, sectionsInOrder } from '@qti-components/delivery';\n\nimport type { ComputedContext, ComputedItem, ItemContext, ResponseVariable } from '@qti-components/base';\nimport type { SessionContext, TestContext } from '@qti-components/base';\nimport type { ItemFacts, ItemRefModel, TestModel } from '@qti-components/delivery';\nimport type { ItemFactsByRef } from './item-facts.context';\n\n/**\n * Whether an item's ended attempt reached the best achievable outcome:\n * 'optimal' (nothing to improve), 'suboptimal' (a better attempt is possible),\n * or 'unscored' (no machine-judgeable optimal value — see `assessOptimality`).\n */\nexport type ItemOptimality = 'optimal' | 'suboptimal' | 'unscored';\n\n/** Everything `computedContext` is derived from. Nothing here is the previous `computedContext`. */\nexport interface ComputedContextInputs {\n /** The test's structure and resolved session control, from its XML (`buildTestModel`). */\n readonly model: TestModel;\n /** The facts of every item fetched so far, by item-ref identifier. */\n readonly itemFacts?: ItemFactsByRef;\n /** The candidate's responses and outcomes, per item. */\n readonly testContext?: Readonly<TestContext>;\n /** Where the candidate is, the view and the plugin state. */\n readonly sessionContext?: Readonly<SessionContext>;\n /** `config.infoItemCategory`: items with it are not numbered. */\n readonly infoItemCategory?: string;\n /** The host's per-item fields (`initContext`). */\n readonly itemData?: readonly { identifier: string; [key: string]: unknown }[];\n /**\n * The optimality of each item's last ended attempt, by item-ref identifier (see `ItemOptimality`).\n * Kept by `test-navigation`, since it is not in the contexts: it is written when an attempt ends,\n * never on a plain change of the answer.\n */\n readonly optimality: ReadonlyMap<string, ItemOptimality>;\n /** `computedContext.itemElement`, passed through. */\n readonly itemElement?: ComputedContext['itemElement'];\n}\n\n/**\n * `computedContext`, derived from its inputs alone: built anew on every call, never from the previous\n * context, and never changing an input. The same inputs give an equal context.\n *\n * Roadmap 1, T2c. `DeliveryState` is not live at runtime yet, so the candidate's state comes from\n * `testContext` and `sessionContext`; T3 and T8 move it into `DeliveryState`, and add their fields here.\n */\nexport function deriveComputedContext(inputs: ComputedContextInputs): ComputedContext {\n const { model, sessionContext, itemElement } = inputs;\n const itemIndexes = indexesInDocumentOrder(\n model.testParts.flatMap(part => itemRefsInOrder(part.sections)),\n inputs.infoItemCategory\n );\n return {\n itemElement,\n identifier: model.identifier,\n title: model.title,\n view: sessionContext?.view,\n plugins: sessionContext?.plugins ?? {},\n testParts: model.testParts.map(testPart => ({\n active: sessionContext?.navPartId === testPart.identifier,\n identifier: testPart.identifier,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n allowSkipping: testPart.sessionControl.allowSkipping,\n itemOrder: itemRefsInOrder(testPart.sections).map(item => item.identifier),\n // Flat, depth first: every section once, each with only its own item-refs, so every item is\n // listed once. Where a section's item-refs and subsections interleave, this list is not in\n // document order; `index` is.\n sections: sectionsInOrder(testPart.sections).map(section => ({\n active: sessionContext?.navSectionId === section.identifier,\n identifier: section.identifier,\n title: section.title,\n allowSkipping: section.sessionControl.allowSkipping,\n // A section that only holds subsections is completed when theirs are.\n completed: itemRefsInOrder(section.content).every(\n item => variableValue(itemContextFor(inputs, item.identifier), 'completionStatus') === 'completed'\n ),\n items: ownItemRefs(section).map(item => deriveItem(inputs, item, itemIndexes.get(item.identifier) ?? null))\n }))\n }))\n };\n}\n\nfunction deriveItem(inputs: ComputedContextInputs, item: ItemRefModel, index: number | null): ComputedItem {\n const itemContext = itemContextFor(inputs, item.identifier);\n const computedItem = {\n active: false,\n identifier: item.identifier,\n categories: [...item.categories],\n href: item.href,\n variables: [] as ComputedItem['variables'],\n sessionControl: { ...item.sessionControl },\n ...factsFor(inputs.itemFacts, item.identifier),\n ...itemContext,\n ...inputs.itemData?.find(data => data.identifier === item.identifier)\n } as ComputedItem;\n\n const rawScore = variableValue(computedItem, 'SCORE');\n const score = rawScore === undefined || rawScore === null ? null : parseFloat(rawScore.toString());\n const rawMaxScore = variableValue(computedItem, 'MAXSCORE');\n const maxScore = rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(rawMaxScore.toString());\n const completionStatus = variableValue(computedItem, 'completionStatus') as string;\n const response = variableValue(computedItem, 'RESPONSE') || '';\n const numAttempts = Number(variableValue(computedItem, 'numAttempts')) || 0;\n\n // Optimality comes from the last *ended attempt*, never from a live mid-attempt selection.\n // `test-navigation` seeds the latch once from a restored context, which still holds the submitted\n // response; before that, an item with no ended attempt is assessed on what it holds.\n const latched = inputs.optimality.get(item.identifier);\n const optimality = latched ?? (itemContext ? assessOptimality(itemContext) : 'unscored');\n\n return {\n ...computedItem,\n completionStatus,\n numAttempts,\n score,\n response,\n index,\n active: inputs.sessionContext?.navItemRefId === item.identifier,\n // Published by the item. One that is not on screen has nothing to be invalid.\n valid: itemContext?.valid ?? true,\n isDefaultResponse: isDefaultResponse(itemContext),\n maxScore,\n done: isItemDone(\n numAttempts,\n optimality,\n computedItem.sessionControl?.maxAttempts,\n computedItem.adaptive,\n completionStatus\n ),\n // Reflects the last *ended* attempt only: the latch, not the fallback above.\n optimal: latched === 'optimal'\n } as ComputedItem;\n}\n\nfunction itemContextFor(inputs: ComputedContextInputs, identifier: string): ItemContext | undefined {\n return inputs.testContext?.items?.find(item => item.identifier === identifier);\n}\n\nfunction variableValue(item: { variables?: ItemContext['variables'] } | undefined, identifier: string) {\n return item?.variables?.find(variable => variable.identifier === identifier)?.value;\n}\n\n/** An item's facts as `computedContext` carries them; nothing until the item is fetched. */\nfunction factsFor(\n itemFacts: ItemFactsByRef | undefined,\n identifier: string\n): Partial<Omit<ItemFacts, 'identifier'>> & { assessmentItemIdentifier?: string } {\n const facts = itemFacts?.get(identifier);\n if (!facts) return {};\n const { identifier: assessmentItemIdentifier, ...rest } = facts;\n return { ...rest, assessmentItemIdentifier };\n}\n\n/** Item numbers in document order, skipping info items; null for an info item. */\nfunction indexesInDocumentOrder(items: ItemRefModel[], infoItemCategory: string | undefined) {\n let index = 1;\n return new Map(\n items.map(item => [item.identifier, item.categories.includes(infoItemCategory) ? null : index++] as const)\n );\n}\n\n/** Every response still holds its default (or the base type's empty value): nothing answered. */\nfunction isDefaultResponse(itemContext: ItemContext | undefined): boolean {\n const responseVariables =\n itemContext?.variables?.filter(v => v.type === 'response' && v.identifier !== 'numAttempts') || [];\n return responseVariables.every(v => {\n if (v.value === undefined || v.value === null) return true;\n let fallbackValue: string;\n switch (v.baseType) {\n case 'integer':\n case 'float':\n case 'duration':\n fallbackValue = '0';\n break;\n case 'boolean':\n fallbackValue = 'false';\n break;\n default:\n fallbackValue = '';\n break;\n }\n const defaultValue = v.defaultValue ?? fallbackValue;\n if (Array.isArray(v.value)) {\n const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];\n return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);\n }\n return v.value === defaultValue;\n });\n}\n\n/**\n * Decide whether an item should be treated as \"the candidate is done with it\"\n * for the purpose of gating forward navigation and further attempts.\n *\n * - The candidate must have actually ended an attempt (numAttempts > 0).\n * - Once attempted, the item is done if they reached the optimal outcome\n * ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*\n * done while a better attempt is still possible ('suboptimal') and attempts\n * remain — see `assessOptimality` for how \"optimal\" is determined.\n *\n * `optimality` reflects the last *ended attempt*, not the live selection — so a\n * freshly-picked optimal answer doesn't count as done until test-end-attempt\n * evaluates it.\n *\n * Adaptive items decide this themselves: max-attempts does not apply to them\n * (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads\n * on to the next part of the item. They are done once their response\n * processing sets completionStatus to 'completed'.\n */\nexport function isItemDone(\n numAttempts: number,\n optimality: ItemOptimality,\n maxAttempts: number | undefined,\n adaptive?: boolean,\n completionStatus?: string\n): boolean {\n if (numAttempts === 0) return false;\n if (adaptive) return completionStatus === 'completed';\n if (optimality !== 'suboptimal') return true;\n const max = maxAttempts ?? 1;\n return max > 0 && numAttempts >= max;\n}\n\n/**\n * Decide whether an item's submission is as good as it can get — i.e. the\n * candidate reached the *optimal* outcome, so there's no reason to make them\n * try again. 'optimal' means best achievable, 'suboptimal' means a better\n * attempt is still possible, 'unscored' means there's nothing to judge against.\n * (\"optimal\" is the spec's own word — a qti-correct-response is defined as\n * \"the (or an) optimal value\".)\n *\n * Two signals, in order of authority:\n * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).\n * This correctly handles partial-credit / qti-mapping items, where an exact\n * response match would under- or over-judge.\n * 2. The declared qti-correct-response, for items that aren't scored (no\n * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping\n * variables like numAttempts can be typed 'response' but never declare a\n * correctResponse, so we filter on a declared correctResponse.\n *\n * Items with neither a comparable score nor a correctResponse (essays, info\n * items, etc.) are 'unscored' — there's no optimal value to require, so one\n * attempt is enough.\n */\nexport function assessOptimality(item: ItemContext): ItemOptimality {\n const variables = item.variables ?? [];\n\n const score = numericVariable(variables, 'SCORE');\n const maxScore = numericVariable(variables, 'MAXSCORE');\n if (score !== null && maxScore !== null) {\n return score >= maxScore ? 'optimal' : 'suboptimal';\n }\n\n const responseVars = variables.filter(\n (v): v is ResponseVariable =>\n v.type === 'response' &&\n (v as ResponseVariable).correctResponse !== undefined &&\n (v as ResponseVariable).correctResponse !== null\n );\n if (responseVars.length === 0) return 'unscored';\n const allMatch = responseVars.every(v => {\n const expected = v.correctResponse;\n const actual = v.value;\n if (actual === undefined || actual === null) return false;\n if (Array.isArray(expected) && Array.isArray(actual)) {\n return expected.length === actual.length && expected.every(e => actual.includes(e));\n }\n if (Array.isArray(expected) || Array.isArray(actual)) return false;\n return expected === actual;\n });\n return allMatch ? 'optimal' : 'suboptimal';\n}\n\n/** Read a single numeric outcome value, or null when absent / non-numeric. */\nfunction numericVariable(variables: ItemContext['variables'], identifier: string): number | null {\n const raw = variables?.find(v => v.identifier === identifier)?.value;\n if (raw === undefined || raw === null || Array.isArray(raw)) return null;\n const parsed = parseFloat(raw.toString());\n return Number.isNaN(parsed) ? null : parsed;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qti-components/test",
|
|
3
3
|
"description": "QTI test utilities",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.24",
|
|
5
5
|
"author": "",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@heximal/templates": "^0.1.5",
|
|
8
|
-
"@qti-components/base": "^3.0.0-next.
|
|
8
|
+
"@qti-components/base": "^3.0.0-next.11",
|
|
9
9
|
"@qti-components/delivery": "^0.1.0-next.4",
|
|
10
10
|
"@qti-components/elements": "^2.0.0-next.7",
|
|
11
11
|
"@qti-components/interactions": "^1.10.5-next.8",
|