@pie-element/multiple-choice 13.3.5-ng.0 → 13.3.6

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.
Files changed (133) hide show
  1. package/CHANGELOG.json +1972 -0
  2. package/CHANGELOG.md +2778 -0
  3. package/LICENSE.md +5 -0
  4. package/PRINT.md +35 -0
  5. package/README.md +56 -0
  6. package/choice.png +0 -0
  7. package/configure/CHANGELOG.json +1387 -0
  8. package/configure/CHANGELOG.md +2114 -0
  9. package/configure/lib/__tests__/root.test.js +279 -0
  10. package/configure/lib/defaults.js +203 -0
  11. package/configure/lib/defaults.js.map +1 -0
  12. package/configure/lib/index.js +203 -0
  13. package/configure/lib/index.js.map +1 -0
  14. package/configure/lib/main.js +484 -0
  15. package/configure/lib/main.js.map +1 -0
  16. package/configure/lib/utils.js +18 -0
  17. package/configure/lib/utils.js.map +1 -0
  18. package/configure/package.json +22 -0
  19. package/controller/CHANGELOG.json +527 -0
  20. package/controller/CHANGELOG.md +1423 -0
  21. package/controller/lib/__tests__/index.test.js +561 -0
  22. package/controller/lib/__tests__/utils.test.js +8 -0
  23. package/controller/lib/defaults.js +33 -0
  24. package/controller/lib/defaults.js.map +1 -0
  25. package/controller/lib/index.js +298 -0
  26. package/controller/lib/index.js.map +1 -0
  27. package/controller/lib/utils.js +15 -0
  28. package/controller/lib/utils.js.map +1 -0
  29. package/controller/package.json +15 -0
  30. package/docs/config-schema.json +2993 -0
  31. package/docs/config-schema.json.md +2217 -0
  32. package/docs/demo/config.js +8 -0
  33. package/docs/demo/generate.js +61 -0
  34. package/docs/demo/index.html +1 -0
  35. package/docs/demo/pie.manifest.json +11 -0
  36. package/docs/demo/session.js +7 -0
  37. package/docs/pie-schema.json +1332 -0
  38. package/docs/pie-schema.json.md +1015 -0
  39. package/lib/__tests__/choice-input-test.js +49 -0
  40. package/lib/__tests__/choice-input.test.js +49 -0
  41. package/lib/__tests__/index-test.js +206 -0
  42. package/lib/__tests__/index.test.js +221 -0
  43. package/lib/__tests__/key-events-test.js +95 -0
  44. package/lib/__tests__/key-events.test.js +107 -0
  45. package/lib/__tests__/multiple-choice-test.js +101 -0
  46. package/lib/__tests__/multiple-choice.test.js +256 -0
  47. package/lib/__tests__/session-updater-test.js +70 -0
  48. package/lib/__tests__/session-updater.test.js +70 -0
  49. package/lib/choice-input.js +383 -0
  50. package/lib/choice-input.js.map +1 -0
  51. package/lib/choice.js +192 -0
  52. package/lib/choice.js.map +1 -0
  53. package/lib/feedback-tick.js +134 -0
  54. package/lib/feedback-tick.js.map +1 -0
  55. package/lib/index.js +405 -0
  56. package/lib/index.js.map +1 -0
  57. package/lib/main.js +63 -0
  58. package/lib/main.js.map +1 -0
  59. package/lib/multiple-choice.js +399 -0
  60. package/lib/multiple-choice.js.map +1 -0
  61. package/lib/print.js +94 -0
  62. package/lib/print.js.map +1 -0
  63. package/lib/session-updater.js +37 -0
  64. package/lib/session-updater.js.map +1 -0
  65. package/lib/utils.js +14 -0
  66. package/lib/utils.js.map +1 -0
  67. package/module/configure.js +1 -0
  68. package/module/controller.js +3045 -0
  69. package/module/demo.js +86 -0
  70. package/module/element.js +1 -0
  71. package/module/index.html +21 -0
  72. package/module/manifest.json +14 -0
  73. package/module/print-demo.js +124 -0
  74. package/module/print.html +18 -0
  75. package/module/print.js +1 -17945
  76. package/package.json +28 -94
  77. package/configure.js +0 -2
  78. package/controller.js +0 -1
  79. package/dist/author/defaults.d.ts +0 -205
  80. package/dist/author/defaults.js +0 -151
  81. package/dist/author/index.d.ts +0 -26
  82. package/dist/author/index.js +0 -119
  83. package/dist/author/main.d.ts +0 -34
  84. package/dist/author/main.js +0 -287
  85. package/dist/author/utils.d.ts +0 -9
  86. package/dist/author/utils.js +0 -7
  87. package/dist/browser/Radio-Bbu0BH_k.js +0 -9581
  88. package/dist/browser/Radio-Bbu0BH_k.js.map +0 -1
  89. package/dist/browser/author/index.js +0 -37436
  90. package/dist/browser/author/index.js.map +0 -1
  91. package/dist/browser/controller/index.js +0 -204
  92. package/dist/browser/controller/index.js.map +0 -1
  93. package/dist/browser/delivery/index.js +0 -251
  94. package/dist/browser/delivery/index.js.map +0 -1
  95. package/dist/browser/dist-CHbLnyuX.js +0 -111
  96. package/dist/browser/dist-CHbLnyuX.js.map +0 -1
  97. package/dist/browser/main-DahQxQZC.js +0 -2451
  98. package/dist/browser/main-DahQxQZC.js.map +0 -1
  99. package/dist/browser/multiple-choice.css +0 -2
  100. package/dist/browser/print/index.js +0 -43
  101. package/dist/browser/print/index.js.map +0 -1
  102. package/dist/controller/defaults.d.ts +0 -35
  103. package/dist/controller/defaults.js +0 -29
  104. package/dist/controller/index.d.ts +0 -65
  105. package/dist/controller/index.js +0 -129
  106. package/dist/controller/utils.d.ts +0 -10
  107. package/dist/controller/utils.js +0 -8
  108. package/dist/delivery/choice-input.d.ts +0 -44
  109. package/dist/delivery/choice-input.js +0 -280
  110. package/dist/delivery/choice.d.ts +0 -20
  111. package/dist/delivery/choice.js +0 -105
  112. package/dist/delivery/feedback-tick.d.ts +0 -20
  113. package/dist/delivery/feedback-tick.js +0 -104
  114. package/dist/delivery/index.d.ts +0 -37
  115. package/dist/delivery/index.js +0 -215
  116. package/dist/delivery/main.d.ts +0 -31
  117. package/dist/delivery/main.js +0 -51
  118. package/dist/delivery/multiple-choice.d.ts +0 -61
  119. package/dist/delivery/multiple-choice.js +0 -245
  120. package/dist/delivery/session-updater.d.ts +0 -10
  121. package/dist/delivery/session-updater.js +0 -9
  122. package/dist/delivery/utils.d.ts +0 -10
  123. package/dist/delivery/utils.js +0 -4
  124. package/dist/index.d.ts +0 -1
  125. package/dist/index.iife.d.ts +0 -8
  126. package/dist/index.iife.js +0 -148
  127. package/dist/index.js +0 -2
  128. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  129. package/dist/print/index.d.ts +0 -15
  130. package/dist/print/index.js +0 -43
  131. package/dist/runtime-support.d.ts +0 -12
  132. package/dist/runtime-support.js +0 -12
  133. package/module/print.js.map +0 -1
@@ -1,245 +0,0 @@
1
- import { clsx as e } from "../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
2
- import { Choice as t } from "./choice.js";
3
- import { reachedMaxSelections as n } from "./utils.js";
4
- import r from "react";
5
- import i from "prop-types";
6
- import * as a from "@pie-lib/render-ui";
7
- import { Collapsible as o, PreviewPrompt as s, color as c, transformDataHeadings as l } from "@pie-lib/render-ui";
8
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
9
- import f from "@pie-lib/correct-answer-toggle";
10
- import { styled as p } from "@mui/material/styles";
11
- import m from "@mui/material/Box";
12
- import h from "@pie-lib/translator";
13
- //#region src/delivery/multiple-choice.tsx
14
- function g(e) {
15
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
16
- }
17
- function _(e, t) {
18
- return !e || g(e) ? e : g(e.default) ? e.default : t && g(e[t]) ? e[t] : t && g(e[t]?.default) ? e[t].default : e;
19
- }
20
- var v = _(s, "PreviewPrompt") || _(S.PreviewPrompt, "PreviewPrompt"), y = _(o, "Collapsible") || _(S.Collapsible, "Collapsible"), b = a, x = b.default, S = x && typeof x == "object" ? x : b, { translator: C } = h, w = p(m)({
21
- color: c.text(),
22
- backgroundColor: c.background(),
23
- "& *": { "-webkit-font-smoothing": "antialiased" },
24
- position: "relative",
25
- "& legend": { border: "none !important" }
26
- }), T = p("h2")(({ theme: e }) => ({
27
- display: "block",
28
- fontSize: "inherit",
29
- margin: "0",
30
- fontWeight: "normal",
31
- paddingBottom: e.spacing(2)
32
- })), E = p(m)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), D = p(m)({
33
- display: "flex",
34
- flexDirection: "row",
35
- flexWrap: "wrap"
36
- }), O = p(m)({ display: "grid" }), k = p("fieldset")({
37
- border: "0px",
38
- padding: "0.01em 0 0 0",
39
- margin: "0px",
40
- minWidth: "0px"
41
- }), A = p("h3")({
42
- position: "absolute",
43
- left: "-10000px",
44
- top: "auto",
45
- width: "1px",
46
- height: "1px",
47
- overflow: "hidden"
48
- }), j = p("div")(({ theme: e }) => ({
49
- fontSize: e.typography.fontSize - 2,
50
- color: e.palette.error.main,
51
- paddingTop: e.spacing(1)
52
- })), M = class extends r.Component {
53
- static propTypes = {
54
- className: i.string,
55
- mode: i.oneOf([
56
- "gather",
57
- "view",
58
- "evaluate"
59
- ]),
60
- choiceMode: i.oneOf(["radio", "checkbox"]),
61
- keyMode: i.oneOf([
62
- "numbers",
63
- "letters",
64
- "none"
65
- ]),
66
- choices: i.array,
67
- partLabel: i.string,
68
- prompt: i.string,
69
- teacherInstructions: i.string,
70
- session: i.object,
71
- disabled: i.bool,
72
- onChoiceChanged: i.func,
73
- responseCorrect: i.bool,
74
- correctResponse: i.array,
75
- choicesLayout: i.oneOf([
76
- "vertical",
77
- "grid",
78
- "horizontal"
79
- ]),
80
- gridColumns: i.string,
81
- alwaysShowCorrect: i.bool,
82
- animationsDisabled: i.bool,
83
- language: i.string,
84
- selectedAnswerBackgroundColor: i.string,
85
- selectedAnswerStrokeColor: i.string,
86
- selectedAnswerStrokeWidth: i.string,
87
- hoverAnswerBackgroundColor: i.string,
88
- hoverAnswerStrokeColor: i.string,
89
- hoverAnswerStrokeWidth: i.string,
90
- onShowCorrectToggle: i.func,
91
- isSelectionButtonBelow: i.bool,
92
- minSelections: i.number,
93
- maxSelections: i.number,
94
- autoplayAudioEnabled: i.bool,
95
- customAudioButton: {
96
- playImage: i.string,
97
- pauseImage: i.string
98
- },
99
- options: i.object,
100
- baseHeadingLevel: i.number,
101
- includeSrHeading: i.bool
102
- };
103
- constructor(e) {
104
- super(e), this.state = {
105
- showCorrect: this.props.options && this.props.alwaysShowCorrect || !1,
106
- maxSelectionsErrorState: !1
107
- }, this.onToggle = this.onToggle.bind(this), this.groupName = `mc-group-${Math.random().toString(36).slice(2, 10)}`;
108
- }
109
- isSelected(e) {
110
- let t = this.props.session && this.props.session.value;
111
- return t && t.indexOf && t.indexOf(e) >= 0;
112
- }
113
- handleChange = (e) => {
114
- let { value: t, checked: r } = e.target, { choiceMode: i, maxSelections: a, onChoiceChanged: o, session: s } = this.props;
115
- i !== "radio" && s.value && n(s.value.length, a) && (this.setState({ maxSelectionsErrorState: r }), r) || o({
116
- value: t,
117
- selected: r,
118
- selector: "Mouse"
119
- });
120
- };
121
- onToggle = () => {
122
- this.props.mode === "evaluate" && this.setState({ showCorrect: !this.state.showCorrect }, () => {
123
- this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
124
- });
125
- };
126
- UNSAFE_componentWillReceiveProps(e) {
127
- !e.correctResponse && this.state.showCorrect !== !1 && this.setState({ showCorrect: !1 }, () => {
128
- this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
129
- }), e.options && e.alwaysShowCorrect && this.state.showCorrect !== !0 && this.setState({ showCorrect: !0 }, () => {
130
- this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
131
- });
132
- }
133
- indexToSymbol(e) {
134
- return this.props.keyMode === "numbers" ? `${e + 1}` : this.props.keyMode === "letters" ? String.fromCharCode(97 + e).toUpperCase() : "";
135
- }
136
- getCorrectness = (e = {}) => {
137
- let t = e.correct, n = this.isSelected(e.value);
138
- if (this.state.showCorrect) return t ? "correct" : void 0;
139
- if (t) return n ? "correct" : "incorrect";
140
- if (n) return "incorrect";
141
- };
142
- getChecked(e) {
143
- return this.props.options && this.props.alwaysShowCorrect || this.state.showCorrect && this.props.mode === "evaluate" ? e.correct || !1 : this.isSelected(e.value);
144
- }
145
- renderHeading() {
146
- let { mode: e, choiceMode: t, includeSrHeading: n, baseHeadingLevel: r, partLabel: i } = this.props;
147
- if (!(!i && n !== !1) || e !== "gather") return null;
148
- let a = r ? Math.min(6, r) : 2;
149
- return /* @__PURE__ */ u(A.withComponent(`h${a}`), { children: t === "radio" ? "Multiple Choice Question" : "Multiple Select Question" });
150
- }
151
- render() {
152
- let { mode: n, disabled: r, className: i, choices: a = [], choiceMode: o, gridColumns: s, partLabel: c, prompt: p, responseCorrect: h, teacherInstructions: g, alwaysShowCorrect: _, animationsDisabled: b, language: x, isSelectionButtonBelow: S, minSelections: A, maxSelections: M, autoplayAudioEnabled: N, session: P, customAudioButton: F, options: I, baseHeadingLevel: L } = this.props, { showCorrect: R, maxSelectionsErrorState: z } = this.state, B = n === "evaluate", V = B && !h, H = s > 1 ? { gridTemplateColumns: `repeat(${s}, 1fr)` } : void 0, U = P.value && P.value.length || 0, W = (() => {
153
- if (!L) return;
154
- let e = 1;
155
- return c && (e += 1), Math.min(6, L + e);
156
- })(), G = (e) => e && W ? l(e, W) : e, K = /* @__PURE__ */ u(v, {
157
- tagName: "div",
158
- className: "prompt",
159
- defaultClassName: "teacher-instructions",
160
- prompt: g
161
- }), q = () => A && M ? A === M ? C.t("translation:multipleChoice:minmaxSelections_equal", {
162
- lng: x,
163
- minSelections: A
164
- }) : C.t("translation:multipleChoice:minmaxSelections_range", {
165
- lng: x,
166
- minSelections: A,
167
- maxSelections: M
168
- }) : A ? C.t("translation:multipleChoice:minSelections", {
169
- lng: x,
170
- minSelections: A
171
- }) : "", J = this.props.choicesLayout === "grid" ? O : this.props.choicesLayout === "horizontal" ? D : m;
172
- return /* @__PURE__ */ d(w, {
173
- id: "main-container",
174
- className: e(i, "multiple-choice"),
175
- children: [
176
- c && /* @__PURE__ */ u(T, {
177
- as: L ? `h${Math.min(6, L + 1)}` : "h2",
178
- children: c
179
- }),
180
- this.renderHeading(),
181
- g && /* @__PURE__ */ u(E, { children: b ? K : /* @__PURE__ */ u(y, {
182
- labels: {
183
- hidden: "Show Teacher Instructions",
184
- visible: "Hide Teacher Instructions"
185
- },
186
- children: K
187
- }) }),
188
- /* @__PURE__ */ d(k, {
189
- role: o === "radio" ? "radiogroup" : "group",
190
- children: [
191
- /* @__PURE__ */ u(v, {
192
- className: "prompt",
193
- defaultClassName: "prompt",
194
- prompt: G(p),
195
- tagName: "legend",
196
- autoplayAudioEnabled: N,
197
- customAudioButton: F
198
- }),
199
- !(I && _) && /* @__PURE__ */ u(f, {
200
- show: V,
201
- toggled: R,
202
- onToggle: this.onToggle.bind(this),
203
- language: x
204
- }),
205
- /* @__PURE__ */ u(J, {
206
- style: H,
207
- children: a.map((e, n) => /* @__PURE__ */ u(t, {
208
- choicesLayout: this.props.choicesLayout,
209
- selectedAnswerBackgroundColor: this.props.selectedAnswerBackgroundColor,
210
- selectedAnswerStrokeColor: this.props.selectedAnswerStrokeColor,
211
- selectedAnswerStrokeWidth: this.props.selectedAnswerStrokeWidth,
212
- hoverAnswerBackgroundColor: this.props.hoverAnswerBackgroundColor,
213
- hoverAnswerStrokeColor: this.props.hoverAnswerStrokeColor,
214
- hoverAnswerStrokeWidth: this.props.hoverAnswerStrokeWidth,
215
- gridColumns: s,
216
- choice: e,
217
- index: n,
218
- choicesLength: a.length,
219
- showCorrect: R,
220
- isEvaluateMode: B,
221
- choiceMode: o,
222
- disabled: r,
223
- tagName: this.groupName,
224
- onChoiceChanged: this.handleChange,
225
- hideTick: e.hideTick,
226
- checked: this.getChecked(e),
227
- correctness: B ? this.getCorrectness(e) : void 0,
228
- displayKey: this.indexToSymbol(n),
229
- isSelectionButtonBelow: S
230
- }, `choice-${n}`))
231
- })
232
- ]
233
- }),
234
- o === "checkbox" && U < A && /* @__PURE__ */ u(j, { children: q() }),
235
- o === "checkbox" && z && /* @__PURE__ */ u(j, { children: C.t(`translation:multipleChoice:maxSelections_${M === 1 ? "one" : "other"}`, {
236
- lng: x,
237
- maxSelections: M
238
- }) })
239
- ]
240
- });
241
- }
242
- };
243
- M.defaultProps = { session: { value: [] } };
244
- //#endregion
245
- export { M as MultipleChoice, M as default };
@@ -1,10 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/multiple-choice/src/session-updater.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- export declare function updateSessionValue(session: any, choiceMode: any, data: any): void;
10
- export declare function updateSessionMetadata(session: any, metadata: any): void;
@@ -1,9 +0,0 @@
1
- //#region src/delivery/session-updater.ts
2
- function e(e, t, n) {
3
- e.value = e.value || [], t === "checkbox" && (n.selected ? e.value = Array.from(/* @__PURE__ */ new Set([...e.value, n.value])) : e.value = e.value.filter((e) => e !== n.value)), t === "radio" && (n.selected ? e.value = [n.value] : e.value = []), e.selector = n.selector;
4
- }
5
- function t(e, t) {
6
- e.audioStartTime = e.audioStartTime || t.audioStartTime, e.audioEndTime = e.audioEndTime || t.audioEndTime, !e.waitTime && e.audioStartTime && e.audioEndTime && (e.waitTime = e.audioEndTime - e.audioStartTime);
7
- }
8
- //#endregion
9
- export { t as updateSessionMetadata, e as updateSessionValue };
@@ -1,10 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/multiple-choice/src/utils.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- export declare const reachedMaxSelections: (count: any, maxSelections: any) => boolean;
10
- export declare const exceedsMaxSelections: (count: any, maxSelections: any) => boolean;
@@ -1,4 +0,0 @@
1
- //#region src/delivery/utils.ts
2
- var e = (e, t) => t != null && e >= t, t = (e, t) => t != null && e > t;
3
- //#endregion
4
- export { t as exceedsMaxSelections, e as reachedMaxSelections };
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from './delivery/index.js';
@@ -1,8 +0,0 @@
1
- /**
2
- * IIFE entry point for multiple-choice element
3
- * This file is only used for IIFE builds and includes auto-registration
4
- *
5
- * @sync-generated - Auto-generated during sync from pie-elements
6
- */
7
- import Element from './index.js';
8
- export default Element;