@pie-element/multiple-choice 14.0.6 → 14.0.7-next.20261019062545
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{Radio-DS22zl1y.js → Radio-Dj4zrLS0.js} +865 -741
- package/dist/browser/{Radio-DS22zl1y.js.map → Radio-Dj4zrLS0.js.map} +1 -1
- package/dist/browser/author/index.js +6300 -6300
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +1 -1
- package/dist/browser/delivery/index.js +77 -73
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/browser/editor-runtime/{Radio-CMqZPx3h.js → Radio-B45MfQhQ.js} +865 -741
- package/dist/browser/editor-runtime/{Radio-CMqZPx3h.js.map → Radio-B45MfQhQ.js.map} +1 -1
- package/dist/browser/editor-runtime/author/index.js +1640 -1640
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/controller/index.js +1 -1
- package/dist/browser/editor-runtime/delivery/index.js +77 -73
- package/dist/browser/editor-runtime/delivery/index.js.map +1 -1
- package/dist/browser/{main-OV2y7QCe.js → editor-runtime/main-BvJ9mP7v.js} +300 -299
- package/dist/browser/editor-runtime/main-BvJ9mP7v.js.map +1 -0
- package/dist/browser/{mathjax-DqXi3q4c-B13HrHzz.js → editor-runtime/mathjax-DqXi3q4c-Y_jZvcuO.js} +2 -2
- package/dist/browser/editor-runtime/{mathjax-DqXi3q4c-DnkUutjP.js.map → mathjax-DqXi3q4c-Y_jZvcuO.js.map} +1 -1
- package/dist/browser/editor-runtime/print/index.js +5 -5
- package/dist/browser/{editor-runtime/main-Cg61UvOA.js → main-DUfYqu6k.js} +299 -298
- package/dist/browser/main-DUfYqu6k.js.map +1 -0
- package/dist/browser/{editor-runtime/mathjax-DqXi3q4c-DnkUutjP.js → mathjax-DqXi3q4c-D_oxb28N.js} +2 -2
- package/dist/browser/{mathjax-DqXi3q4c-B13HrHzz.js.map → mathjax-DqXi3q4c-D_oxb28N.js.map} +1 -1
- package/dist/browser/print/index.js +5 -5
- package/dist/delivery/index.js +39 -35
- package/dist/index.iife.js +21 -21
- package/dist/schemas/configuration.schema.json +1 -1
- package/dist/schemas/model.schema.json +1 -1
- package/dist/schemas/session.schema.json +1 -1
- package/module/print.js +3338 -3322
- package/module/print.js.map +1 -1
- package/package.json +14 -14
- package/dist/browser/editor-runtime/main-Cg61UvOA.js.map +0 -1
- package/dist/browser/main-OV2y7QCe.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as a } from "../main-
|
|
1
|
+
import { G as e, J as t, M as n, U as r, rn as i } from "../Radio-Dj4zrLS0.js";
|
|
2
|
+
import { t as a } from "../main-DUfYqu6k.js";
|
|
3
3
|
import { a as o, p as s } from "../dist-DL6MQNxd.js";
|
|
4
4
|
import c from "react";
|
|
5
5
|
import { createRoot as l } from "react-dom/client";
|
|
@@ -10,8 +10,8 @@ var u = (0, (/* @__PURE__ */ i(t(), 1)).default)("pie-element:multiple-choice:pr
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super(), this._options = null, this._model = null, this._session = [], this._root = null, this._rerender = o(() => {
|
|
12
12
|
if (this._model && this._session) {
|
|
13
|
-
if (!
|
|
14
|
-
|
|
13
|
+
if (!r(this._model.language)) {
|
|
14
|
+
e(this._model.language).then(() => this._rerender());
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
let t = d(this._model, this._options), i = this._options && c.createElement(a, {
|
|
@@ -44,7 +44,7 @@ var u = (0, (/* @__PURE__ */ i(t(), 1)).default)("pie-element:multiple-choice:pr
|
|
|
44
44
|
}
|
|
45
45
|
}, p = Object.freeze({
|
|
46
46
|
name: "@pie-element/multiple-choice",
|
|
47
|
-
version: "14.0.
|
|
47
|
+
version: "14.0.7-next.20261019062545"
|
|
48
48
|
});
|
|
49
49
|
//#endregion
|
|
50
50
|
export { f as default, p as piePackage };
|
package/dist/delivery/index.js
CHANGED
|
@@ -5,27 +5,27 @@ import { updateSessionMetadata as r, updateSessionValue as i } from "./session-u
|
|
|
5
5
|
import a from "react";
|
|
6
6
|
import * as o from "@pie-lib/render-ui";
|
|
7
7
|
import { EnableAudioAutoplayImage as s, createUniqueId as c } from "@pie-lib/render-ui";
|
|
8
|
-
import { isLocaleReady as l, loadLocale as u, stampElementLanguage as d } from "@pie-element/shared-i18n";
|
|
9
|
-
import { createRoot as
|
|
10
|
-
import { debounce as
|
|
11
|
-
import
|
|
12
|
-
import { ModelSetEvent as
|
|
13
|
-
import { renderMath as
|
|
14
|
-
import { autoplayAudioOn as
|
|
8
|
+
import { isLocaleReady as l, loadLocale as u, stampElementLanguage as d, subscribeInterfaceLocale as f } from "@pie-element/shared-i18n";
|
|
9
|
+
import { createRoot as p } from "react-dom/client";
|
|
10
|
+
import { debounce as m } from "@pie-element/shared-lodash";
|
|
11
|
+
import h from "debug";
|
|
12
|
+
import { ModelSetEvent as g, SessionChangedEvent as _, createSessionNotifier as v, flushSessionNotifiers as y } from "@pie-element/shared-player-events";
|
|
13
|
+
import { renderMath as b } from "@pie-element/shared-math-rendering-mathjax";
|
|
14
|
+
import { autoplayAudioOn as x, promptAudioPending as S, trackPromptAudioFailure as C } from "@pie-element/shared-utils";
|
|
15
15
|
//#region src/delivery/index.ts
|
|
16
|
-
function
|
|
16
|
+
function w(e) {
|
|
17
17
|
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return !e ||
|
|
19
|
+
function T(e, t) {
|
|
20
|
+
return !e || w(e) ? e : w(e.default) ? e.default : t && w(e[t]) ? e[t] : t && w(e[t]?.default) ? e[t].default : e;
|
|
21
21
|
}
|
|
22
|
-
var
|
|
22
|
+
var E = o, D = E.default, O = D && typeof D == "object" ? D : E, k = T(s, "EnableAudioAutoplayImage") || T(O.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), A = h("pie-ui:multiple-choice"), j = (e, n, r, i) => {
|
|
23
23
|
let { completeAudioEnabled: a } = n || {};
|
|
24
|
-
if (a &&
|
|
24
|
+
if (a && S(i, e, r) || !e || !e.value) return !1;
|
|
25
25
|
let { choiceMode: o, minSelections: s = 1, maxSelections: c } = n || {}, l = e.value.length || 0;
|
|
26
26
|
return o === "radio" ? !!l : !(l < s || t(l, c));
|
|
27
27
|
};
|
|
28
|
-
function
|
|
28
|
+
function M(e) {
|
|
29
29
|
let t = e.closest("pie-player") || e.closest("pie-item-player");
|
|
30
30
|
if (!t) return {
|
|
31
31
|
baseHeadingLevel: void 0,
|
|
@@ -40,20 +40,21 @@ function j(e) {
|
|
|
40
40
|
includeSrHeading: o == null || o !== !1 && o !== "false"
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
let t =
|
|
43
|
+
function N(e) {
|
|
44
|
+
let t = M(e);
|
|
45
45
|
return {
|
|
46
46
|
baseHeadingLevel: e._baseHeadingLevel === void 0 ? t.baseHeadingLevel : e._baseHeadingLevel,
|
|
47
47
|
includeSrHeading: e._includeSrHeading === void 0 ? t.includeSrHeading : e._includeSrHeading
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
var
|
|
50
|
+
var P = class extends HTMLElement {
|
|
51
51
|
static pieSupports = Object.freeze(["answer-masking"]);
|
|
52
52
|
constructor() {
|
|
53
|
-
super(), this._model = null, this._session = null, this._eliminatedChoices = /* @__PURE__ */ new Set(), this._options = null, this.audioComplete = !1, this._boundHandleKeyDown = this.handleKeyDown.bind(this), this._keyboardEventsEnabled = !1, this._audioInitialized = !1, this._root = null, this._mathObserver = null, this._mathRenderPending = !1, this._rerender =
|
|
53
|
+
super(), this._model = null, this._session = null, this._eliminatedChoices = /* @__PURE__ */ new Set(), this._options = null, this.audioComplete = !1, this._boundHandleKeyDown = this.handleKeyDown.bind(this), this._keyboardEventsEnabled = !1, this._audioInitialized = !1, this._root = null, this._mathObserver = null, this._mathRenderPending = !1, this._interfaceLocale = null, this._disconnectInterfaceLocale = null, this._rerender = m(() => {
|
|
54
54
|
if (this._model && this._session) {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
let r = this._interfaceLocale ?? this._model.language;
|
|
56
|
+
if (!l(r)) {
|
|
57
|
+
u(r).then(() => this._rerender());
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
var t = a.createElement(n, {
|
|
@@ -63,18 +64,19 @@ var N = class extends HTMLElement {
|
|
|
63
64
|
onChoiceChanged: this._onChange.bind(this),
|
|
64
65
|
onShowCorrectToggle: this.onShowCorrectToggle.bind(this),
|
|
65
66
|
eliminatedChoices: [...this._eliminatedChoices],
|
|
66
|
-
|
|
67
|
+
language: r,
|
|
68
|
+
...N(this)
|
|
67
69
|
});
|
|
68
|
-
let
|
|
69
|
-
this.setAttribute("aria-label",
|
|
70
|
-
} else
|
|
70
|
+
let i = e.forLocale(r);
|
|
71
|
+
this.setAttribute("aria-label", i.t(this._model.choiceMode === "radio" ? "multipleChoiceQuestion" : "multipleCorrectAnswerQuestion")), this.setAttribute("role", "region"), d(this, this._model.language), this._initMathObserver(), this._root ||= p(this), this._root.render(t), this._model.keyboardEventsEnabled === !0 && !this._keyboardEventsEnabled && this.enableKeyboardEvents();
|
|
72
|
+
} else A("skip");
|
|
71
73
|
}, 50, {
|
|
72
74
|
leading: !1,
|
|
73
75
|
trailing: !0
|
|
74
|
-
}), this._sessionNotifier =
|
|
75
|
-
this.dispatchEvent(new
|
|
76
|
-
}), this._dispatchResponseChanged = () => this._sessionNotifier.notify(), this._dispatchModelSet =
|
|
77
|
-
this.dispatchEvent(new
|
|
76
|
+
}), this._sessionNotifier = v(this, () => {
|
|
77
|
+
this.dispatchEvent(new _(this.tagName.toLowerCase(), j(this._session, this._model, this.audioComplete, this)));
|
|
78
|
+
}), this._dispatchResponseChanged = () => this._sessionNotifier.notify(), this._dispatchModelSet = m(() => {
|
|
79
|
+
this.dispatchEvent(new g(this.tagName.toLowerCase(), j(this._session, this._model, this.audioComplete, this), this._model !== void 0));
|
|
78
80
|
}, 50, {
|
|
79
81
|
leading: !1,
|
|
80
82
|
trailing: !0
|
|
@@ -82,7 +84,7 @@ var N = class extends HTMLElement {
|
|
|
82
84
|
}
|
|
83
85
|
_scheduleMathRender = () => {
|
|
84
86
|
this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
|
|
85
|
-
this._mathObserver && this._mathObserver.disconnect(),
|
|
87
|
+
this._mathObserver && this._mathObserver.disconnect(), A("render complete - render math"), b(this), this._mathRenderPending = !1, setTimeout(() => {
|
|
86
88
|
this._mathObserver && this._mathObserver.observe(this, {
|
|
87
89
|
childList: !0,
|
|
88
90
|
subtree: !0
|
|
@@ -100,7 +102,7 @@ var N = class extends HTMLElement {
|
|
|
100
102
|
this._mathObserver &&= (this._mathObserver.disconnect(), null);
|
|
101
103
|
}
|
|
102
104
|
onShowCorrectToggle() {
|
|
103
|
-
|
|
105
|
+
b(this);
|
|
104
106
|
}
|
|
105
107
|
set model(e) {
|
|
106
108
|
this._model = e, this._rerender(), this._audioInitialized = !1, this._dispatchModelSet();
|
|
@@ -163,16 +165,18 @@ var N = class extends HTMLElement {
|
|
|
163
165
|
cursor: "pointer"
|
|
164
166
|
});
|
|
165
167
|
let t = document.createElement("img");
|
|
166
|
-
return t.src =
|
|
168
|
+
return t.src = k, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
|
|
167
169
|
}
|
|
168
170
|
connectedCallback() {
|
|
169
|
-
this._initMathObserver(), this._initPlayerObserver(), this.
|
|
171
|
+
this._initMathObserver(), this._initPlayerObserver(), this._disconnectInterfaceLocale ||= f(this, (e) => {
|
|
172
|
+
e?.locale && e.locale !== this._interfaceLocale && (this._interfaceLocale = e.locale, this._rerender());
|
|
173
|
+
}), this._rerender(), new MutationObserver((e, t) => {
|
|
170
174
|
e.forEach((e) => {
|
|
171
175
|
if (e.type === "childList") {
|
|
172
176
|
if (this._audioInitialized) return;
|
|
173
177
|
let e = this.querySelector("audio"), n = e && e.closest(".preview-prompt");
|
|
174
178
|
if (!this._model) return;
|
|
175
|
-
let { completeAudioEnabled: i } = this._model, a =
|
|
179
|
+
let { completeAudioEnabled: i } = this._model, a = x(this._model);
|
|
176
180
|
if (!a && !i || e && !n || !e) return;
|
|
177
181
|
let o = this._createAudioInfoToast(), s = this.querySelector(".main-container"), c = () => {
|
|
178
182
|
this.querySelector(".play-audio-info") && (e.play(), s.removeChild(o)), document.removeEventListener("click", c);
|
|
@@ -189,7 +193,7 @@ var N = class extends HTMLElement {
|
|
|
189
193
|
let u = () => {
|
|
190
194
|
r(this._session, { audioEndTime: (/* @__PURE__ */ new Date()).getTime() }), this.audioComplete = !0, this._dispatchResponseChanged(), e.removeEventListener("ended", u);
|
|
191
195
|
};
|
|
192
|
-
e.addEventListener("ended", u), this._stopTrackingAudioFailure =
|
|
196
|
+
e.addEventListener("ended", u), this._stopTrackingAudioFailure = C(e, () => this._dispatchResponseChanged()), this._audio = e, this._handlePlaying = l, this._handleEnded = u, this._enableAudio = c, this._audioInitialized = !0, t.disconnect();
|
|
193
197
|
}
|
|
194
198
|
});
|
|
195
199
|
}).observe(this, {
|
|
@@ -218,7 +222,7 @@ var N = class extends HTMLElement {
|
|
|
218
222
|
this._playerObserver &&= (this._playerObserver.disconnect(), null);
|
|
219
223
|
}
|
|
220
224
|
disconnectedCallback() {
|
|
221
|
-
|
|
225
|
+
y(this), this._disconnectInterfaceLocale?.(), this._disconnectInterfaceLocale = null, this._disconnectMathObserver(), this._disconnectPlayerObserver(), this._keyboardEventsEnabled &&= (window.removeEventListener("keydown", this._boundHandleKeyDown), !1), document.removeEventListener("click", this._enableAudio), this._audio &&= (this._audio.removeEventListener("playing", this._handlePlaying), this._audio.removeEventListener("ended", this._handleEnded), this._stopTrackingAudioFailure?.(), null), this._rerender.cancel(), this._root &&= (this._root.unmount(), null);
|
|
222
226
|
}
|
|
223
227
|
handleKeyDown(e) {
|
|
224
228
|
if (!this._model || !this._session) return;
|
|
@@ -238,4 +242,4 @@ var N = class extends HTMLElement {
|
|
|
238
242
|
}
|
|
239
243
|
};
|
|
240
244
|
//#endregion
|
|
241
|
-
export {
|
|
245
|
+
export { P as default, j as isComplete };
|