@citolab/qti-components 10.0.0-next.3 → 10.0.0-next.5
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/cdn/index.global.js +1 -1
- package/cdn/index.js +330 -297
- package/dist/base.d.ts +4 -4
- package/dist/base.js +1 -1
- package/dist/{chunk-SIE3E4FG.js → chunk-A2AP6CUL.js} +2097 -2036
- package/dist/chunk-A2AP6CUL.js.map +1 -0
- package/dist/{chunk-MI7774NV.js → chunk-CXTHPEUN.js} +2 -2
- package/dist/{chunk-FD4AB6TM.js → chunk-F7QDRKCR.js} +2 -2
- package/dist/{chunk-RU6332MD.js → chunk-JNZ3HSFI.js} +2 -2
- package/dist/{chunk-TDWJ6WZA.js → chunk-JZZMY3FA.js} +1 -1
- package/dist/chunk-JZZMY3FA.js.map +1 -0
- package/dist/{chunk-D3BYGEQU.js → chunk-KB2NJTSD.js} +6 -6
- package/dist/{chunk-GBZNFSFY.js → chunk-O5HGNYB2.js} +2 -2
- package/dist/{chunk-6U3YPHXU.js → chunk-QU23PPEZ.js} +2 -2
- package/dist/{chunk-6K3QWJHH.js → chunk-R7ZCUQU2.js} +2 -2
- package/dist/{chunk-RSMYGGQK.js → chunk-WC3P4KCV.js} +2 -2
- package/dist/{chunk-OQDBARD5.js → chunk-WV53LUE3.js} +2 -2
- package/dist/{chunk-35WWWFS6.js → chunk-WVDQLBMT.js} +2 -2
- package/dist/{computed.types.d-gJrBeUMG.d.ts → computed.types.d-DvxBgnze.d.ts} +10 -1
- package/dist/corrections.d.ts +4 -4
- package/dist/corrections.js +7 -7
- package/dist/elements.js +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +22 -18
- package/dist/interactions.js +3 -3
- package/dist/item.d.ts +2 -2
- package/dist/item.js +3 -3
- package/dist/processing.js +3 -3
- package/dist/qti-components-jsx.d.ts +777 -753
- package/dist/{qti-item.d-DgC1AQbY.d.ts → qti-item.d-klsgIEKQ.d.ts} +1 -1
- package/dist/{qti-test.d-86TlaMlI.d.ts → qti-test.d-Cra3sS-2.d.ts} +124 -97
- package/dist/{session.context.d-D5080LVx.d.ts → session.context.d-DYAdqSer.d.ts} +6 -0
- package/dist/test.d.ts +111 -6
- package/dist/test.js +14 -10
- package/package.json +8 -8
- package/dist/chunk-SIE3E4FG.js.map +0 -1
- package/dist/chunk-TDWJ6WZA.js.map +0 -1
- /package/dist/{chunk-MI7774NV.js.map → chunk-CXTHPEUN.js.map} +0 -0
- /package/dist/{chunk-FD4AB6TM.js.map → chunk-F7QDRKCR.js.map} +0 -0
- /package/dist/{chunk-RU6332MD.js.map → chunk-JNZ3HSFI.js.map} +0 -0
- /package/dist/{chunk-D3BYGEQU.js.map → chunk-KB2NJTSD.js.map} +0 -0
- /package/dist/{chunk-GBZNFSFY.js.map → chunk-O5HGNYB2.js.map} +0 -0
- /package/dist/{chunk-6U3YPHXU.js.map → chunk-QU23PPEZ.js.map} +0 -0
- /package/dist/{chunk-6K3QWJHH.js.map → chunk-R7ZCUQU2.js.map} +0 -0
- /package/dist/{chunk-RSMYGGQK.js.map → chunk-WC3P4KCV.js.map} +0 -0
- /package/dist/{chunk-OQDBARD5.js.map → chunk-WV53LUE3.js.map} +0 -0
- /package/dist/{chunk-35WWWFS6.js.map → chunk-WVDQLBMT.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
dispatchDeclared,
|
|
4
4
|
listenDeclared,
|
|
5
5
|
listenPublic
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QU23PPEZ.js";
|
|
7
7
|
import {
|
|
8
8
|
item_css_default
|
|
9
9
|
} from "./chunk-ZP6QQYSU.js";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
qtiContext,
|
|
25
25
|
sessionContext,
|
|
26
26
|
testContext
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-JZZMY3FA.js";
|
|
28
28
|
|
|
29
29
|
// ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
|
|
30
30
|
import { LitElement, nothing as nothing2 } from "lit";
|
|
@@ -636,18 +636,18 @@ var EvalAstFactory = class {
|
|
|
636
636
|
}
|
|
637
637
|
const value = this.right.evaluate(scope);
|
|
638
638
|
let receiver = void 0;
|
|
639
|
-
let
|
|
639
|
+
let property24;
|
|
640
640
|
if (this.left.type === "Getter") {
|
|
641
641
|
receiver = this.left.receiver.evaluate(scope);
|
|
642
|
-
|
|
642
|
+
property24 = this.left.name;
|
|
643
643
|
} else if (this.left.type === "Index") {
|
|
644
644
|
receiver = this.left.receiver.evaluate(scope);
|
|
645
|
-
|
|
645
|
+
property24 = this.left.argument.evaluate(scope);
|
|
646
646
|
} else if (this.left.type === "ID") {
|
|
647
647
|
receiver = scope;
|
|
648
|
-
|
|
648
|
+
property24 = this.left.value;
|
|
649
649
|
}
|
|
650
|
-
return receiver === void 0 ? void 0 : receiver[
|
|
650
|
+
return receiver === void 0 ? void 0 : receiver[property24] = value;
|
|
651
651
|
}
|
|
652
652
|
return f(this.left.evaluate(scope), this.right.evaluate(scope));
|
|
653
653
|
},
|
|
@@ -1108,6 +1108,7 @@ var PUBLIC_EVENTS = {
|
|
|
1108
1108
|
"cito-test-navigate": { kind: "request", scope: "test", deprecated: "qti-request-navigation" },
|
|
1109
1109
|
"cito-test-end-attempt": { kind: "request", scope: "test", deprecated: "test-end-attempt" },
|
|
1110
1110
|
"cito-test-update-outcome": { kind: "request", scope: "test", deprecated: "test-update-outcome-variable" },
|
|
1111
|
+
"cito-test-update-plugin-state": { kind: "request", scope: "test" },
|
|
1111
1112
|
"cito-test-switch-view": { kind: "request", scope: "test", deprecated: "on-test-switch-view" },
|
|
1112
1113
|
"cito-test-navigated": { kind: "notification", scope: "test" },
|
|
1113
1114
|
"cito-test-navigation-started": {
|
|
@@ -2674,6 +2675,7 @@ var toState = (test, session) => ({
|
|
|
2674
2675
|
outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
|
|
2675
2676
|
},
|
|
2676
2677
|
session: {
|
|
2678
|
+
...session?.plugins && Object.keys(session.plugins).length > 0 ? { plugins: { ...session.plugins } } : {},
|
|
2677
2679
|
...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
|
|
2678
2680
|
...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
|
|
2679
2681
|
...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
|
|
@@ -2696,6 +2698,7 @@ var TestStateMixin = (superClass) => {
|
|
|
2696
2698
|
this.#ready = false;
|
|
2697
2699
|
this.#lastEmitted = null;
|
|
2698
2700
|
});
|
|
2701
|
+
listenPublic2(this, "cito-test-update-plugin-state", ({ detail }) => this.#updatePluginState(detail));
|
|
2699
2702
|
listenPublic2(this, "cito-test-loaded", () => {
|
|
2700
2703
|
if (this.#pending) {
|
|
2701
2704
|
this.#apply(this.#pending);
|
|
@@ -2704,6 +2707,22 @@ var TestStateMixin = (superClass) => {
|
|
|
2704
2707
|
this.#ready = true;
|
|
2705
2708
|
});
|
|
2706
2709
|
}
|
|
2710
|
+
/** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */
|
|
2711
|
+
#updatePluginState({ plugin, value }) {
|
|
2712
|
+
if (typeof plugin !== "string" || plugin === "")
|
|
2713
|
+
return;
|
|
2714
|
+
const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};
|
|
2715
|
+
let next = others;
|
|
2716
|
+
if (value !== null && value !== void 0) {
|
|
2717
|
+
try {
|
|
2718
|
+
next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };
|
|
2719
|
+
} catch {
|
|
2720
|
+
console.warn(`[qti-test] Ignoring plugin state for "${plugin}": it is not JSON.`);
|
|
2721
|
+
return;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
this.sessionContext = { ...this.sessionContext, plugins: next };
|
|
2725
|
+
}
|
|
2707
2726
|
get state() {
|
|
2708
2727
|
return toState(this.testContext, this.sessionContext);
|
|
2709
2728
|
}
|
|
@@ -2744,7 +2763,11 @@ var TestStateMixin = (superClass) => {
|
|
|
2744
2763
|
...this.testContext,
|
|
2745
2764
|
testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
|
|
2746
2765
|
};
|
|
2747
|
-
this.sessionContext = {
|
|
2766
|
+
this.sessionContext = {
|
|
2767
|
+
...this.sessionContext,
|
|
2768
|
+
...this.#validSession(state9.session),
|
|
2769
|
+
plugins: state9.session.plugins && typeof state9.session.plugins === "object" ? { ...state9.session.plugins } : {}
|
|
2770
|
+
};
|
|
2748
2771
|
}
|
|
2749
2772
|
/** A stored position may point at an item or section a revised test no longer has. */
|
|
2750
2773
|
#validSession(session) {
|
|
@@ -2870,106 +2893,18 @@ __decorate12([
|
|
|
2870
2893
|
provide2({ context: qtiContext })
|
|
2871
2894
|
], QtiTest.prototype, "qtiContext", void 0);
|
|
2872
2895
|
|
|
2873
|
-
// ../qti-test/dist/components/test-check-item/test-check-item.js
|
|
2874
|
-
import { consume as consume6 } from "@lit/context";
|
|
2875
|
-
import { css as css6, html as html10, LitElement as LitElement11 } from "lit";
|
|
2876
|
-
|
|
2877
|
-
// ../qti-test/dist/components/styles.js
|
|
2878
|
-
import { css as css5 } from "lit";
|
|
2879
|
-
var form = css5`
|
|
2880
|
-
display: inline-flex;
|
|
2881
|
-
align-items: center;
|
|
2882
|
-
justify-content: center;
|
|
2883
|
-
gap: 0.375em;
|
|
2884
|
-
box-sizing: border-box;
|
|
2885
|
-
min-block-size: var(--test-button-size, 2.25rem);
|
|
2886
|
-
padding: 0 0.875rem;
|
|
2887
|
-
font: inherit;
|
|
2888
|
-
line-height: 1.25;
|
|
2889
|
-
cursor: pointer;
|
|
2890
|
-
user-select: none;
|
|
2891
|
-
border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
|
|
2892
|
-
`;
|
|
2893
|
-
var btn = css5`
|
|
2894
|
-
${form};
|
|
2895
|
-
background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
|
|
2896
|
-
color: var(--test-button-color, var(--qti-component-color, inherit));
|
|
2897
|
-
border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
|
|
2898
|
-
var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
|
|
2899
|
-
`;
|
|
2900
|
-
var btnInteractive = css5`
|
|
2901
|
-
background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
|
|
2902
|
-
`;
|
|
2903
|
-
var focusRing = css5`
|
|
2904
|
-
outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
|
|
2905
|
-
outline-offset: 2px;
|
|
2906
|
-
`;
|
|
2907
|
-
var dis = css5`
|
|
2908
|
-
cursor: not-allowed;
|
|
2909
|
-
opacity: 0.45;
|
|
2910
|
-
`;
|
|
2911
|
-
var ind = css5`
|
|
2912
|
-
${form};
|
|
2913
|
-
border: 1px solid gray;
|
|
2914
|
-
`;
|
|
2915
|
-
|
|
2916
|
-
// ../qti-test/dist/components/test-check-item/test-check-item.js
|
|
2917
|
-
var __decorate13 = function(decorators, target, key, desc) {
|
|
2918
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2919
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2920
|
-
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;
|
|
2921
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2922
|
-
};
|
|
2923
|
-
var TestCheckItem = class extends LitElement11 {
|
|
2924
|
-
static {
|
|
2925
|
-
this.styles = css6`
|
|
2926
|
-
:host {
|
|
2927
|
-
${btn};
|
|
2928
|
-
}
|
|
2929
|
-
:host(:hover:not([disabled])) {
|
|
2930
|
-
${btnInteractive};
|
|
2931
|
-
}
|
|
2932
|
-
:host(:focus-visible) {
|
|
2933
|
-
${focusRing};
|
|
2934
|
-
}
|
|
2935
|
-
:host([disabled]) {
|
|
2936
|
-
${dis};
|
|
2937
|
-
}
|
|
2938
|
-
`;
|
|
2939
|
-
}
|
|
2940
|
-
constructor() {
|
|
2941
|
-
super();
|
|
2942
|
-
this.addEventListener("click", () => {
|
|
2943
|
-
dispatchPublic(this, "cito-test-end-attempt", {});
|
|
2944
|
-
const testContainer = this.testHost?.querySelector("test-container");
|
|
2945
|
-
if (!testContainer)
|
|
2946
|
-
return;
|
|
2947
|
-
const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
|
|
2948
|
-
viewElements.forEach((element) => {
|
|
2949
|
-
element.classList.toggle("show", true);
|
|
2950
|
-
});
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
render() {
|
|
2954
|
-
return html10` <slot></slot> `;
|
|
2955
|
-
}
|
|
2956
|
-
};
|
|
2957
|
-
__decorate13([
|
|
2958
|
-
consume6({ context: testHostContext, subscribe: true })
|
|
2959
|
-
], TestCheckItem.prototype, "testHost", void 0);
|
|
2960
|
-
|
|
2961
2896
|
// ../qti-test/dist/components/test-container/test-container.js
|
|
2962
|
-
import { consume as
|
|
2963
|
-
import { LitElement as
|
|
2897
|
+
import { consume as consume6 } from "@lit/context";
|
|
2898
|
+
import { LitElement as LitElement11, html as html10 } from "lit";
|
|
2964
2899
|
import { property as property10, state as state3 } from "lit/decorators.js";
|
|
2965
2900
|
import { until } from "lit/directives/until.js";
|
|
2966
|
-
var
|
|
2901
|
+
var __decorate13 = function(decorators, target, key, desc) {
|
|
2967
2902
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2968
2903
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2969
2904
|
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;
|
|
2970
2905
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2971
2906
|
};
|
|
2972
|
-
var TestContainer = class extends
|
|
2907
|
+
var TestContainer = class extends LitElement11 {
|
|
2973
2908
|
constructor() {
|
|
2974
2909
|
super(...arguments);
|
|
2975
2910
|
this.customElementRegistry = null;
|
|
@@ -3054,7 +2989,7 @@ var TestContainer = class extends LitElement12 {
|
|
|
3054
2989
|
}
|
|
3055
2990
|
#initializeTemplateContent() {
|
|
3056
2991
|
const template = this.querySelector("template");
|
|
3057
|
-
this.#templateContent = template ? template.content :
|
|
2992
|
+
this.#templateContent = template ? template.content : html10``;
|
|
3058
2993
|
}
|
|
3059
2994
|
#applyStyles() {
|
|
3060
2995
|
const sheet = new CSSStyleSheet();
|
|
@@ -3062,57 +2997,98 @@ var TestContainer = class extends LitElement12 {
|
|
|
3062
2997
|
this.shadowRoot.adoptedStyleSheets = [sheet];
|
|
3063
2998
|
}
|
|
3064
2999
|
render() {
|
|
3065
|
-
return
|
|
3000
|
+
return html10`
|
|
3066
3001
|
${this.#templateContent}
|
|
3067
3002
|
<slot></slot>
|
|
3068
|
-
${until(this.testDoc,
|
|
3003
|
+
${until(this.testDoc, html10`<span>Loading...</span>`)}
|
|
3069
3004
|
`;
|
|
3070
3005
|
}
|
|
3071
3006
|
};
|
|
3072
|
-
|
|
3007
|
+
__decorate13([
|
|
3073
3008
|
property10({ attribute: false })
|
|
3074
3009
|
], TestContainer.prototype, "customElementRegistry", void 0);
|
|
3075
|
-
|
|
3010
|
+
__decorate13([
|
|
3076
3011
|
property10({ type: String, attribute: "test-url" })
|
|
3077
3012
|
], TestContainer.prototype, "testURL", void 0);
|
|
3078
|
-
|
|
3013
|
+
__decorate13([
|
|
3079
3014
|
state3()
|
|
3080
3015
|
], TestContainer.prototype, "testDoc", void 0);
|
|
3081
|
-
|
|
3016
|
+
__decorate13([
|
|
3082
3017
|
state3()
|
|
3083
3018
|
], TestContainer.prototype, "testXML", void 0);
|
|
3084
|
-
|
|
3085
|
-
|
|
3019
|
+
__decorate13([
|
|
3020
|
+
consume6({ context: testHostContext, subscribe: true })
|
|
3086
3021
|
], TestContainer.prototype, "testHost", void 0);
|
|
3087
|
-
|
|
3022
|
+
__decorate13([
|
|
3088
3023
|
state3(),
|
|
3089
|
-
|
|
3024
|
+
consume6({ context: qtiContext, subscribe: true })
|
|
3090
3025
|
], TestContainer.prototype, "qtiContext", void 0);
|
|
3091
|
-
|
|
3026
|
+
__decorate13([
|
|
3092
3027
|
watch("testURL", { waitUntilFirstUpdate: true })
|
|
3093
3028
|
], TestContainer.prototype, "handleTestURLChange", null);
|
|
3094
|
-
|
|
3029
|
+
__decorate13([
|
|
3095
3030
|
watch("testXML", { waitUntilFirstUpdate: true })
|
|
3096
3031
|
], TestContainer.prototype, "handleTestXMLChange", null);
|
|
3097
3032
|
|
|
3098
3033
|
// ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
|
|
3099
|
-
import { css as
|
|
3034
|
+
import { css as css6, html as html11, LitElement as LitElement12 } from "lit";
|
|
3100
3035
|
import { property as property11 } from "lit/decorators.js";
|
|
3101
|
-
import { consume as
|
|
3102
|
-
|
|
3036
|
+
import { consume as consume7 } from "@lit/context";
|
|
3037
|
+
|
|
3038
|
+
// ../qti-test/dist/components/styles.js
|
|
3039
|
+
import { css as css5 } from "lit";
|
|
3040
|
+
var form = css5`
|
|
3041
|
+
display: inline-flex;
|
|
3042
|
+
align-items: center;
|
|
3043
|
+
justify-content: center;
|
|
3044
|
+
gap: 0.375em;
|
|
3045
|
+
box-sizing: border-box;
|
|
3046
|
+
min-block-size: var(--test-button-size, 2.25rem);
|
|
3047
|
+
padding: 0 0.875rem;
|
|
3048
|
+
font: inherit;
|
|
3049
|
+
line-height: 1.25;
|
|
3050
|
+
cursor: pointer;
|
|
3051
|
+
user-select: none;
|
|
3052
|
+
border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
|
|
3053
|
+
`;
|
|
3054
|
+
var btn = css5`
|
|
3055
|
+
${form};
|
|
3056
|
+
background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
|
|
3057
|
+
color: var(--test-button-color, var(--qti-component-color, inherit));
|
|
3058
|
+
border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
|
|
3059
|
+
var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
|
|
3060
|
+
`;
|
|
3061
|
+
var btnInteractive = css5`
|
|
3062
|
+
background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
|
|
3063
|
+
`;
|
|
3064
|
+
var focusRing = css5`
|
|
3065
|
+
outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
|
|
3066
|
+
outline-offset: 2px;
|
|
3067
|
+
`;
|
|
3068
|
+
var dis = css5`
|
|
3069
|
+
cursor: not-allowed;
|
|
3070
|
+
opacity: 0.45;
|
|
3071
|
+
`;
|
|
3072
|
+
var ind = css5`
|
|
3073
|
+
${form};
|
|
3074
|
+
border: 1px solid gray;
|
|
3075
|
+
`;
|
|
3076
|
+
|
|
3077
|
+
// ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
|
|
3078
|
+
var __decorate14 = function(decorators, target, key, desc) {
|
|
3103
3079
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3104
3080
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3105
3081
|
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;
|
|
3106
3082
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3107
3083
|
};
|
|
3108
|
-
var TestEndAttempt = class extends
|
|
3084
|
+
var TestEndAttempt = class extends LitElement12 {
|
|
3109
3085
|
_handleTestElementChange(_oldValue, newValue) {
|
|
3110
3086
|
if (newValue) {
|
|
3111
3087
|
this.requestUpdate();
|
|
3112
3088
|
}
|
|
3113
3089
|
}
|
|
3114
3090
|
static {
|
|
3115
|
-
this.styles =
|
|
3091
|
+
this.styles = css6`
|
|
3116
3092
|
:host {
|
|
3117
3093
|
${btn};
|
|
3118
3094
|
}
|
|
@@ -3172,32 +3148,32 @@ var TestEndAttempt = class extends LitElement13 {
|
|
|
3172
3148
|
}
|
|
3173
3149
|
}
|
|
3174
3150
|
render() {
|
|
3175
|
-
return
|
|
3151
|
+
return html11` <slot></slot> `;
|
|
3176
3152
|
}
|
|
3177
3153
|
};
|
|
3178
|
-
|
|
3179
|
-
|
|
3154
|
+
__decorate14([
|
|
3155
|
+
consume7({ context: computedContext, subscribe: true }),
|
|
3180
3156
|
property11({ attribute: false })
|
|
3181
3157
|
], TestEndAttempt.prototype, "computedContext", void 0);
|
|
3182
|
-
|
|
3158
|
+
__decorate14([
|
|
3183
3159
|
property11({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
3184
3160
|
], TestEndAttempt.prototype, "_internalDisabled", void 0);
|
|
3185
|
-
|
|
3161
|
+
__decorate14([
|
|
3186
3162
|
watch("computedContext")
|
|
3187
3163
|
], TestEndAttempt.prototype, "_handleTestElementChange", null);
|
|
3188
3164
|
|
|
3189
3165
|
// ../qti-test/dist/components/test-item-link/test-item-link.js
|
|
3190
|
-
import { css as
|
|
3166
|
+
import { css as css7, html as html12, LitElement as LitElement13 } from "lit";
|
|
3191
3167
|
import { property as property12 } from "lit/decorators.js";
|
|
3192
|
-
var
|
|
3168
|
+
var __decorate15 = function(decorators, target, key, desc) {
|
|
3193
3169
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3194
3170
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3195
3171
|
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;
|
|
3196
3172
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3197
3173
|
};
|
|
3198
|
-
var TestItemLink = class extends
|
|
3174
|
+
var TestItemLink = class extends LitElement13 {
|
|
3199
3175
|
static {
|
|
3200
|
-
this.styles =
|
|
3176
|
+
this.styles = css7`
|
|
3201
3177
|
:host {
|
|
3202
3178
|
${btn};
|
|
3203
3179
|
}
|
|
@@ -3221,2079 +3197,2179 @@ var TestItemLink = class extends LitElement14 {
|
|
|
3221
3197
|
dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
|
|
3222
3198
|
}
|
|
3223
3199
|
render() {
|
|
3224
|
-
return
|
|
3200
|
+
return html12` <slot></slot> `;
|
|
3225
3201
|
}
|
|
3226
3202
|
};
|
|
3227
|
-
|
|
3203
|
+
__decorate15([
|
|
3228
3204
|
property12({ type: String, attribute: "item-id" })
|
|
3229
3205
|
], TestItemLink.prototype, "itemId", void 0);
|
|
3230
3206
|
|
|
3231
|
-
// ../qti-test/dist/components/test-
|
|
3232
|
-
import {
|
|
3233
|
-
import {
|
|
3207
|
+
// ../qti-test/dist/components/test-navigation/test-navigation.js
|
|
3208
|
+
import { ContextConsumer, consume as consume8, provide as provide3 } from "@lit/context";
|
|
3209
|
+
import { html as html13, LitElement as LitElement14 } from "lit";
|
|
3234
3210
|
import { property as property13, state as state4 } from "lit/decorators.js";
|
|
3235
|
-
|
|
3236
|
-
var __decorate17 = function(decorators, target, key, desc) {
|
|
3211
|
+
var __decorate16 = function(decorators, target, key, desc) {
|
|
3237
3212
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3238
3213
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3239
3214
|
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;
|
|
3240
3215
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3241
3216
|
};
|
|
3242
|
-
var
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3217
|
+
var newQtiContext = () => ({
|
|
3218
|
+
QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
|
|
3219
|
+
});
|
|
3220
|
+
var TestNavigation = class extends LitElement14 {
|
|
3221
|
+
/**
|
|
3222
|
+
* @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
|
|
3223
|
+
* enclosing test's: reading returns it, writing replaces it, so a host that has always set the
|
|
3224
|
+
* shuffle seed here keeps working. Removed in the next major.
|
|
3225
|
+
*
|
|
3226
|
+
* Written before the navigation is inside a test, it waits and is handed over on connect.
|
|
3227
|
+
*/
|
|
3228
|
+
get qtiContext() {
|
|
3229
|
+
return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
|
|
3252
3230
|
}
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
play: "M8 5v14l11-7z",
|
|
3258
|
-
pause: "M6 5h4v14H6zM14 5h4v14h-4z",
|
|
3259
|
-
stop: "M6 6h12v12H6z",
|
|
3260
|
-
prev: "M6 5h2v14H6zM20 5v14L9 12z",
|
|
3261
|
-
next: "M16 5h2v14h-2zM4 5v14l11-7z",
|
|
3262
|
-
pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
|
|
3263
|
-
};
|
|
3264
|
-
var iconContent = (icon, label) => {
|
|
3265
|
-
const svg = html14`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3266
|
-
<path d="${ICONS[icon]}"></path>
|
|
3267
|
-
</svg>`;
|
|
3268
|
-
return html14`${svg}<span class="label">${label}</span>`;
|
|
3269
|
-
};
|
|
3270
|
-
var TtsButtonBase = class extends LitElement15 {
|
|
3271
|
-
static {
|
|
3272
|
-
this.styles = css9`
|
|
3273
|
-
:host {
|
|
3274
|
-
display: inline-flex;
|
|
3275
|
-
}
|
|
3276
|
-
button {
|
|
3277
|
-
${btn};
|
|
3278
|
-
min-inline-size: var(--test-button-size, 2.25rem);
|
|
3279
|
-
padding-inline: 0.5rem;
|
|
3280
|
-
/* Containing block for the visually hidden .label. Without it the label is placed against
|
|
3281
|
-
the nearest positioned ancestor, which can sit outside a scroll container and make the
|
|
3282
|
-
page as tall as the scrolled content. */
|
|
3283
|
-
position: relative;
|
|
3284
|
-
}
|
|
3285
|
-
button:hover:not(:disabled) {
|
|
3286
|
-
${btnInteractive};
|
|
3287
|
-
}
|
|
3288
|
-
button:focus-visible {
|
|
3289
|
-
${focusRing};
|
|
3290
|
-
}
|
|
3291
|
-
button:disabled {
|
|
3292
|
-
${dis};
|
|
3293
|
-
}
|
|
3294
|
-
button[aria-pressed='true'],
|
|
3295
|
-
button[aria-pressed='true']:hover {
|
|
3296
|
-
background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
|
|
3297
|
-
color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
|
|
3298
|
-
}
|
|
3299
|
-
svg,
|
|
3300
|
-
::slotted(svg) {
|
|
3301
|
-
flex: none;
|
|
3302
|
-
inline-size: var(--test-tts-icon-size, 1.125rem);
|
|
3303
|
-
block-size: var(--test-tts-icon-size, 1.125rem);
|
|
3304
|
-
}
|
|
3305
|
-
svg {
|
|
3306
|
-
fill: currentColor;
|
|
3231
|
+
set qtiContext(value) {
|
|
3232
|
+
if (!this.#warnedQtiContext) {
|
|
3233
|
+
this.#warnedQtiContext = true;
|
|
3234
|
+
console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.");
|
|
3307
3235
|
}
|
|
3308
|
-
|
|
3309
|
-
.label {
|
|
3310
|
-
position: absolute;
|
|
3311
|
-
inline-size: 1px;
|
|
3312
|
-
block-size: 1px;
|
|
3313
|
-
overflow: hidden;
|
|
3314
|
-
clip-path: inset(50%);
|
|
3315
|
-
white-space: nowrap;
|
|
3316
|
-
}
|
|
3317
|
-
`;
|
|
3236
|
+
this.#writeQtiContext(value);
|
|
3318
3237
|
}
|
|
3319
|
-
#
|
|
3320
|
-
#
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
const
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
this.#mirroredPicking = picking;
|
|
3329
|
-
this.#internals.states.clear();
|
|
3330
|
-
if (state9)
|
|
3331
|
-
this.#internals.states.add(state9);
|
|
3332
|
-
if (picking)
|
|
3333
|
-
this.#internals.states.add("picking");
|
|
3238
|
+
#pendingQtiContext;
|
|
3239
|
+
#warnedQtiContext;
|
|
3240
|
+
/** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */
|
|
3241
|
+
#writeQtiContext(value) {
|
|
3242
|
+
const owner = this.#owner();
|
|
3243
|
+
if (owner)
|
|
3244
|
+
owner.qtiContext = value;
|
|
3245
|
+
else
|
|
3246
|
+
this.#pendingQtiContext = value;
|
|
3334
3247
|
}
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
var TestItemToSpeech = class extends LitElement15 {
|
|
3343
|
-
static {
|
|
3344
|
-
this.styles = css9`
|
|
3345
|
-
:host {
|
|
3346
|
-
display: inline-flex;
|
|
3347
|
-
flex-wrap: wrap;
|
|
3348
|
-
align-items: center;
|
|
3349
|
-
gap: var(--test-tts-gap, 0.25rem);
|
|
3350
|
-
}
|
|
3351
|
-
`;
|
|
3248
|
+
/**
|
|
3249
|
+
* The `qti-test` this navigation is in, found through context so it works across shadow roots.
|
|
3250
|
+
* A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.
|
|
3251
|
+
*/
|
|
3252
|
+
#testHost;
|
|
3253
|
+
#owner() {
|
|
3254
|
+
return this.#testHost.value ?? null;
|
|
3352
3255
|
}
|
|
3353
|
-
#
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
#
|
|
3362
|
-
// Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
|
|
3363
|
-
#itemRef;
|
|
3364
|
-
// Where the item-connected (and, in cursor mode, navigation) events are listened for.
|
|
3365
|
-
#eventHost;
|
|
3366
|
-
#boundHandleItemConnected;
|
|
3367
|
-
#boundHandleNavigation;
|
|
3368
|
-
// Cursor mode: the previous navigation position, to detect moving to another item or section.
|
|
3369
|
-
#prevNavItemRefId;
|
|
3370
|
-
#prevNavSectionId;
|
|
3371
|
-
// Current set of block-level reading elements for the item
|
|
3372
|
-
#readingElements;
|
|
3373
|
-
#currentElementIndex;
|
|
3374
|
-
// Text nodes of the element currently being spoken (for word-boundary highlight)
|
|
3375
|
-
#textNodes;
|
|
3376
|
-
// The utterance this player is speaking; lets the error handler tell "our speech was
|
|
3377
|
-
// cancelled by another player" apart from a cancel we issued ourselves.
|
|
3378
|
-
#currentUtterance;
|
|
3379
|
-
// Pick mode: all elements highlighted, a click on one starts reading from there.
|
|
3380
|
-
#picking;
|
|
3381
|
-
#pickRoot;
|
|
3382
|
-
#boundHandlePickClick;
|
|
3383
|
-
// Set when the last element has been read: the cursor stays on it (so prev still works),
|
|
3384
|
-
// but the next play starts the item over instead of repeating that last element.
|
|
3385
|
-
#finished;
|
|
3386
|
-
// Two separate CSS Highlight objects
|
|
3387
|
-
#elementHighlight;
|
|
3388
|
-
// whole-element cursor
|
|
3389
|
-
#wordHighlight;
|
|
3390
|
-
// current word during speech
|
|
3256
|
+
#testElement;
|
|
3257
|
+
/**
|
|
3258
|
+
* Whether each item's last *ended attempt* reached the optimal outcome, keyed
|
|
3259
|
+
* by item-ref id. Written from #handleItemContextUpdated when processResponse
|
|
3260
|
+
* ends an attempt — never on a plain selection. Mirrors how inline feedback
|
|
3261
|
+
* only re-evaluates when an attempt is processed, so a freshly-picked answer
|
|
3262
|
+
* doesn't flip `done` until the candidate ends the attempt.
|
|
3263
|
+
*/
|
|
3264
|
+
#optimality;
|
|
3391
3265
|
constructor() {
|
|
3392
3266
|
super();
|
|
3393
|
-
this.
|
|
3394
|
-
this
|
|
3395
|
-
this.#
|
|
3396
|
-
this.#
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
this
|
|
3407
|
-
this
|
|
3408
|
-
this.#
|
|
3409
|
-
this.#
|
|
3410
|
-
this
|
|
3411
|
-
this.#
|
|
3412
|
-
this
|
|
3413
|
-
this.#
|
|
3414
|
-
this
|
|
3415
|
-
|
|
3416
|
-
currentElementIndex: 0,
|
|
3417
|
-
elementCount: 0,
|
|
3418
|
-
play: () => this.#playSpeech(),
|
|
3419
|
-
pause: () => this.#pause(),
|
|
3420
|
-
resume: () => this.#resume(),
|
|
3421
|
-
stop: () => {
|
|
3422
|
-
this.#stopPicking();
|
|
3423
|
-
this.#stop();
|
|
3424
|
-
},
|
|
3425
|
-
prevElement: () => this.#prevElement(),
|
|
3426
|
-
nextElement: () => this.#nextElement(),
|
|
3427
|
-
togglePick: () => this.#togglePick(),
|
|
3428
|
-
picking: false
|
|
3429
|
-
};
|
|
3267
|
+
this.identifier = void 0;
|
|
3268
|
+
this.initContext = [];
|
|
3269
|
+
this.#warnedQtiContext = false;
|
|
3270
|
+
this.#testHost = new ContextConsumer(this, {
|
|
3271
|
+
context: testHostContext,
|
|
3272
|
+
subscribe: true,
|
|
3273
|
+
callback: (host) => {
|
|
3274
|
+
if (host && this.#pendingQtiContext) {
|
|
3275
|
+
host.qtiContext = this.#pendingQtiContext;
|
|
3276
|
+
this.#pendingQtiContext = void 0;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
});
|
|
3280
|
+
this.configContext = {};
|
|
3281
|
+
this.autoScoreItems = false;
|
|
3282
|
+
this.#optimality = /* @__PURE__ */ new Map();
|
|
3283
|
+
this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
|
|
3284
|
+
listenPublic2(this, "cito-test-loaded", this.#handleTestConnected.bind(this));
|
|
3285
|
+
this.addEventListener("qti-assessment-item-connected", this.#handleItemConnected.bind(this));
|
|
3286
|
+
listenPublic(this, "cito-item-response-changed", this.#handleInteractionChanged.bind(this));
|
|
3287
|
+
this.addEventListener("qti-item-context-updated", this.#handleItemContextUpdated.bind(this));
|
|
3288
|
+
listenPublic2(this, "cito-test-end-attempt", this.#handleTestEndAttempt.bind(this));
|
|
3289
|
+
listenPublic2(this, "cito-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
|
|
3430
3290
|
}
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3291
|
+
/**
|
|
3292
|
+
* Latch whether an item reached its optimal outcome whenever it has just ended
|
|
3293
|
+
* an attempt. processResponse — fired by test-end-attempt, autoscore, or an
|
|
3294
|
+
* in-item end-attempt interaction — flags its context update with
|
|
3295
|
+
* `responseProcessed`; a plain selection updates the context without it, so
|
|
3296
|
+
* `done` can't flip until the candidate actually ends the attempt.
|
|
3297
|
+
*/
|
|
3298
|
+
#handleItemContextUpdated(event) {
|
|
3299
|
+
if (!event.detail?.responseProcessed)
|
|
3436
3300
|
return;
|
|
3437
|
-
const
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
const
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3301
|
+
const itemContext = event.detail.itemContext;
|
|
3302
|
+
if (!itemContext?.identifier)
|
|
3303
|
+
return;
|
|
3304
|
+
const optimality = this.#assessOptimality(itemContext);
|
|
3305
|
+
this.#optimality.set(itemContext.identifier, optimality);
|
|
3306
|
+
const computedItem = this.computedItemFor(itemContext.identifier);
|
|
3307
|
+
const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
|
|
3308
|
+
const completionStatus = itemContext.variables?.find((v) => v.identifier === "completionStatus")?.value;
|
|
3309
|
+
this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.maxAttempts, computedItem?.adaptive, completionStatus));
|
|
3445
3310
|
}
|
|
3446
|
-
/**
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
this.#updateContext();
|
|
3311
|
+
/**
|
|
3312
|
+
* Extension point for presentation packages reacting to an ended attempt.
|
|
3313
|
+
* `done` is settled here — from the freshly latched optimality and the
|
|
3314
|
+
* session-control cascade — because the computed context only catches up on
|
|
3315
|
+
* the next update, after this event has finished bubbling.
|
|
3316
|
+
*/
|
|
3317
|
+
afterAttemptEnded(_assessmentItem, _computedItem, _done) {
|
|
3454
3318
|
}
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
this
|
|
3458
|
-
this.#stimulusMode = this.#stimulusPlaceholder() !== null;
|
|
3459
|
-
if (this.#stimulusMode) {
|
|
3460
|
-
this.#stimulusObserver = new MutationObserver((records) => {
|
|
3461
|
-
if (records.some((record) => !this.contains(record.target)))
|
|
3462
|
-
this.#handleStimulusReplaced();
|
|
3463
|
-
});
|
|
3464
|
-
this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
|
|
3465
|
-
return;
|
|
3466
|
-
}
|
|
3467
|
-
this.#contentMode = this.#contentElement() !== null;
|
|
3468
|
-
if (this.#contentMode)
|
|
3469
|
-
return;
|
|
3470
|
-
this.#itemRef = this.closest("qti-assessment-item-ref");
|
|
3471
|
-
this.#eventHost = this.#itemRef ?? this.closest("test-navigation") ?? this.testHost ?? this.getRootNode();
|
|
3472
|
-
this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
3473
|
-
if (!this.#itemRef) {
|
|
3474
|
-
this.#eventHost.addEventListener("cito-test-navigate", this.#boundHandleNavigation);
|
|
3475
|
-
this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
3476
|
-
}
|
|
3319
|
+
/** The computed-context entry for an item, from the session-control cascade. */
|
|
3320
|
+
computedItemFor(identifier) {
|
|
3321
|
+
return this.computedContext?.testParts?.flatMap((part) => part.sections).flatMap((section) => section.items).find((i) => i.identifier === identifier);
|
|
3477
3322
|
}
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
if (
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
this.#stopPicking();
|
|
3485
|
-
this.#clearAllHighlights();
|
|
3486
|
-
this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
3487
|
-
this.#eventHost?.removeEventListener("cito-test-navigate", this.#boundHandleNavigation);
|
|
3488
|
-
this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
3489
|
-
this.#eventHost = null;
|
|
3490
|
-
this.#itemRef = null;
|
|
3491
|
-
this.#stimulusObserver?.disconnect();
|
|
3492
|
-
this.#stimulusObserver = null;
|
|
3493
|
-
this.#stimulusMode = false;
|
|
3494
|
-
this.#contentMode = false;
|
|
3323
|
+
/** The assessment item for an item-ref id, if it has been rendered. */
|
|
3324
|
+
#assessmentItemFor(identifier) {
|
|
3325
|
+
if (!identifier)
|
|
3326
|
+
return void 0;
|
|
3327
|
+
const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"]`);
|
|
3328
|
+
return itemRef?.assessmentItem ?? void 0;
|
|
3495
3329
|
}
|
|
3496
|
-
|
|
3497
|
-
|
|
3330
|
+
/** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
|
|
3331
|
+
#itemElement;
|
|
3332
|
+
/** The currently active assessment item, exposed for optional presentation extensions. */
|
|
3333
|
+
get activeAssessmentItem() {
|
|
3334
|
+
if (!this.#testElement || !this._sessionContext?.navItemRefId)
|
|
3335
|
+
return void 0;
|
|
3336
|
+
return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
|
|
3498
3337
|
}
|
|
3499
3338
|
/**
|
|
3500
|
-
*
|
|
3501
|
-
*
|
|
3502
|
-
*
|
|
3339
|
+
* Handles the 'test-end-attempt' event.
|
|
3340
|
+
* @private
|
|
3341
|
+
* @listens TestNavigation#test-end-attempt
|
|
3342
|
+
* @param {CustomEvent} event - The custom event object.
|
|
3503
3343
|
*/
|
|
3504
|
-
#
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
}
|
|
3511
|
-
/**
|
|
3512
|
-
* Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
|
|
3513
|
-
* collected, so the next play reads the new content from the top. Unlike
|
|
3514
|
-
* #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
|
|
3515
|
-
* while an item player on the same page is speaking.
|
|
3516
|
-
*/
|
|
3517
|
-
#handleStimulusReplaced() {
|
|
3518
|
-
if (this.#currentUtterance) {
|
|
3519
|
-
this.#currentUtterance = null;
|
|
3520
|
-
speechSynthesis.cancel();
|
|
3521
|
-
}
|
|
3522
|
-
this.#stopPicking();
|
|
3523
|
-
this.#clearAllHighlights();
|
|
3524
|
-
this.#setSpeechState("idle");
|
|
3525
|
-
this.#readingElements = null;
|
|
3526
|
-
this.#currentElementIndex = 0;
|
|
3527
|
-
this.#finished = false;
|
|
3528
|
-
this.#updateContext();
|
|
3529
|
-
}
|
|
3530
|
-
/**
|
|
3531
|
-
* Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
|
|
3532
|
-
* null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
|
|
3533
|
-
* loading replaces the placeholder's content.
|
|
3534
|
-
*/
|
|
3535
|
-
#stimulusPlaceholder() {
|
|
3536
|
-
return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
|
|
3537
|
-
}
|
|
3538
|
-
/**
|
|
3539
|
-
* Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
|
|
3540
|
-
* The marker goes on one container; the player finds the readable elements inside it.
|
|
3541
|
-
*/
|
|
3542
|
-
#contentElement() {
|
|
3543
|
-
return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
|
|
3544
|
-
}
|
|
3545
|
-
/**
|
|
3546
|
-
* The element whose text is read: the stimulus body next to the player (stimulus mode), the
|
|
3547
|
-
* marked content next to it (content mode), or the item body of the item to read.
|
|
3548
|
-
*/
|
|
3549
|
-
#resolveReadingRoot() {
|
|
3550
|
-
if (this.#stimulusMode)
|
|
3551
|
-
return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
|
|
3552
|
-
if (this.#contentMode)
|
|
3553
|
-
return this.#contentElement();
|
|
3554
|
-
return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
|
|
3344
|
+
#handleTestEndAttempt(_event) {
|
|
3345
|
+
const qtiAssessmentItemEl = this.activeAssessmentItem;
|
|
3346
|
+
if (!qtiAssessmentItemEl)
|
|
3347
|
+
return;
|
|
3348
|
+
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
3349
|
+
qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
|
|
3555
3350
|
}
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
if (
|
|
3559
|
-
return
|
|
3560
|
-
|
|
3561
|
-
return identifier ? this.#findItemInDom(identifier) : null;
|
|
3351
|
+
#handleTestUpdateOutcomeVariable(event) {
|
|
3352
|
+
const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);
|
|
3353
|
+
if (!qtiAssessmentItemEl)
|
|
3354
|
+
return;
|
|
3355
|
+
qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
|
|
3562
3356
|
}
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
if (direct)
|
|
3573
|
-
return direct;
|
|
3574
|
-
for (const container of Array.from(scope.querySelectorAll("test-container"))) {
|
|
3575
|
-
const inShadow = container.shadowRoot?.querySelector(selector);
|
|
3576
|
-
if (inShadow)
|
|
3577
|
-
return inShadow;
|
|
3357
|
+
#handleInteractionChanged(_event) {
|
|
3358
|
+
if (this.autoScoreItems) {
|
|
3359
|
+
const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
|
|
3360
|
+
if (!assessmentItem)
|
|
3361
|
+
return;
|
|
3362
|
+
const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
|
|
3363
|
+
if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
|
|
3364
|
+
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
3365
|
+
assessmentItem.processResponse(true, reportValidityAfterScoring);
|
|
3578
3366
|
}
|
|
3579
|
-
return null;
|
|
3580
|
-
};
|
|
3581
|
-
const test = this.closest("qti-test");
|
|
3582
|
-
const inTest = test && search(test);
|
|
3583
|
-
if (inTest)
|
|
3584
|
-
return inTest;
|
|
3585
|
-
let root = this.getRootNode();
|
|
3586
|
-
for (; ; ) {
|
|
3587
|
-
const found = search(root);
|
|
3588
|
-
if (found)
|
|
3589
|
-
return found;
|
|
3590
|
-
const host = root.host;
|
|
3591
|
-
if (!host)
|
|
3592
|
-
return null;
|
|
3593
|
-
root = host.getRootNode();
|
|
3594
3367
|
}
|
|
3595
3368
|
}
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
this._ttsContext = { ...this._ttsContext, state: state9 };
|
|
3599
|
-
this.#internals.states.delete("idle");
|
|
3600
|
-
this.#internals.states.delete("playing");
|
|
3601
|
-
this.#internals.states.delete("paused");
|
|
3602
|
-
this.#internals.states.add(state9);
|
|
3603
|
-
}
|
|
3604
|
-
/** Push currentElementIndex and elementCount into context so children can react. */
|
|
3605
|
-
#updateContext() {
|
|
3606
|
-
this._ttsContext = {
|
|
3607
|
-
...this._ttsContext,
|
|
3608
|
-
currentElementIndex: this.#currentElementIndex,
|
|
3609
|
-
elementCount: this.#getReadingElements().length
|
|
3610
|
-
};
|
|
3611
|
-
}
|
|
3612
|
-
/**
|
|
3613
|
-
* Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
|
|
3614
|
-
* first call), filtered live for visibility on every call. Feedback and other
|
|
3615
|
-
* conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
|
|
3616
|
-
* CSS custom state reveals it) is excluded while hidden and picked up again once shown,
|
|
3617
|
-
* without needing to re-collect the candidate set.
|
|
3618
|
-
*/
|
|
3619
|
-
#getReadingElements() {
|
|
3620
|
-
if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
|
|
3621
|
-
this.#readingElements = null;
|
|
3622
|
-
this.#currentElementIndex = 0;
|
|
3623
|
-
this.#finished = false;
|
|
3624
|
-
}
|
|
3625
|
-
if (this.#readingElements === null) {
|
|
3626
|
-
const root = this.#resolveReadingRoot();
|
|
3627
|
-
if (!root)
|
|
3628
|
-
return [];
|
|
3629
|
-
const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
|
|
3630
|
-
this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
|
|
3631
|
-
}
|
|
3632
|
-
return this.#readingElements.filter((el) => this.#isVisible(el));
|
|
3369
|
+
render() {
|
|
3370
|
+
return html13`<slot></slot>`;
|
|
3633
3371
|
}
|
|
3634
|
-
|
|
3635
|
-
#
|
|
3636
|
-
|
|
3637
|
-
|
|
3372
|
+
/* PK: on test connected we can build the computed context */
|
|
3373
|
+
#handleTestConnected(event) {
|
|
3374
|
+
this.#testElement = event.detail;
|
|
3375
|
+
this.#optimality.clear();
|
|
3376
|
+
if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
|
|
3377
|
+
const currentContext = this.qtiContext.QTI_CONTEXT || {
|
|
3378
|
+
testIdentifier: "",
|
|
3379
|
+
candidateIdentifier: "not set",
|
|
3380
|
+
environmentIdentifier: "default"
|
|
3381
|
+
};
|
|
3382
|
+
this.#writeQtiContext({
|
|
3383
|
+
QTI_CONTEXT: {
|
|
3384
|
+
...currentContext,
|
|
3385
|
+
testIdentifier: this.#testElement.identifier,
|
|
3386
|
+
environmentIdentifier: currentContext.environmentIdentifier || "default"
|
|
3387
|
+
}
|
|
3388
|
+
});
|
|
3638
3389
|
}
|
|
3639
|
-
|
|
3390
|
+
const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
|
|
3391
|
+
contextDeclarations.forEach((declaration) => {
|
|
3392
|
+
const defaultValues = this.#extractDefaultValues(declaration);
|
|
3393
|
+
if (Object.keys(defaultValues).length > 0) {
|
|
3394
|
+
this.#writeQtiContext({
|
|
3395
|
+
QTI_CONTEXT: {
|
|
3396
|
+
...defaultValues,
|
|
3397
|
+
// Default values first
|
|
3398
|
+
...this.qtiContext.QTI_CONTEXT
|
|
3399
|
+
// Runtime values override defaults
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
});
|
|
3404
|
+
const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
|
|
3405
|
+
this.computedContext = {
|
|
3406
|
+
itemElement: this.#itemElement,
|
|
3407
|
+
identifier: this.#testElement.identifier,
|
|
3408
|
+
title: this.#testElement.title,
|
|
3409
|
+
view: this._sessionContext?.view,
|
|
3410
|
+
plugins: this._sessionContext?.plugins ?? {},
|
|
3411
|
+
testParts: testPartElements.map((testPart) => {
|
|
3412
|
+
const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
|
|
3413
|
+
const testPartSessionControl = testPart.querySelector(":scope > qti-item-session-control");
|
|
3414
|
+
const partAllowSkipping = testPartSessionControl ? testPartSessionControl.allowSkipping : true;
|
|
3415
|
+
const partMaxAttempts = testPartSessionControl ? testPartSessionControl.maxAttempts : 1;
|
|
3416
|
+
const partShowFeedback = testPartSessionControl ? testPartSessionControl.showFeedback : false;
|
|
3417
|
+
const partShowSolution = testPartSessionControl ? testPartSessionControl.showSolution : false;
|
|
3418
|
+
return {
|
|
3419
|
+
active: false,
|
|
3420
|
+
identifier: testPart.identifier,
|
|
3421
|
+
navigationMode: testPart.navigationMode,
|
|
3422
|
+
submissionMode: testPart.submissionMode,
|
|
3423
|
+
allowSkipping: partAllowSkipping,
|
|
3424
|
+
sections: sectionElements.map((section) => {
|
|
3425
|
+
const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
|
|
3426
|
+
const sectionSessionControl = section.querySelector(":scope > qti-item-session-control");
|
|
3427
|
+
const sectionAllowSkipping = sectionSessionControl ? sectionSessionControl.allowSkipping : partAllowSkipping;
|
|
3428
|
+
const sectionMaxAttempts = sectionSessionControl ? sectionSessionControl.maxAttempts : partMaxAttempts;
|
|
3429
|
+
const sectionShowFeedback = sectionSessionControl ? sectionSessionControl.showFeedback : partShowFeedback;
|
|
3430
|
+
const sectionShowSolution = sectionSessionControl ? sectionSessionControl.showSolution : partShowSolution;
|
|
3431
|
+
return {
|
|
3432
|
+
active: false,
|
|
3433
|
+
identifier: section.identifier,
|
|
3434
|
+
title: section.title,
|
|
3435
|
+
navigationMode: section.navigationMode,
|
|
3436
|
+
submissionMode: section.submissionMode,
|
|
3437
|
+
allowSkipping: sectionAllowSkipping,
|
|
3438
|
+
items: itemElements.map((item) => {
|
|
3439
|
+
const itemSessionControl = item.querySelector(":scope > qti-item-session-control");
|
|
3440
|
+
const itemAllowSkipping = itemSessionControl ? itemSessionControl.allowSkipping : sectionAllowSkipping;
|
|
3441
|
+
const itemMaxAttempts = itemSessionControl ? itemSessionControl.maxAttempts : sectionMaxAttempts;
|
|
3442
|
+
const itemShowFeedback = itemSessionControl ? itemSessionControl.showFeedback : sectionShowFeedback;
|
|
3443
|
+
const itemShowSolution = itemSessionControl ? itemSessionControl.showSolution : sectionShowSolution;
|
|
3444
|
+
return {
|
|
3445
|
+
...this.initContext?.find((i) => i.identifier === item.identifier),
|
|
3446
|
+
active: false,
|
|
3447
|
+
identifier: item.identifier,
|
|
3448
|
+
categories: item.category ? item.category?.split(" ") : [],
|
|
3449
|
+
href: item.href,
|
|
3450
|
+
variables: [],
|
|
3451
|
+
allowSkipping: itemAllowSkipping,
|
|
3452
|
+
maxAttempts: itemMaxAttempts,
|
|
3453
|
+
showFeedback: itemShowFeedback,
|
|
3454
|
+
showSolution: itemShowSolution
|
|
3455
|
+
};
|
|
3456
|
+
})
|
|
3457
|
+
};
|
|
3458
|
+
})
|
|
3459
|
+
};
|
|
3460
|
+
})
|
|
3461
|
+
};
|
|
3640
3462
|
}
|
|
3641
3463
|
/**
|
|
3642
|
-
*
|
|
3643
|
-
* Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
|
|
3644
|
-
* Empty `lang=""` is treated as absent.
|
|
3464
|
+
* Extract default values from a qti-context-declaration element
|
|
3645
3465
|
*/
|
|
3646
|
-
#
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
return lang.trim();
|
|
3652
|
-
node = node.parentElement ?? node.getRootNode().host ?? null;
|
|
3466
|
+
#extractDefaultValues(declaration) {
|
|
3467
|
+
const defaultValues = {};
|
|
3468
|
+
const defaultValueElement = declaration.querySelector("qti-default-value");
|
|
3469
|
+
if (!defaultValueElement) {
|
|
3470
|
+
return defaultValues;
|
|
3653
3471
|
}
|
|
3654
|
-
const
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3472
|
+
const valueElements = defaultValueElement.querySelectorAll("qti-value[field-identifier]");
|
|
3473
|
+
valueElements.forEach((valueElement) => {
|
|
3474
|
+
const fieldIdentifier = valueElement.getAttribute("field-identifier");
|
|
3475
|
+
const baseType = valueElement.getAttribute("base-type") || "string";
|
|
3476
|
+
const textContent = valueElement.textContent?.trim() || "";
|
|
3477
|
+
if (fieldIdentifier) {
|
|
3478
|
+
let value = textContent;
|
|
3479
|
+
switch (baseType) {
|
|
3480
|
+
case "integer":
|
|
3481
|
+
value = parseInt(textContent, 10);
|
|
3482
|
+
break;
|
|
3483
|
+
case "float":
|
|
3484
|
+
case "duration":
|
|
3485
|
+
value = parseFloat(textContent);
|
|
3486
|
+
break;
|
|
3487
|
+
case "boolean":
|
|
3488
|
+
value = textContent.toLowerCase() === "true";
|
|
3489
|
+
break;
|
|
3490
|
+
case "string":
|
|
3491
|
+
default:
|
|
3492
|
+
value = textContent;
|
|
3493
|
+
break;
|
|
3494
|
+
}
|
|
3495
|
+
defaultValues[fieldIdentifier] = value;
|
|
3496
|
+
}
|
|
3497
|
+
});
|
|
3498
|
+
return defaultValues;
|
|
3658
3499
|
}
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3500
|
+
/* PK: on item connected we can add item only properties in the xml */
|
|
3501
|
+
#handleItemConnected(event) {
|
|
3502
|
+
const itemElement = event.detail;
|
|
3503
|
+
this.computedContext = {
|
|
3504
|
+
...this.computedContext,
|
|
3505
|
+
testParts: this.computedContext.testParts.map((testPart) => {
|
|
3506
|
+
return {
|
|
3507
|
+
...testPart,
|
|
3508
|
+
sections: testPart.sections.map((section) => {
|
|
3509
|
+
return {
|
|
3510
|
+
...section,
|
|
3511
|
+
items: section.items.map((item) => {
|
|
3512
|
+
if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
|
|
3513
|
+
return item;
|
|
3514
|
+
}
|
|
3515
|
+
const scoreOutcome = itemElement.querySelector("qti-outcome-declaration[identifier='SCORE']");
|
|
3516
|
+
const externalScored = scoreOutcome?.getAttribute("externalScored");
|
|
3517
|
+
const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
|
|
3518
|
+
const containsCorrectResponse = Array.from(responseDeclarations).some((r) => r.querySelector("qti-correct-response"));
|
|
3519
|
+
const containsMapping = Array.from(responseDeclarations).some((r) => {
|
|
3520
|
+
const mapping = r.querySelector("qti-mapping");
|
|
3521
|
+
const areaMapping = r.querySelector("qti-area-mapping");
|
|
3522
|
+
return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
|
|
3523
|
+
});
|
|
3524
|
+
const hasCorrectResponse = containsCorrectResponse || containsMapping;
|
|
3525
|
+
const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
|
|
3526
|
+
return {
|
|
3527
|
+
...item,
|
|
3528
|
+
assessmentItemIdentifier: itemElement.getAttribute("identifier"),
|
|
3529
|
+
label: itemElement.getAttribute("label"),
|
|
3530
|
+
title: itemElement.title,
|
|
3531
|
+
externalScored,
|
|
3532
|
+
adaptive: itemElement.adaptive == "true" || false,
|
|
3533
|
+
timeDependent: itemElement.timeDependent == "true" || false,
|
|
3534
|
+
variables: itemElement.variables,
|
|
3535
|
+
hasCorrectResponse,
|
|
3536
|
+
hasResponseProcessing
|
|
3537
|
+
};
|
|
3538
|
+
})
|
|
3539
|
+
};
|
|
3540
|
+
})
|
|
3541
|
+
};
|
|
3542
|
+
})
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
/* PK: on every change of the candidate we will recomputed the computedContext */
|
|
3546
|
+
willUpdate(_changedProperties) {
|
|
3547
|
+
if (!this.computedContext)
|
|
3548
|
+
return;
|
|
3549
|
+
let itemIndex = 1;
|
|
3550
|
+
this.computedContext = {
|
|
3551
|
+
...this.computedContext,
|
|
3552
|
+
view: this._sessionContext?.view,
|
|
3553
|
+
plugins: this._sessionContext?.plugins ?? {},
|
|
3554
|
+
testParts: this.computedContext.testParts.map((testPart) => {
|
|
3555
|
+
return {
|
|
3556
|
+
...testPart,
|
|
3557
|
+
active: this._sessionContext?.navPartId === testPart.identifier || false,
|
|
3558
|
+
sections: testPart.sections.map((section) => {
|
|
3559
|
+
return {
|
|
3560
|
+
...section,
|
|
3561
|
+
active: this._sessionContext?.navSectionId === section.identifier || false,
|
|
3562
|
+
completed: section.items.every((item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"),
|
|
3563
|
+
items: section.items.map((item) => {
|
|
3564
|
+
const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
|
|
3565
|
+
const computedItem = {
|
|
3566
|
+
...item,
|
|
3567
|
+
...itemContext,
|
|
3568
|
+
...this.initContext?.find((i) => i.identifier === item.identifier)
|
|
3569
|
+
};
|
|
3570
|
+
const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
|
|
3571
|
+
const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
|
|
3572
|
+
const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
|
|
3573
|
+
const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
|
|
3574
|
+
const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
|
|
3575
|
+
const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
|
|
3576
|
+
const valid = itemContext?.valid ?? true;
|
|
3577
|
+
const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
|
|
3578
|
+
const isDefaultResponse = responseVars.every((v) => {
|
|
3579
|
+
if (v.value === void 0 || v.value === null) {
|
|
3580
|
+
return true;
|
|
3581
|
+
}
|
|
3582
|
+
let fallbackValue;
|
|
3583
|
+
switch (v.baseType) {
|
|
3584
|
+
case "integer":
|
|
3585
|
+
case "float":
|
|
3586
|
+
case "duration":
|
|
3587
|
+
fallbackValue = "0";
|
|
3588
|
+
break;
|
|
3589
|
+
case "boolean":
|
|
3590
|
+
fallbackValue = "false";
|
|
3591
|
+
break;
|
|
3592
|
+
case "string":
|
|
3593
|
+
case "directedPair":
|
|
3594
|
+
case "identifier":
|
|
3595
|
+
case "pair":
|
|
3596
|
+
case "record":
|
|
3597
|
+
default:
|
|
3598
|
+
fallbackValue = "";
|
|
3599
|
+
break;
|
|
3600
|
+
}
|
|
3601
|
+
const defaultValue = v.defaultValue ?? fallbackValue;
|
|
3602
|
+
if (Array.isArray(v.value)) {
|
|
3603
|
+
const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
3604
|
+
return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
|
|
3605
|
+
}
|
|
3606
|
+
return v.value === defaultValue;
|
|
3607
|
+
});
|
|
3608
|
+
const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
|
|
3609
|
+
const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
|
|
3610
|
+
const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
|
|
3611
|
+
let optimality = this.#optimality.get(computedItem.identifier);
|
|
3612
|
+
if (optimality === void 0) {
|
|
3613
|
+
optimality = itemContext ? this.#assessOptimality(itemContext) : "unscored";
|
|
3614
|
+
if (numAttempts > 0)
|
|
3615
|
+
this.#optimality.set(computedItem.identifier, optimality);
|
|
3616
|
+
}
|
|
3617
|
+
const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts, computedItem.adaptive, completionStatus);
|
|
3618
|
+
return {
|
|
3619
|
+
...computedItem,
|
|
3620
|
+
completionStatus,
|
|
3621
|
+
numAttempts,
|
|
3622
|
+
score,
|
|
3623
|
+
response,
|
|
3624
|
+
index,
|
|
3625
|
+
active,
|
|
3626
|
+
valid,
|
|
3627
|
+
isDefaultResponse,
|
|
3628
|
+
maxScore,
|
|
3629
|
+
done,
|
|
3630
|
+
// Reflects the last *ended* attempt only. Read the latch directly
|
|
3631
|
+
// (not the `optimality` local) — the latch is written solely on
|
|
3632
|
+
// responseProcessed / restore-seed (line above, guarded by
|
|
3633
|
+
// numAttempts > 0), so a freshly-picked mid-attempt selection
|
|
3634
|
+
// computed live is never stored and never counts as optimal.
|
|
3635
|
+
optimal: this.#optimality.get(computedItem.identifier) === "optimal"
|
|
3636
|
+
// type,
|
|
3637
|
+
// correct,
|
|
3638
|
+
// incorrect,
|
|
3639
|
+
// completed
|
|
3640
|
+
};
|
|
3641
|
+
})
|
|
3642
|
+
};
|
|
3643
|
+
})
|
|
3644
|
+
};
|
|
3645
|
+
})
|
|
3646
|
+
};
|
|
3647
|
+
this.dispatchEvent(new CustomEvent("qti-computed-context-updated", {
|
|
3648
|
+
detail: this.computedContext,
|
|
3649
|
+
bubbles: true
|
|
3650
|
+
}));
|
|
3651
|
+
}
|
|
3652
|
+
/**
|
|
3653
|
+
* Decide whether an item should be treated as "the candidate is done with it"
|
|
3654
|
+
* for the purpose of gating forward navigation and further attempts.
|
|
3655
|
+
*
|
|
3656
|
+
* - The candidate must have actually ended an attempt (numAttempts > 0).
|
|
3657
|
+
* - Once attempted, the item is done if they reached the optimal outcome
|
|
3658
|
+
* ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
|
|
3659
|
+
* done while a better attempt is still possible ('suboptimal') and attempts
|
|
3660
|
+
* remain — see #assessOptimality for how "optimal" is determined.
|
|
3661
|
+
*
|
|
3662
|
+
* `optimality` reflects the last *ended attempt* (see #optimality), not the
|
|
3663
|
+
* live selection — so a freshly-picked optimal answer doesn't count as done
|
|
3664
|
+
* until test-end-attempt evaluates it.
|
|
3665
|
+
*
|
|
3666
|
+
* Adaptive items decide this themselves: max-attempts does not apply to them
|
|
3667
|
+
* (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads
|
|
3668
|
+
* on to the next part of the item. They are done once their response
|
|
3669
|
+
* processing sets completionStatus to 'completed'.
|
|
3670
|
+
*/
|
|
3671
|
+
#isItemDone(numAttempts, optimality, maxAttempts, adaptive, completionStatus) {
|
|
3672
|
+
if (numAttempts === 0)
|
|
3673
|
+
return false;
|
|
3674
|
+
if (adaptive)
|
|
3675
|
+
return completionStatus === "completed";
|
|
3676
|
+
if (optimality !== "suboptimal")
|
|
3677
|
+
return true;
|
|
3678
|
+
const max = maxAttempts ?? 1;
|
|
3679
|
+
return max > 0 && numAttempts >= max;
|
|
3680
|
+
}
|
|
3681
|
+
/**
|
|
3682
|
+
* Decide whether an item's submission is as good as it can get — i.e. the
|
|
3683
|
+
* candidate reached the *optimal* outcome, so there's no reason to make them
|
|
3684
|
+
* try again. 'optimal' means best achievable, 'suboptimal' means a better
|
|
3685
|
+
* attempt is still possible, 'unscored' means there's nothing to judge against.
|
|
3686
|
+
* ("optimal" is the spec's own word — a qti-correct-response is defined as
|
|
3687
|
+
* "the (or an) optimal value".)
|
|
3688
|
+
*
|
|
3689
|
+
* Two signals, in order of authority:
|
|
3690
|
+
* 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).
|
|
3691
|
+
* This correctly handles partial-credit / qti-mapping items, where an exact
|
|
3692
|
+
* response match would under- or over-judge.
|
|
3693
|
+
* 2. The declared qti-correct-response, for items that aren't scored (no
|
|
3694
|
+
* SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping
|
|
3695
|
+
* variables like numAttempts can be typed 'response' but never declare a
|
|
3696
|
+
* correctResponse, so we filter on a declared correctResponse.
|
|
3697
|
+
*
|
|
3698
|
+
* Items with neither a comparable score nor a correctResponse (essays, info
|
|
3699
|
+
* items, etc.) are 'unscored' — there's no optimal value to require, so one
|
|
3700
|
+
* attempt is enough.
|
|
3701
|
+
*/
|
|
3702
|
+
#assessOptimality(item) {
|
|
3703
|
+
const variables = item.variables ?? [];
|
|
3704
|
+
const score = this.#numericVariable(variables, "SCORE");
|
|
3705
|
+
const maxScore = this.#numericVariable(variables, "MAXSCORE");
|
|
3706
|
+
if (score !== null && maxScore !== null) {
|
|
3707
|
+
return score >= maxScore ? "optimal" : "suboptimal";
|
|
3664
3708
|
}
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3709
|
+
const responseVars = variables.filter((v) => v.type === "response" && v.correctResponse !== void 0 && v.correctResponse !== null);
|
|
3710
|
+
if (responseVars.length === 0)
|
|
3711
|
+
return "unscored";
|
|
3712
|
+
const allMatch = responseVars.every((v) => {
|
|
3713
|
+
const expected = v.correctResponse;
|
|
3714
|
+
const actual = v.value;
|
|
3715
|
+
if (actual === void 0 || actual === null)
|
|
3716
|
+
return false;
|
|
3717
|
+
if (Array.isArray(expected) && Array.isArray(actual)) {
|
|
3718
|
+
return expected.length === actual.length && expected.every((e) => actual.includes(e));
|
|
3719
|
+
}
|
|
3720
|
+
if (Array.isArray(expected) || Array.isArray(actual))
|
|
3721
|
+
return false;
|
|
3722
|
+
return expected === actual;
|
|
3723
|
+
});
|
|
3724
|
+
return allMatch ? "optimal" : "suboptimal";
|
|
3725
|
+
}
|
|
3726
|
+
/** Read a single numeric outcome value, or null when absent / non-numeric. */
|
|
3727
|
+
#numericVariable(variables, identifier) {
|
|
3728
|
+
const raw = variables?.find((v) => v.identifier === identifier)?.value;
|
|
3729
|
+
if (raw === void 0 || raw === null || Array.isArray(raw))
|
|
3730
|
+
return null;
|
|
3731
|
+
const parsed = parseFloat(raw.toString());
|
|
3732
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
3733
|
+
}
|
|
3734
|
+
};
|
|
3735
|
+
__decorate16([
|
|
3736
|
+
property13({ type: String })
|
|
3737
|
+
], TestNavigation.prototype, "identifier", void 0);
|
|
3738
|
+
__decorate16([
|
|
3739
|
+
state4()
|
|
3740
|
+
], TestNavigation.prototype, "initContext", void 0);
|
|
3741
|
+
__decorate16([
|
|
3742
|
+
state4(),
|
|
3743
|
+
consume8({ context: configContext, subscribe: true })
|
|
3744
|
+
], TestNavigation.prototype, "configContext", void 0);
|
|
3745
|
+
__decorate16([
|
|
3746
|
+
state4(),
|
|
3747
|
+
consume8({ context: testContext, subscribe: true })
|
|
3748
|
+
], TestNavigation.prototype, "_testContext", void 0);
|
|
3749
|
+
__decorate16([
|
|
3750
|
+
state4(),
|
|
3751
|
+
consume8({ context: sessionContext, subscribe: true })
|
|
3752
|
+
], TestNavigation.prototype, "_sessionContext", void 0);
|
|
3753
|
+
__decorate16([
|
|
3754
|
+
state4(),
|
|
3755
|
+
provide3({ context: computedContext })
|
|
3756
|
+
], TestNavigation.prototype, "computedContext", void 0);
|
|
3757
|
+
__decorate16([
|
|
3758
|
+
property13({ type: Boolean, attribute: "auto-score-items" })
|
|
3759
|
+
], TestNavigation.prototype, "autoScoreItems", void 0);
|
|
3760
|
+
|
|
3761
|
+
// ../qti-test/dist/components/test-next/test-next.js
|
|
3762
|
+
import { css as css8, html as html14, LitElement as LitElement15 } from "lit";
|
|
3763
|
+
import { property as property14 } from "lit/decorators.js";
|
|
3764
|
+
import { consume as consume9 } from "@lit/context";
|
|
3765
|
+
var __decorate17 = function(decorators, target, key, desc) {
|
|
3766
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3767
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3768
|
+
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;
|
|
3769
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3770
|
+
};
|
|
3771
|
+
var TestNext = class extends LitElement15 {
|
|
3772
|
+
_handleTestElementChange(_oldValue, newValue) {
|
|
3773
|
+
if (newValue) {
|
|
3774
|
+
this.requestUpdate();
|
|
3670
3775
|
}
|
|
3671
|
-
if (this.#contentMode && this.#currentElementIndex === 0)
|
|
3672
|
-
this.#readingElements = null;
|
|
3673
|
-
this.#speakElement(this.#currentElementIndex);
|
|
3674
3776
|
}
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
this.#clearWordHighlight();
|
|
3680
|
-
this.#currentElementIndex = elements.length - 1;
|
|
3681
|
-
if (elements.length > 0)
|
|
3682
|
-
this.#highlightElement(elements[this.#currentElementIndex]);
|
|
3683
|
-
this.#finished = true;
|
|
3684
|
-
this.#setSpeechState("idle");
|
|
3685
|
-
this.#updateContext();
|
|
3686
|
-
return;
|
|
3777
|
+
static {
|
|
3778
|
+
this.styles = css8`
|
|
3779
|
+
:host {
|
|
3780
|
+
${btn};
|
|
3687
3781
|
}
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
this.#updateContext();
|
|
3691
|
-
const element = elements[index];
|
|
3692
|
-
element.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3693
|
-
this.#highlightElement(element);
|
|
3694
|
-
this.#textNodes = this.#collectTextNodes(element);
|
|
3695
|
-
const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
|
|
3696
|
-
if (!text.trim()) {
|
|
3697
|
-
this.#speakElement(index + 1);
|
|
3698
|
-
return;
|
|
3782
|
+
:host(:hover:not([disabled])) {
|
|
3783
|
+
${btnInteractive};
|
|
3699
3784
|
}
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
};
|
|
3708
|
-
utterance.onend = () => {
|
|
3709
|
-
if (this.#currentUtterance !== utterance)
|
|
3710
|
-
return;
|
|
3711
|
-
this.#currentUtterance = null;
|
|
3712
|
-
this.#clearWordHighlight();
|
|
3713
|
-
this.#speakElement(this.#currentElementIndex + 1);
|
|
3714
|
-
};
|
|
3715
|
-
utterance.onerror = () => {
|
|
3716
|
-
if (this.#currentUtterance !== utterance)
|
|
3717
|
-
return;
|
|
3718
|
-
this.#currentUtterance = null;
|
|
3719
|
-
this.#clearAllHighlights();
|
|
3720
|
-
this.#setSpeechState("idle");
|
|
3721
|
-
};
|
|
3722
|
-
this.#currentUtterance = utterance;
|
|
3723
|
-
speechSynthesis.speak(utterance);
|
|
3724
|
-
this.#setSpeechState("playing");
|
|
3785
|
+
:host(:focus-visible) {
|
|
3786
|
+
${focusRing};
|
|
3787
|
+
}
|
|
3788
|
+
:host([disabled]) {
|
|
3789
|
+
${dis};
|
|
3790
|
+
}
|
|
3791
|
+
`;
|
|
3725
3792
|
}
|
|
3726
|
-
#
|
|
3727
|
-
|
|
3728
|
-
|
|
3793
|
+
#internals;
|
|
3794
|
+
constructor() {
|
|
3795
|
+
super();
|
|
3796
|
+
this._internalDisabled = true;
|
|
3797
|
+
this.#internals = this.attachInternals();
|
|
3798
|
+
this.#internals.role = "button";
|
|
3799
|
+
this.#internals.ariaLabel = "Next item";
|
|
3800
|
+
this.addEventListener("click", (e) => {
|
|
3801
|
+
e.preventDefault();
|
|
3802
|
+
if (!this._internalDisabled)
|
|
3803
|
+
this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);
|
|
3804
|
+
});
|
|
3729
3805
|
}
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
this
|
|
3806
|
+
connectedCallback() {
|
|
3807
|
+
super.connectedCallback();
|
|
3808
|
+
this.checkDisabled();
|
|
3809
|
+
}
|
|
3810
|
+
willUpdate(_changedProperties) {
|
|
3811
|
+
if (!this.computedContext)
|
|
3812
|
+
return;
|
|
3813
|
+
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
3814
|
+
if (!testPart)
|
|
3815
|
+
return;
|
|
3816
|
+
this.sectionItems = testPart.sections.flatMap((section) => section.items);
|
|
3817
|
+
this.itemIndex = this.sectionItems.findIndex((item) => item.active);
|
|
3818
|
+
this.checkDisabled();
|
|
3819
|
+
}
|
|
3820
|
+
checkDisabled() {
|
|
3821
|
+
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
3822
|
+
if (!testPart)
|
|
3823
|
+
return;
|
|
3824
|
+
const activeSection = testPart.sections.find((s) => s.active);
|
|
3825
|
+
const navigationMode = activeSection?.navigationMode || testPart.navigationMode;
|
|
3826
|
+
const submissionMode = activeSection?.submissionMode || testPart.submissionMode;
|
|
3827
|
+
const activeItem = this.sectionItems[this.itemIndex];
|
|
3828
|
+
const isLinearIndividual = navigationMode === "linear" && submissionMode === "individual";
|
|
3829
|
+
this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 || isLinearIndividual && !activeItem?.done;
|
|
3830
|
+
}
|
|
3831
|
+
_requestItem(identifier) {
|
|
3832
|
+
dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
|
|
3833
|
+
}
|
|
3834
|
+
render() {
|
|
3835
|
+
return html14`<slot></slot>`;
|
|
3836
|
+
}
|
|
3837
|
+
};
|
|
3838
|
+
__decorate17([
|
|
3839
|
+
property14({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
3840
|
+
], TestNext.prototype, "_internalDisabled", void 0);
|
|
3841
|
+
__decorate17([
|
|
3842
|
+
consume9({ context: computedContext, subscribe: true })
|
|
3843
|
+
], TestNext.prototype, "computedContext", void 0);
|
|
3844
|
+
__decorate17([
|
|
3845
|
+
watch("computedContext")
|
|
3846
|
+
], TestNext.prototype, "_handleTestElementChange", null);
|
|
3847
|
+
|
|
3848
|
+
// ../qti-test/dist/components/test-prev/test-prev.js
|
|
3849
|
+
import { css as css9, html as html15, LitElement as LitElement16 } from "lit";
|
|
3850
|
+
import { property as property15 } from "lit/decorators.js";
|
|
3851
|
+
import { consume as consume10 } from "@lit/context";
|
|
3852
|
+
var __decorate18 = function(decorators, target, key, desc) {
|
|
3853
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3854
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3855
|
+
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;
|
|
3856
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3857
|
+
};
|
|
3858
|
+
var TestPrev = class extends LitElement16 {
|
|
3859
|
+
_handleTestElementChange(_oldValue, newValue) {
|
|
3860
|
+
if (newValue) {
|
|
3861
|
+
this.requestUpdate();
|
|
3862
|
+
}
|
|
3733
3863
|
}
|
|
3734
|
-
|
|
3735
|
-
this
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3864
|
+
static {
|
|
3865
|
+
this.styles = css9`
|
|
3866
|
+
:host {
|
|
3867
|
+
${btn};
|
|
3868
|
+
}
|
|
3869
|
+
:host(:hover:not([disabled])) {
|
|
3870
|
+
${btnInteractive};
|
|
3871
|
+
}
|
|
3872
|
+
:host(:focus-visible) {
|
|
3873
|
+
${focusRing};
|
|
3874
|
+
}
|
|
3875
|
+
:host([disabled]) {
|
|
3876
|
+
${dis};
|
|
3877
|
+
}
|
|
3878
|
+
`;
|
|
3739
3879
|
}
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
this
|
|
3880
|
+
constructor() {
|
|
3881
|
+
super();
|
|
3882
|
+
this._internalDisabled = true;
|
|
3883
|
+
this.addEventListener("click", (e) => {
|
|
3884
|
+
e.preventDefault();
|
|
3885
|
+
if (!this._internalDisabled)
|
|
3886
|
+
this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);
|
|
3887
|
+
});
|
|
3746
3888
|
}
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
if (this.#contentMode)
|
|
3750
|
-
this.#readingElements = null;
|
|
3751
|
-
const elements = this.#getReadingElements();
|
|
3752
|
-
if (!elements.length) {
|
|
3753
|
-
console.warn("test-item-to-speech: no readable elements found");
|
|
3889
|
+
willUpdate(_changedProperties) {
|
|
3890
|
+
if (!this.computedContext)
|
|
3754
3891
|
return;
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
this.#picking = true;
|
|
3758
|
-
this.#internals.states.add("picking");
|
|
3759
|
-
this.#highlightElements(elements);
|
|
3760
|
-
this.#pickRoot = elements[0].getRootNode();
|
|
3761
|
-
this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
|
|
3762
|
-
this._ttsContext = { ...this._ttsContext, picking: true };
|
|
3763
|
-
}
|
|
3764
|
-
#stopPicking() {
|
|
3765
|
-
if (!this.#picking)
|
|
3892
|
+
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
3893
|
+
if (!testPart)
|
|
3766
3894
|
return;
|
|
3767
|
-
this
|
|
3768
|
-
this
|
|
3769
|
-
this
|
|
3770
|
-
this.#pickRoot = null;
|
|
3771
|
-
this.#clearAllHighlights();
|
|
3772
|
-
this._ttsContext = { ...this._ttsContext, picking: false };
|
|
3895
|
+
this.sectionItems = testPart.sections.flatMap((section) => section.items);
|
|
3896
|
+
this.itemIndex = this.sectionItems.findIndex((item) => item.active);
|
|
3897
|
+
this.checkDisabled();
|
|
3773
3898
|
}
|
|
3774
|
-
|
|
3775
|
-
const
|
|
3776
|
-
const
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
|
|
3780
|
-
if (container)
|
|
3781
|
-
index = elements.findIndex((el) => container.contains(el));
|
|
3782
|
-
}
|
|
3783
|
-
if (index < 0)
|
|
3784
|
-
return;
|
|
3785
|
-
event.preventDefault();
|
|
3786
|
-
event.stopPropagation();
|
|
3787
|
-
this.#stopPicking();
|
|
3788
|
-
speechSynthesis.cancel();
|
|
3789
|
-
this.#speakElement(index);
|
|
3899
|
+
checkDisabled() {
|
|
3900
|
+
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
3901
|
+
const activeSection = testPart?.sections.find((s) => s.active);
|
|
3902
|
+
const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || "nonlinear";
|
|
3903
|
+
this._internalDisabled = navigationMode === "linear" || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
|
|
3790
3904
|
}
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
if (!elements.length)
|
|
3794
|
-
return;
|
|
3795
|
-
this.#currentUtterance = null;
|
|
3796
|
-
speechSynthesis.cancel();
|
|
3797
|
-
this.#clearWordHighlight();
|
|
3798
|
-
this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
|
|
3799
|
-
this.#finished = false;
|
|
3800
|
-
this.#updateContext();
|
|
3801
|
-
const el = elements[this.#currentElementIndex];
|
|
3802
|
-
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3803
|
-
this.#highlightElement(el);
|
|
3804
|
-
this.#setSpeechState("idle");
|
|
3905
|
+
_requestItem(identifier) {
|
|
3906
|
+
dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
|
|
3805
3907
|
}
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
if (!elements.length)
|
|
3809
|
-
return;
|
|
3810
|
-
this.#currentUtterance = null;
|
|
3811
|
-
speechSynthesis.cancel();
|
|
3812
|
-
this.#clearWordHighlight();
|
|
3813
|
-
this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
|
|
3814
|
-
this.#finished = false;
|
|
3815
|
-
this.#updateContext();
|
|
3816
|
-
const el = elements[this.#currentElementIndex];
|
|
3817
|
-
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3818
|
-
this.#highlightElement(el);
|
|
3819
|
-
this.#setSpeechState("idle");
|
|
3908
|
+
render() {
|
|
3909
|
+
return html15`<slot></slot>`;
|
|
3820
3910
|
}
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3911
|
+
};
|
|
3912
|
+
__decorate18([
|
|
3913
|
+
property15({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
3914
|
+
], TestPrev.prototype, "_internalDisabled", void 0);
|
|
3915
|
+
__decorate18([
|
|
3916
|
+
consume10({ context: computedContext, subscribe: true })
|
|
3917
|
+
], TestPrev.prototype, "computedContext", void 0);
|
|
3918
|
+
__decorate18([
|
|
3919
|
+
watch("computedContext")
|
|
3920
|
+
], TestPrev.prototype, "_handleTestElementChange", null);
|
|
3921
|
+
|
|
3922
|
+
// ../qti-test/dist/components/test-section-link/test-section-link.js
|
|
3923
|
+
import { css as css10, html as html16, LitElement as LitElement17 } from "lit";
|
|
3924
|
+
import { property as property16 } from "lit/decorators.js";
|
|
3925
|
+
var __decorate19 = function(decorators, target, key, desc) {
|
|
3926
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3927
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3928
|
+
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;
|
|
3929
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3930
|
+
};
|
|
3931
|
+
var TestSectionLink = class extends LitElement17 {
|
|
3932
|
+
static {
|
|
3933
|
+
this.styles = css10`
|
|
3934
|
+
:host {
|
|
3935
|
+
${btn};
|
|
3830
3936
|
}
|
|
3831
|
-
|
|
3937
|
+
:host(:hover:not([disabled])) {
|
|
3938
|
+
${btnInteractive};
|
|
3939
|
+
}
|
|
3940
|
+
:host(:focus-visible) {
|
|
3941
|
+
${focusRing};
|
|
3942
|
+
}
|
|
3943
|
+
:host([disabled]) {
|
|
3944
|
+
${dis};
|
|
3945
|
+
}
|
|
3946
|
+
`;
|
|
3832
3947
|
}
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
this.#highlightElements([element]);
|
|
3948
|
+
#requestItem(identifier) {
|
|
3949
|
+
dispatchPublic(this, "cito-test-navigate", { type: "section", id: identifier });
|
|
3836
3950
|
}
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
this.#ensureHighlightStyles();
|
|
3842
|
-
this.#elementHighlight.clear();
|
|
3843
|
-
for (const element of elements) {
|
|
3844
|
-
const range = new Range();
|
|
3845
|
-
range.selectNodeContents(element);
|
|
3846
|
-
this.#elementHighlight.add(range);
|
|
3847
|
-
}
|
|
3848
|
-
CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
|
|
3951
|
+
constructor() {
|
|
3952
|
+
super();
|
|
3953
|
+
this.sectionId = null;
|
|
3954
|
+
this.addEventListener("click", () => this.#requestItem(this.sectionId));
|
|
3849
3955
|
}
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3956
|
+
render() {
|
|
3957
|
+
return html16` <slot></slot> `;
|
|
3958
|
+
}
|
|
3959
|
+
};
|
|
3960
|
+
__decorate19([
|
|
3961
|
+
property16({ type: String, attribute: "section-id" })
|
|
3962
|
+
], TestSectionLink.prototype, "sectionId", void 0);
|
|
3963
|
+
|
|
3964
|
+
// ../qti-test/dist/plugin-state.js
|
|
3965
|
+
var pluginState = (context, plugin) => context?.plugins?.[plugin];
|
|
3966
|
+
|
|
3967
|
+
// ../qti-test/dist/components/test-bookmark/test-bookmark.js
|
|
3968
|
+
import { css as css11, html as html17, LitElement as LitElement18 } from "lit";
|
|
3969
|
+
import { consume as consume11 } from "@lit/context";
|
|
3970
|
+
import { property as property17 } from "lit/decorators.js";
|
|
3971
|
+
var __decorate20 = function(decorators, target, key, desc) {
|
|
3972
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3973
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3974
|
+
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;
|
|
3975
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3976
|
+
};
|
|
3977
|
+
var bookmarkedItems = (context) => pluginState(context, "bookmarks") ?? [];
|
|
3978
|
+
var itemRefOf = (element) => {
|
|
3979
|
+
const itemRef = element.closest("qti-assessment-item-ref");
|
|
3980
|
+
if (itemRef)
|
|
3981
|
+
return itemRef.getAttribute("identifier") ?? void 0;
|
|
3982
|
+
const root = element.getRootNode();
|
|
3983
|
+
return root instanceof ShadowRoot ? itemRefOf(root.host) : void 0;
|
|
3984
|
+
};
|
|
3985
|
+
var TestBookmark = class extends LitElement18 {
|
|
3986
|
+
static {
|
|
3987
|
+
this.styles = css11`
|
|
3988
|
+
:host {
|
|
3989
|
+
${btn};
|
|
3875
3990
|
}
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3991
|
+
:host(:hover:not([disabled])) {
|
|
3992
|
+
${btnInteractive};
|
|
3993
|
+
}
|
|
3994
|
+
:host {
|
|
3995
|
+
display: inline-flex;
|
|
3996
|
+
align-items: center;
|
|
3997
|
+
gap: 0.4em;
|
|
3998
|
+
}
|
|
3999
|
+
svg {
|
|
4000
|
+
width: 1.1em;
|
|
4001
|
+
height: 1.1em;
|
|
4002
|
+
flex: none;
|
|
4003
|
+
fill: none;
|
|
4004
|
+
stroke: currentColor;
|
|
4005
|
+
stroke-width: 2;
|
|
4006
|
+
stroke-linejoin: round;
|
|
4007
|
+
}
|
|
4008
|
+
:host([bookmarked]) {
|
|
4009
|
+
color: var(--qti-bookmark-color, #b45309);
|
|
4010
|
+
}
|
|
4011
|
+
:host([bookmarked]) svg {
|
|
4012
|
+
fill: currentColor;
|
|
4013
|
+
}
|
|
4014
|
+
:host(:focus-visible) {
|
|
4015
|
+
${focusRing};
|
|
3882
4016
|
}
|
|
4017
|
+
:host([disabled]) {
|
|
4018
|
+
${dis};
|
|
4019
|
+
}
|
|
4020
|
+
`;
|
|
4021
|
+
}
|
|
4022
|
+
constructor() {
|
|
4023
|
+
super();
|
|
4024
|
+
this.bookmarked = false;
|
|
4025
|
+
this.disabled = false;
|
|
4026
|
+
this.addEventListener("click", () => this.#toggle());
|
|
4027
|
+
this.addEventListener("keydown", (event) => {
|
|
4028
|
+
if (event.key !== "Enter" && event.key !== " ")
|
|
4029
|
+
return;
|
|
4030
|
+
event.preventDefault();
|
|
4031
|
+
this.#toggle();
|
|
4032
|
+
});
|
|
3883
4033
|
}
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
if (
|
|
3889
|
-
|
|
4034
|
+
connectedCallback() {
|
|
4035
|
+
super.connectedCallback();
|
|
4036
|
+
if (!this.hasAttribute("role"))
|
|
4037
|
+
this.setAttribute("role", "button");
|
|
4038
|
+
if (!this.hasAttribute("tabindex"))
|
|
4039
|
+
this.setAttribute("tabindex", "0");
|
|
3890
4040
|
}
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
this.#clearWordHighlight();
|
|
3895
|
-
this.#elementHighlight.clear();
|
|
3896
|
-
if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
|
|
3897
|
-
CSS.highlights.delete(HIGHLIGHT_ELEMENT);
|
|
4041
|
+
/** The item this button marks: its own, or else the one on screen. */
|
|
4042
|
+
get #activeItem() {
|
|
4043
|
+
return this.item || (itemRefOf(this) ?? this.computedContext?.testParts?.flatMap((part) => part.sections.flatMap((section) => section.items)).find((item) => item.active)?.identifier);
|
|
3898
4044
|
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
4045
|
+
willUpdate() {
|
|
4046
|
+
const active = this.#activeItem;
|
|
4047
|
+
this.disabled = !active;
|
|
4048
|
+
this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);
|
|
3903
4049
|
}
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
* across shadow DOM). Called lazily on first highlight use so test-container is
|
|
3908
|
-
* guaranteed to be in the DOM by the time navigation or speech starts.
|
|
3909
|
-
*/
|
|
3910
|
-
#ensureHighlightStyles() {
|
|
3911
|
-
if (!("highlights" in CSS))
|
|
3912
|
-
return;
|
|
3913
|
-
const sheet = getHighlightSheet();
|
|
3914
|
-
if (!document.adoptedStyleSheets.includes(sheet)) {
|
|
3915
|
-
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
3916
|
-
}
|
|
3917
|
-
const roots = /* @__PURE__ */ new Set();
|
|
3918
|
-
const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.testHost?.querySelector("test-container");
|
|
3919
|
-
if (testContainer?.shadowRoot)
|
|
3920
|
-
roots.add(testContainer.shadowRoot);
|
|
3921
|
-
const ownRoot = this.getRootNode();
|
|
3922
|
-
if (ownRoot instanceof ShadowRoot)
|
|
3923
|
-
roots.add(ownRoot);
|
|
3924
|
-
const itemRoot = this.#readingElements?.[0]?.getRootNode();
|
|
3925
|
-
if (itemRoot instanceof ShadowRoot)
|
|
3926
|
-
roots.add(itemRoot);
|
|
3927
|
-
for (const root of roots) {
|
|
3928
|
-
if (!root.adoptedStyleSheets.includes(sheet)) {
|
|
3929
|
-
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
3930
|
-
}
|
|
3931
|
-
}
|
|
4050
|
+
updated() {
|
|
4051
|
+
this.setAttribute("aria-pressed", String(this.bookmarked));
|
|
4052
|
+
this.setAttribute("aria-disabled", String(this.disabled));
|
|
3932
4053
|
}
|
|
3933
|
-
};
|
|
3934
|
-
__decorate17([
|
|
3935
|
-
property13({ type: String })
|
|
3936
|
-
], TestItemToSpeech.prototype, "language", void 0);
|
|
3937
|
-
__decorate17([
|
|
3938
|
-
consume9({ context: sessionContext, subscribe: true })
|
|
3939
|
-
], TestItemToSpeech.prototype, "_sessionContext", void 0);
|
|
3940
|
-
__decorate17([
|
|
3941
|
-
consume9({ context: testHostContext, subscribe: true })
|
|
3942
|
-
], TestItemToSpeech.prototype, "testHost", void 0);
|
|
3943
|
-
__decorate17([
|
|
3944
|
-
state4(),
|
|
3945
|
-
provide3({ context: ttsContext })
|
|
3946
|
-
], TestItemToSpeech.prototype, "_ttsContext", void 0);
|
|
3947
|
-
var TestTtsPlay = class extends TtsButtonBase {
|
|
3948
4054
|
#toggle() {
|
|
3949
|
-
|
|
4055
|
+
const active = this.#activeItem;
|
|
4056
|
+
if (!active)
|
|
3950
4057
|
return;
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
4058
|
+
const marked = bookmarkedItems(this.computedContext);
|
|
4059
|
+
const next = marked.includes(active) ? marked.filter((id) => id !== active) : [...marked, active];
|
|
4060
|
+
dispatchPublic(this, "cito-test-update-plugin-state", {
|
|
4061
|
+
plugin: "bookmarks",
|
|
4062
|
+
value: next.length > 0 ? next : null
|
|
4063
|
+
});
|
|
3957
4064
|
}
|
|
3958
4065
|
render() {
|
|
3959
|
-
|
|
3960
|
-
return html14`
|
|
3961
|
-
<button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
|
|
3962
|
-
${playing ? html14`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html14`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
|
|
3963
|
-
</button>
|
|
3964
|
-
`;
|
|
4066
|
+
return html17`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot>`;
|
|
3965
4067
|
}
|
|
3966
4068
|
};
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4069
|
+
__decorate20([
|
|
4070
|
+
consume11({ context: computedContext, subscribe: true }),
|
|
4071
|
+
property17({ attribute: false })
|
|
4072
|
+
], TestBookmark.prototype, "computedContext", void 0);
|
|
4073
|
+
__decorate20([
|
|
4074
|
+
property17({ reflect: true })
|
|
4075
|
+
], TestBookmark.prototype, "item", void 0);
|
|
4076
|
+
__decorate20([
|
|
4077
|
+
property17({ type: Boolean, reflect: true })
|
|
4078
|
+
], TestBookmark.prototype, "bookmarked", void 0);
|
|
4079
|
+
__decorate20([
|
|
4080
|
+
property17({ type: Boolean, reflect: true })
|
|
4081
|
+
], TestBookmark.prototype, "disabled", void 0);
|
|
4082
|
+
|
|
4083
|
+
// ../qti-test/dist/components/test-check-item/test-check-item.js
|
|
4084
|
+
import { css as css12, html as html18, LitElement as LitElement19 } from "lit";
|
|
4085
|
+
import { property as property18 } from "lit/decorators.js";
|
|
4086
|
+
var __decorate21 = function(decorators, target, key, desc) {
|
|
4087
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4088
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4089
|
+
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;
|
|
4090
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3983
4091
|
};
|
|
3984
|
-
var
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
4092
|
+
var TestCheckItem = class extends LitElement19 {
|
|
4093
|
+
static {
|
|
4094
|
+
this.styles = css12`
|
|
4095
|
+
:host {
|
|
4096
|
+
${btn};
|
|
4097
|
+
}
|
|
4098
|
+
:host(:hover:not([disabled])) {
|
|
4099
|
+
${btnInteractive};
|
|
4100
|
+
}
|
|
4101
|
+
:host(:focus-visible) {
|
|
4102
|
+
${focusRing};
|
|
4103
|
+
}
|
|
4104
|
+
:host([disabled]) {
|
|
4105
|
+
${dis};
|
|
4106
|
+
}
|
|
4107
|
+
`;
|
|
3996
4108
|
}
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
</button>
|
|
4005
|
-
`;
|
|
4109
|
+
constructor() {
|
|
4110
|
+
super();
|
|
4111
|
+
this.view = "scorer";
|
|
4112
|
+
this.addEventListener("click", () => {
|
|
4113
|
+
dispatchPublic(this, "cito-test-end-attempt", {});
|
|
4114
|
+
dispatchPublic(this, "cito-test-switch-view", this.view);
|
|
4115
|
+
});
|
|
4006
4116
|
}
|
|
4007
|
-
};
|
|
4008
|
-
var TestTtsPrev = class extends TtsButtonBase {
|
|
4009
4117
|
render() {
|
|
4010
|
-
|
|
4011
|
-
const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
|
|
4012
|
-
return html14`
|
|
4013
|
-
<button
|
|
4014
|
-
part="button"
|
|
4015
|
-
aria-label=${ifDefined(this.label)}
|
|
4016
|
-
?disabled=${collected && atStart}
|
|
4017
|
-
@click=${() => this._tts?.prevElement()}
|
|
4018
|
-
>
|
|
4019
|
-
<slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
|
|
4020
|
-
</button>
|
|
4021
|
-
`;
|
|
4118
|
+
return html18` <slot></slot> `;
|
|
4022
4119
|
}
|
|
4023
4120
|
};
|
|
4024
|
-
|
|
4121
|
+
__decorate21([
|
|
4122
|
+
property18({ type: String })
|
|
4123
|
+
], TestCheckItem.prototype, "view", void 0);
|
|
4124
|
+
|
|
4125
|
+
// ../qti-test/dist/components/test-print-context/test-print-context.js
|
|
4126
|
+
import { html as html19, LitElement as LitElement20 } from "lit";
|
|
4127
|
+
import { consume as consume12 } from "@lit/context";
|
|
4128
|
+
import { state as state5 } from "lit/decorators.js";
|
|
4129
|
+
var __decorate22 = function(decorators, target, key, desc) {
|
|
4130
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4131
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4132
|
+
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;
|
|
4133
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4134
|
+
};
|
|
4135
|
+
var TestPrintContext = class extends LitElement20 {
|
|
4025
4136
|
render() {
|
|
4026
|
-
|
|
4027
|
-
const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
|
|
4028
|
-
return html14`
|
|
4029
|
-
<button
|
|
4030
|
-
part="button"
|
|
4031
|
-
aria-label=${ifDefined(this.label)}
|
|
4032
|
-
?disabled=${atEnd}
|
|
4033
|
-
@click=${() => this._tts?.nextElement()}
|
|
4034
|
-
>
|
|
4035
|
-
<slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
|
|
4036
|
-
</button>
|
|
4037
|
-
`;
|
|
4137
|
+
return html19` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
|
|
4038
4138
|
}
|
|
4039
4139
|
};
|
|
4040
|
-
|
|
4140
|
+
__decorate22([
|
|
4141
|
+
state5(),
|
|
4142
|
+
consume12({ context: computedContext, subscribe: true })
|
|
4143
|
+
], TestPrintContext.prototype, "computedContext", void 0);
|
|
4144
|
+
|
|
4145
|
+
// ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
|
|
4146
|
+
import { html as html20, css as css13, LitElement as LitElement21 } from "lit";
|
|
4147
|
+
import { consume as consume13 } from "@lit/context";
|
|
4148
|
+
var __decorate23 = function(decorators, target, key, desc) {
|
|
4149
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4150
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4151
|
+
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;
|
|
4152
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4153
|
+
};
|
|
4154
|
+
var TestPrintVariables = class extends LitElement21 {
|
|
4155
|
+
static {
|
|
4156
|
+
this.styles = css13`
|
|
4157
|
+
table {
|
|
4158
|
+
width: 100%;
|
|
4159
|
+
border-collapse: collapse;
|
|
4160
|
+
margin: 20px 0;
|
|
4161
|
+
font-size: 14px;
|
|
4162
|
+
text-align: left;
|
|
4163
|
+
}
|
|
4164
|
+
th,
|
|
4165
|
+
td {
|
|
4166
|
+
border: 1px solid #ddd;
|
|
4167
|
+
padding: 8px;
|
|
4168
|
+
}
|
|
4169
|
+
th {
|
|
4170
|
+
background-color: #f4f4f4;
|
|
4171
|
+
font-weight: bold;
|
|
4172
|
+
}
|
|
4173
|
+
h3 {
|
|
4174
|
+
margin-top: 20px;
|
|
4175
|
+
font-size: 16px;
|
|
4176
|
+
}
|
|
4177
|
+
`;
|
|
4178
|
+
}
|
|
4041
4179
|
render() {
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
>
|
|
4049
|
-
|
|
4050
|
-
|
|
4180
|
+
const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
4181
|
+
if (!activeItem || !activeItem.variables)
|
|
4182
|
+
return html20``;
|
|
4183
|
+
const responseVariables = activeItem.variables.filter((v) => v.type === "response");
|
|
4184
|
+
const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
|
|
4185
|
+
const renderTable = (variables, title) => html20`
|
|
4186
|
+
<h3>${title}</h3>
|
|
4187
|
+
<table>
|
|
4188
|
+
<thead>
|
|
4189
|
+
<tr>
|
|
4190
|
+
<th>Identifier</th>
|
|
4191
|
+
<th>Value</th>
|
|
4192
|
+
<th>Cardinality</th>
|
|
4193
|
+
<th>Base Type</th>
|
|
4194
|
+
<th>Correct Response / Mappings</th>
|
|
4195
|
+
</tr>
|
|
4196
|
+
</thead>
|
|
4197
|
+
<tbody>
|
|
4198
|
+
${variables.map((v) => {
|
|
4199
|
+
const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
|
|
4200
|
+
const mapEntries = v.mapping?.mapEntries?.map((m) => `${m.mapKey}=${m.mappedValue}pt`).join(", ") || "";
|
|
4201
|
+
const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m) => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ") || "";
|
|
4202
|
+
return html20`
|
|
4203
|
+
<tr>
|
|
4204
|
+
<td>${v.identifier}</td>
|
|
4205
|
+
<td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
|
|
4206
|
+
<td>${v.cardinality}</td>
|
|
4207
|
+
<td>${v.baseType}</td>
|
|
4208
|
+
<td>${correctResponse || mapEntries || areaMapEntries}</td>
|
|
4209
|
+
</tr>
|
|
4210
|
+
`;
|
|
4211
|
+
})}
|
|
4212
|
+
</tbody>
|
|
4213
|
+
</table>
|
|
4214
|
+
`;
|
|
4215
|
+
return html20`
|
|
4216
|
+
${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
|
|
4051
4217
|
`;
|
|
4052
4218
|
}
|
|
4053
4219
|
};
|
|
4220
|
+
__decorate23([
|
|
4221
|
+
consume13({ context: computedContext, subscribe: true })
|
|
4222
|
+
], TestPrintVariables.prototype, "computedContext", void 0);
|
|
4054
4223
|
|
|
4055
|
-
// ../qti-test/dist/components/test-
|
|
4056
|
-
import {
|
|
4057
|
-
import {
|
|
4058
|
-
import { property as
|
|
4059
|
-
var
|
|
4224
|
+
// ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
|
|
4225
|
+
import { html as html21, LitElement as LitElement22, nothing as nothing3 } from "lit";
|
|
4226
|
+
import { consume as consume14 } from "@lit/context";
|
|
4227
|
+
import { property as property19 } from "lit/decorators.js";
|
|
4228
|
+
var __decorate24 = function(decorators, target, key, desc) {
|
|
4060
4229
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4061
4230
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4062
4231
|
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;
|
|
4063
4232
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4064
4233
|
};
|
|
4065
|
-
var
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
var TestNavigation = class extends LitElement16 {
|
|
4069
|
-
/**
|
|
4070
|
-
* @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
|
|
4071
|
-
* enclosing test's: reading returns it, writing replaces it, so a host that has always set the
|
|
4072
|
-
* shuffle seed here keeps working. Removed in the next major.
|
|
4073
|
-
*
|
|
4074
|
-
* Written before the navigation is inside a test, it waits and is handed over on connect.
|
|
4075
|
-
*/
|
|
4076
|
-
get qtiContext() {
|
|
4077
|
-
return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
|
|
4234
|
+
var TestScoringButtons = class extends LitElement22 {
|
|
4235
|
+
createRenderRoot() {
|
|
4236
|
+
return this;
|
|
4078
4237
|
}
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4238
|
+
connectedCallback() {
|
|
4239
|
+
super.connectedCallback();
|
|
4240
|
+
const templateElement = this.querySelector("template");
|
|
4241
|
+
if (!templateElement) {
|
|
4242
|
+
this.myTemplate = null;
|
|
4243
|
+
return;
|
|
4083
4244
|
}
|
|
4084
|
-
this
|
|
4085
|
-
}
|
|
4086
|
-
#pendingQtiContext;
|
|
4087
|
-
#warnedQtiContext;
|
|
4088
|
-
/** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */
|
|
4089
|
-
#writeQtiContext(value) {
|
|
4090
|
-
const owner = this.#owner();
|
|
4091
|
-
if (owner)
|
|
4092
|
-
owner.qtiContext = value;
|
|
4093
|
-
else
|
|
4094
|
-
this.#pendingQtiContext = value;
|
|
4095
|
-
}
|
|
4096
|
-
/**
|
|
4097
|
-
* The `qti-test` this navigation is in, found through context so it works across shadow roots.
|
|
4098
|
-
* A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.
|
|
4099
|
-
*/
|
|
4100
|
-
#testHost;
|
|
4101
|
-
#owner() {
|
|
4102
|
-
return this.#testHost.value ?? null;
|
|
4245
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
4103
4246
|
}
|
|
4104
|
-
#
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
#optimality;
|
|
4113
|
-
constructor() {
|
|
4114
|
-
super();
|
|
4115
|
-
this.identifier = void 0;
|
|
4116
|
-
this.initContext = [];
|
|
4117
|
-
this.#warnedQtiContext = false;
|
|
4118
|
-
this.#testHost = new ContextConsumer(this, {
|
|
4119
|
-
context: testHostContext,
|
|
4120
|
-
subscribe: true,
|
|
4121
|
-
callback: (host) => {
|
|
4122
|
-
if (host && this.#pendingQtiContext) {
|
|
4123
|
-
host.qtiContext = this.#pendingQtiContext;
|
|
4124
|
-
this.#pendingQtiContext = void 0;
|
|
4125
|
-
}
|
|
4126
|
-
}
|
|
4247
|
+
#changeOutcomeScore(value) {
|
|
4248
|
+
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
4249
|
+
const sectionItems = testPart.sections.flatMap((section) => section.items);
|
|
4250
|
+
const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
|
|
4251
|
+
dispatchPublic(this, "cito-test-update-outcome", {
|
|
4252
|
+
assessmentItemRefId: currentItemIdentifier,
|
|
4253
|
+
outcomeVariableId: "SCORE",
|
|
4254
|
+
value
|
|
4127
4255
|
});
|
|
4128
|
-
this.configContext = {};
|
|
4129
|
-
this.autoScoreItems = false;
|
|
4130
|
-
this.#optimality = /* @__PURE__ */ new Map();
|
|
4131
|
-
listenPublic2(this, "cito-test-loaded", this.#handleTestConnected.bind(this));
|
|
4132
|
-
this.addEventListener("qti-assessment-item-connected", this.#handleItemConnected.bind(this));
|
|
4133
|
-
listenPublic(this, "cito-item-response-changed", this.#handleInteractionChanged.bind(this));
|
|
4134
|
-
this.addEventListener("qti-item-context-updated", this.#handleItemContextUpdated.bind(this));
|
|
4135
|
-
listenPublic2(this, "cito-test-end-attempt", this.#handleTestEndAttempt.bind(this));
|
|
4136
|
-
listenPublic2(this, "cito-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
|
|
4137
|
-
}
|
|
4138
|
-
/**
|
|
4139
|
-
* Latch whether an item reached its optimal outcome whenever it has just ended
|
|
4140
|
-
* an attempt. processResponse — fired by test-end-attempt, autoscore, or an
|
|
4141
|
-
* in-item end-attempt interaction — flags its context update with
|
|
4142
|
-
* `responseProcessed`; a plain selection updates the context without it, so
|
|
4143
|
-
* `done` can't flip until the candidate actually ends the attempt.
|
|
4144
|
-
*/
|
|
4145
|
-
#handleItemContextUpdated(event) {
|
|
4146
|
-
if (!event.detail?.responseProcessed)
|
|
4147
|
-
return;
|
|
4148
|
-
const itemContext = event.detail.itemContext;
|
|
4149
|
-
if (!itemContext?.identifier)
|
|
4150
|
-
return;
|
|
4151
|
-
const optimality = this.#assessOptimality(itemContext);
|
|
4152
|
-
this.#optimality.set(itemContext.identifier, optimality);
|
|
4153
|
-
const computedItem = this.computedItemFor(itemContext.identifier);
|
|
4154
|
-
const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
|
|
4155
|
-
const completionStatus = itemContext.variables?.find((v) => v.identifier === "completionStatus")?.value;
|
|
4156
|
-
this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.maxAttempts, computedItem?.adaptive, completionStatus));
|
|
4157
|
-
}
|
|
4158
|
-
/**
|
|
4159
|
-
* Extension point for presentation packages reacting to an ended attempt.
|
|
4160
|
-
* `done` is settled here — from the freshly latched optimality and the
|
|
4161
|
-
* session-control cascade — because the computed context only catches up on
|
|
4162
|
-
* the next update, after this event has finished bubbling.
|
|
4163
|
-
*/
|
|
4164
|
-
afterAttemptEnded(_assessmentItem, _computedItem, _done) {
|
|
4165
|
-
}
|
|
4166
|
-
/** The computed-context entry for an item, from the session-control cascade. */
|
|
4167
|
-
computedItemFor(identifier) {
|
|
4168
|
-
return this.computedContext?.testParts?.flatMap((part) => part.sections).flatMap((section) => section.items).find((i) => i.identifier === identifier);
|
|
4169
|
-
}
|
|
4170
|
-
/** The assessment item for an item-ref id, if it has been rendered. */
|
|
4171
|
-
#assessmentItemFor(identifier) {
|
|
4172
|
-
if (!identifier)
|
|
4173
|
-
return void 0;
|
|
4174
|
-
const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${identifier}"]`);
|
|
4175
|
-
return itemRef?.assessmentItem ?? void 0;
|
|
4176
|
-
}
|
|
4177
|
-
/** The currently active assessment item, exposed for optional presentation extensions. */
|
|
4178
|
-
get activeAssessmentItem() {
|
|
4179
|
-
if (!this.#testElement || !this._sessionContext?.navItemRefId)
|
|
4180
|
-
return void 0;
|
|
4181
|
-
return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
|
|
4182
|
-
}
|
|
4183
|
-
/**
|
|
4184
|
-
* Handles the 'test-end-attempt' event.
|
|
4185
|
-
* @private
|
|
4186
|
-
* @listens TestNavigation#test-end-attempt
|
|
4187
|
-
* @param {CustomEvent} event - The custom event object.
|
|
4188
|
-
*/
|
|
4189
|
-
#handleTestEndAttempt(_event) {
|
|
4190
|
-
const qtiAssessmentItemEl = this.activeAssessmentItem;
|
|
4191
|
-
if (!qtiAssessmentItemEl)
|
|
4192
|
-
return;
|
|
4193
|
-
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
4194
|
-
qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
|
|
4195
|
-
}
|
|
4196
|
-
#handleTestUpdateOutcomeVariable(event) {
|
|
4197
|
-
const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);
|
|
4198
|
-
if (!qtiAssessmentItemEl)
|
|
4199
|
-
return;
|
|
4200
|
-
qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
|
|
4201
|
-
}
|
|
4202
|
-
#handleInteractionChanged(_event) {
|
|
4203
|
-
if (this.autoScoreItems) {
|
|
4204
|
-
const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
|
|
4205
|
-
if (!assessmentItem)
|
|
4206
|
-
return;
|
|
4207
|
-
const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
|
|
4208
|
-
if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
|
|
4209
|
-
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
4210
|
-
assessmentItem.processResponse(true, reportValidityAfterScoring);
|
|
4211
|
-
}
|
|
4212
|
-
}
|
|
4213
4256
|
}
|
|
4214
4257
|
render() {
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
};
|
|
4227
|
-
this.#writeQtiContext({
|
|
4228
|
-
QTI_CONTEXT: {
|
|
4229
|
-
...currentContext,
|
|
4230
|
-
testIdentifier: this.#testElement.identifier,
|
|
4231
|
-
environmentIdentifier: currentContext.environmentIdentifier || "default"
|
|
4232
|
-
}
|
|
4233
|
-
});
|
|
4234
|
-
}
|
|
4235
|
-
const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
|
|
4236
|
-
contextDeclarations.forEach((declaration) => {
|
|
4237
|
-
const defaultValues = this.#extractDefaultValues(declaration);
|
|
4238
|
-
if (Object.keys(defaultValues).length > 0) {
|
|
4239
|
-
this.#writeQtiContext({
|
|
4240
|
-
QTI_CONTEXT: {
|
|
4241
|
-
...defaultValues,
|
|
4242
|
-
// Default values first
|
|
4243
|
-
...this.qtiContext.QTI_CONTEXT
|
|
4244
|
-
// Runtime values override defaults
|
|
4245
|
-
}
|
|
4246
|
-
});
|
|
4247
|
-
}
|
|
4248
|
-
});
|
|
4249
|
-
const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
|
|
4250
|
-
this.computedContext = {
|
|
4251
|
-
identifier: this.#testElement.identifier,
|
|
4252
|
-
title: this.#testElement.title,
|
|
4253
|
-
view: this._sessionContext?.view,
|
|
4254
|
-
testParts: testPartElements.map((testPart) => {
|
|
4255
|
-
const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
|
|
4256
|
-
const testPartSessionControl = testPart.querySelector(":scope > qti-item-session-control");
|
|
4257
|
-
const partAllowSkipping = testPartSessionControl ? testPartSessionControl.allowSkipping : true;
|
|
4258
|
-
const partMaxAttempts = testPartSessionControl ? testPartSessionControl.maxAttempts : 1;
|
|
4259
|
-
const partShowFeedback = testPartSessionControl ? testPartSessionControl.showFeedback : false;
|
|
4260
|
-
const partShowSolution = testPartSessionControl ? testPartSessionControl.showSolution : false;
|
|
4261
|
-
return {
|
|
4262
|
-
active: false,
|
|
4263
|
-
identifier: testPart.identifier,
|
|
4264
|
-
navigationMode: testPart.navigationMode,
|
|
4265
|
-
submissionMode: testPart.submissionMode,
|
|
4266
|
-
allowSkipping: partAllowSkipping,
|
|
4267
|
-
sections: sectionElements.map((section) => {
|
|
4268
|
-
const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
|
|
4269
|
-
const sectionSessionControl = section.querySelector(":scope > qti-item-session-control");
|
|
4270
|
-
const sectionAllowSkipping = sectionSessionControl ? sectionSessionControl.allowSkipping : partAllowSkipping;
|
|
4271
|
-
const sectionMaxAttempts = sectionSessionControl ? sectionSessionControl.maxAttempts : partMaxAttempts;
|
|
4272
|
-
const sectionShowFeedback = sectionSessionControl ? sectionSessionControl.showFeedback : partShowFeedback;
|
|
4273
|
-
const sectionShowSolution = sectionSessionControl ? sectionSessionControl.showSolution : partShowSolution;
|
|
4274
|
-
return {
|
|
4275
|
-
active: false,
|
|
4276
|
-
identifier: section.identifier,
|
|
4277
|
-
title: section.title,
|
|
4278
|
-
navigationMode: section.navigationMode,
|
|
4279
|
-
submissionMode: section.submissionMode,
|
|
4280
|
-
allowSkipping: sectionAllowSkipping,
|
|
4281
|
-
items: itemElements.map((item) => {
|
|
4282
|
-
const itemSessionControl = item.querySelector(":scope > qti-item-session-control");
|
|
4283
|
-
const itemAllowSkipping = itemSessionControl ? itemSessionControl.allowSkipping : sectionAllowSkipping;
|
|
4284
|
-
const itemMaxAttempts = itemSessionControl ? itemSessionControl.maxAttempts : sectionMaxAttempts;
|
|
4285
|
-
const itemShowFeedback = itemSessionControl ? itemSessionControl.showFeedback : sectionShowFeedback;
|
|
4286
|
-
const itemShowSolution = itemSessionControl ? itemSessionControl.showSolution : sectionShowSolution;
|
|
4287
|
-
return {
|
|
4288
|
-
...this.initContext?.find((i) => i.identifier === item.identifier),
|
|
4289
|
-
active: false,
|
|
4290
|
-
identifier: item.identifier,
|
|
4291
|
-
categories: item.category ? item.category?.split(" ") : [],
|
|
4292
|
-
href: item.href,
|
|
4293
|
-
variables: [],
|
|
4294
|
-
allowSkipping: itemAllowSkipping,
|
|
4295
|
-
maxAttempts: itemMaxAttempts,
|
|
4296
|
-
showFeedback: itemShowFeedback,
|
|
4297
|
-
showSolution: itemShowSolution
|
|
4298
|
-
};
|
|
4299
|
-
})
|
|
4300
|
-
};
|
|
4301
|
-
})
|
|
4302
|
-
};
|
|
4303
|
-
})
|
|
4304
|
-
};
|
|
4258
|
+
const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
4259
|
+
if (!activeItem || !activeItem.variables)
|
|
4260
|
+
return html21``;
|
|
4261
|
+
const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
|
|
4262
|
+
const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
|
|
4263
|
+
const score = scoreOutcome?.value;
|
|
4264
|
+
const disabled = !(scoreOutcome?.externalScored === "human");
|
|
4265
|
+
if (!maxScore || !scoreOutcome)
|
|
4266
|
+
return nothing3;
|
|
4267
|
+
const scores = [...Array(Number(maxScore) + 1).keys()];
|
|
4268
|
+
return html21`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing3}`;
|
|
4305
4269
|
}
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
valueElements.forEach((valueElement) => {
|
|
4317
|
-
const fieldIdentifier = valueElement.getAttribute("field-identifier");
|
|
4318
|
-
const baseType = valueElement.getAttribute("base-type") || "string";
|
|
4319
|
-
const textContent = valueElement.textContent?.trim() || "";
|
|
4320
|
-
if (fieldIdentifier) {
|
|
4321
|
-
let value = textContent;
|
|
4322
|
-
switch (baseType) {
|
|
4323
|
-
case "integer":
|
|
4324
|
-
value = parseInt(textContent, 10);
|
|
4325
|
-
break;
|
|
4326
|
-
case "float":
|
|
4327
|
-
case "duration":
|
|
4328
|
-
value = parseFloat(textContent);
|
|
4329
|
-
break;
|
|
4330
|
-
case "boolean":
|
|
4331
|
-
value = textContent.toLowerCase() === "true";
|
|
4332
|
-
break;
|
|
4333
|
-
case "string":
|
|
4334
|
-
default:
|
|
4335
|
-
value = textContent;
|
|
4336
|
-
break;
|
|
4337
|
-
}
|
|
4338
|
-
defaultValues[fieldIdentifier] = value;
|
|
4270
|
+
constructor() {
|
|
4271
|
+
super();
|
|
4272
|
+
this.view = "";
|
|
4273
|
+
this.disabled = false;
|
|
4274
|
+
this.myTemplate = null;
|
|
4275
|
+
this.addEventListener("click", (e) => {
|
|
4276
|
+
const target = e.target;
|
|
4277
|
+
const value = parseFloat(target.value);
|
|
4278
|
+
if (target.tagName === "INPUT") {
|
|
4279
|
+
this.#changeOutcomeScore(value);
|
|
4339
4280
|
}
|
|
4340
4281
|
});
|
|
4341
|
-
return defaultValues;
|
|
4342
4282
|
}
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
}
|
|
4283
|
+
};
|
|
4284
|
+
__decorate24([
|
|
4285
|
+
property19({ type: String, attribute: "view" })
|
|
4286
|
+
], TestScoringButtons.prototype, "view", void 0);
|
|
4287
|
+
__decorate24([
|
|
4288
|
+
property19({ type: Boolean })
|
|
4289
|
+
], TestScoringButtons.prototype, "disabled", void 0);
|
|
4290
|
+
__decorate24([
|
|
4291
|
+
consume14({ context: computedContext, subscribe: true })
|
|
4292
|
+
], TestScoringButtons.prototype, "computedContext", void 0);
|
|
4293
|
+
|
|
4294
|
+
// ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
|
|
4295
|
+
import { consume as consume15 } from "@lit/context";
|
|
4296
|
+
import { html as html22, LitElement as LitElement23 } from "lit";
|
|
4297
|
+
import { property as property20 } from "lit/decorators.js";
|
|
4298
|
+
var __decorate25 = function(decorators, target, key, desc) {
|
|
4299
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4300
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4301
|
+
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;
|
|
4302
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4303
|
+
};
|
|
4304
|
+
var TestScoringFeedback = class extends LitElement23 {
|
|
4305
|
+
constructor() {
|
|
4306
|
+
super(...arguments);
|
|
4307
|
+
this.view = null;
|
|
4308
|
+
}
|
|
4309
|
+
render() {
|
|
4310
|
+
const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
4311
|
+
if (!activeItem || !activeItem.variables)
|
|
4312
|
+
return html22``;
|
|
4313
|
+
if (activeItem["category"] === "dep-informational")
|
|
4314
|
+
return html22`<div>${this.dataset.informational}</div>`;
|
|
4315
|
+
const completionStatus = activeItem?.variables.find((v) => v.identifier === "completionStatus")?.value;
|
|
4316
|
+
const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
|
|
4317
|
+
const score = parseFloat(scoreOutcome?.value);
|
|
4318
|
+
const externalScored = activeItem["externalScored"];
|
|
4319
|
+
const feedbackText = () => {
|
|
4320
|
+
if (completionStatus !== "completed") {
|
|
4321
|
+
return this.dataset.textNoResponse;
|
|
4322
|
+
}
|
|
4323
|
+
if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
|
|
4324
|
+
return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
|
|
4325
|
+
}
|
|
4326
|
+
if (externalScored === "externalMachine") {
|
|
4327
|
+
return Number.isNaN(score) || score === void 0 ? this.dataset.scoreUnknown : `We hebben je antwoord ${score === 0 ? "geen punten" : score == 1 ? "\xE9\xE9n punt" : `${score} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`;
|
|
4328
|
+
}
|
|
4329
|
+
if (externalScored === "human") {
|
|
4330
|
+
return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
|
|
4331
|
+
}
|
|
4332
|
+
return this.dataset.inProgress;
|
|
4386
4333
|
};
|
|
4334
|
+
return html22`<div>${feedbackText()}</div>`;
|
|
4387
4335
|
}
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
if (v.value === void 0 || v.value === null) {
|
|
4422
|
-
return true;
|
|
4423
|
-
}
|
|
4424
|
-
let fallbackValue;
|
|
4425
|
-
switch (v.baseType) {
|
|
4426
|
-
case "integer":
|
|
4427
|
-
case "float":
|
|
4428
|
-
case "duration":
|
|
4429
|
-
fallbackValue = "0";
|
|
4430
|
-
break;
|
|
4431
|
-
case "boolean":
|
|
4432
|
-
fallbackValue = "false";
|
|
4433
|
-
break;
|
|
4434
|
-
case "string":
|
|
4435
|
-
case "directedPair":
|
|
4436
|
-
case "identifier":
|
|
4437
|
-
case "pair":
|
|
4438
|
-
case "record":
|
|
4439
|
-
default:
|
|
4440
|
-
fallbackValue = "";
|
|
4441
|
-
break;
|
|
4442
|
-
}
|
|
4443
|
-
const defaultValue = v.defaultValue ?? fallbackValue;
|
|
4444
|
-
if (Array.isArray(v.value)) {
|
|
4445
|
-
const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
4446
|
-
return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
|
|
4447
|
-
}
|
|
4448
|
-
return v.value === defaultValue;
|
|
4449
|
-
});
|
|
4450
|
-
const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
|
|
4451
|
-
const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
|
|
4452
|
-
const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
|
|
4453
|
-
let optimality = this.#optimality.get(computedItem.identifier);
|
|
4454
|
-
if (optimality === void 0) {
|
|
4455
|
-
optimality = itemContext ? this.#assessOptimality(itemContext) : "unscored";
|
|
4456
|
-
if (numAttempts > 0)
|
|
4457
|
-
this.#optimality.set(computedItem.identifier, optimality);
|
|
4458
|
-
}
|
|
4459
|
-
const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts, computedItem.adaptive, completionStatus);
|
|
4460
|
-
return {
|
|
4461
|
-
...computedItem,
|
|
4462
|
-
completionStatus,
|
|
4463
|
-
numAttempts,
|
|
4464
|
-
score,
|
|
4465
|
-
response,
|
|
4466
|
-
index,
|
|
4467
|
-
active,
|
|
4468
|
-
valid,
|
|
4469
|
-
isDefaultResponse,
|
|
4470
|
-
maxScore,
|
|
4471
|
-
done,
|
|
4472
|
-
// Reflects the last *ended* attempt only. Read the latch directly
|
|
4473
|
-
// (not the `optimality` local) — the latch is written solely on
|
|
4474
|
-
// responseProcessed / restore-seed (line above, guarded by
|
|
4475
|
-
// numAttempts > 0), so a freshly-picked mid-attempt selection
|
|
4476
|
-
// computed live is never stored and never counts as optimal.
|
|
4477
|
-
optimal: this.#optimality.get(computedItem.identifier) === "optimal"
|
|
4478
|
-
// type,
|
|
4479
|
-
// correct,
|
|
4480
|
-
// incorrect,
|
|
4481
|
-
// completed
|
|
4482
|
-
};
|
|
4483
|
-
})
|
|
4484
|
-
};
|
|
4485
|
-
})
|
|
4486
|
-
};
|
|
4487
|
-
})
|
|
4336
|
+
};
|
|
4337
|
+
__decorate25([
|
|
4338
|
+
consume15({ context: computedContext, subscribe: true })
|
|
4339
|
+
], TestScoringFeedback.prototype, "computedContext", void 0);
|
|
4340
|
+
__decorate25([
|
|
4341
|
+
property20({ type: String, attribute: "view" })
|
|
4342
|
+
], TestScoringFeedback.prototype, "view", void 0);
|
|
4343
|
+
|
|
4344
|
+
// ../qti-test/dist/components/test-stamp/test-stamp.js
|
|
4345
|
+
import { html as html23, LitElement as LitElement24, nothing as nothing4 } from "lit";
|
|
4346
|
+
import { property as property21, state as state6 } from "lit/decorators.js";
|
|
4347
|
+
import { consume as consume16 } from "@lit/context";
|
|
4348
|
+
var __decorate26 = function(decorators, target, key, desc) {
|
|
4349
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4350
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4351
|
+
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;
|
|
4352
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4353
|
+
};
|
|
4354
|
+
var TestStamp = class extends LitElement24 {
|
|
4355
|
+
constructor() {
|
|
4356
|
+
super(...arguments);
|
|
4357
|
+
this.debug = false;
|
|
4358
|
+
this.stampContext = {
|
|
4359
|
+
view: "candidate",
|
|
4360
|
+
activeItem: {},
|
|
4361
|
+
activeSection: {
|
|
4362
|
+
items: []
|
|
4363
|
+
},
|
|
4364
|
+
activeTestpart: {
|
|
4365
|
+
items: [],
|
|
4366
|
+
sections: []
|
|
4367
|
+
},
|
|
4368
|
+
test: {}
|
|
4488
4369
|
};
|
|
4489
|
-
|
|
4490
|
-
|
|
4370
|
+
}
|
|
4371
|
+
createRenderRoot() {
|
|
4372
|
+
return this;
|
|
4373
|
+
}
|
|
4374
|
+
connectedCallback() {
|
|
4375
|
+
super.connectedCallback();
|
|
4376
|
+
const templateElement = this.querySelector("template");
|
|
4377
|
+
if (!templateElement) {
|
|
4378
|
+
this.myTemplate = null;
|
|
4379
|
+
return;
|
|
4380
|
+
}
|
|
4381
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
4382
|
+
}
|
|
4383
|
+
willUpdate(_changedProperties) {
|
|
4384
|
+
if (!this.computedContext) {
|
|
4385
|
+
return;
|
|
4386
|
+
}
|
|
4387
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
4388
|
+
const activeSection = activeTestPart?.sections.find((section) => section.active);
|
|
4389
|
+
const activeItem = activeSection?.items.find((item) => item.active);
|
|
4390
|
+
const { variables, ...augmentedItem } = activeItem || {};
|
|
4391
|
+
if (!activeTestPart) {
|
|
4392
|
+
return;
|
|
4393
|
+
}
|
|
4394
|
+
const augmentedTestPart = {
|
|
4395
|
+
...activeTestPart,
|
|
4396
|
+
items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables: variables2, ...rest }) => rest)),
|
|
4397
|
+
sections: activeTestPart.sections.map((section) => ({
|
|
4398
|
+
...section,
|
|
4399
|
+
items: section.items.map(({ variables: variables2, ...rest }) => rest)
|
|
4400
|
+
}))
|
|
4401
|
+
};
|
|
4402
|
+
const augmentedSection = {
|
|
4403
|
+
...activeSection,
|
|
4404
|
+
items: (activeSection?.items ?? []).map(({ variables: variables2, ...rest }) => rest)
|
|
4405
|
+
};
|
|
4406
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
4407
|
+
this.stampContext = {
|
|
4408
|
+
view: this.computedContext.view,
|
|
4409
|
+
activeItem: augmentedItem,
|
|
4410
|
+
activeSection: augmentedSection,
|
|
4411
|
+
activeTestpart: augmentedTestPart,
|
|
4412
|
+
test: activeTest
|
|
4413
|
+
};
|
|
4414
|
+
this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
|
|
4415
|
+
detail: this.stampContext,
|
|
4491
4416
|
bubbles: true
|
|
4492
4417
|
}));
|
|
4493
4418
|
}
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
*
|
|
4498
|
-
* - The candidate must have actually ended an attempt (numAttempts > 0).
|
|
4499
|
-
* - Once attempted, the item is done if they reached the optimal outcome
|
|
4500
|
-
* ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
|
|
4501
|
-
* done while a better attempt is still possible ('suboptimal') and attempts
|
|
4502
|
-
* remain — see #assessOptimality for how "optimal" is determined.
|
|
4503
|
-
*
|
|
4504
|
-
* `optimality` reflects the last *ended attempt* (see #optimality), not the
|
|
4505
|
-
* live selection — so a freshly-picked optimal answer doesn't count as done
|
|
4506
|
-
* until test-end-attempt evaluates it.
|
|
4507
|
-
*
|
|
4508
|
-
* Adaptive items decide this themselves: max-attempts does not apply to them
|
|
4509
|
-
* (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads
|
|
4510
|
-
* on to the next part of the item. They are done once their response
|
|
4511
|
-
* processing sets completionStatus to 'completed'.
|
|
4512
|
-
*/
|
|
4513
|
-
#isItemDone(numAttempts, optimality, maxAttempts, adaptive, completionStatus) {
|
|
4514
|
-
if (numAttempts === 0)
|
|
4515
|
-
return false;
|
|
4516
|
-
if (adaptive)
|
|
4517
|
-
return completionStatus === "completed";
|
|
4518
|
-
if (optimality !== "suboptimal")
|
|
4519
|
-
return true;
|
|
4520
|
-
const max = maxAttempts ?? 1;
|
|
4521
|
-
return max > 0 && numAttempts >= max;
|
|
4419
|
+
render() {
|
|
4420
|
+
return html23` ${this.debug ? html23`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing4}
|
|
4421
|
+
${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
|
|
4522
4422
|
}
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4423
|
+
};
|
|
4424
|
+
__decorate26([
|
|
4425
|
+
property21({ type: Boolean, reflect: true })
|
|
4426
|
+
], TestStamp.prototype, "debug", void 0);
|
|
4427
|
+
__decorate26([
|
|
4428
|
+
state6(),
|
|
4429
|
+
consume16({ context: computedContext, subscribe: true })
|
|
4430
|
+
], TestStamp.prototype, "computedContext", void 0);
|
|
4431
|
+
__decorate26([
|
|
4432
|
+
state6()
|
|
4433
|
+
], TestStamp.prototype, "stampContext", void 0);
|
|
4434
|
+
|
|
4435
|
+
// ../qti-test/dist/components/test-view-toggle/test-view.js
|
|
4436
|
+
import { html as html24, LitElement as LitElement25 } from "lit";
|
|
4437
|
+
import { property as property22, state as state7 } from "lit/decorators.js";
|
|
4438
|
+
import { consume as consume17 } from "@lit/context";
|
|
4439
|
+
var __decorate27 = function(decorators, target, key, desc) {
|
|
4440
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4441
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4442
|
+
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;
|
|
4443
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4444
|
+
};
|
|
4445
|
+
var _a;
|
|
4446
|
+
var TestView = class extends LitElement25 {
|
|
4447
|
+
constructor() {
|
|
4448
|
+
super(...arguments);
|
|
4449
|
+
this.label = "view";
|
|
4450
|
+
this._handleViewOptionsChange = () => {
|
|
4451
|
+
this.#updateViewOptions();
|
|
4452
|
+
};
|
|
4453
|
+
this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
|
|
4454
|
+
}
|
|
4455
|
+
static {
|
|
4456
|
+
this.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
|
|
4457
|
+
}
|
|
4458
|
+
connectedCallback() {
|
|
4459
|
+
super.connectedCallback();
|
|
4460
|
+
this.#updateViewOptions();
|
|
4461
|
+
}
|
|
4462
|
+
#updateViewOptions() {
|
|
4463
|
+
if (this.viewOptions) {
|
|
4464
|
+
const options = this.viewOptions.split(",").map((opt) => opt.trim());
|
|
4465
|
+
this._viewOptions = options.filter((opt) => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
|
|
4466
|
+
} else {
|
|
4467
|
+
this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
|
|
4550
4468
|
}
|
|
4551
|
-
const responseVars = variables.filter((v) => v.type === "response" && v.correctResponse !== void 0 && v.correctResponse !== null);
|
|
4552
|
-
if (responseVars.length === 0)
|
|
4553
|
-
return "unscored";
|
|
4554
|
-
const allMatch = responseVars.every((v) => {
|
|
4555
|
-
const expected = v.correctResponse;
|
|
4556
|
-
const actual = v.value;
|
|
4557
|
-
if (actual === void 0 || actual === null)
|
|
4558
|
-
return false;
|
|
4559
|
-
if (Array.isArray(expected) && Array.isArray(actual)) {
|
|
4560
|
-
return expected.length === actual.length && expected.every((e) => actual.includes(e));
|
|
4561
|
-
}
|
|
4562
|
-
if (Array.isArray(expected) || Array.isArray(actual))
|
|
4563
|
-
return false;
|
|
4564
|
-
return expected === actual;
|
|
4565
|
-
});
|
|
4566
|
-
return allMatch ? "optimal" : "suboptimal";
|
|
4567
4469
|
}
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4470
|
+
_switchView(view) {
|
|
4471
|
+
dispatchPublic(this, "cito-test-switch-view", view);
|
|
4472
|
+
}
|
|
4473
|
+
render() {
|
|
4474
|
+
return html24`
|
|
4475
|
+
<label part="label" for="viewSelect">${this.label}</label>
|
|
4476
|
+
<select
|
|
4477
|
+
part="select"
|
|
4478
|
+
id="viewSelect"
|
|
4479
|
+
@change=${(e) => {
|
|
4480
|
+
const el = e.target;
|
|
4481
|
+
this._switchView(el.value);
|
|
4482
|
+
}}
|
|
4483
|
+
>
|
|
4484
|
+
${this._viewOptions.map((v) => html24`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
|
|
4485
|
+
</select>
|
|
4486
|
+
`;
|
|
4575
4487
|
}
|
|
4576
4488
|
};
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
],
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4489
|
+
_a = TestView;
|
|
4490
|
+
__decorate27([
|
|
4491
|
+
consume17({ context: sessionContext, subscribe: true })
|
|
4492
|
+
], TestView.prototype, "sessionContext", void 0);
|
|
4493
|
+
__decorate27([
|
|
4494
|
+
property22({ type: String })
|
|
4495
|
+
], TestView.prototype, "label", void 0);
|
|
4496
|
+
__decorate27([
|
|
4497
|
+
property22({ type: String, attribute: "view-options" })
|
|
4498
|
+
], TestView.prototype, "viewOptions", void 0);
|
|
4499
|
+
__decorate27([
|
|
4500
|
+
watch("viewOptions", { waitUntilFirstUpdate: true })
|
|
4501
|
+
], TestView.prototype, "_handleViewOptionsChange", void 0);
|
|
4502
|
+
__decorate27([
|
|
4503
|
+
state7()
|
|
4504
|
+
], TestView.prototype, "_viewOptions", void 0);
|
|
4505
|
+
|
|
4506
|
+
// ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
|
|
4507
|
+
import { consume as consume18 } from "@lit/context";
|
|
4508
|
+
import { html as html25, LitElement as LitElement26, nothing as nothing5 } from "lit";
|
|
4509
|
+
var __decorate28 = function(decorators, target, key, desc) {
|
|
4510
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4511
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4512
|
+
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;
|
|
4513
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4514
|
+
};
|
|
4515
|
+
var TestViewToggle = class extends LitElement26 {
|
|
4516
|
+
createRenderRoot() {
|
|
4517
|
+
return this;
|
|
4518
|
+
}
|
|
4519
|
+
connectedCallback() {
|
|
4520
|
+
super.connectedCallback();
|
|
4521
|
+
const templateElement = this.querySelector("template");
|
|
4522
|
+
if (!templateElement) {
|
|
4523
|
+
this.myTemplate = null;
|
|
4524
|
+
return;
|
|
4525
|
+
}
|
|
4526
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
4527
|
+
}
|
|
4528
|
+
_switchView(view) {
|
|
4529
|
+
dispatchPublic(this, "cito-test-switch-view", view);
|
|
4530
|
+
}
|
|
4531
|
+
firstUpdated(_changedProperties) {
|
|
4532
|
+
this.addEventListener("click", () => {
|
|
4533
|
+
if (this.sessionContext?.view === "scorer") {
|
|
4534
|
+
this._switchView("candidate");
|
|
4535
|
+
} else {
|
|
4536
|
+
this._switchView("scorer");
|
|
4537
|
+
}
|
|
4538
|
+
});
|
|
4539
|
+
}
|
|
4540
|
+
render() {
|
|
4541
|
+
return html25`${this.myTemplate ? this.myTemplate({
|
|
4542
|
+
view: this.sessionContext?.view
|
|
4543
|
+
}) : nothing5}`;
|
|
4544
|
+
}
|
|
4545
|
+
};
|
|
4546
|
+
__decorate28([
|
|
4547
|
+
consume18({ context: sessionContext, subscribe: true })
|
|
4548
|
+
], TestViewToggle.prototype, "sessionContext", void 0);
|
|
4602
4549
|
|
|
4603
|
-
// ../qti-test/dist/
|
|
4604
|
-
import {
|
|
4605
|
-
import {
|
|
4606
|
-
import {
|
|
4607
|
-
|
|
4550
|
+
// ../qti-test/dist/tts/test-item-to-speech.js
|
|
4551
|
+
import { html as html26, LitElement as LitElement27, css as css14 } from "lit";
|
|
4552
|
+
import { consume as consume19, provide as provide4, createContext as createContext2 } from "@lit/context";
|
|
4553
|
+
import { property as property23, state as state8 } from "lit/decorators.js";
|
|
4554
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
4555
|
+
var __decorate29 = function(decorators, target, key, desc) {
|
|
4608
4556
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4609
4557
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4610
4558
|
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;
|
|
4611
4559
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4612
4560
|
};
|
|
4613
|
-
var
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4561
|
+
var HIGHLIGHT_ELEMENT = "tts-element";
|
|
4562
|
+
var HIGHLIGHT_WORD = "tts-word";
|
|
4563
|
+
var highlightSheet = null;
|
|
4564
|
+
function getHighlightSheet() {
|
|
4565
|
+
if (!highlightSheet) {
|
|
4566
|
+
highlightSheet = new CSSStyleSheet();
|
|
4567
|
+
highlightSheet.replaceSync(`
|
|
4568
|
+
::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
|
|
4569
|
+
::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
|
|
4570
|
+
`);
|
|
4618
4571
|
}
|
|
4572
|
+
return highlightSheet;
|
|
4573
|
+
}
|
|
4574
|
+
var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
|
|
4575
|
+
var ICONS = {
|
|
4576
|
+
play: "M8 5v14l11-7z",
|
|
4577
|
+
pause: "M6 5h4v14H6zM14 5h4v14h-4z",
|
|
4578
|
+
stop: "M6 6h12v12H6z",
|
|
4579
|
+
prev: "M6 5h2v14H6zM20 5v14L9 12z",
|
|
4580
|
+
next: "M16 5h2v14h-2zM4 5v14l11-7z",
|
|
4581
|
+
pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
|
|
4582
|
+
};
|
|
4583
|
+
var iconContent = (icon, label) => {
|
|
4584
|
+
const svg = html26`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
4585
|
+
<path d="${ICONS[icon]}"></path>
|
|
4586
|
+
</svg>`;
|
|
4587
|
+
return html26`${svg}<span class="label">${label}</span>`;
|
|
4588
|
+
};
|
|
4589
|
+
var TtsButtonBase = class extends LitElement27 {
|
|
4619
4590
|
static {
|
|
4620
|
-
this.styles =
|
|
4591
|
+
this.styles = css14`
|
|
4621
4592
|
:host {
|
|
4593
|
+
display: inline-flex;
|
|
4594
|
+
}
|
|
4595
|
+
button {
|
|
4622
4596
|
${btn};
|
|
4597
|
+
min-inline-size: var(--test-button-size, 2.25rem);
|
|
4598
|
+
padding-inline: 0.5rem;
|
|
4599
|
+
/* Containing block for the visually hidden .label. Without it the label is placed against
|
|
4600
|
+
the nearest positioned ancestor, which can sit outside a scroll container and make the
|
|
4601
|
+
page as tall as the scrolled content. */
|
|
4602
|
+
position: relative;
|
|
4623
4603
|
}
|
|
4624
|
-
:
|
|
4604
|
+
button:hover:not(:disabled) {
|
|
4625
4605
|
${btnInteractive};
|
|
4626
4606
|
}
|
|
4627
|
-
:
|
|
4607
|
+
button:focus-visible {
|
|
4628
4608
|
${focusRing};
|
|
4629
4609
|
}
|
|
4630
|
-
:
|
|
4610
|
+
button:disabled {
|
|
4631
4611
|
${dis};
|
|
4632
4612
|
}
|
|
4613
|
+
button[aria-pressed='true'],
|
|
4614
|
+
button[aria-pressed='true']:hover {
|
|
4615
|
+
background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
|
|
4616
|
+
color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
|
|
4617
|
+
}
|
|
4618
|
+
svg,
|
|
4619
|
+
::slotted(svg) {
|
|
4620
|
+
flex: none;
|
|
4621
|
+
inline-size: var(--test-tts-icon-size, 1.125rem);
|
|
4622
|
+
block-size: var(--test-tts-icon-size, 1.125rem);
|
|
4623
|
+
}
|
|
4624
|
+
svg {
|
|
4625
|
+
fill: currentColor;
|
|
4626
|
+
}
|
|
4627
|
+
/* The default content is icon-only; this keeps the button's accessible name. */
|
|
4628
|
+
.label {
|
|
4629
|
+
position: absolute;
|
|
4630
|
+
inline-size: 1px;
|
|
4631
|
+
block-size: 1px;
|
|
4632
|
+
overflow: hidden;
|
|
4633
|
+
clip-path: inset(50%);
|
|
4634
|
+
white-space: nowrap;
|
|
4635
|
+
}
|
|
4633
4636
|
`;
|
|
4634
4637
|
}
|
|
4635
|
-
#internals;
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
this
|
|
4641
|
-
this.#
|
|
4642
|
-
this.addEventListener("click", (e) => {
|
|
4643
|
-
e.preventDefault();
|
|
4644
|
-
if (!this._internalDisabled)
|
|
4645
|
-
this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);
|
|
4646
|
-
});
|
|
4647
|
-
}
|
|
4648
|
-
connectedCallback() {
|
|
4649
|
-
super.connectedCallback();
|
|
4650
|
-
this.checkDisabled();
|
|
4651
|
-
}
|
|
4652
|
-
willUpdate(_changedProperties) {
|
|
4653
|
-
if (!this.computedContext)
|
|
4654
|
-
return;
|
|
4655
|
-
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
4656
|
-
if (!testPart)
|
|
4657
|
-
return;
|
|
4658
|
-
this.sectionItems = testPart.sections.flatMap((section) => section.items);
|
|
4659
|
-
this.itemIndex = this.sectionItems.findIndex((item) => item.active);
|
|
4660
|
-
this.checkDisabled();
|
|
4661
|
-
}
|
|
4662
|
-
checkDisabled() {
|
|
4663
|
-
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
4664
|
-
if (!testPart)
|
|
4638
|
+
#internals = this.attachInternals();
|
|
4639
|
+
#mirroredState;
|
|
4640
|
+
#mirroredPicking = false;
|
|
4641
|
+
updated(_changed) {
|
|
4642
|
+
const state9 = this._tts?.state;
|
|
4643
|
+
const picking = this._tts?.picking ?? false;
|
|
4644
|
+
if (state9 === this.#mirroredState && picking === this.#mirroredPicking)
|
|
4665
4645
|
return;
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
_requestItem(identifier) {
|
|
4674
|
-
dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
|
|
4675
|
-
}
|
|
4676
|
-
render() {
|
|
4677
|
-
return html16`<slot></slot>`;
|
|
4646
|
+
this.#mirroredState = state9;
|
|
4647
|
+
this.#mirroredPicking = picking;
|
|
4648
|
+
this.#internals.states.clear();
|
|
4649
|
+
if (state9)
|
|
4650
|
+
this.#internals.states.add(state9);
|
|
4651
|
+
if (picking)
|
|
4652
|
+
this.#internals.states.add("picking");
|
|
4678
4653
|
}
|
|
4679
4654
|
};
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
],
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
],
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
var
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
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;
|
|
4697
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4698
|
-
};
|
|
4699
|
-
var TestPagingButtonsStamp = class extends LitElement18 {
|
|
4700
|
-
#internals;
|
|
4701
|
-
createRenderRoot() {
|
|
4702
|
-
return this;
|
|
4655
|
+
__decorate29([
|
|
4656
|
+
property23({ type: String })
|
|
4657
|
+
], TtsButtonBase.prototype, "label", void 0);
|
|
4658
|
+
__decorate29([
|
|
4659
|
+
consume19({ context: ttsContext, subscribe: true })
|
|
4660
|
+
], TtsButtonBase.prototype, "_tts", void 0);
|
|
4661
|
+
var TestItemToSpeech = class extends LitElement27 {
|
|
4662
|
+
static {
|
|
4663
|
+
this.styles = css14`
|
|
4664
|
+
:host {
|
|
4665
|
+
display: inline-flex;
|
|
4666
|
+
flex-wrap: wrap;
|
|
4667
|
+
align-items: center;
|
|
4668
|
+
gap: var(--test-tts-gap, 0.25rem);
|
|
4669
|
+
}
|
|
4670
|
+
`;
|
|
4703
4671
|
}
|
|
4672
|
+
#internals;
|
|
4673
|
+
// Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
|
|
4674
|
+
// placeholder itself is looked up on every use — a host may swap the element.
|
|
4675
|
+
#stimulusMode;
|
|
4676
|
+
// Stimulus mode: resets the player when the stimulus content next to it is replaced.
|
|
4677
|
+
#stimulusObserver;
|
|
4678
|
+
// Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
|
|
4679
|
+
// Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
|
|
4680
|
+
#contentMode;
|
|
4681
|
+
// Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
|
|
4682
|
+
#itemRef;
|
|
4683
|
+
// Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's
|
|
4684
|
+
// navigation request is heard.
|
|
4685
|
+
#eventHost;
|
|
4686
|
+
#boundHandleItemConnected;
|
|
4687
|
+
#boundHandleNavigation;
|
|
4688
|
+
// Cursor mode: the previous navigation position, to detect moving to another item or section.
|
|
4689
|
+
#prevNavItemRefId;
|
|
4690
|
+
#prevNavSectionId;
|
|
4691
|
+
// Current set of block-level reading elements for the item, and the root they were collected from
|
|
4692
|
+
#readingElements;
|
|
4693
|
+
#readingRoot;
|
|
4694
|
+
#currentElementIndex;
|
|
4695
|
+
// Text nodes of the element currently being spoken (for word-boundary highlight)
|
|
4696
|
+
#textNodes;
|
|
4697
|
+
// The utterance this player is speaking; lets the error handler tell "our speech was
|
|
4698
|
+
// cancelled by another player" apart from a cancel we issued ourselves.
|
|
4699
|
+
#currentUtterance;
|
|
4700
|
+
// Pick mode: all elements highlighted, a click on one starts reading from there.
|
|
4701
|
+
#picking;
|
|
4702
|
+
#pickRoot;
|
|
4703
|
+
#boundHandlePickClick;
|
|
4704
|
+
// Set when the last element has been read: the cursor stays on it (so prev still works),
|
|
4705
|
+
// but the next play starts the item over instead of repeating that last element.
|
|
4706
|
+
#finished;
|
|
4707
|
+
// Two separate CSS Highlight objects
|
|
4708
|
+
#elementHighlight;
|
|
4709
|
+
// whole-element cursor
|
|
4710
|
+
#wordHighlight;
|
|
4711
|
+
// current word during speech
|
|
4704
4712
|
constructor() {
|
|
4705
4713
|
super();
|
|
4714
|
+
this.language = "nl-NL";
|
|
4706
4715
|
this.#internals = this.attachInternals();
|
|
4707
|
-
this.#
|
|
4716
|
+
this.#stimulusMode = false;
|
|
4717
|
+
this.#stimulusObserver = null;
|
|
4718
|
+
this.#contentMode = false;
|
|
4719
|
+
this.#itemRef = null;
|
|
4720
|
+
this.#eventHost = null;
|
|
4721
|
+
this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
|
|
4722
|
+
this.#boundHandleNavigation = () => this.#stop();
|
|
4723
|
+
this.#prevNavItemRefId = void 0;
|
|
4724
|
+
this.#prevNavSectionId = void 0;
|
|
4725
|
+
this.#readingElements = null;
|
|
4726
|
+
this.#readingRoot = null;
|
|
4727
|
+
this.#currentElementIndex = 0;
|
|
4728
|
+
this.#textNodes = [];
|
|
4729
|
+
this.#currentUtterance = null;
|
|
4730
|
+
this.#picking = false;
|
|
4731
|
+
this.#pickRoot = null;
|
|
4732
|
+
this.#boundHandlePickClick = this.#handlePickClick.bind(this);
|
|
4733
|
+
this.#finished = false;
|
|
4734
|
+
this.#elementHighlight = new Highlight();
|
|
4735
|
+
this.#wordHighlight = new Highlight();
|
|
4736
|
+
this._ttsContext = {
|
|
4737
|
+
state: "idle",
|
|
4738
|
+
currentElementIndex: 0,
|
|
4739
|
+
elementCount: 0,
|
|
4740
|
+
play: () => this.#playSpeech(),
|
|
4741
|
+
pause: () => this.#pause(),
|
|
4742
|
+
resume: () => this.#resume(),
|
|
4743
|
+
stop: () => {
|
|
4744
|
+
this.#stopPicking();
|
|
4745
|
+
this.#stop();
|
|
4746
|
+
},
|
|
4747
|
+
prevElement: () => this.#prevElement(),
|
|
4748
|
+
nextElement: () => this.#nextElement(),
|
|
4749
|
+
togglePick: () => this.#togglePick(),
|
|
4750
|
+
picking: false
|
|
4751
|
+
};
|
|
4752
|
+
}
|
|
4753
|
+
// willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
|
|
4754
|
+
// render already under way instead of scheduling a second one (Lit's change-in-update).
|
|
4755
|
+
willUpdate(changed) {
|
|
4756
|
+
super.willUpdate(changed);
|
|
4757
|
+
if (this.#stimulusMode || this.#contentMode || this.#itemRef)
|
|
4758
|
+
return;
|
|
4759
|
+
const { item, section } = this.#activePosition();
|
|
4760
|
+
const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
|
|
4761
|
+
const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
|
|
4762
|
+
const rerendered = this.#readingElements !== null && this.#readingRoot !== null && this.#readingRoot !== this.#resolveReadingRoot();
|
|
4763
|
+
if (itemChanged || sectionChanged || rerendered)
|
|
4764
|
+
this.#resetReadingPosition();
|
|
4765
|
+
this.#prevNavItemRefId = item;
|
|
4766
|
+
this.#prevNavSectionId = section;
|
|
4767
|
+
}
|
|
4768
|
+
/** Stop speech and forget the collected reading elements, so the next play starts afresh. */
|
|
4769
|
+
#resetReadingPosition() {
|
|
4770
|
+
this.#stopPicking();
|
|
4771
|
+
this.#stop();
|
|
4772
|
+
this.#readingElements = null;
|
|
4773
|
+
this.#currentElementIndex = 0;
|
|
4774
|
+
this.#finished = false;
|
|
4775
|
+
this.#updateContext();
|
|
4708
4776
|
}
|
|
4709
4777
|
connectedCallback() {
|
|
4710
4778
|
super.connectedCallback();
|
|
4711
|
-
|
|
4712
|
-
this
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
};
|
|
4721
|
-
__decorate20([
|
|
4722
|
-
consume12({ context: computedContext, subscribe: true })
|
|
4723
|
-
], TestPagingButtonsStamp.prototype, "computedContext", void 0);
|
|
4724
|
-
|
|
4725
|
-
// ../qti-test/dist/components/test-prev/test-prev.js
|
|
4726
|
-
import { css as css11, html as html18, LitElement as LitElement19 } from "lit";
|
|
4727
|
-
import { property as property16 } from "lit/decorators.js";
|
|
4728
|
-
import { consume as consume13 } from "@lit/context";
|
|
4729
|
-
var __decorate21 = function(decorators, target, key, desc) {
|
|
4730
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4731
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4732
|
-
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;
|
|
4733
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4734
|
-
};
|
|
4735
|
-
var TestPrev = class extends LitElement19 {
|
|
4736
|
-
_handleTestElementChange(_oldValue, newValue) {
|
|
4737
|
-
if (newValue) {
|
|
4738
|
-
this.requestUpdate();
|
|
4739
|
-
}
|
|
4740
|
-
}
|
|
4741
|
-
static {
|
|
4742
|
-
this.styles = css11`
|
|
4743
|
-
:host {
|
|
4744
|
-
${btn};
|
|
4745
|
-
}
|
|
4746
|
-
:host(:hover:not([disabled])) {
|
|
4747
|
-
${btnInteractive};
|
|
4779
|
+
this.#setSpeechState("idle");
|
|
4780
|
+
this.#stimulusMode = this.#stimulusPlaceholder() !== null;
|
|
4781
|
+
if (this.#stimulusMode) {
|
|
4782
|
+
this.#stimulusObserver = new MutationObserver((records) => {
|
|
4783
|
+
if (records.some((record) => !this.contains(record.target)))
|
|
4784
|
+
this.#handleStimulusReplaced();
|
|
4785
|
+
});
|
|
4786
|
+
this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
|
|
4787
|
+
return;
|
|
4748
4788
|
}
|
|
4749
|
-
|
|
4750
|
-
|
|
4789
|
+
this.#contentMode = this.#contentElement() !== null;
|
|
4790
|
+
if (this.#contentMode)
|
|
4791
|
+
return;
|
|
4792
|
+
this.#itemRef = this.closest("qti-assessment-item-ref");
|
|
4793
|
+
if (this.#itemRef) {
|
|
4794
|
+
this.#eventHost = this.#itemRef;
|
|
4795
|
+
this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
4796
|
+
} else {
|
|
4797
|
+
this.#eventHost = this.closest("test-navigation") ?? this.getRootNode();
|
|
4798
|
+
this.#eventHost.addEventListener("cito-test-navigate", this.#boundHandleNavigation);
|
|
4799
|
+
this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
4751
4800
|
}
|
|
4752
|
-
|
|
4753
|
-
|
|
4801
|
+
}
|
|
4802
|
+
disconnectedCallback() {
|
|
4803
|
+
super.disconnectedCallback();
|
|
4804
|
+
if (this.#currentUtterance) {
|
|
4805
|
+
this.#currentUtterance = null;
|
|
4806
|
+
speechSynthesis.cancel();
|
|
4754
4807
|
}
|
|
4755
|
-
|
|
4808
|
+
this.#stopPicking();
|
|
4809
|
+
this.#clearAllHighlights();
|
|
4810
|
+
this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
4811
|
+
this.#eventHost?.removeEventListener("cito-test-navigate", this.#boundHandleNavigation);
|
|
4812
|
+
this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
4813
|
+
this.#eventHost = null;
|
|
4814
|
+
this.#itemRef = null;
|
|
4815
|
+
this.#stimulusObserver?.disconnect();
|
|
4816
|
+
this.#stimulusObserver = null;
|
|
4817
|
+
this.#stimulusMode = false;
|
|
4818
|
+
this.#contentMode = false;
|
|
4756
4819
|
}
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
this._internalDisabled = true;
|
|
4760
|
-
this.addEventListener("click", (e) => {
|
|
4761
|
-
e.preventDefault();
|
|
4762
|
-
if (!this._internalDisabled)
|
|
4763
|
-
this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);
|
|
4764
|
-
});
|
|
4820
|
+
render() {
|
|
4821
|
+
return html26`<slot></slot>`;
|
|
4765
4822
|
}
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
if (!testPart)
|
|
4771
|
-
return;
|
|
4772
|
-
this.sectionItems = testPart.sections.flatMap((section) => section.items);
|
|
4773
|
-
this.itemIndex = this.sectionItems.findIndex((item) => item.active);
|
|
4774
|
-
this.checkDisabled();
|
|
4823
|
+
/** Item-ref mode: our item rendered again, so the elements collected earlier are detached. */
|
|
4824
|
+
#handleItemConnected() {
|
|
4825
|
+
if (this.#readingElements !== null)
|
|
4826
|
+
this.#resetReadingPosition();
|
|
4775
4827
|
}
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
const
|
|
4779
|
-
|
|
4780
|
-
|
|
4828
|
+
/** Cursor mode: the active item and section, from the computed context. */
|
|
4829
|
+
#activePosition() {
|
|
4830
|
+
for (const part of this._computedContext?.testParts ?? []) {
|
|
4831
|
+
for (const section of part.sections) {
|
|
4832
|
+
if (!section.active)
|
|
4833
|
+
continue;
|
|
4834
|
+
return { item: section.items.find((item) => item.active)?.identifier ?? null, section: section.identifier };
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
return { item: null, section: null };
|
|
4781
4838
|
}
|
|
4782
|
-
|
|
4783
|
-
|
|
4839
|
+
/**
|
|
4840
|
+
* Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
|
|
4841
|
+
* collected, so the next play reads the new content from the top. Unlike
|
|
4842
|
+
* #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
|
|
4843
|
+
* while an item player on the same page is speaking.
|
|
4844
|
+
*/
|
|
4845
|
+
#handleStimulusReplaced() {
|
|
4846
|
+
if (this.#currentUtterance) {
|
|
4847
|
+
this.#currentUtterance = null;
|
|
4848
|
+
speechSynthesis.cancel();
|
|
4849
|
+
}
|
|
4850
|
+
this.#stopPicking();
|
|
4851
|
+
this.#clearAllHighlights();
|
|
4852
|
+
this.#setSpeechState("idle");
|
|
4853
|
+
this.#readingElements = null;
|
|
4854
|
+
this.#currentElementIndex = 0;
|
|
4855
|
+
this.#finished = false;
|
|
4856
|
+
this.#updateContext();
|
|
4784
4857
|
}
|
|
4785
|
-
|
|
4786
|
-
|
|
4858
|
+
/**
|
|
4859
|
+
* Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
|
|
4860
|
+
* null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
|
|
4861
|
+
* loading replaces the placeholder's content.
|
|
4862
|
+
*/
|
|
4863
|
+
#stimulusPlaceholder() {
|
|
4864
|
+
return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
|
|
4787
4865
|
}
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
], TestPrev.prototype, "computedContext", void 0);
|
|
4795
|
-
__decorate21([
|
|
4796
|
-
watch("computedContext")
|
|
4797
|
-
], TestPrev.prototype, "_handleTestElementChange", null);
|
|
4798
|
-
|
|
4799
|
-
// ../qti-test/dist/components/test-print-context/test-print-context.js
|
|
4800
|
-
import { html as html19, LitElement as LitElement20 } from "lit";
|
|
4801
|
-
import { consume as consume14 } from "@lit/context";
|
|
4802
|
-
import { state as state6 } from "lit/decorators.js";
|
|
4803
|
-
var __decorate22 = function(decorators, target, key, desc) {
|
|
4804
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4805
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4806
|
-
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;
|
|
4807
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4808
|
-
};
|
|
4809
|
-
var TestPrintContext = class extends LitElement20 {
|
|
4810
|
-
render() {
|
|
4811
|
-
return html19` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
|
|
4866
|
+
/**
|
|
4867
|
+
* Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
|
|
4868
|
+
* The marker goes on one container; the player finds the readable elements inside it.
|
|
4869
|
+
*/
|
|
4870
|
+
#contentElement() {
|
|
4871
|
+
return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
|
|
4812
4872
|
}
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4824
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4825
|
-
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;
|
|
4826
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4827
|
-
};
|
|
4828
|
-
var TestPrintVariables = class extends LitElement21 {
|
|
4829
|
-
static {
|
|
4830
|
-
this.styles = css12`
|
|
4831
|
-
table {
|
|
4832
|
-
width: 100%;
|
|
4833
|
-
border-collapse: collapse;
|
|
4834
|
-
margin: 20px 0;
|
|
4835
|
-
font-size: 14px;
|
|
4836
|
-
text-align: left;
|
|
4837
|
-
}
|
|
4838
|
-
th,
|
|
4839
|
-
td {
|
|
4840
|
-
border: 1px solid #ddd;
|
|
4841
|
-
padding: 8px;
|
|
4842
|
-
}
|
|
4843
|
-
th {
|
|
4844
|
-
background-color: #f4f4f4;
|
|
4845
|
-
font-weight: bold;
|
|
4846
|
-
}
|
|
4847
|
-
h3 {
|
|
4848
|
-
margin-top: 20px;
|
|
4849
|
-
font-size: 16px;
|
|
4850
|
-
}
|
|
4851
|
-
`;
|
|
4873
|
+
/**
|
|
4874
|
+
* The element whose text is read: the stimulus body next to the player (stimulus mode), the
|
|
4875
|
+
* marked content next to it (content mode), or the item body of the item to read.
|
|
4876
|
+
*/
|
|
4877
|
+
#resolveReadingRoot() {
|
|
4878
|
+
if (this.#stimulusMode)
|
|
4879
|
+
return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
|
|
4880
|
+
if (this.#contentMode)
|
|
4881
|
+
return this.#contentElement();
|
|
4882
|
+
return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
|
|
4852
4883
|
}
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
<tbody>
|
|
4872
|
-
${variables.map((v) => {
|
|
4873
|
-
const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
|
|
4874
|
-
const mapEntries = v.mapping?.mapEntries?.map((m) => `${m.mapKey}=${m.mappedValue}pt`).join(", ") || "";
|
|
4875
|
-
const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m) => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ") || "";
|
|
4876
|
-
return html20`
|
|
4877
|
-
<tr>
|
|
4878
|
-
<td>${v.identifier}</td>
|
|
4879
|
-
<td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
|
|
4880
|
-
<td>${v.cardinality}</td>
|
|
4881
|
-
<td>${v.baseType}</td>
|
|
4882
|
-
<td>${correctResponse || mapEntries || areaMapEntries}</td>
|
|
4883
|
-
</tr>
|
|
4884
|
-
`;
|
|
4885
|
-
})}
|
|
4886
|
-
</tbody>
|
|
4887
|
-
</table>
|
|
4888
|
-
`;
|
|
4889
|
-
return html20`
|
|
4890
|
-
${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
|
|
4891
|
-
`;
|
|
4884
|
+
/**
|
|
4885
|
+
* The item to read: our item-ref's (item-ref mode), or the active one (cursor mode). The test
|
|
4886
|
+
* looks the active one up in its own items (`computedContext.itemElement`), so a page with
|
|
4887
|
+
* several tests showing the same item still reads the right one.
|
|
4888
|
+
*/
|
|
4889
|
+
#resolveItem() {
|
|
4890
|
+
if (this.#itemRef)
|
|
4891
|
+
return this.#itemRef.assessmentItem;
|
|
4892
|
+
const { item } = this.#activePosition();
|
|
4893
|
+
return item ? this._computedContext?.itemElement?.(item) ?? null : null;
|
|
4894
|
+
}
|
|
4895
|
+
/** Update speech state on both the context (notifies children) and the host's CSS custom states. */
|
|
4896
|
+
#setSpeechState(state9) {
|
|
4897
|
+
this._ttsContext = { ...this._ttsContext, state: state9 };
|
|
4898
|
+
this.#internals.states.delete("idle");
|
|
4899
|
+
this.#internals.states.delete("playing");
|
|
4900
|
+
this.#internals.states.delete("paused");
|
|
4901
|
+
this.#internals.states.add(state9);
|
|
4892
4902
|
}
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
import { consume as consume16 } from "@lit/context";
|
|
4901
|
-
import { property as property17 } from "lit/decorators.js";
|
|
4902
|
-
var __decorate24 = function(decorators, target, key, desc) {
|
|
4903
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4904
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4905
|
-
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;
|
|
4906
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4907
|
-
};
|
|
4908
|
-
var TestScoringButtons = class extends LitElement22 {
|
|
4909
|
-
createRenderRoot() {
|
|
4910
|
-
return this;
|
|
4903
|
+
/** Push currentElementIndex and elementCount into context so children can react. */
|
|
4904
|
+
#updateContext() {
|
|
4905
|
+
this._ttsContext = {
|
|
4906
|
+
...this._ttsContext,
|
|
4907
|
+
currentElementIndex: this.#currentElementIndex,
|
|
4908
|
+
elementCount: this.#getReadingElements().length
|
|
4909
|
+
};
|
|
4911
4910
|
}
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4911
|
+
/**
|
|
4912
|
+
* Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
|
|
4913
|
+
* first call), filtered live for visibility on every call. Feedback and other
|
|
4914
|
+
* conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
|
|
4915
|
+
* CSS custom state reveals it) is excluded while hidden and picked up again once shown,
|
|
4916
|
+
* without needing to re-collect the candidate set.
|
|
4917
|
+
*/
|
|
4918
|
+
#getReadingElements() {
|
|
4919
|
+
if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
|
|
4920
|
+
this.#readingElements = null;
|
|
4921
|
+
this.#currentElementIndex = 0;
|
|
4922
|
+
this.#finished = false;
|
|
4918
4923
|
}
|
|
4919
|
-
this
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
value
|
|
4929
|
-
});
|
|
4924
|
+
if (this.#readingElements === null) {
|
|
4925
|
+
const root = this.#resolveReadingRoot();
|
|
4926
|
+
if (!root)
|
|
4927
|
+
return [];
|
|
4928
|
+
this.#readingRoot = root;
|
|
4929
|
+
const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
|
|
4930
|
+
this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
|
|
4931
|
+
}
|
|
4932
|
+
return this.#readingElements.filter((el) => this.#isVisible(el));
|
|
4930
4933
|
}
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
if (
|
|
4934
|
-
return
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
const score = scoreOutcome?.value;
|
|
4938
|
-
const disabled = !(scoreOutcome?.externalScored === "human");
|
|
4939
|
-
if (!maxScore || !scoreOutcome)
|
|
4940
|
-
return nothing3;
|
|
4941
|
-
const scores = [...Array(Number(maxScore) + 1).keys()];
|
|
4942
|
-
return html21`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing3}`;
|
|
4934
|
+
/** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
|
|
4935
|
+
#isVisible(element) {
|
|
4936
|
+
if (typeof element.checkVisibility === "function") {
|
|
4937
|
+
return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
|
|
4938
|
+
}
|
|
4939
|
+
return element.getClientRects().length > 0;
|
|
4943
4940
|
}
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4941
|
+
/**
|
|
4942
|
+
* Resolve the speech language for a reading element.
|
|
4943
|
+
* Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
|
|
4944
|
+
* Empty `lang=""` is treated as absent.
|
|
4945
|
+
*/
|
|
4946
|
+
#resolveLang(element) {
|
|
4947
|
+
let node = element;
|
|
4948
|
+
while (node) {
|
|
4949
|
+
const lang = node.getAttribute("lang") || node.getAttribute("xml:lang");
|
|
4950
|
+
if (lang?.trim())
|
|
4951
|
+
return lang.trim();
|
|
4952
|
+
node = node.parentElement ?? node.getRootNode().host ?? null;
|
|
4953
|
+
}
|
|
4954
|
+
const documentLang = document.documentElement.getAttribute("lang");
|
|
4955
|
+
if (documentLang?.trim())
|
|
4956
|
+
return documentLang.trim();
|
|
4957
|
+
return this.language;
|
|
4956
4958
|
}
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
var __decorate25 = function(decorators, target, key, desc) {
|
|
4973
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4974
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4975
|
-
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;
|
|
4976
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4977
|
-
};
|
|
4978
|
-
var TestScoringFeedback = class extends LitElement23 {
|
|
4979
|
-
constructor() {
|
|
4980
|
-
super(...arguments);
|
|
4981
|
-
this.view = null;
|
|
4959
|
+
#playSpeech() {
|
|
4960
|
+
const elements = this.#getReadingElements();
|
|
4961
|
+
if (!elements.length) {
|
|
4962
|
+
console.warn("test-item-to-speech: no readable elements found");
|
|
4963
|
+
return;
|
|
4964
|
+
}
|
|
4965
|
+
this.#stopPicking();
|
|
4966
|
+
speechSynthesis.cancel();
|
|
4967
|
+
if (this.#finished) {
|
|
4968
|
+
this.#finished = false;
|
|
4969
|
+
this.#currentElementIndex = 0;
|
|
4970
|
+
}
|
|
4971
|
+
if (this.#contentMode && this.#currentElementIndex === 0)
|
|
4972
|
+
this.#readingElements = null;
|
|
4973
|
+
this.#speakElement(this.#currentElementIndex);
|
|
4982
4974
|
}
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
return
|
|
4975
|
+
/** Speak the element at the given index, then auto-advance when it ends. */
|
|
4976
|
+
#speakElement(index) {
|
|
4977
|
+
const elements = this.#getReadingElements();
|
|
4978
|
+
if (index >= elements.length) {
|
|
4979
|
+
this.#clearWordHighlight();
|
|
4980
|
+
this.#currentElementIndex = elements.length - 1;
|
|
4981
|
+
if (elements.length > 0)
|
|
4982
|
+
this.#highlightElement(elements[this.#currentElementIndex]);
|
|
4983
|
+
this.#finished = true;
|
|
4984
|
+
this.#setSpeechState("idle");
|
|
4985
|
+
this.#updateContext();
|
|
4986
|
+
return;
|
|
4987
|
+
}
|
|
4988
|
+
this.#currentElementIndex = index;
|
|
4989
|
+
this.#finished = false;
|
|
4990
|
+
this.#updateContext();
|
|
4991
|
+
const element = elements[index];
|
|
4992
|
+
element.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
4993
|
+
this.#highlightElement(element);
|
|
4994
|
+
this.#textNodes = this.#collectTextNodes(element);
|
|
4995
|
+
const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
|
|
4996
|
+
if (!text.trim()) {
|
|
4997
|
+
this.#speakElement(index + 1);
|
|
4998
|
+
return;
|
|
4999
|
+
}
|
|
5000
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
5001
|
+
utterance.lang = this.#resolveLang(element);
|
|
5002
|
+
utterance.rate = 1;
|
|
5003
|
+
utterance.onboundary = (event) => {
|
|
5004
|
+
if (event.name !== "word")
|
|
5005
|
+
return;
|
|
5006
|
+
this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
|
|
5007
5007
|
};
|
|
5008
|
-
|
|
5008
|
+
utterance.onend = () => {
|
|
5009
|
+
if (this.#currentUtterance !== utterance)
|
|
5010
|
+
return;
|
|
5011
|
+
this.#currentUtterance = null;
|
|
5012
|
+
this.#clearWordHighlight();
|
|
5013
|
+
this.#speakElement(this.#currentElementIndex + 1);
|
|
5014
|
+
};
|
|
5015
|
+
utterance.onerror = () => {
|
|
5016
|
+
if (this.#currentUtterance !== utterance)
|
|
5017
|
+
return;
|
|
5018
|
+
this.#currentUtterance = null;
|
|
5019
|
+
this.#clearAllHighlights();
|
|
5020
|
+
this.#setSpeechState("idle");
|
|
5021
|
+
};
|
|
5022
|
+
this.#currentUtterance = utterance;
|
|
5023
|
+
speechSynthesis.speak(utterance);
|
|
5024
|
+
this.#setSpeechState("playing");
|
|
5009
5025
|
}
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5024
|
-
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;
|
|
5025
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5026
|
-
};
|
|
5027
|
-
var TestSectionButtonsStamp = class extends LitElement24 {
|
|
5028
|
-
#internals;
|
|
5029
|
-
createRenderRoot() {
|
|
5030
|
-
return this;
|
|
5026
|
+
#pause() {
|
|
5027
|
+
speechSynthesis.pause();
|
|
5028
|
+
this.#setSpeechState("paused");
|
|
5029
|
+
}
|
|
5030
|
+
#resume() {
|
|
5031
|
+
speechSynthesis.resume();
|
|
5032
|
+
this.#setSpeechState("playing");
|
|
5033
|
+
}
|
|
5034
|
+
#stop() {
|
|
5035
|
+
this.#currentUtterance = null;
|
|
5036
|
+
speechSynthesis.cancel();
|
|
5037
|
+
this.#clearAllHighlights();
|
|
5038
|
+
this.#setSpeechState("idle");
|
|
5031
5039
|
}
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
this.#
|
|
5035
|
-
|
|
5040
|
+
// ─── Pick mode ────────────────────────────────────────────────────────────
|
|
5041
|
+
#togglePick() {
|
|
5042
|
+
if (this.#picking)
|
|
5043
|
+
this.#stopPicking();
|
|
5044
|
+
else
|
|
5045
|
+
this.#startPicking();
|
|
5036
5046
|
}
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5047
|
+
/** Highlight every reading element and wait for a click on one of them. */
|
|
5048
|
+
#startPicking() {
|
|
5049
|
+
if (this.#contentMode)
|
|
5050
|
+
this.#readingElements = null;
|
|
5051
|
+
const elements = this.#getReadingElements();
|
|
5052
|
+
if (!elements.length) {
|
|
5053
|
+
console.warn("test-item-to-speech: no readable elements found");
|
|
5054
|
+
return;
|
|
5055
|
+
}
|
|
5056
|
+
this.#stop();
|
|
5057
|
+
this.#picking = true;
|
|
5058
|
+
this.#internals.states.add("picking");
|
|
5059
|
+
this.#highlightElements(elements);
|
|
5060
|
+
this.#pickRoot = elements[0].getRootNode();
|
|
5061
|
+
this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
|
|
5062
|
+
this._ttsContext = { ...this._ttsContext, picking: true };
|
|
5041
5063
|
}
|
|
5042
|
-
|
|
5043
|
-
if (!this
|
|
5044
|
-
return
|
|
5045
|
-
|
|
5046
|
-
|
|
5064
|
+
#stopPicking() {
|
|
5065
|
+
if (!this.#picking)
|
|
5066
|
+
return;
|
|
5067
|
+
this.#picking = false;
|
|
5068
|
+
this.#internals.states.delete("picking");
|
|
5069
|
+
this.#pickRoot?.removeEventListener("click", this.#boundHandlePickClick, true);
|
|
5070
|
+
this.#pickRoot = null;
|
|
5071
|
+
this.#clearAllHighlights();
|
|
5072
|
+
this._ttsContext = { ...this._ttsContext, picking: false };
|
|
5047
5073
|
}
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
var __decorate27 = function(decorators, target, key, desc) {
|
|
5057
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5058
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5059
|
-
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;
|
|
5060
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5061
|
-
};
|
|
5062
|
-
var TestSectionLink = class extends LitElement25 {
|
|
5063
|
-
static {
|
|
5064
|
-
this.styles = css13`
|
|
5065
|
-
:host {
|
|
5066
|
-
${btn};
|
|
5067
|
-
}
|
|
5068
|
-
:host(:hover:not([disabled])) {
|
|
5069
|
-
${btnInteractive};
|
|
5070
|
-
}
|
|
5071
|
-
:host(:focus-visible) {
|
|
5072
|
-
${focusRing};
|
|
5073
|
-
}
|
|
5074
|
-
:host([disabled]) {
|
|
5075
|
-
${dis};
|
|
5074
|
+
#handlePickClick(event) {
|
|
5075
|
+
const elements = this.#getReadingElements();
|
|
5076
|
+
const path = event.composedPath();
|
|
5077
|
+
let index = elements.findIndex((el) => path.includes(el));
|
|
5078
|
+
if (index < 0) {
|
|
5079
|
+
const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
|
|
5080
|
+
if (container)
|
|
5081
|
+
index = elements.findIndex((el) => container.contains(el));
|
|
5076
5082
|
}
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5083
|
+
if (index < 0)
|
|
5084
|
+
return;
|
|
5085
|
+
event.preventDefault();
|
|
5086
|
+
event.stopPropagation();
|
|
5087
|
+
this.#stopPicking();
|
|
5088
|
+
speechSynthesis.cancel();
|
|
5089
|
+
this.#speakElement(index);
|
|
5081
5090
|
}
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5091
|
+
#prevElement() {
|
|
5092
|
+
const elements = this.#getReadingElements();
|
|
5093
|
+
if (!elements.length)
|
|
5094
|
+
return;
|
|
5095
|
+
this.#currentUtterance = null;
|
|
5096
|
+
speechSynthesis.cancel();
|
|
5097
|
+
this.#clearWordHighlight();
|
|
5098
|
+
this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
|
|
5099
|
+
this.#finished = false;
|
|
5100
|
+
this.#updateContext();
|
|
5101
|
+
const el = elements[this.#currentElementIndex];
|
|
5102
|
+
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
5103
|
+
this.#highlightElement(el);
|
|
5104
|
+
this.#setSpeechState("idle");
|
|
5086
5105
|
}
|
|
5087
|
-
|
|
5088
|
-
|
|
5106
|
+
#nextElement() {
|
|
5107
|
+
const elements = this.#getReadingElements();
|
|
5108
|
+
if (!elements.length)
|
|
5109
|
+
return;
|
|
5110
|
+
this.#currentUtterance = null;
|
|
5111
|
+
speechSynthesis.cancel();
|
|
5112
|
+
this.#clearWordHighlight();
|
|
5113
|
+
this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
|
|
5114
|
+
this.#finished = false;
|
|
5115
|
+
this.#updateContext();
|
|
5116
|
+
const el = elements[this.#currentElementIndex];
|
|
5117
|
+
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
5118
|
+
this.#highlightElement(el);
|
|
5119
|
+
this.#setSpeechState("idle");
|
|
5089
5120
|
}
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5102
|
-
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;
|
|
5103
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5104
|
-
};
|
|
5105
|
-
var TestStamp = class extends LitElement26 {
|
|
5106
|
-
constructor() {
|
|
5107
|
-
super(...arguments);
|
|
5108
|
-
this.debug = false;
|
|
5109
|
-
this.stampContext = {
|
|
5110
|
-
view: "candidate",
|
|
5111
|
-
activeItem: {},
|
|
5112
|
-
activeSection: {
|
|
5113
|
-
items: []
|
|
5114
|
-
},
|
|
5115
|
-
activeTestpart: {
|
|
5116
|
-
items: [],
|
|
5117
|
-
sections: []
|
|
5118
|
-
},
|
|
5119
|
-
test: {}
|
|
5120
|
-
};
|
|
5121
|
+
/** Walk text nodes without crossing shadow DOM boundaries. */
|
|
5122
|
+
#collectTextNodes(root) {
|
|
5123
|
+
const nodes = [];
|
|
5124
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
5125
|
+
let node;
|
|
5126
|
+
while (node = walker.nextNode()) {
|
|
5127
|
+
if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
|
|
5128
|
+
nodes.push(node);
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
return nodes;
|
|
5121
5132
|
}
|
|
5122
|
-
|
|
5123
|
-
|
|
5133
|
+
/** Highlight the whole element as the navigation cursor (blue). */
|
|
5134
|
+
#highlightElement(element) {
|
|
5135
|
+
this.#highlightElements([element]);
|
|
5124
5136
|
}
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
if (!templateElement) {
|
|
5129
|
-
this.myTemplate = null;
|
|
5137
|
+
/** Put the blue cursor highlight on several elements at once (pick mode). */
|
|
5138
|
+
#highlightElements(elements) {
|
|
5139
|
+
if (!("highlights" in CSS))
|
|
5130
5140
|
return;
|
|
5141
|
+
this.#ensureHighlightStyles();
|
|
5142
|
+
this.#elementHighlight.clear();
|
|
5143
|
+
for (const element of elements) {
|
|
5144
|
+
const range = new Range();
|
|
5145
|
+
range.selectNodeContents(element);
|
|
5146
|
+
this.#elementHighlight.add(range);
|
|
5131
5147
|
}
|
|
5132
|
-
|
|
5148
|
+
CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
|
|
5133
5149
|
}
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
}
|
|
5138
|
-
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
5139
|
-
const activeSection = activeTestPart?.sections.find((section) => section.active);
|
|
5140
|
-
const activeItem = activeSection?.items.find((item) => item.active);
|
|
5141
|
-
const { variables, ...augmentedItem } = activeItem || {};
|
|
5142
|
-
if (!activeTestPart || !activeSection || !activeItem) {
|
|
5150
|
+
/** Highlight the current word within #textNodes (yellow, during speech). */
|
|
5151
|
+
#updateWordHighlight(charIndex, charLength) {
|
|
5152
|
+
if (!("highlights" in CSS))
|
|
5143
5153
|
return;
|
|
5154
|
+
this.#ensureHighlightStyles();
|
|
5155
|
+
this.#wordHighlight.clear();
|
|
5156
|
+
const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
|
|
5157
|
+
const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));
|
|
5158
|
+
let offset = 0;
|
|
5159
|
+
let startNode = null;
|
|
5160
|
+
let startOffset = 0;
|
|
5161
|
+
let endNode = null;
|
|
5162
|
+
let endOffset = 0;
|
|
5163
|
+
for (const node of this.#textNodes) {
|
|
5164
|
+
const len = node.textContent?.length ?? 0;
|
|
5165
|
+
if (!startNode && offset + len > charIndex) {
|
|
5166
|
+
startNode = node;
|
|
5167
|
+
startOffset = charIndex - offset;
|
|
5168
|
+
}
|
|
5169
|
+
if (startNode && offset + len >= endIndex) {
|
|
5170
|
+
endNode = node;
|
|
5171
|
+
endOffset = endIndex - offset;
|
|
5172
|
+
break;
|
|
5173
|
+
}
|
|
5174
|
+
offset += len;
|
|
5175
|
+
}
|
|
5176
|
+
if (startNode && endNode) {
|
|
5177
|
+
const range = new Range();
|
|
5178
|
+
range.setStart(startNode, startOffset);
|
|
5179
|
+
range.setEnd(endNode, endOffset);
|
|
5180
|
+
this.#wordHighlight.add(range);
|
|
5181
|
+
CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);
|
|
5144
5182
|
}
|
|
5145
|
-
const augmentedTestPart = {
|
|
5146
|
-
...activeTestPart,
|
|
5147
|
-
items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables: variables2, ...rest }) => rest)),
|
|
5148
|
-
sections: activeTestPart.sections.map((section) => ({
|
|
5149
|
-
...section,
|
|
5150
|
-
items: section.items.map(({ variables: variables2, ...rest }) => rest)
|
|
5151
|
-
}))
|
|
5152
|
-
};
|
|
5153
|
-
const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables: variables2, ...rest }) => rest) };
|
|
5154
|
-
const { testParts, ...activeTest } = this.computedContext;
|
|
5155
|
-
this.stampContext = {
|
|
5156
|
-
view: this.computedContext.view,
|
|
5157
|
-
activeItem: augmentedItem,
|
|
5158
|
-
activeSection: augmentedSection,
|
|
5159
|
-
activeTestpart: augmentedTestPart,
|
|
5160
|
-
test: activeTest
|
|
5161
|
-
};
|
|
5162
|
-
this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
|
|
5163
|
-
detail: this.stampContext,
|
|
5164
|
-
bubbles: true
|
|
5165
|
-
}));
|
|
5166
|
-
}
|
|
5167
|
-
render() {
|
|
5168
|
-
return html25` ${this.debug ? html25`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing4}
|
|
5169
|
-
${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
|
|
5170
|
-
}
|
|
5171
|
-
};
|
|
5172
|
-
__decorate28([
|
|
5173
|
-
property20({ type: Boolean, reflect: true })
|
|
5174
|
-
], TestStamp.prototype, "debug", void 0);
|
|
5175
|
-
__decorate28([
|
|
5176
|
-
state7(),
|
|
5177
|
-
consume19({ context: computedContext, subscribe: true })
|
|
5178
|
-
], TestStamp.prototype, "computedContext", void 0);
|
|
5179
|
-
__decorate28([
|
|
5180
|
-
state7()
|
|
5181
|
-
], TestStamp.prototype, "stampContext", void 0);
|
|
5182
|
-
|
|
5183
|
-
// ../qti-test/dist/components/test-view-toggle/test-view.js
|
|
5184
|
-
import { html as html26, LitElement as LitElement27 } from "lit";
|
|
5185
|
-
import { property as property21, state as state8 } from "lit/decorators.js";
|
|
5186
|
-
import { consume as consume20 } from "@lit/context";
|
|
5187
|
-
var __decorate29 = function(decorators, target, key, desc) {
|
|
5188
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5189
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5190
|
-
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;
|
|
5191
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5192
|
-
};
|
|
5193
|
-
var _a;
|
|
5194
|
-
var TestView = class extends LitElement27 {
|
|
5195
|
-
constructor() {
|
|
5196
|
-
super(...arguments);
|
|
5197
|
-
this.label = "view";
|
|
5198
|
-
this._handleViewOptionsChange = () => {
|
|
5199
|
-
this.#updateViewOptions();
|
|
5200
|
-
};
|
|
5201
|
-
this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
|
|
5202
5183
|
}
|
|
5203
|
-
|
|
5204
|
-
|
|
5184
|
+
#clearWordHighlight() {
|
|
5185
|
+
if (!("highlights" in CSS))
|
|
5186
|
+
return;
|
|
5187
|
+
this.#wordHighlight.clear();
|
|
5188
|
+
if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight)
|
|
5189
|
+
CSS.highlights.delete(HIGHLIGHT_WORD);
|
|
5205
5190
|
}
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5191
|
+
#clearAllHighlights() {
|
|
5192
|
+
if (!("highlights" in CSS))
|
|
5193
|
+
return;
|
|
5194
|
+
this.#clearWordHighlight();
|
|
5195
|
+
this.#elementHighlight.clear();
|
|
5196
|
+
if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
|
|
5197
|
+
CSS.highlights.delete(HIGHLIGHT_ELEMENT);
|
|
5209
5198
|
}
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5199
|
+
/** Fallback word-length when charLength is 0. */
|
|
5200
|
+
#wordLengthAt(charIndex, text) {
|
|
5201
|
+
const right = text.slice(charIndex).search(/\s/);
|
|
5202
|
+
return right < 0 ? text.length - charIndex : right;
|
|
5203
|
+
}
|
|
5204
|
+
/**
|
|
5205
|
+
* Add ::highlight() rules both to the shadow root the highlighted text lives in and to the
|
|
5206
|
+
* document (safety net — spec allows document rules to apply across shadow DOM). Called lazily
|
|
5207
|
+
* on first highlight use, once the reading elements have been collected.
|
|
5208
|
+
*/
|
|
5209
|
+
#ensureHighlightStyles() {
|
|
5210
|
+
if (!("highlights" in CSS))
|
|
5211
|
+
return;
|
|
5212
|
+
const sheet = getHighlightSheet();
|
|
5213
|
+
if (!document.adoptedStyleSheets.includes(sheet)) {
|
|
5214
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
5215
|
+
}
|
|
5216
|
+
const roots = /* @__PURE__ */ new Set();
|
|
5217
|
+
const ownRoot = this.getRootNode();
|
|
5218
|
+
if (ownRoot instanceof ShadowRoot)
|
|
5219
|
+
roots.add(ownRoot);
|
|
5220
|
+
const itemRoot = this.#readingElements?.[0]?.getRootNode();
|
|
5221
|
+
if (itemRoot instanceof ShadowRoot)
|
|
5222
|
+
roots.add(itemRoot);
|
|
5223
|
+
for (const root of roots) {
|
|
5224
|
+
if (!root.adoptedStyleSheets.includes(sheet)) {
|
|
5225
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
5226
|
+
}
|
|
5216
5227
|
}
|
|
5217
5228
|
}
|
|
5218
|
-
|
|
5219
|
-
|
|
5229
|
+
};
|
|
5230
|
+
__decorate29([
|
|
5231
|
+
property23({ type: String })
|
|
5232
|
+
], TestItemToSpeech.prototype, "language", void 0);
|
|
5233
|
+
__decorate29([
|
|
5234
|
+
consume19({ context: computedContext, subscribe: true })
|
|
5235
|
+
], TestItemToSpeech.prototype, "_computedContext", void 0);
|
|
5236
|
+
__decorate29([
|
|
5237
|
+
state8(),
|
|
5238
|
+
provide4({ context: ttsContext })
|
|
5239
|
+
], TestItemToSpeech.prototype, "_ttsContext", void 0);
|
|
5240
|
+
var TestTtsPlay = class extends TtsButtonBase {
|
|
5241
|
+
#toggle() {
|
|
5242
|
+
if (!this._tts)
|
|
5243
|
+
return;
|
|
5244
|
+
if (this._tts.state === "idle")
|
|
5245
|
+
this._tts.play();
|
|
5246
|
+
else if (this._tts.state === "playing")
|
|
5247
|
+
this._tts.pause();
|
|
5248
|
+
else
|
|
5249
|
+
this._tts.resume();
|
|
5220
5250
|
}
|
|
5221
5251
|
render() {
|
|
5252
|
+
const playing = this._tts?.state === "playing";
|
|
5222
5253
|
return html26`
|
|
5223
|
-
<
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
id="viewSelect"
|
|
5227
|
-
@change=${(e) => {
|
|
5228
|
-
const el = e.target;
|
|
5229
|
-
this._switchView(el.value);
|
|
5230
|
-
}}
|
|
5231
|
-
>
|
|
5232
|
-
${this._viewOptions.map((v) => html26`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
|
|
5233
|
-
</select>
|
|
5254
|
+
<button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
|
|
5255
|
+
${playing ? html26`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html26`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
|
|
5256
|
+
</button>
|
|
5234
5257
|
`;
|
|
5235
5258
|
}
|
|
5236
5259
|
};
|
|
5237
|
-
_a = TestView;
|
|
5238
|
-
__decorate29([
|
|
5239
|
-
consume20({ context: sessionContext, subscribe: true })
|
|
5240
|
-
], TestView.prototype, "sessionContext", void 0);
|
|
5241
|
-
__decorate29([
|
|
5242
|
-
property21({ type: String })
|
|
5243
|
-
], TestView.prototype, "label", void 0);
|
|
5244
|
-
__decorate29([
|
|
5245
|
-
property21({ type: String, attribute: "view-options" })
|
|
5246
|
-
], TestView.prototype, "viewOptions", void 0);
|
|
5247
|
-
__decorate29([
|
|
5248
|
-
watch("viewOptions", { waitUntilFirstUpdate: true })
|
|
5249
|
-
], TestView.prototype, "_handleViewOptionsChange", void 0);
|
|
5250
5260
|
__decorate29([
|
|
5251
|
-
|
|
5252
|
-
],
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5261
|
+
property23({ type: String, attribute: "pause-label" })
|
|
5262
|
+
], TestTtsPlay.prototype, "pauseLabel", void 0);
|
|
5263
|
+
var TestTtsPause = class extends TtsButtonBase {
|
|
5264
|
+
render() {
|
|
5265
|
+
return html26`
|
|
5266
|
+
<button
|
|
5267
|
+
part="button"
|
|
5268
|
+
aria-label=${ifDefined(this.label)}
|
|
5269
|
+
?disabled=${this._tts?.state !== "playing"}
|
|
5270
|
+
@click=${() => this._tts?.pause()}
|
|
5271
|
+
>
|
|
5272
|
+
<slot>${iconContent("pause", this.label ?? "Pause")}</slot>
|
|
5273
|
+
</button>
|
|
5274
|
+
`;
|
|
5275
|
+
}
|
|
5262
5276
|
};
|
|
5263
|
-
var
|
|
5264
|
-
|
|
5265
|
-
return
|
|
5277
|
+
var TestTtsResume = class extends TtsButtonBase {
|
|
5278
|
+
render() {
|
|
5279
|
+
return html26`
|
|
5280
|
+
<button
|
|
5281
|
+
part="button"
|
|
5282
|
+
aria-label=${ifDefined(this.label)}
|
|
5283
|
+
?disabled=${this._tts?.state !== "paused"}
|
|
5284
|
+
@click=${() => this._tts?.resume()}
|
|
5285
|
+
>
|
|
5286
|
+
<slot>${iconContent("play", this.label ?? "Resume")}</slot>
|
|
5287
|
+
</button>
|
|
5288
|
+
`;
|
|
5266
5289
|
}
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5290
|
+
};
|
|
5291
|
+
var TestTtsStop = class extends TtsButtonBase {
|
|
5292
|
+
render() {
|
|
5293
|
+
const idle = this._tts?.state === "idle" && !this._tts?.picking;
|
|
5294
|
+
return html26`
|
|
5295
|
+
<button part="button" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>
|
|
5296
|
+
<slot>${iconContent("stop", this.label ?? "Stop")}</slot>
|
|
5297
|
+
</button>
|
|
5298
|
+
`;
|
|
5275
5299
|
}
|
|
5276
|
-
|
|
5277
|
-
|
|
5300
|
+
};
|
|
5301
|
+
var TestTtsPrev = class extends TtsButtonBase {
|
|
5302
|
+
render() {
|
|
5303
|
+
const collected = (this._tts?.elementCount ?? 0) > 0;
|
|
5304
|
+
const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
|
|
5305
|
+
return html26`
|
|
5306
|
+
<button
|
|
5307
|
+
part="button"
|
|
5308
|
+
aria-label=${ifDefined(this.label)}
|
|
5309
|
+
?disabled=${collected && atStart}
|
|
5310
|
+
@click=${() => this._tts?.prevElement()}
|
|
5311
|
+
>
|
|
5312
|
+
<slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
|
|
5313
|
+
</button>
|
|
5314
|
+
`;
|
|
5278
5315
|
}
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5316
|
+
};
|
|
5317
|
+
var TestTtsNext = class extends TtsButtonBase {
|
|
5318
|
+
render() {
|
|
5319
|
+
const count = this._tts?.elementCount ?? 0;
|
|
5320
|
+
const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
|
|
5321
|
+
return html26`
|
|
5322
|
+
<button
|
|
5323
|
+
part="button"
|
|
5324
|
+
aria-label=${ifDefined(this.label)}
|
|
5325
|
+
?disabled=${atEnd}
|
|
5326
|
+
@click=${() => this._tts?.nextElement()}
|
|
5327
|
+
>
|
|
5328
|
+
<slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
|
|
5329
|
+
</button>
|
|
5330
|
+
`;
|
|
5287
5331
|
}
|
|
5332
|
+
};
|
|
5333
|
+
var TestTtsPick = class extends TtsButtonBase {
|
|
5288
5334
|
render() {
|
|
5289
|
-
return
|
|
5290
|
-
|
|
5291
|
-
|
|
5335
|
+
return html26`
|
|
5336
|
+
<button
|
|
5337
|
+
part="button"
|
|
5338
|
+
aria-label=${ifDefined(this.label)}
|
|
5339
|
+
aria-pressed=${this._tts?.picking ? "true" : "false"}
|
|
5340
|
+
@click=${() => this._tts?.togglePick()}
|
|
5341
|
+
>
|
|
5342
|
+
<slot>${iconContent("pick", this.label ?? "Read from here")}</slot>
|
|
5343
|
+
</button>
|
|
5344
|
+
`;
|
|
5292
5345
|
}
|
|
5293
5346
|
};
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5347
|
+
|
|
5348
|
+
// ../qti-test/dist/tts/elements.js
|
|
5349
|
+
var ttsElements = [
|
|
5350
|
+
{ tag: "test-item-to-speech", ctor: TestItemToSpeech },
|
|
5351
|
+
{ tag: "test-tts-next", ctor: TestTtsNext },
|
|
5352
|
+
{ tag: "test-tts-pause", ctor: TestTtsPause },
|
|
5353
|
+
{ tag: "test-tts-pick", ctor: TestTtsPick },
|
|
5354
|
+
{ tag: "test-tts-play", ctor: TestTtsPlay },
|
|
5355
|
+
{ tag: "test-tts-prev", ctor: TestTtsPrev },
|
|
5356
|
+
{ tag: "test-tts-resume", ctor: TestTtsResume },
|
|
5357
|
+
{ tag: "test-tts-stop", ctor: TestTtsStop }
|
|
5358
|
+
];
|
|
5359
|
+
|
|
5360
|
+
// ../qti-test/dist/plugins/elements.js
|
|
5361
|
+
var pluginElements = [
|
|
5362
|
+
{ tag: "test-check-item", ctor: TestCheckItem },
|
|
5363
|
+
{ tag: "test-bookmark", ctor: TestBookmark },
|
|
5364
|
+
{ tag: "test-print-context", ctor: TestPrintContext },
|
|
5365
|
+
{ tag: "test-print-item-variables", ctor: TestPrintVariables },
|
|
5366
|
+
{ tag: "test-scoring-buttons", ctor: TestScoringButtons },
|
|
5367
|
+
{ tag: "test-scoring-feedback", ctor: TestScoringFeedback },
|
|
5368
|
+
{ tag: "test-stamp", ctor: TestStamp },
|
|
5369
|
+
{ tag: "test-view", ctor: TestView },
|
|
5370
|
+
{ tag: "test-view-toggle", ctor: TestViewToggle },
|
|
5371
|
+
...ttsElements
|
|
5372
|
+
];
|
|
5297
5373
|
|
|
5298
5374
|
// ../qti-test/dist/elements.js
|
|
5299
5375
|
var qtiTestElements = [
|
|
@@ -5310,31 +5386,14 @@ var qtiTestElements = [
|
|
|
5310
5386
|
{ tag: "qti-test-feedback", ctor: QtiTestFeedback },
|
|
5311
5387
|
{ tag: "qti-test-part", ctor: QtiTestPart },
|
|
5312
5388
|
{ tag: "qti-test-variables", ctor: QtiTestVariables },
|
|
5313
|
-
{ tag: "test-check-item", ctor: TestCheckItem },
|
|
5314
5389
|
{ tag: "test-container", ctor: TestContainer },
|
|
5315
5390
|
{ tag: "test-end-attempt", ctor: TestEndAttempt },
|
|
5316
5391
|
{ tag: "test-item-link", ctor: TestItemLink },
|
|
5317
|
-
{ tag: "test-item-to-speech", ctor: TestItemToSpeech },
|
|
5318
5392
|
{ tag: "test-navigation", ctor: TestNavigation },
|
|
5319
5393
|
{ tag: "test-next", ctor: TestNext },
|
|
5320
|
-
{ tag: "test-paging-buttons-stamp", ctor: TestPagingButtonsStamp },
|
|
5321
5394
|
{ tag: "test-prev", ctor: TestPrev },
|
|
5322
|
-
{ tag: "test-print-context", ctor: TestPrintContext },
|
|
5323
|
-
{ tag: "test-print-item-variables", ctor: TestPrintVariables },
|
|
5324
|
-
{ tag: "test-scoring-buttons", ctor: TestScoringButtons },
|
|
5325
|
-
{ tag: "test-scoring-feedback", ctor: TestScoringFeedback },
|
|
5326
|
-
{ tag: "test-section-buttons-stamp", ctor: TestSectionButtonsStamp },
|
|
5327
5395
|
{ tag: "test-section-link", ctor: TestSectionLink },
|
|
5328
|
-
|
|
5329
|
-
{ tag: "test-tts-next", ctor: TestTtsNext },
|
|
5330
|
-
{ tag: "test-tts-pause", ctor: TestTtsPause },
|
|
5331
|
-
{ tag: "test-tts-pick", ctor: TestTtsPick },
|
|
5332
|
-
{ tag: "test-tts-play", ctor: TestTtsPlay },
|
|
5333
|
-
{ tag: "test-tts-prev", ctor: TestTtsPrev },
|
|
5334
|
-
{ tag: "test-tts-resume", ctor: TestTtsResume },
|
|
5335
|
-
{ tag: "test-tts-stop", ctor: TestTtsStop },
|
|
5336
|
-
{ tag: "test-view", ctor: TestView },
|
|
5337
|
-
{ tag: "test-view-toggle", ctor: TestViewToggle }
|
|
5396
|
+
...pluginElements
|
|
5338
5397
|
];
|
|
5339
5398
|
|
|
5340
5399
|
export {
|
|
@@ -5354,32 +5413,34 @@ export {
|
|
|
5354
5413
|
QtiTestVariablesExpression,
|
|
5355
5414
|
QTI_TEST_STATE_VERSION,
|
|
5356
5415
|
QtiTest,
|
|
5357
|
-
TestCheckItem,
|
|
5358
5416
|
TestContainer,
|
|
5359
5417
|
TestEndAttempt,
|
|
5360
5418
|
TestItemLink,
|
|
5361
|
-
ttsContext,
|
|
5362
|
-
TestItemToSpeech,
|
|
5363
|
-
TestTtsPlay,
|
|
5364
|
-
TestTtsPause,
|
|
5365
|
-
TestTtsResume,
|
|
5366
|
-
TestTtsStop,
|
|
5367
|
-
TestTtsPrev,
|
|
5368
|
-
TestTtsNext,
|
|
5369
|
-
TestTtsPick,
|
|
5370
5419
|
TestNavigation,
|
|
5371
5420
|
TestNext,
|
|
5372
|
-
TestPagingButtonsStamp,
|
|
5373
5421
|
TestPrev,
|
|
5422
|
+
TestSectionLink,
|
|
5423
|
+
pluginState,
|
|
5424
|
+
bookmarkedItems,
|
|
5425
|
+
TestBookmark,
|
|
5426
|
+
TestCheckItem,
|
|
5374
5427
|
TestPrintContext,
|
|
5375
5428
|
TestPrintVariables,
|
|
5376
5429
|
TestScoringButtons,
|
|
5377
5430
|
TestScoringFeedback,
|
|
5378
|
-
TestSectionButtonsStamp,
|
|
5379
|
-
TestSectionLink,
|
|
5380
5431
|
TestStamp,
|
|
5381
5432
|
TestView,
|
|
5382
5433
|
TestViewToggle,
|
|
5434
|
+
TestItemToSpeech,
|
|
5435
|
+
TestTtsPlay,
|
|
5436
|
+
TestTtsPause,
|
|
5437
|
+
TestTtsResume,
|
|
5438
|
+
TestTtsStop,
|
|
5439
|
+
TestTtsPrev,
|
|
5440
|
+
TestTtsNext,
|
|
5441
|
+
TestTtsPick,
|
|
5442
|
+
ttsElements,
|
|
5443
|
+
pluginElements,
|
|
5383
5444
|
qtiTestElements
|
|
5384
5445
|
};
|
|
5385
5446
|
/*! Bundled license information:
|
|
@@ -5394,4 +5455,4 @@ export {
|
|
|
5394
5455
|
* Portions Copyright (c) 2013, the Dart project authors.
|
|
5395
5456
|
*)
|
|
5396
5457
|
*/
|
|
5397
|
-
//# sourceMappingURL=chunk-
|
|
5458
|
+
//# sourceMappingURL=chunk-A2AP6CUL.js.map
|