@qti-components/test 2.0.0-next.11 → 2.0.0-next.13
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/styles.d.ts +11 -0
- package/dist/components/styles.js +65 -2
- package/dist/components/styles.js.map +1 -1
- package/dist/components/test-bookmark/test-bookmark.d.ts +1 -1
- package/dist/components/test-bookmark/test-bookmark.js +22 -39
- package/dist/components/test-bookmark/test-bookmark.js.map +1 -1
- package/dist/components/test-check-item/test-check-item.js +3 -21
- package/dist/components/test-check-item/test-check-item.js.map +1 -1
- package/dist/components/test-end-attempt/test-end-attempt.d.ts +25 -0
- package/dist/components/test-end-attempt/test-end-attempt.js +57 -28
- package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
- package/dist/components/test-item-link/test-item-link.js +3 -21
- package/dist/components/test-item-link/test-item-link.js.map +1 -1
- package/dist/components/test-navigation/test-navigation.d.ts +1 -0
- package/dist/components/test-navigation/test-navigation.js +61 -8
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/components/test-next/test-next.d.ts +1 -1
- package/dist/components/test-next/test-next.js +3 -22
- package/dist/components/test-next/test-next.js.map +1 -1
- package/dist/components/test-prev/test-prev.js +3 -21
- package/dist/components/test-prev/test-prev.js.map +1 -1
- package/dist/components/test-scoring-feedback/test-scoring-feedback.js +2 -2
- package/dist/components/test-scoring-feedback/test-scoring-feedback.js.map +1 -1
- package/dist/components/test-section-link/test-section-link.js +3 -21
- package/dist/components/test-section-link/test-section-link.js.map +1 -1
- package/dist/components/test-submit/test-submit.js +3 -21
- package/dist/components/test-submit/test-submit.js.map +1 -1
- package/dist/public-events.d.ts +7 -1
- package/dist/public-events.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const hostBox: import("lit").CSSResult;
|
|
2
|
+
/** The box of the control itself: the inner element. */
|
|
1
3
|
export declare const form: import("lit").CSSResult;
|
|
2
4
|
export declare const btn: import("lit").CSSResult;
|
|
3
5
|
/** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */
|
|
@@ -12,3 +14,12 @@ export declare const btnPrimaryActive: import("lit").CSSResult;
|
|
|
12
14
|
export declare const focusRing: import("lit").CSSResult;
|
|
13
15
|
export declare const dis: import("lit").CSSResult;
|
|
14
16
|
export declare const ind: import("lit").CSSResult;
|
|
17
|
+
/** What a test control renders: the inner element that carries the look (see `hostBox`). */
|
|
18
|
+
export declare const control: import("lit").TemplateResult<1>;
|
|
19
|
+
/**
|
|
20
|
+
* The stylesheet of a neutral test control: the host box, the look on `.control`, and its hover, press,
|
|
21
|
+
* focus and disabled states. A control with its own content (a bookmark's icon) adds to it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const button: import("lit").CSSResult;
|
|
24
|
+
/** The filled look of `test-next`: add after `button`, so its rules win at equal specificity. */
|
|
25
|
+
export declare const buttonPrimary: import("lit").CSSResult;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// /* eslint-disable lit-plugin(no-invalid-css) */
|
|
2
|
-
import { css } from 'lit';
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
3
|
/*
|
|
4
4
|
* The resting look of the test controls (next, prev, item/section links, TTS buttons).
|
|
5
5
|
*
|
|
@@ -28,8 +28,26 @@ const surface = css `var(--qti-color-base-100, var(--cito-color-base-100, Canvas
|
|
|
28
28
|
const content = css `var(--qti-color-base-content, var(--cito-color-base-content, CanvasText))`;
|
|
29
29
|
const neutral = css `var(--qti-color-neutral, var(--cito-color-neutral, CanvasText))`;
|
|
30
30
|
const neutralContent = css `var(--qti-color-neutral-content, var(--cito-color-neutral-content, Canvas))`;
|
|
31
|
-
|
|
31
|
+
/*
|
|
32
|
+
* A test control is drawn on an inner element (`.control`, part "button"), never on its host.
|
|
33
|
+
*
|
|
34
|
+
* A page's reset, Tailwind's preflight for one (`*, ::before, ::after { margin: 0; padding: 0; border: 0 solid }`),
|
|
35
|
+
* is a rule of the page, and a page rule beats the `:host` rules of a shadow root whatever its layer or its
|
|
36
|
+
* specificity. A control that paints its padding and border on the host loses them to such a reset. The
|
|
37
|
+
* inner element lives in the shadow tree, where the page's `*` does not reach, so the control looks the same with
|
|
38
|
+
* or without a reset. The host keeps only what a reset leaves alone: its display, the radius its focus ring
|
|
39
|
+
* follows, and the cursor.
|
|
40
|
+
*/
|
|
41
|
+
export const hostBox = css `
|
|
32
42
|
display: inline-flex;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
user-select: none;
|
|
45
|
+
border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));
|
|
46
|
+
`;
|
|
47
|
+
/** The box of the control itself: the inner element. */
|
|
48
|
+
export const form = css `
|
|
49
|
+
display: flex;
|
|
50
|
+
flex: 1 1 auto;
|
|
33
51
|
align-items: center;
|
|
34
52
|
justify-content: center;
|
|
35
53
|
gap: 0.375em;
|
|
@@ -94,4 +112,49 @@ export const ind = css `
|
|
|
94
112
|
${form};
|
|
95
113
|
border: var(--qti-border-width, var(--cito-border-width, 1px)) solid var(--qti-border-color, GrayText);
|
|
96
114
|
`;
|
|
115
|
+
/** What a test control renders: the inner element that carries the look (see `hostBox`). */
|
|
116
|
+
export const control = html `<span class="control" part="button"><slot></slot></span>`;
|
|
117
|
+
/**
|
|
118
|
+
* The stylesheet of a neutral test control: the host box, the look on `.control`, and its hover, press,
|
|
119
|
+
* focus and disabled states. A control with its own content (a bookmark's icon) adds to it.
|
|
120
|
+
*/
|
|
121
|
+
export const button = css `
|
|
122
|
+
:host {
|
|
123
|
+
${hostBox};
|
|
124
|
+
}
|
|
125
|
+
.control {
|
|
126
|
+
${btn};
|
|
127
|
+
}
|
|
128
|
+
@media (hover: hover) and (pointer: fine) {
|
|
129
|
+
:host(:hover:not([disabled])) .control {
|
|
130
|
+
${btnInteractive};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
:host(:active:not([disabled])) .control {
|
|
134
|
+
${btnActive};
|
|
135
|
+
}
|
|
136
|
+
:host(:focus-visible) {
|
|
137
|
+
${focusRing};
|
|
138
|
+
}
|
|
139
|
+
:host([disabled]) {
|
|
140
|
+
${dis};
|
|
141
|
+
}
|
|
142
|
+
:host([disabled]) .control {
|
|
143
|
+
cursor: not-allowed;
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
146
|
+
/** The filled look of `test-next`: add after `button`, so its rules win at equal specificity. */
|
|
147
|
+
export const buttonPrimary = css `
|
|
148
|
+
.control {
|
|
149
|
+
${btnPrimary};
|
|
150
|
+
}
|
|
151
|
+
@media (hover: hover) and (pointer: fine) {
|
|
152
|
+
:host(:hover:not([disabled])) .control {
|
|
153
|
+
${btnPrimaryInteractive};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
:host(:active:not([disabled])) .control {
|
|
157
|
+
${btnPrimaryActive};
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
97
160
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,OAAO,GAAG,GAAG,CAAA,+DAA+D,CAAC;AACnF,MAAM,OAAO,GAAG,GAAG,CAAA,2EAA2E,CAAC;AAC/F,MAAM,OAAO,GAAG,GAAG,CAAA,iEAAiE,CAAC;AACrF,MAAM,cAAc,GAAG,GAAG,CAAA,6EAA6E,CAAC;AAExG;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;;;;;CAKzB,CAAC;A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,CAAA;;MAE1B,UAAU;;;;QAIR,qBAAqB;;;;MAIvB,gBAAgB;;CAErB,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css, html } from 'lit';\n\n/*\n * The resting look of the test controls (next, prev, item/section links, TTS buttons).\n *\n * Two looks, both plain: a neutral one (the page's surface, the theme's border, the surrounding text\n * colour) and a filled one that `test-next` wears, in the theme's neutral colour with its content\n * colour on top. No shadow, no glow, no transition, so the controls read as unbranded until a host\n * repaints them.\n *\n * Every colour is the theme's tier 1 (CONTRACT.md §8 in qti-theme), with a CSS system colour behind\n * it for a page that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the\n * controls stay legible in dark mode without the theme too. Hover and press mix the content colour\n * into the fill, by --qti-hover-mix and --qti-active-mix.\n *\n * Paint comes from the `--test-button-*` slots, which repaint the test controls alone, and never\n * from the shared `--qti-component-*` tokens: those also paint the items' own borders, and a change\n * to how a button looks must not move an interaction.\n *\n * --test-button-background-color, --test-button-color, --test-button-border-color,\n * --test-button-hover-background-color, --test-button-active-background-color\n * the neutral look, and the filled look's slots\n * --test-button-primary-background-color, --test-button-primary-color,\n * --test-button-primary-hover-background-color, --test-button-primary-active-background-color\n * the filled look only\n */\n\nconst surface = css`var(--qti-color-base-100, var(--cito-color-base-100, Canvas))`;\nconst content = css`var(--qti-color-base-content, var(--cito-color-base-content, CanvasText))`;\nconst neutral = css`var(--qti-color-neutral, var(--cito-color-neutral, CanvasText))`;\nconst neutralContent = css`var(--qti-color-neutral-content, var(--cito-color-neutral-content, Canvas))`;\n\n/*\n * A test control is drawn on an inner element (`.control`, part \"button\"), never on its host.\n *\n * A page's reset, Tailwind's preflight for one (`*, ::before, ::after { margin: 0; padding: 0; border: 0 solid }`),\n * is a rule of the page, and a page rule beats the `:host` rules of a shadow root whatever its layer or its\n * specificity. A control that paints its padding and border on the host loses them to such a reset. The\n * inner element lives in the shadow tree, where the page's `*` does not reach, so the control looks the same with\n * or without a reset. The host keeps only what a reset leaves alone: its display, the radius its focus ring\n * follows, and the cursor.\n */\nexport const hostBox = css`\n display: inline-flex;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));\n`;\n\n/** The box of the control itself: the inner element. */\nexport const form = css`\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--test-button-size, 2.25rem);\n padding: 0 0.875rem;\n font: inherit;\n line-height: 1.25;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--test-button-background-color, ${surface});\n color: var(--test-button-color, inherit);\n border: var(--qti-border-width, var(--cito-border-width, 1px)) solid\n var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})));\n`;\n\n/** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */\nexport const btnPrimary = css`\n background-color: var(--test-button-primary-background-color, ${neutral});\n color: var(--test-button-primary-color, ${neutralContent});\n border-color: var(--test-button-primary-background-color, ${neutral});\n`;\n\n/** Hover; paint only, so the box never moves. */\nexport const btnInteractive = css`\n background-color: var(\n --test-button-hover-background-color,\n color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%))\n );\n`;\n\nexport const btnPrimaryInteractive = css`\n background-color: var(\n --test-button-primary-hover-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))\n );\n`;\n\n/** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */\nexport const btnActive = css`\n background-color: var(\n --test-button-active-background-color,\n color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%))\n );\n`;\n\nexport const btnPrimaryActive = css`\n background-color: var(\n --test-button-primary-active-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))\n );\n`;\n\n/** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */\nexport const focusRing = css`\n outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, Highlight);\n outline-offset: var(--qti-focus-offset, 2px);\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.45;\n`;\n\nexport const ind = css`\n ${form};\n border: var(--qti-border-width, var(--cito-border-width, 1px)) solid var(--qti-border-color, GrayText);\n`;\n\n/** What a test control renders: the inner element that carries the look (see `hostBox`). */\nexport const control = html`<span class=\"control\" part=\"button\"><slot></slot></span>`;\n\n/**\n * The stylesheet of a neutral test control: the host box, the look on `.control`, and its hover, press,\n * focus and disabled states. A control with its own content (a bookmark's icon) adds to it.\n */\nexport const button = css`\n :host {\n ${hostBox};\n }\n .control {\n ${btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnActive};\n }\n :host(:focus-visible) {\n ${focusRing};\n }\n :host([disabled]) {\n ${dis};\n }\n :host([disabled]) .control {\n cursor: not-allowed;\n }\n`;\n\n/** The filled look of `test-next`: add after `button`, so its rules win at equal specificity. */\nexport const buttonPrimary = css`\n .control {\n ${btnPrimary};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnPrimaryInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnPrimaryActive};\n }\n`;\n"]}
|
|
@@ -34,7 +34,7 @@ export declare class TestBookmark extends LitElement {
|
|
|
34
34
|
item?: string;
|
|
35
35
|
bookmarked: boolean;
|
|
36
36
|
disabled: boolean;
|
|
37
|
-
static styles: import("lit").CSSResult;
|
|
37
|
+
static styles: import("lit").CSSResult[];
|
|
38
38
|
constructor();
|
|
39
39
|
connectedCallback(): void;
|
|
40
40
|
protected willUpdate(): void;
|
|
@@ -42,45 +42,26 @@ const itemRefOf = (element) => {
|
|
|
42
42
|
* @attr disabled - Reflected: there is no item on screen.
|
|
43
43
|
*/
|
|
44
44
|
export class TestBookmark extends LitElement {
|
|
45
|
-
static { this.styles =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
static { this.styles = [
|
|
46
|
+
styles.button,
|
|
47
|
+
css `
|
|
48
|
+
svg {
|
|
49
|
+
width: 1.1em;
|
|
50
|
+
height: 1.1em;
|
|
51
|
+
flex: none;
|
|
52
|
+
fill: none;
|
|
53
|
+
stroke: currentColor;
|
|
54
|
+
stroke-width: 2;
|
|
55
|
+
stroke-linejoin: round;
|
|
52
56
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
svg {
|
|
63
|
-
width: 1.1em;
|
|
64
|
-
height: 1.1em;
|
|
65
|
-
flex: none;
|
|
66
|
-
fill: none;
|
|
67
|
-
stroke: currentColor;
|
|
68
|
-
stroke-width: 2;
|
|
69
|
-
stroke-linejoin: round;
|
|
70
|
-
}
|
|
71
|
-
:host([bookmarked]) {
|
|
72
|
-
color: var(--qti-bookmark-color, #b45309);
|
|
73
|
-
}
|
|
74
|
-
:host([bookmarked]) svg {
|
|
75
|
-
fill: currentColor;
|
|
76
|
-
}
|
|
77
|
-
:host(:focus-visible) {
|
|
78
|
-
${styles.focusRing};
|
|
79
|
-
}
|
|
80
|
-
:host([disabled]) {
|
|
81
|
-
${styles.dis};
|
|
82
|
-
}
|
|
83
|
-
`; }
|
|
57
|
+
:host([bookmarked]) {
|
|
58
|
+
color: var(--qti-bookmark-color, #b45309);
|
|
59
|
+
}
|
|
60
|
+
:host([bookmarked]) svg {
|
|
61
|
+
fill: currentColor;
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
]; }
|
|
84
65
|
constructor() {
|
|
85
66
|
super();
|
|
86
67
|
this.bookmarked = false;
|
|
@@ -130,7 +111,9 @@ export class TestBookmark extends LitElement {
|
|
|
130
111
|
});
|
|
131
112
|
}
|
|
132
113
|
render() {
|
|
133
|
-
return html `<
|
|
114
|
+
return html `<span class="control" part="button"
|
|
115
|
+
><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot
|
|
116
|
+
></span>`;
|
|
134
117
|
}
|
|
135
118
|
}
|
|
136
119
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAqD,EAAY,EAAE,CACjG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AAE1C,2HAA2H;AAC3H,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAsB,EAAE;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC3D,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,SAA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;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACa;AAEf;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAoB;AAEnB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { consume } from '@lit/context';\nimport { property } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { pluginState } from '../../plugin-state';\n\nimport type { ComputedContext } from '@qti-components/base';\n\ndeclare module '../../types/qti-test-state' {\n interface QtiTestPluginState {\n /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */\n bookmarks: string[];\n }\n}\n\n/** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */\nexport const bookmarkedItems = (context: Pick<ComputedContext, 'plugins'> | undefined): string[] =>\n pluginState(context, 'bookmarks') ?? [];\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A toggle that marks the item on screen to come back to. The marks live in the test's state under\n * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a\n * reloaded test shows them again.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in\n * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button\n * (`role=\"button\"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is\n * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads\n * the marks with `bookmarkedItems(computedContext)`.\n *\n * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a\n * stamp template that lists the items of a section, `<test-bookmark item=\"{{ item.identifier }}\">`\n * puts a button next to each one.\n *\n * @slot - The label.\n * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.\n * @attr bookmarked - Reflected: the item on screen is bookmarked.\n * @attr disabled - Reflected: there is no item on screen.\n */\nexport class TestBookmark extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext?: ComputedContext;\n\n @property({ reflect: true }) item?: string;\n\n @property({ type: Boolean, reflect: true }) bookmarked = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n static override styles = [\n styles.button,\n css`\n svg {\n width: 1.1em;\n height: 1.1em;\n flex: none;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n }\n :host([bookmarked]) {\n color: var(--qti-bookmark-color, #b45309);\n }\n :host([bookmarked]) svg {\n fill: currentColor;\n }\n `\n ];\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#toggle());\n this.addEventListener('keydown', event => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n this.#toggle();\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'button');\n if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', '0');\n }\n\n /** The item this button marks: its own, or else the one on screen. */\n get #activeItem(): string | undefined {\n return (\n this.item ||\n (itemRefOf(this) ??\n this.computedContext?.testParts\n ?.flatMap(part => part.sections.flatMap(section => section.items))\n .find(item => item.active)?.identifier)\n );\n }\n\n protected override willUpdate(): void {\n const active = this.#activeItem;\n this.disabled = !active;\n this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);\n }\n\n protected override updated(): void {\n this.setAttribute('aria-pressed', String(this.bookmarked));\n this.setAttribute('aria-disabled', String(this.disabled));\n }\n\n #toggle(): void {\n const active = this.#activeItem;\n if (!active) return;\n const marked = bookmarkedItems(this.computedContext);\n const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];\n // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.\n dispatchPublic(this, 'cito-test-update-plugin-state', {\n plugin: 'bookmarks',\n value: next.length > 0 ? next : null\n });\n }\n\n override render() {\n return html`<span class=\"control\" part=\"button\"\n ><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot\n ></span>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { LitElement } from 'lit';
|
|
8
8
|
import { property } from 'lit/decorators.js';
|
|
9
9
|
import * as styles from '../styles';
|
|
10
10
|
import { dispatchPublic } from '../../public-events';
|
|
@@ -16,25 +16,7 @@ import { dispatchPublic } from '../../public-events';
|
|
|
16
16
|
* @attr view - The view to switch to after the attempt ended.
|
|
17
17
|
*/
|
|
18
18
|
export class TestCheckItem extends LitElement {
|
|
19
|
-
static { this.styles =
|
|
20
|
-
:host {
|
|
21
|
-
${styles.btn};
|
|
22
|
-
}
|
|
23
|
-
@media (hover: hover) and (pointer: fine) {
|
|
24
|
-
:host(:hover:not([disabled])) {
|
|
25
|
-
${styles.btnInteractive};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
:host(:active:not([disabled])) {
|
|
29
|
-
${styles.btnActive};
|
|
30
|
-
}
|
|
31
|
-
:host(:focus-visible) {
|
|
32
|
-
${styles.focusRing};
|
|
33
|
-
}
|
|
34
|
-
:host([disabled]) {
|
|
35
|
-
${styles.dis};
|
|
36
|
-
}
|
|
37
|
-
`; }
|
|
19
|
+
static { this.styles = styles.button; }
|
|
38
20
|
constructor() {
|
|
39
21
|
super();
|
|
40
22
|
this.view = 'scorer';
|
|
@@ -44,7 +26,7 @@ export class TestCheckItem extends LitElement {
|
|
|
44
26
|
});
|
|
45
27
|
}
|
|
46
28
|
render() {
|
|
47
|
-
return
|
|
29
|
+
return styles.control;
|
|
48
30
|
}
|
|
49
31
|
}
|
|
50
32
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;aAG3B,WAAM,GAAG,MAAM,CAAC,MAAM,AAAhB,CAAiB;IAEvC;QACE,KAAK,EAAE,CAAC;QALkB,SAAI,GAAS,QAAQ,CAAC;QAMhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAd2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { View } from '@qti-components/base';\n\n/**\n * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which\n * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until\n * something switches it back (`test-view-toggle`).\n *\n * @attr view - The view to switch to after the attempt ended.\n */\nexport class TestCheckItem extends LitElement {\n @property({ type: String }) view: View = 'scorer';\n\n static override styles = styles.button;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n dispatchPublic(this, 'cito-test-switch-view', this.view);\n });\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import type { ComputedContext } from '@qti-components/base';
|
|
3
|
+
/**
|
|
4
|
+
* A button that ends the attempt of an item: its response is processed, `numAttempts` goes up and
|
|
5
|
+
* feedback is shown as the item's session control allows. It dispatches `cito-test-end-attempt`,
|
|
6
|
+
* which `<test-navigation>` handles.
|
|
7
|
+
*
|
|
8
|
+
* Put it inside `<test-navigation>`, either in the toolbar, where it ends the attempt of the item on
|
|
9
|
+
* screen, or in the `<template item-ref>`, where each item gets its own and it ends the attempt of
|
|
10
|
+
* that item: with `<qti-test navigate="section">` every item of the section is on screen, each with
|
|
11
|
+
* its own button. Give it an `item` (an item-ref identifier) to end the attempt of that item instead,
|
|
12
|
+
* wherever the button sits.
|
|
13
|
+
*
|
|
14
|
+
* It is `disabled` by the state of its item: when the attempts allowed by `max-attempts` are used
|
|
15
|
+
* (non-adaptive items), when the last attempt was already optimal (non-adaptive items), when an
|
|
16
|
+
* adaptive item is completed, or, when skipping is not allowed, while the response is invalid or
|
|
17
|
+
* still the default.
|
|
18
|
+
*
|
|
19
|
+
* @slot - The label.
|
|
20
|
+
* @attr require-answer - Also disabled while the response is invalid or still the default, without `allow-skipping="false"` (which is about leaving an item, not about ending its attempt).
|
|
21
|
+
* @attr item - The item-ref identifier whose attempt this button ends; without it, the item it is stamped into, or else the one on screen.
|
|
22
|
+
* @attr disabled - Reflected: the item's attempt cannot be ended.
|
|
23
|
+
*/
|
|
3
24
|
export declare class TestEndAttempt extends LitElement {
|
|
25
|
+
#private;
|
|
4
26
|
protected computedContext: ComputedContext;
|
|
5
27
|
_internalDisabled: boolean;
|
|
28
|
+
item?: string;
|
|
29
|
+
/** Ends no attempt until the response is valid and not the default, whatever the item's `allow-skipping` says. */
|
|
30
|
+
requireAnswer: boolean;
|
|
6
31
|
_handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext): void;
|
|
7
32
|
static styles: import("lit").CSSResult;
|
|
8
33
|
constructor();
|
|
@@ -4,58 +4,81 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { LitElement } from 'lit';
|
|
8
8
|
import { property } from 'lit/decorators.js';
|
|
9
9
|
import { consume } from '@lit/context';
|
|
10
10
|
import { computedContext } from '@qti-components/base';
|
|
11
11
|
import { watch } from '@qti-components/utilities';
|
|
12
12
|
import * as styles from '../styles';
|
|
13
13
|
import { dispatchPublic } from '../../public-events';
|
|
14
|
+
/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */
|
|
15
|
+
const itemRefOf = (element) => {
|
|
16
|
+
const itemRef = element.closest('qti-assessment-item-ref');
|
|
17
|
+
if (itemRef)
|
|
18
|
+
return itemRef.getAttribute('identifier') ?? undefined;
|
|
19
|
+
const root = element.getRootNode();
|
|
20
|
+
return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A button that ends the attempt of an item: its response is processed, `numAttempts` goes up and
|
|
24
|
+
* feedback is shown as the item's session control allows. It dispatches `cito-test-end-attempt`,
|
|
25
|
+
* which `<test-navigation>` handles.
|
|
26
|
+
*
|
|
27
|
+
* Put it inside `<test-navigation>`, either in the toolbar, where it ends the attempt of the item on
|
|
28
|
+
* screen, or in the `<template item-ref>`, where each item gets its own and it ends the attempt of
|
|
29
|
+
* that item: with `<qti-test navigate="section">` every item of the section is on screen, each with
|
|
30
|
+
* its own button. Give it an `item` (an item-ref identifier) to end the attempt of that item instead,
|
|
31
|
+
* wherever the button sits.
|
|
32
|
+
*
|
|
33
|
+
* It is `disabled` by the state of its item: when the attempts allowed by `max-attempts` are used
|
|
34
|
+
* (non-adaptive items), when the last attempt was already optimal (non-adaptive items), when an
|
|
35
|
+
* adaptive item is completed, or, when skipping is not allowed, while the response is invalid or
|
|
36
|
+
* still the default.
|
|
37
|
+
*
|
|
38
|
+
* @slot - The label.
|
|
39
|
+
* @attr require-answer - Also disabled while the response is invalid or still the default, without `allow-skipping="false"` (which is about leaving an item, not about ending its attempt).
|
|
40
|
+
* @attr item - The item-ref identifier whose attempt this button ends; without it, the item it is stamped into, or else the one on screen.
|
|
41
|
+
* @attr disabled - Reflected: the item's attempt cannot be ended.
|
|
42
|
+
*/
|
|
14
43
|
export class TestEndAttempt extends LitElement {
|
|
15
44
|
_handleTestElementChange(_oldValue, newValue) {
|
|
16
45
|
if (newValue) {
|
|
17
46
|
this.requestUpdate();
|
|
18
47
|
}
|
|
19
48
|
}
|
|
20
|
-
static { this.styles =
|
|
21
|
-
:host {
|
|
22
|
-
${styles.btn};
|
|
23
|
-
}
|
|
24
|
-
@media (hover: hover) and (pointer: fine) {
|
|
25
|
-
:host(:hover:not([disabled])) {
|
|
26
|
-
${styles.btnInteractive};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
:host(:active:not([disabled])) {
|
|
30
|
-
${styles.btnActive};
|
|
31
|
-
}
|
|
32
|
-
:host(:focus-visible) {
|
|
33
|
-
${styles.focusRing};
|
|
34
|
-
}
|
|
35
|
-
:host([disabled]) {
|
|
36
|
-
${styles.dis};
|
|
37
|
-
}
|
|
38
|
-
`; }
|
|
49
|
+
static { this.styles = styles.button; }
|
|
39
50
|
constructor() {
|
|
40
51
|
super();
|
|
41
52
|
this._internalDisabled = false;
|
|
53
|
+
/** Ends no attempt until the response is valid and not the default, whatever the item's `allow-skipping` says. */
|
|
54
|
+
this.requireAnswer = false;
|
|
42
55
|
this.addEventListener('click', e => {
|
|
43
56
|
e.preventDefault();
|
|
44
57
|
if (!this._internalDisabled) {
|
|
45
|
-
|
|
58
|
+
// An item of its own goes along, so the navigation ends that item's attempt and not the
|
|
59
|
+
// one on screen; without one, the navigation takes the item on screen, as before.
|
|
60
|
+
const itemId = this.#ownItem;
|
|
61
|
+
dispatchPublic(this, 'cito-test-end-attempt', itemId ? { itemId } : {});
|
|
46
62
|
}
|
|
47
63
|
});
|
|
48
64
|
}
|
|
65
|
+
/** The item named by `item`, or else the item-ref it is stamped into. */
|
|
66
|
+
get #ownItem() {
|
|
67
|
+
return this.item || itemRefOf(this);
|
|
68
|
+
}
|
|
49
69
|
willUpdate(_changedProperties) {
|
|
50
70
|
this.checkDisabled();
|
|
51
71
|
}
|
|
52
72
|
checkDisabled() {
|
|
53
|
-
const
|
|
54
|
-
|
|
73
|
+
const testParts = this.computedContext?.testParts;
|
|
74
|
+
const ownItem = this.#ownItem;
|
|
75
|
+
const testPart = testParts?.find(testPart => testPart.active);
|
|
76
|
+
if (!testParts || (!ownItem && !testPart))
|
|
55
77
|
return;
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
78
|
+
// Its own item wherever it is in the test, or else the item on screen in the active part.
|
|
79
|
+
const activeItem = ownItem
|
|
80
|
+
? testParts.flatMap(part => part.sections.flatMap(section => section.items)).find(i => i.identifier === ownItem)
|
|
81
|
+
: testPart.sections.flatMap(section => section.items).find(item => item.active);
|
|
59
82
|
if (!activeItem) {
|
|
60
83
|
this._internalDisabled = false;
|
|
61
84
|
return;
|
|
@@ -80,7 +103,7 @@ export class TestEndAttempt extends LitElement {
|
|
|
80
103
|
this._internalDisabled = true;
|
|
81
104
|
return;
|
|
82
105
|
}
|
|
83
|
-
if (activeItem.allowSkipping === false) {
|
|
106
|
+
if (this.requireAnswer || activeItem.allowSkipping === false) {
|
|
84
107
|
this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;
|
|
85
108
|
}
|
|
86
109
|
else {
|
|
@@ -88,7 +111,7 @@ export class TestEndAttempt extends LitElement {
|
|
|
88
111
|
}
|
|
89
112
|
}
|
|
90
113
|
render() {
|
|
91
|
-
return
|
|
114
|
+
return styles.control;
|
|
92
115
|
}
|
|
93
116
|
}
|
|
94
117
|
__decorate([
|
|
@@ -98,6 +121,12 @@ __decorate([
|
|
|
98
121
|
__decorate([
|
|
99
122
|
property({ type: Boolean, reflect: true, attribute: 'disabled' })
|
|
100
123
|
], TestEndAttempt.prototype, "_internalDisabled", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ reflect: true })
|
|
126
|
+
], TestEndAttempt.prototype, "item", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
property({ type: Boolean, reflect: true, attribute: 'require-answer' })
|
|
129
|
+
], TestEndAttempt.prototype, "requireAnswer", void 0);
|
|
101
130
|
__decorate([
|
|
102
131
|
watch('computedContext')
|
|
103
132
|
], TestEndAttempt.prototype, "_handleTestElementChange", null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":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;IACxB,CAAC;;AAzFS;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDACY;AAGpC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAEJ;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAe;AAG8B;IAAxE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;qDAAuB;AAG/F;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext } from '@qti-components/base';\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A button that ends the attempt of an item: its response is processed, `numAttempts` goes up and\n * feedback is shown as the item's session control allows. It dispatches `cito-test-end-attempt`,\n * which `<test-navigation>` handles.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it ends the attempt of the item on\n * screen, or in the `<template item-ref>`, where each item gets its own and it ends the attempt of\n * that item: with `<qti-test navigate=\"section\">` every item of the section is on screen, each with\n * its own button. Give it an `item` (an item-ref identifier) to end the attempt of that item instead,\n * wherever the button sits.\n *\n * It is `disabled` by the state of its item: when the attempts allowed by `max-attempts` are used\n * (non-adaptive items), when the last attempt was already optimal (non-adaptive items), when an\n * adaptive item is completed, or, when skipping is not allowed, while the response is invalid or\n * still the default.\n *\n * @slot - The label.\n * @attr require-answer - Also disabled while the response is invalid or still the default, without `allow-skipping=\"false\"` (which is about leaving an item, not about ending its attempt).\n * @attr item - The item-ref identifier whose attempt this button ends; without it, the item it is stamped into, or else the one on screen.\n * @attr disabled - Reflected: the item's attempt cannot be ended.\n */\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @property({ reflect: true }) item?: string;\n\n /** Ends no attempt until the response is valid and not the default, whatever the item's `allow-skipping` says. */\n @property({ type: Boolean, reflect: true, attribute: 'require-answer' }) requireAnswer = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = styles.button;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n // An item of its own goes along, so the navigation ends that item's attempt and not the\n // one on screen; without one, the navigation takes the item on screen, as before.\n const itemId = this.#ownItem;\n dispatchPublic(this, 'cito-test-end-attempt', itemId ? { itemId } : {});\n }\n });\n }\n\n /** The item named by `item`, or else the item-ref it is stamped into. */\n get #ownItem(): string | undefined {\n return this.item || itemRefOf(this);\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testParts = this.computedContext?.testParts;\n const ownItem = this.#ownItem;\n const testPart = testParts?.find(testPart => testPart.active);\n if (!testParts || (!ownItem && !testPart)) return;\n // Its own item wherever it is in the test, or else the item on screen in the active part.\n const activeItem = ownItem\n ? testParts.flatMap(part => part.sections.flatMap(section => section.items)).find(i => i.identifier === ownItem)\n : testPart.sections.flatMap(section => section.items).find(item => item.active);\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // An adaptive item ends itself: once its response processing set completionStatus\n // to 'completed', there is no next attempt.\n if (activeItem.adaptive && activeItem.completionStatus === 'completed') {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (this.requireAnswer || activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
|
|
@@ -4,30 +4,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { LitElement } from 'lit';
|
|
8
8
|
import { property } from 'lit/decorators.js';
|
|
9
9
|
import * as styles from '../styles';
|
|
10
10
|
import { dispatchPublic } from '../../public-events';
|
|
11
11
|
export class TestItemLink extends LitElement {
|
|
12
|
-
static { this.styles =
|
|
13
|
-
:host {
|
|
14
|
-
${styles.btn};
|
|
15
|
-
}
|
|
16
|
-
@media (hover: hover) and (pointer: fine) {
|
|
17
|
-
:host(:hover:not([disabled])) {
|
|
18
|
-
${styles.btnInteractive};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
:host(:active:not([disabled])) {
|
|
22
|
-
${styles.btnActive};
|
|
23
|
-
}
|
|
24
|
-
:host(:focus-visible) {
|
|
25
|
-
${styles.focusRing};
|
|
26
|
-
}
|
|
27
|
-
:host([disabled]) {
|
|
28
|
-
${styles.dis};
|
|
29
|
-
}
|
|
30
|
-
`; }
|
|
12
|
+
static { this.styles = styles.button; }
|
|
31
13
|
constructor() {
|
|
32
14
|
super();
|
|
33
15
|
this.itemId = null;
|
|
@@ -37,7 +19,7 @@ export class TestItemLink extends LitElement {
|
|
|
37
19
|
dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });
|
|
38
20
|
}
|
|
39
21
|
render() {
|
|
40
|
-
return
|
|
22
|
+
return styles.control;
|
|
41
23
|
}
|
|
42
24
|
}
|
|
43
25
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,MAAM,CAAC,MAAM,AAAhB,CAAiB;IAKvC;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = styles.button;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return styles.control;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
|
|
@@ -41,6 +41,7 @@ export declare class TestNavigation extends LitElement {
|
|
|
41
41
|
protected get activeAssessmentItem(): QtiAssessmentItem | undefined;
|
|
42
42
|
render(): import("lit").TemplateResult<1>;
|
|
43
43
|
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
44
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
44
45
|
}
|
|
45
46
|
declare global {
|
|
46
47
|
interface HTMLElementTagNameMap {
|