@pie-element/multiple-choice 13.2.2-next.5 → 13.3.0

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/CHANGELOG.json +1972 -0
  2. package/CHANGELOG.md +2738 -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 +2080 -0
  9. package/configure/lib/defaults.js +203 -0
  10. package/configure/lib/defaults.js.map +1 -0
  11. package/configure/lib/index.js +202 -0
  12. package/configure/lib/index.js.map +1 -0
  13. package/configure/lib/main.js +484 -0
  14. package/configure/lib/main.js.map +1 -0
  15. package/configure/lib/utils.js +18 -0
  16. package/configure/lib/utils.js.map +1 -0
  17. package/configure/package.json +22 -0
  18. package/controller/CHANGELOG.json +527 -0
  19. package/controller/CHANGELOG.md +1405 -0
  20. package/controller/lib/defaults.js +33 -0
  21. package/controller/lib/defaults.js.map +1 -0
  22. package/controller/lib/index.js +288 -0
  23. package/controller/lib/index.js.map +1 -0
  24. package/controller/lib/utils.js +15 -0
  25. package/controller/lib/utils.js.map +1 -0
  26. package/controller/package.json +15 -0
  27. package/docs/config-schema.json +2993 -0
  28. package/docs/config-schema.json.md +2217 -0
  29. package/docs/demo/config.js +8 -0
  30. package/docs/demo/generate.js +61 -0
  31. package/docs/demo/index.html +1 -0
  32. package/docs/demo/session.js +7 -0
  33. package/docs/pie-schema.json +1332 -0
  34. package/docs/pie-schema.json.md +1015 -0
  35. package/lib/choice-input.js +383 -0
  36. package/lib/choice-input.js.map +1 -0
  37. package/lib/choice.js +192 -0
  38. package/lib/choice.js.map +1 -0
  39. package/lib/feedback-tick.js +134 -0
  40. package/lib/feedback-tick.js.map +1 -0
  41. package/lib/index.js +402 -0
  42. package/lib/index.js.map +1 -0
  43. package/lib/main.js +63 -0
  44. package/lib/main.js.map +1 -0
  45. package/lib/multiple-choice.js +397 -0
  46. package/lib/multiple-choice.js.map +1 -0
  47. package/lib/print.js +94 -0
  48. package/lib/print.js.map +1 -0
  49. package/lib/session-updater.js +37 -0
  50. package/lib/session-updater.js.map +1 -0
  51. package/module/configure.js +1 -0
  52. package/module/controller.js +3045 -0
  53. package/module/demo.js +86 -0
  54. package/module/element.js +1 -0
  55. package/module/index.html +21 -0
  56. package/module/manifest.json +14 -0
  57. package/module/print-demo.js +124 -0
  58. package/module/print.html +18 -0
  59. package/module/print.js +1 -0
  60. package/package.json +29 -89
  61. package/configure.js +0 -2
  62. package/controller.js +0 -1
  63. package/dist/author/defaults.d.ts +0 -205
  64. package/dist/author/defaults.js +0 -151
  65. package/dist/author/index.d.ts +0 -26
  66. package/dist/author/index.js +0 -119
  67. package/dist/author/main.d.ts +0 -34
  68. package/dist/author/main.js +0 -287
  69. package/dist/author/utils.d.ts +0 -9
  70. package/dist/author/utils.js +0 -7
  71. package/dist/browser/Radio-DZ5Wx5Zu.js +0 -9579
  72. package/dist/browser/Radio-DZ5Wx5Zu.js.map +0 -1
  73. package/dist/browser/author/index.js +0 -45648
  74. package/dist/browser/author/index.js.map +0 -1
  75. package/dist/browser/controller/index.js +0 -199
  76. package/dist/browser/controller/index.js.map +0 -1
  77. package/dist/browser/delivery/index.js +0 -251
  78. package/dist/browser/delivery/index.js.map +0 -1
  79. package/dist/browser/dist-BcIm7NXG.js +0 -111
  80. package/dist/browser/dist-BcIm7NXG.js.map +0 -1
  81. package/dist/browser/main-BE0cajBs.js +0 -2440
  82. package/dist/browser/main-BE0cajBs.js.map +0 -1
  83. package/dist/browser/multiple-choice.css +0 -2
  84. package/dist/browser/print/index.js +0 -43
  85. package/dist/browser/print/index.js.map +0 -1
  86. package/dist/controller/defaults.d.ts +0 -35
  87. package/dist/controller/defaults.js +0 -29
  88. package/dist/controller/index.d.ts +0 -65
  89. package/dist/controller/index.js +0 -124
  90. package/dist/controller/utils.d.ts +0 -10
  91. package/dist/controller/utils.js +0 -8
  92. package/dist/delivery/choice-input.d.ts +0 -44
  93. package/dist/delivery/choice-input.js +0 -272
  94. package/dist/delivery/choice.d.ts +0 -20
  95. package/dist/delivery/choice.js +0 -105
  96. package/dist/delivery/feedback-tick.d.ts +0 -20
  97. package/dist/delivery/feedback-tick.js +0 -104
  98. package/dist/delivery/index.d.ts +0 -37
  99. package/dist/delivery/index.js +0 -214
  100. package/dist/delivery/main.d.ts +0 -31
  101. package/dist/delivery/main.js +0 -51
  102. package/dist/delivery/multiple-choice.d.ts +0 -61
  103. package/dist/delivery/multiple-choice.js +0 -244
  104. package/dist/delivery/session-updater.d.ts +0 -10
  105. package/dist/delivery/session-updater.js +0 -9
  106. package/dist/index.d.ts +0 -1
  107. package/dist/index.iife.d.ts +0 -8
  108. package/dist/index.iife.js +0 -148
  109. package/dist/index.js +0 -2
  110. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  111. package/dist/print/index.d.ts +0 -15
  112. package/dist/print/index.js +0 -43
  113. package/dist/runtime-support.d.ts +0 -12
  114. package/dist/runtime-support.js +0 -12
@@ -1,287 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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;
@@ -1,7 +0,0 @@
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 };