@pie-element/multiple-choice 13.2.1 → 13.2.2-next.1

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 (114) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/defaults.d.ts +205 -0
  4. package/dist/author/defaults.js +151 -0
  5. package/dist/author/index.d.ts +26 -0
  6. package/dist/author/index.js +119 -0
  7. package/dist/author/main.d.ts +34 -0
  8. package/dist/author/main.js +287 -0
  9. package/dist/author/utils.d.ts +9 -0
  10. package/dist/author/utils.js +7 -0
  11. package/dist/browser/Radio-D9xGO4mD.js +9572 -0
  12. package/dist/browser/Radio-D9xGO4mD.js.map +1 -0
  13. package/dist/browser/author/index.js +39745 -0
  14. package/dist/browser/author/index.js.map +1 -0
  15. package/dist/browser/controller/index.js +199 -0
  16. package/dist/browser/controller/index.js.map +1 -0
  17. package/dist/browser/delivery/index.js +251 -0
  18. package/dist/browser/delivery/index.js.map +1 -0
  19. package/dist/browser/dist-nl5urzAW.js +107 -0
  20. package/dist/browser/dist-nl5urzAW.js.map +1 -0
  21. package/dist/browser/main-D2qC-1Hm.js +2440 -0
  22. package/dist/browser/main-D2qC-1Hm.js.map +1 -0
  23. package/dist/browser/multiple-choice.css +2 -0
  24. package/dist/browser/print/index.js +43 -0
  25. package/dist/browser/print/index.js.map +1 -0
  26. package/dist/controller/defaults.d.ts +35 -0
  27. package/dist/controller/defaults.js +29 -0
  28. package/dist/controller/index.d.ts +65 -0
  29. package/dist/controller/index.js +124 -0
  30. package/dist/controller/utils.d.ts +10 -0
  31. package/dist/controller/utils.js +8 -0
  32. package/dist/delivery/choice-input.d.ts +44 -0
  33. package/dist/delivery/choice-input.js +272 -0
  34. package/dist/delivery/choice.d.ts +20 -0
  35. package/dist/delivery/choice.js +105 -0
  36. package/dist/delivery/feedback-tick.d.ts +20 -0
  37. package/dist/delivery/feedback-tick.js +104 -0
  38. package/dist/delivery/index.d.ts +37 -0
  39. package/dist/delivery/index.js +214 -0
  40. package/dist/delivery/main.d.ts +31 -0
  41. package/dist/delivery/main.js +51 -0
  42. package/dist/delivery/multiple-choice.d.ts +61 -0
  43. package/dist/delivery/multiple-choice.js +244 -0
  44. package/dist/delivery/session-updater.d.ts +10 -0
  45. package/dist/delivery/session-updater.js +9 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.iife.d.ts +8 -0
  48. package/dist/index.iife.js +148 -0
  49. package/dist/index.js +2 -0
  50. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  51. package/dist/print/index.d.ts +15 -0
  52. package/dist/print/index.js +43 -0
  53. package/dist/runtime-support.d.ts +12 -0
  54. package/dist/runtime-support.js +12 -0
  55. package/package.json +90 -29
  56. package/CHANGELOG.json +0 -1972
  57. package/CHANGELOG.md +0 -2720
  58. package/LICENSE.md +0 -5
  59. package/PRINT.md +0 -35
  60. package/README.md +0 -56
  61. package/choice.png +0 -0
  62. package/configure/CHANGELOG.json +0 -1387
  63. package/configure/CHANGELOG.md +0 -2068
  64. package/configure/lib/defaults.js +0 -203
  65. package/configure/lib/defaults.js.map +0 -1
  66. package/configure/lib/index.js +0 -202
  67. package/configure/lib/index.js.map +0 -1
  68. package/configure/lib/main.js +0 -484
  69. package/configure/lib/main.js.map +0 -1
  70. package/configure/lib/utils.js +0 -18
  71. package/configure/lib/utils.js.map +0 -1
  72. package/configure/package.json +0 -22
  73. package/controller/CHANGELOG.json +0 -527
  74. package/controller/CHANGELOG.md +0 -1405
  75. package/controller/lib/defaults.js +0 -33
  76. package/controller/lib/defaults.js.map +0 -1
  77. package/controller/lib/index.js +0 -288
  78. package/controller/lib/index.js.map +0 -1
  79. package/controller/lib/utils.js +0 -15
  80. package/controller/lib/utils.js.map +0 -1
  81. package/controller/package.json +0 -15
  82. package/docs/config-schema.json +0 -2993
  83. package/docs/config-schema.json.md +0 -2217
  84. package/docs/demo/config.js +0 -8
  85. package/docs/demo/generate.js +0 -61
  86. package/docs/demo/index.html +0 -1
  87. package/docs/demo/session.js +0 -7
  88. package/docs/pie-schema.json +0 -1332
  89. package/docs/pie-schema.json.md +0 -1015
  90. package/lib/choice-input.js +0 -374
  91. package/lib/choice-input.js.map +0 -1
  92. package/lib/choice.js +0 -192
  93. package/lib/choice.js.map +0 -1
  94. package/lib/feedback-tick.js +0 -134
  95. package/lib/feedback-tick.js.map +0 -1
  96. package/lib/index.js +0 -402
  97. package/lib/index.js.map +0 -1
  98. package/lib/main.js +0 -63
  99. package/lib/main.js.map +0 -1
  100. package/lib/multiple-choice.js +0 -397
  101. package/lib/multiple-choice.js.map +0 -1
  102. package/lib/print.js +0 -94
  103. package/lib/print.js.map +0 -1
  104. package/lib/session-updater.js +0 -37
  105. package/lib/session-updater.js.map +0 -1
  106. package/module/configure.js +0 -1
  107. package/module/controller.js +0 -3045
  108. package/module/demo.js +0 -86
  109. package/module/element.js +0 -1
  110. package/module/index.html +0 -21
  111. package/module/manifest.json +0 -14
  112. package/module/print-demo.js +0 -124
  113. package/module/print.html +0 -18
  114. package/module/print.js +0 -1
@@ -0,0 +1,287 @@
1
+ import { generateValidationMessage as e } from "./utils.js";
2
+ import t from "react";
3
+ import n from "prop-types";
4
+ import { color as r } from "@pie-lib/render-ui";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { styled as o } from "@mui/material/styles";
7
+ import s from "@mui/material/Box";
8
+ import { merge as c } from "@pie-element/shared-lodash";
9
+ import l from "@pie-lib/editable-html-tip-tap";
10
+ import { AlertDialog as u, ChoiceConfiguration as ee, InputContainer as d, choiceUtils as f, layout as te, settings as p } from "@pie-lib/config-ui";
11
+ import m from "@mui/material/Button";
12
+ import h from "@mui/material/Tooltip";
13
+ import g from "@mui/material/Typography";
14
+ import ne from "@mui/icons-material/Info";
15
+ //#region src/author/main.tsx
16
+ var { Panel: re, toggle: _, radio: v, dropdown: y } = p, ie = 9, b = o(d)(({ theme: e }) => ({
17
+ width: "100%",
18
+ paddingTop: e.spacing(2),
19
+ marginBottom: e.spacing(2)
20
+ })), ae = o(d)(({ theme: e }) => ({
21
+ flex: 1,
22
+ marginTop: e.spacing(1.5),
23
+ paddingTop: e.spacing(2),
24
+ marginLeft: e.spacing(3.5)
25
+ })), oe = o(d)(({ theme: e }) => ({
26
+ display: "flex",
27
+ flexDirection: "column",
28
+ marginBottom: e.spacing(1),
29
+ width: "100%"
30
+ })), x = o(m)(({ theme: e }) => ({
31
+ marginTop: e.spacing(1),
32
+ float: "right"
33
+ })), se = o(x)({
34
+ cursor: "not-allowed",
35
+ pointerEvents: "all",
36
+ backgroundColor: r.disabled(),
37
+ "&:hover": { backgroundColor: r.disabled() },
38
+ "&:focus": { backgroundColor: r.disabled() }
39
+ }), ce = o(s)({
40
+ display: "flex",
41
+ alignItems: "center"
42
+ }), le = o(g)(({ theme: e }) => ({
43
+ fontSize: e.typography.fontSize + 2,
44
+ marginRight: e.spacing(1)
45
+ })), S = o(h)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
46
+ fontSize: e.typography.fontSize - 2,
47
+ whiteSpace: "pre",
48
+ maxWidth: "500px"
49
+ } })), C = o("div")(({ theme: e }) => ({
50
+ fontSize: e.typography.fontSize - 2,
51
+ color: e.palette.error.main,
52
+ paddingTop: e.spacing(1)
53
+ })), ue = (t) => {
54
+ let { model: n, configuration: r, onPromptChanged: o, onChoiceChanged: s, onRemoveChoice: c, onAddChoice: u, imageSupport: d, uploadSoundSupport: f, onChangeModel: p, onConfigurationChanged: m, onTeacherInstructionsChanged: h } = t, { addChoiceButton: g = {}, contentDimensions: ue = {}, feedback: w = {}, deleteChoice: de = {}, choiceMode: T = {}, choicePrefix: fe = {}, partialScoring: E = {}, lockChoiceOrder: D = {}, teacherInstructions: O = {}, studentInstructions: k = {}, rationale: A = {}, scoringType: j = {}, sequentialChoiceLabels: M = {}, settingsPanelDisabled: pe, choicesLayout: N, spellCheck: P = {}, gridColumns: me, maxImageWidth: F = {}, maxImageHeight: I = {}, prompt: L = {}, withRubric: R = {}, mathMlOptions: z = {}, language: B = {}, languageChoices: V = {} } = r || {}, { maxAnswerChoices: H } = r || {}, { limitChoicesNumber: he, teacherInstructionsEnabled: ge, rationaleEnabled: _e, feedbackEnabled: ve, promptEnabled: ye, spellCheckEnabled: U, choices: W, errors: be, toolbarEditorPosition: xe, extraCSSRules: Se } = n || {}, { answerChoices: G, choices: Ce, correctResponse: K, prompt: q, rationale: J, teacherInstructions: Y } = be || {}, we = W?.length ? Array.from({ length: W.length }, (e, t) => `${t + 1}`) : [], { baseInputConfiguration: Te = {} } = r, X = { position: xe === "top" ? "top" : "bottom" };
55
+ he && (H = ie);
56
+ let Z = (e = {}) => ({
57
+ ...Te,
58
+ ...e
59
+ }), Ee = e(r), Q = F && F.prompt, $ = I && I.prompt, De = H && W?.length >= H ? `Only ${H} allowed maximum` : "", Oe = {
60
+ choiceMode: T.settings && v(T.label, ["checkbox", "radio"]),
61
+ "sequentialChoiceLabels.enabled": M.settings && _(M.label, !0),
62
+ choicePrefix: fe.settings && v(fe.label, ["numbers", "letters"]),
63
+ partialScoring: E.settings && _(E.label),
64
+ lockChoiceOrder: D.settings && _(D.label),
65
+ feedbackEnabled: w.settings && _(w.label),
66
+ choicesLayout: N.settings && y(N.label, [
67
+ "vertical",
68
+ "grid",
69
+ "horizontal"
70
+ ]),
71
+ gridColumns: N.settings && n.choicesLayout === "grid" && we.length > 0 && y(me.label, we),
72
+ "language.enabled": B.settings && _(B.label, !0),
73
+ language: B.settings && B.enabled && y(V.label, V.options)
74
+ }, ke = {
75
+ teacherInstructionsEnabled: O.settings && _(O.label),
76
+ studentInstructionsEnabled: k.settings && _(k.label),
77
+ promptEnabled: L.settings && _(L.label),
78
+ rationaleEnabled: A.settings && _(A.label),
79
+ spellCheckEnabled: P.settings && _(P.label),
80
+ scoringType: j.settings && v(j.label, ["auto", "rubric"]),
81
+ rubricEnabled: R?.settings && _(R?.label)
82
+ };
83
+ return /* @__PURE__ */ a(te.ConfigLayout, {
84
+ dimensions: ue,
85
+ hideSettings: pe,
86
+ extraCSSRules: Se,
87
+ classes: {},
88
+ settings: /* @__PURE__ */ i(re, {
89
+ model: n,
90
+ onChangeModel: p,
91
+ configuration: r,
92
+ onChangeConfiguration: m,
93
+ groups: {
94
+ Settings: Oe,
95
+ Properties: ke
96
+ }
97
+ }),
98
+ children: [
99
+ ge && /* @__PURE__ */ a(b, {
100
+ label: O.label,
101
+ children: [/* @__PURE__ */ i(l, {
102
+ markup: n.teacherInstructions || "",
103
+ onChange: h,
104
+ imageSupport: d,
105
+ nonEmpty: !1,
106
+ disableUnderline: !0,
107
+ error: Y,
108
+ toolbarOpts: X,
109
+ pluginProps: Z(r?.teacherInstructions?.inputConfiguration),
110
+ spellCheck: U,
111
+ maxImageWidth: F && F.teacherInstructions || Q,
112
+ maxImageHeight: I && I.teacherInstructions || $,
113
+ uploadSoundSupport: f,
114
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
115
+ mathMlOptions: z
116
+ }), Y && /* @__PURE__ */ i(C, { children: Y })]
117
+ }),
118
+ ye && /* @__PURE__ */ a(b, {
119
+ label: L.label,
120
+ children: [/* @__PURE__ */ i(l, {
121
+ markup: n.prompt,
122
+ onChange: o,
123
+ imageSupport: d,
124
+ nonEmpty: !1,
125
+ disableUnderline: !0,
126
+ error: q,
127
+ toolbarOpts: X,
128
+ pluginProps: Z(r?.prompt?.inputConfiguration),
129
+ spellCheck: U,
130
+ maxImageWidth: F && F.prompt,
131
+ maxImageHeight: I && I.prompt,
132
+ uploadSoundSupport: f,
133
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
134
+ mathMlOptions: z
135
+ }), q && /* @__PURE__ */ i(C, { children: q })]
136
+ }),
137
+ /* @__PURE__ */ a(ce, { children: [/* @__PURE__ */ i(le, {
138
+ component: "div",
139
+ children: "Choices"
140
+ }), /* @__PURE__ */ i(S, {
141
+ disableFocusListener: !0,
142
+ disableTouchListener: !0,
143
+ placement: "right",
144
+ title: Ee,
145
+ children: /* @__PURE__ */ i(ne, {
146
+ fontSize: "small",
147
+ color: "primary"
148
+ })
149
+ })] }),
150
+ W.map((e, t) => /* @__PURE__ */ a(oe, { children: [/* @__PURE__ */ i(ee, {
151
+ index: t + 1,
152
+ useLetterOrdering: n.choicePrefix === "letters",
153
+ mode: n.choiceMode,
154
+ data: e,
155
+ defaultFeedback: {},
156
+ imageSupport: d,
157
+ disableImageAlignmentButtons: !0,
158
+ onDelete: () => c(t),
159
+ onChange: (e) => s(t, e),
160
+ allowFeedBack: ve,
161
+ allowDelete: de.settings,
162
+ noLabels: !0,
163
+ pluginOpts: Z(r?.choices?.inputConfiguration),
164
+ toolbarOpts: X,
165
+ spellCheck: U,
166
+ error: Ce?.[e.value] || null,
167
+ noCorrectAnswerError: K,
168
+ maxImageWidth: F && F.choices || Q,
169
+ maxImageHeight: I && I.choices || $,
170
+ uploadSoundSupport: f,
171
+ mathMlOptions: z
172
+ }, t), _e && /* @__PURE__ */ a(ae, {
173
+ label: A.label,
174
+ children: [/* @__PURE__ */ i(l, {
175
+ markup: e.rationale || "",
176
+ onChange: (n) => s(t, {
177
+ ...e,
178
+ rationale: n
179
+ }),
180
+ imageSupport: d,
181
+ error: J?.[e.value] || null,
182
+ toolbarOpts: X,
183
+ pluginProps: Z(r?.rationale?.inputConfiguration),
184
+ spellCheck: U,
185
+ maxImageWidth: F && F.rationale || Q,
186
+ maxImageHeight: I && I.rationale || $,
187
+ uploadSoundSupport: f,
188
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
189
+ mathMlOptions: z
190
+ }), J?.[e.value] && /* @__PURE__ */ i(C, { children: J?.[e.value] })]
191
+ }, `rationale-${t}`)] }, `choice-${t}`)),
192
+ K && /* @__PURE__ */ i(C, { children: K }),
193
+ G && /* @__PURE__ */ i(C, { children: G }),
194
+ g.settings && /* @__PURE__ */ i(S, {
195
+ title: De,
196
+ children: H && W?.length >= H ? /* @__PURE__ */ i(se, {
197
+ variant: "contained",
198
+ color: "primary",
199
+ onClick: u,
200
+ disabled: !0,
201
+ children: g.label
202
+ }) : /* @__PURE__ */ i(x, {
203
+ variant: "contained",
204
+ color: "primary",
205
+ onClick: u,
206
+ children: g.label
207
+ })
208
+ })
209
+ ]
210
+ });
211
+ }, w = class extends t.Component {
212
+ static propTypes = {
213
+ model: n.object.isRequired,
214
+ configuration: n.object.isRequired,
215
+ disableSidePanel: n.bool,
216
+ onModelChanged: n.func.isRequired,
217
+ onConfigurationChanged: n.func.isRequired,
218
+ imageSupport: n.shape({
219
+ add: n.func.isRequired,
220
+ delete: n.func.isRequired
221
+ })
222
+ };
223
+ state = { showWarning: !1 };
224
+ onRemoveChoice = (e) => {
225
+ let { model: t, configuration: n, onModelChanged: r } = this.props, { minAnswerChoices: i } = n || {};
226
+ if (i && t.choices.length === i) {
227
+ this.setState({ showWarning: !0 });
228
+ return;
229
+ }
230
+ t.choices.splice(e, 1), r({ choices: t.choices });
231
+ };
232
+ onAddChoice = () => {
233
+ let { model: e, configuration: t, onModelChanged: n } = this.props, { maxAnswerChoices: r } = t || {}, { limitChoicesNumber: i } = e || {};
234
+ i && (r = ie), !(r && e.choices.length >= r) && (e.choices.push({
235
+ label: "",
236
+ value: f.firstAvailableIndex(e.choices.map((e) => e.value), 0),
237
+ feedback: { type: "none" }
238
+ }), n({ choices: e.choices }));
239
+ };
240
+ onChoiceChanged = (e, t) => {
241
+ let { model: n, onModelChanged: r } = this.props;
242
+ t.correct && n.choiceMode === "radio" && (n.choices = n.choices.map((e) => c({}, e, { correct: !1 }))), n.choices.splice(e, 1, t), r({ choices: n.choices });
243
+ };
244
+ onPromptChanged = (e) => {
245
+ this.props.onModelChanged({ prompt: e });
246
+ };
247
+ onTeacherInstructionsChanged = (e) => {
248
+ this.props.onModelChanged({ teacherInstructions: e });
249
+ };
250
+ onModelChanged = (e, t) => {
251
+ let { onModelChanged: n } = this.props;
252
+ switch (t) {
253
+ case "choiceMode":
254
+ if (e.choiceMode === "radio") {
255
+ let t = !1;
256
+ e.choices = e.choices.map((e) => t ? (e.correct = !1, e) : (e.correct && (t = !0), e));
257
+ }
258
+ n({
259
+ choiceMode: e.choiceMode,
260
+ choices: e.choices
261
+ }, !0);
262
+ break;
263
+ default:
264
+ n(e);
265
+ break;
266
+ }
267
+ };
268
+ render() {
269
+ let { configuration: { minAnswerChoices: e } = {} } = this.props, { showWarning: n } = this.state;
270
+ return /* @__PURE__ */ a(t.Fragment, { children: [/* @__PURE__ */ i(u, {
271
+ open: n,
272
+ title: "Warning",
273
+ text: `There can't be less than ${e || 0} choices.`,
274
+ onConfirm: () => this.setState({ showWarning: !1 })
275
+ }), /* @__PURE__ */ i(ue, {
276
+ ...this.props,
277
+ onChangeModel: this.onModelChanged,
278
+ onRemoveChoice: this.onRemoveChoice,
279
+ onChoiceChanged: this.onChoiceChanged,
280
+ onAddChoice: this.onAddChoice,
281
+ onPromptChanged: this.onPromptChanged,
282
+ onTeacherInstructionsChanged: this.onTeacherInstructionsChanged
283
+ })] });
284
+ }
285
+ };
286
+ //#endregion
287
+ export { w as default };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/multiple-choice/configure/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 generateValidationMessage: (config: any) => string;
@@ -0,0 +1,7 @@
1
+ //#region src/author/utils.ts
2
+ var e = (e) => {
3
+ let { minAnswerChoices: t, maxAnswerChoices: n } = e;
4
+ return "Validation requirements:" + (`\nThere should be at least ${t} ` + (n ? `and at most ${n} ` : "") + "answer choices defined.\nEvery answer choice should be non-blank and unique.") + "\nA correct answer must be defined.";
5
+ };
6
+ //#endregion
7
+ export { e as generateValidationMessage };