@citolab/qti-components 9.2.0 → 9.3.0

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.
@@ -1,6 +1,7 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, nothing } from 'lit';
3
3
  import { t as transformItemApi, b as transformTestApi } from './qti-transform-test.d-BL7GGFJj.js';
4
+ import { C as ComputedContext, a as ComputedItem } from './computed.types.d-DB5gfOh9.js';
4
5
  import { QtiAssessmentItem, QtiModalFeedback } from './elements.js';
5
6
  import { TemplateFunction } from '@heximal/templates';
6
7
  import { T as TestContext, Q as QtiExpression, a as QtiExpressionBase } from './qti-expression.d-BksT9iLB.js';
@@ -8,7 +9,6 @@ import { h as VariableValue, c as OutcomeVariable, V as VariableDeclaration } fr
8
9
  import { S as SessionContext, V as View } from './session.context.d-Cjs0BkJB.js';
9
10
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
10
11
  import { b as QtiRuleBase } from './qti-rule-base.d-Bdzg8eGH.js';
11
- import { C as ComputedContext, a as ComputedItem } from './computed.types.d-DB5gfOh9.js';
12
12
  import { Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
13
13
 
14
14
  /**
@@ -26,6 +26,12 @@ interface ItemRefTemplateModel {
26
26
  identifier?: string;
27
27
  href?: string;
28
28
  category?: string;
29
+ /**
30
+ * This item's entry in the computed context, the same object the stamps
31
+ * iterate as `item`: `index` (1-based, null for info items), `score`,
32
+ * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.
33
+ */
34
+ item?: ComputedItem;
29
35
  /** The element being rendered. */
30
36
  itemRef: QtiAssessmentItemRef;
31
37
  }
@@ -36,6 +42,7 @@ declare class QtiAssessmentItemRef extends LitElement {
36
42
  required?: boolean;
37
43
  fixed?: boolean;
38
44
  href?: string;
45
+ protected computedContext?: ComputedContext;
39
46
  /**
40
47
  * The `<qti-weight>` children of this ref, keyed by identifier — what
41
48
  * `qti-test-variables`' `weight-identifier` resolves against.
@@ -585,6 +592,8 @@ declare global {
585
592
  type SpeechState = 'idle' | 'playing' | 'paused';
586
593
  interface TtsContext {
587
594
  state: SpeechState;
595
+ /** True while every reading element is highlighted and a click on one starts reading there. */
596
+ picking: boolean;
588
597
  /** Index of the currently highlighted reading element (0-based). */
589
598
  currentElementIndex: number;
590
599
  /** Total number of navigable reading elements in the current item. */
@@ -595,6 +604,8 @@ interface TtsContext {
595
604
  stop(): void;
596
605
  prevElement(): void;
597
606
  nextElement(): void;
607
+ /** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */
608
+ togglePick(): void;
598
609
  }
599
610
 
600
611
  declare const ttsContext: {
@@ -608,8 +619,14 @@ declare const ttsContext: {
608
619
  declare abstract class TtsButtonBase extends LitElement {
609
620
  #private;
610
621
  static styles: lit.CSSResult;
622
+ /**
623
+ * Accessible name of the button. Without it the default icon carries an English name, and
624
+ * slotted content names the button by its text; set it when you slot an icon of your own,
625
+ * which has no text to be named by.
626
+ */
627
+ label?: string;
611
628
  protected _tts?: TtsContext;
612
- updated(changed: PropertyValues): void;
629
+ updated(_changed: PropertyValues): void;
613
630
  }
614
631
  /**
615
632
  * `<test-item-to-speech>` is the controller and context provider. It manages
@@ -620,37 +637,82 @@ declare abstract class TtsButtonBase extends LitElement {
620
637
  * ```html
621
638
  * <test-item-to-speech language="nl-NL">
622
639
  * <test-tts-play></test-tts-play>
623
- * <test-tts-prev>◀◀</test-tts-prev>
624
- * <test-tts-next>▶▶</test-tts-next>
625
- * <test-tts-stop>■</test-tts-stop>
640
+ * <test-tts-prev></test-tts-prev>
641
+ * <test-tts-next></test-tts-next>
642
+ * <test-tts-stop></test-tts-stop>
626
643
  * </test-item-to-speech>
627
644
  * ```
628
645
  *
646
+ * The controller lays its controls out as a wrapping row; each control draws an icon button,
647
+ * and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a
648
+ * control with a slotted icon a `label`, since an icon has no text to name the button by. Buttons read the qti-theme tokens (with the theme's
649
+ * defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.
650
+ *
651
+ * ### Language resolution
652
+ *
653
+ * Each reading element is spoken in the language of the nearest `lang` attribute:
654
+ *
655
+ * 1. `lang` (or `xml:lang`) on the element itself
656
+ * 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across
657
+ * shadow roots, anything wrapping the test
658
+ * 3. `lang` on the document's `<html>` element
659
+ * 4. the `language` attribute on `<test-item-to-speech>`
660
+ *
661
+ * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with
662
+ * `xml:lang="en-GB"` on a `<p>` or on the item root is honoured without further work.
663
+ *
664
+ * ### Which item is read
665
+ *
666
+ * By default the player reads the item the test is navigated to (`navItemRefId` from the
667
+ * session context). When several items share one page — a keep-together section or a
668
+ * vertically scrolling booklet — give each player its own `item-ref-id` so it reads that
669
+ * item regardless of the navigation cursor. The item is looked up by its
670
+ * `qti-assessment-item-ref` identifier, in the player's own tree first and otherwise in
671
+ * any `test-container` shadow root reachable from it, so the player can live inside the
672
+ * item card, next to it, or in the page chrome.
673
+ *
674
+ * Only one item can be spoken at a time; starting one player stops any other.
675
+ *
676
+ * ### Starting somewhere in the middle
677
+ *
678
+ * `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue
679
+ * cursor highlight, and the first click on one of them leaves pick mode and starts reading
680
+ * from that element. Pressing the button again leaves pick mode without reading.
681
+ *
629
682
  * @cssstate idle - No speech active
683
+ * @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click
630
684
  * @cssstate playing - Speech is playing
631
685
  * @cssstate paused - Speech is paused
632
686
  */
633
687
  declare class TestItemToSpeech extends LitElement {
634
688
  #private;
689
+ static styles: lit.CSSResult;
690
+ /** Fallback language when neither the item content nor the document declares one. */
635
691
  language: string;
692
+ /**
693
+ * Identifier of the `qti-assessment-item-ref` this player reads. Leave unset to follow the
694
+ * navigation cursor (`navItemRefId`) instead.
695
+ */
696
+ itemRefId?: string;
636
697
  protected _sessionContext?: SessionContext;
637
698
  _ttsContext: TtsContext;
638
699
  constructor();
639
700
  willUpdate(changed: PropertyValues): void;
640
- updated(_changed: PropertyValues): void;
701
+ updated(changed: PropertyValues): void;
641
702
  connectedCallback(): void;
642
703
  disconnectedCallback(): void;
643
704
  render(): lit.TemplateResult<1>;
644
705
  }
645
706
  /**
646
707
  * Play/pause/resume toggle button — always enabled, cycles through states.
647
- * Use named slots `play` and `pause` to customise the icons/labels independently.
708
+ * Use named slots `play` and `pause` to customise the icons/labels independently; `label` and
709
+ * `pause-label` name the button in each state (set them when the slotted content is an icon).
648
710
  *
649
711
  * @example
650
712
  * ```html
651
713
  * <test-tts-play>
652
- * <span slot="play">▶ Play</span>
653
- * <span slot="pause">⏸ Pause</span>
714
+ * <span slot="play">Voorlezen</span>
715
+ * <span slot="pause">Pauzeren</span>
654
716
  * </test-tts-play>
655
717
  * ```
656
718
  *
@@ -659,6 +721,8 @@ declare class TestItemToSpeech extends LitElement {
659
721
  */
660
722
  declare class TestTtsPlay extends TtsButtonBase {
661
723
  #private;
724
+ /** Accessible name of the button while speech is playing; see `label`. */
725
+ pauseLabel?: string;
662
726
  render(): lit.TemplateResult<1>;
663
727
  }
664
728
  /**
@@ -678,7 +742,7 @@ declare class TestTtsResume extends TtsButtonBase {
678
742
  render(): lit.TemplateResult<1>;
679
743
  }
680
744
  /**
681
- * Stop button — enabled when playing or paused.
745
+ * Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).
682
746
  * @cssstate idle / playing / paused
683
747
  * @csspart button
684
748
  */
@@ -687,7 +751,9 @@ declare class TestTtsStop extends TtsButtonBase {
687
751
  }
688
752
  /**
689
753
  * Prev-element button — moves cursor to the previous reading element and pauses.
690
- * Disabled at the first element or when no elements are loaded.
754
+ * Disabled at the first element. Reading elements are collected lazily, so an element count
755
+ * of 0 means "not looked yet" rather than "nothing to read": the button stays enabled and the
756
+ * first click collects them.
691
757
  * @cssstate idle / playing / paused
692
758
  * @csspart button
693
759
  */
@@ -696,13 +762,24 @@ declare class TestTtsPrev extends TtsButtonBase {
696
762
  }
697
763
  /**
698
764
  * Next-element button — moves cursor to the next reading element and pauses.
699
- * Disabled at the last element or when no elements are loaded.
765
+ * Disabled at the last element; enabled while the elements have not been collected yet
766
+ * (see `TestTtsPrev`).
700
767
  * @cssstate idle / playing / paused
701
768
  * @csspart button
702
769
  */
703
770
  declare class TestTtsNext extends TtsButtonBase {
704
771
  render(): lit.TemplateResult<1>;
705
772
  }
773
+ /**
774
+ * Pick button — toggles pick mode on the controller: every reading element is highlighted and
775
+ * a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.
776
+ * @cssstate idle / playing / paused
777
+ * @cssstate picking
778
+ * @csspart button
779
+ */
780
+ declare class TestTtsPick extends TtsButtonBase {
781
+ render(): lit.TemplateResult<1>;
782
+ }
706
783
  declare global {
707
784
  interface HTMLElementTagNameMap {
708
785
  'test-item-to-speech': TestItemToSpeech;
@@ -712,6 +789,7 @@ declare global {
712
789
  'test-tts-stop': TestTtsStop;
713
790
  'test-tts-prev': TestTtsPrev;
714
791
  'test-tts-next': TestTtsNext;
792
+ 'test-tts-pick': TestTtsPick;
715
793
  }
716
794
  }
717
795
 
@@ -786,4 +864,4 @@ declare global {
786
864
  }
787
865
  }
788
866
 
789
- export { TestStamp as A, TestTtsNext as B, TestTtsPause as C, TestTtsPlay as D, TestTtsPrev as E, TestTtsResume as F, TestTtsStop as G, TestView as H, type ITestNavigationMixin as I, TestViewToggle as J, type TtsContext as K, ttsContext as L, QtiAssessmentItemRef as Q, type SpeechState as S, TestCheckItem as T, type ItemRefTemplateModel as a, QtiAssessmentSection as b, QtiAssessmentTest as c, QtiItemSessionControl as d, QtiNumberSelected as e, QtiOutcomeProcessing as f, QtiOutcomeProcessingProcessor as g, QtiTest as h, QtiTestFeedback as i, QtiTestPart as j, QtiTestVariables as k, QtiTestVariablesExpression as l, TestContainer as m, TestEndAttempt as n, TestItemLink as o, TestItemToSpeech as p, TestNavigation as q, TestNext as r, TestPagingButtonsStamp as s, TestPrev as t, TestPrintContext as u, TestPrintVariables as v, TestScoringButtons as w, TestScoringFeedback as x, TestSectionButtonsStamp as y, TestSectionLink as z };
867
+ export { TestStamp as A, TestTtsNext as B, TestTtsPause as C, TestTtsPick as D, TestTtsPlay as E, TestTtsPrev as F, TestTtsResume as G, TestTtsStop as H, type ITestNavigationMixin as I, TestView as J, TestViewToggle as K, type TtsContext as L, ttsContext as M, QtiAssessmentItemRef as Q, type SpeechState as S, TestCheckItem as T, type ItemRefTemplateModel as a, QtiAssessmentSection as b, QtiAssessmentTest as c, QtiItemSessionControl as d, QtiNumberSelected as e, QtiOutcomeProcessing as f, QtiOutcomeProcessingProcessor as g, QtiTest as h, QtiTestFeedback as i, QtiTestPart as j, QtiTestVariables as k, QtiTestVariablesExpression as l, TestContainer as m, TestEndAttempt as n, TestItemLink as o, TestItemToSpeech as p, TestNavigation as q, TestNext as r, TestPagingButtonsStamp as s, TestPrev as t, TestPrintContext as u, TestPrintVariables as v, TestScoringButtons as w, TestScoringFeedback as x, TestSectionButtonsStamp as y, TestSectionLink as z };
package/dist/test.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { I as ITestNavigationMixin } from './qti-test.d-BfAZE6UF.js';
2
- export { a as ItemRefTemplateModel, Q as QtiAssessmentItemRef, b as QtiAssessmentSection, c as QtiAssessmentTest, d as QtiItemSessionControl, e as QtiNumberSelected, f as QtiOutcomeProcessing, g as QtiOutcomeProcessingProcessor, h as QtiTest, i as QtiTestFeedback, j as QtiTestPart, k as QtiTestVariables, l as QtiTestVariablesExpression, S as SpeechState, T as TestCheckItem, m as TestContainer, n as TestEndAttempt, o as TestItemLink, p as TestItemToSpeech, q as TestNavigation, r as TestNext, s as TestPagingButtonsStamp, t as TestPrev, u as TestPrintContext, v as TestPrintVariables, w as TestScoringButtons, x as TestScoringFeedback, y as TestSectionButtonsStamp, z as TestSectionLink, A as TestStamp, B as TestTtsNext, C as TestTtsPause, D as TestTtsPlay, E as TestTtsPrev, F as TestTtsResume, G as TestTtsStop, H as TestView, J as TestViewToggle, K as TtsContext, L as ttsContext } from './qti-test.d-BfAZE6UF.js';
1
+ import { I as ITestNavigationMixin } from './qti-test.d-D-ELy0Mr.js';
2
+ export { a as ItemRefTemplateModel, Q as QtiAssessmentItemRef, b as QtiAssessmentSection, c as QtiAssessmentTest, d as QtiItemSessionControl, e as QtiNumberSelected, f as QtiOutcomeProcessing, g as QtiOutcomeProcessingProcessor, h as QtiTest, i as QtiTestFeedback, j as QtiTestPart, k as QtiTestVariables, l as QtiTestVariablesExpression, S as SpeechState, T as TestCheckItem, m as TestContainer, n as TestEndAttempt, o as TestItemLink, p as TestItemToSpeech, q as TestNavigation, r as TestNext, s as TestPagingButtonsStamp, t as TestPrev, u as TestPrintContext, v as TestPrintVariables, w as TestScoringButtons, x as TestScoringFeedback, y as TestSectionButtonsStamp, z as TestSectionLink, A as TestStamp, B as TestTtsNext, C as TestTtsPause, D as TestTtsPick, E as TestTtsPlay, F as TestTtsPrev, G as TestTtsResume, H as TestTtsStop, J as TestView, K as TestViewToggle, L as TtsContext, M as ttsContext } from './qti-test.d-D-ELy0Mr.js';
3
3
  import { LitElement } from 'lit';
4
4
  import { h as VariableValue, c as OutcomeVariable, V as VariableDeclaration } from './item.types.d-BDFrq19E.js';
5
5
  import { S as SessionContext } from './session.context.d-Cjs0BkJB.js';
6
6
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
7
7
  import { T as TestContext } from './qti-expression.d-BksT9iLB.js';
8
8
  import './qti-transform-test.d-BL7GGFJj.js';
9
+ import './computed.types.d-DB5gfOh9.js';
9
10
  import './elements.js';
10
11
  import './interaction.interface.d-CvjHM2bi.js';
11
12
  import './qti-feedback.d-D-w6-mJv.js';
12
13
  import './qti-rule-base.d-Bdzg8eGH.js';
13
14
  import '@heximal/templates';
14
- import './computed.types.d-DB5gfOh9.js';
15
15
  import './qti.context.d-CejJMlfZ.js';
16
16
 
17
17
  interface IQtiTest extends LitElement, ITestNavigationMixin, ITestProcessingMixin, IMyQtiTest {
package/dist/test.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-ZOQVTG5L.js";
1
+ import "./chunk-7VDR765S.js";
2
2
  import {
3
3
  QtiAssessmentItemRef,
4
4
  QtiAssessmentSection,
@@ -30,6 +30,7 @@ import {
30
30
  TestStamp,
31
31
  TestTtsNext,
32
32
  TestTtsPause,
33
+ TestTtsPick,
33
34
  TestTtsPlay,
34
35
  TestTtsPrev,
35
36
  TestTtsResume,
@@ -37,7 +38,7 @@ import {
37
38
  TestView,
38
39
  TestViewToggle,
39
40
  ttsContext
40
- } from "./chunk-7PXUE2GR.js";
41
+ } from "./chunk-TDWLV5OD.js";
41
42
  import "./chunk-REKCRWJV.js";
42
43
  import "./chunk-A32YH4H5.js";
43
44
  import "./chunk-4DB4SC5K.js";
@@ -74,6 +75,7 @@ export {
74
75
  TestStamp,
75
76
  TestTtsNext,
76
77
  TestTtsPause,
78
+ TestTtsPick,
77
79
  TestTtsPlay,
78
80
  TestTtsPrev,
79
81
  TestTtsResume,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@citolab/qti-components",
3
3
  "description": "QTI component utilities",
4
- "version": "9.2.0",
4
+ "version": "9.3.0",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
@@ -17,7 +17,7 @@
17
17
  "@qti-components/item": "^1.5.0",
18
18
  "@qti-components/loader": "^1.3.3",
19
19
  "@qti-components/processing": "^1.6.0",
20
- "@qti-components/test": "^1.7.0",
20
+ "@qti-components/test": "^1.8.0",
21
21
  "@qti-components/theme": "^2.2.1",
22
22
  "@qti-components/transformers": "^1.7.3"
23
23
  },