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