@pie-element/placement-ordering 14.1.1 → 14.1.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 (108) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/choice-editor.d.ts +39 -0
  4. package/dist/author/choice-editor.js +156 -0
  5. package/dist/author/choice-tile.d.ts +40 -0
  6. package/dist/author/choice-tile.js +132 -0
  7. package/dist/author/defaults.d.ts +213 -0
  8. package/dist/author/defaults.js +159 -0
  9. package/dist/author/design.d.ts +21 -0
  10. package/dist/author/design.js +273 -0
  11. package/dist/author/help.d.ts +11 -0
  12. package/dist/author/index.d.ts +45 -0
  13. package/dist/author/index.js +85 -0
  14. package/dist/author/utils.d.ts +15 -0
  15. package/dist/author/utils.js +62 -0
  16. package/dist/browser/author/index.js +40697 -0
  17. package/dist/browser/author/index.js.map +1 -0
  18. package/dist/browser/browser-Dbw2uHQ7.js +372 -0
  19. package/dist/browser/browser-Dbw2uHQ7.js.map +1 -0
  20. package/dist/browser/controller/index.js +242 -0
  21. package/dist/browser/controller/index.js.map +1 -0
  22. package/dist/browser/delivery/index.js +1035 -0
  23. package/dist/browser/delivery/index.js.map +1 -0
  24. package/dist/browser/dist-D9ARZhQk.js +1426 -0
  25. package/dist/browser/dist-D9ARZhQk.js.map +1 -0
  26. package/dist/browser/drag-provider-DSf9QLEN.js +10548 -0
  27. package/dist/browser/drag-provider-DSf9QLEN.js.map +1 -0
  28. package/dist/browser/placement-ordering.css +2 -0
  29. package/dist/controller/defaults.d.ts +31 -0
  30. package/dist/controller/defaults.js +25 -0
  31. package/dist/controller/index.d.ts +29 -0
  32. package/dist/controller/index.js +123 -0
  33. package/dist/controller/scoring.d.ts +27 -0
  34. package/dist/controller/scoring.js +30 -0
  35. package/dist/delivery/index.d.ts +26 -0
  36. package/dist/delivery/index.js +70 -0
  37. package/dist/delivery/main.d.ts +19 -0
  38. package/dist/delivery/main.js +22 -0
  39. package/dist/delivery/ordering.d.ts +18 -0
  40. package/dist/delivery/ordering.js +93 -0
  41. package/dist/delivery/placement-ordering.d.ts +28 -0
  42. package/dist/delivery/placement-ordering.js +213 -0
  43. package/dist/delivery/tile.d.ts +28 -0
  44. package/dist/delivery/tile.js +165 -0
  45. package/dist/delivery/tiler.d.ts +42 -0
  46. package/dist/delivery/tiler.js +89 -0
  47. package/dist/delivery/utils.d.ts +9 -0
  48. package/dist/delivery/utils.js +8 -0
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.iife.d.ts +8 -0
  51. package/dist/index.iife.js +152 -0
  52. package/dist/index.js +2 -0
  53. package/dist/runtime-support.d.ts +12 -0
  54. package/dist/runtime-support.js +12 -0
  55. package/package.json +90 -22
  56. package/CHANGELOG.json +0 -1312
  57. package/CHANGELOG.md +0 -2432
  58. package/LICENSE.md +0 -5
  59. package/README.md +0 -57
  60. package/configure/CHANGELOG.json +0 -952
  61. package/configure/CHANGELOG.md +0 -2127
  62. package/configure/lib/choice-editor.js +0 -252
  63. package/configure/lib/choice-editor.js.map +0 -1
  64. package/configure/lib/choice-tile.js +0 -205
  65. package/configure/lib/choice-tile.js.map +0 -1
  66. package/configure/lib/defaults.js +0 -211
  67. package/configure/lib/defaults.js.map +0 -1
  68. package/configure/lib/design.js +0 -427
  69. package/configure/lib/design.js.map +0 -1
  70. package/configure/lib/help.js +0 -14
  71. package/configure/lib/help.js.map +0 -1
  72. package/configure/lib/index.js +0 -155
  73. package/configure/lib/index.js.map +0 -1
  74. package/configure/lib/utils.js +0 -108
  75. package/configure/lib/utils.js.map +0 -1
  76. package/configure/package.json +0 -26
  77. package/controller/CHANGELOG.json +0 -517
  78. package/controller/CHANGELOG.md +0 -1518
  79. package/controller/lib/defaults.js +0 -29
  80. package/controller/lib/defaults.js.map +0 -1
  81. package/controller/lib/index.js +0 -285
  82. package/controller/lib/index.js.map +0 -1
  83. package/controller/lib/scoring.js +0 -109
  84. package/controller/lib/scoring.js.map +0 -1
  85. package/controller/package.json +0 -15
  86. package/docs/config-schema.json +0 -2964
  87. package/docs/config-schema.json.md +0 -2190
  88. package/docs/demo/config.js +0 -8
  89. package/docs/demo/generate.js +0 -50
  90. package/docs/demo/index.html +0 -1
  91. package/docs/demo/session.js +0 -7
  92. package/docs/pie-schema.json +0 -1613
  93. package/docs/pie-schema.json.md +0 -973
  94. package/icon.png +0 -0
  95. package/lib/index.js +0 -122
  96. package/lib/index.js.map +0 -1
  97. package/lib/main.js +0 -32
  98. package/lib/main.js.map +0 -1
  99. package/lib/ordering.js +0 -165
  100. package/lib/ordering.js.map +0 -1
  101. package/lib/placement-ordering.js +0 -419
  102. package/lib/placement-ordering.js.map +0 -1
  103. package/lib/tile.js +0 -259
  104. package/lib/tile.js.map +0 -1
  105. package/lib/tiler.js +0 -165
  106. package/lib/tiler.js.map +0 -1
  107. package/lib/utils.js +0 -18
  108. package/lib/utils.js.map +0 -1
@@ -0,0 +1,159 @@
1
+ //#region src/author/defaults.ts
2
+ var e = {
3
+ model: {
4
+ choiceLabel: "",
5
+ choiceLabelEnabled: !0,
6
+ choices: [],
7
+ correctResponse: [],
8
+ feedbackEnabled: !1,
9
+ numberedGuides: !1,
10
+ orientation: "vertical",
11
+ partialScoring: !0,
12
+ placementArea: !1,
13
+ prompt: "",
14
+ promptEnabled: !0,
15
+ rationale: "",
16
+ rationaleEnabled: !0,
17
+ removeTilesAfterPlacing: !0,
18
+ scoringType: "auto",
19
+ studentInstructionsEnabled: !0,
20
+ targetLabel: "",
21
+ teacherInstructions: "",
22
+ teacherInstructionsEnabled: !0,
23
+ toolbarEditorPosition: "bottom"
24
+ },
25
+ configuration: {
26
+ baseInputConfiguration: {
27
+ h3: { disabled: !0 },
28
+ audio: { disabled: !1 },
29
+ video: { disabled: !1 },
30
+ image: { disabled: !1 },
31
+ textAlign: { disabled: !0 },
32
+ showParagraphs: { disabled: !1 },
33
+ separateParagraphs: { disabled: !0 }
34
+ },
35
+ choiceLabel: {
36
+ settings: !0,
37
+ label: "Choice label",
38
+ inputConfiguration: {
39
+ audio: { disabled: !1 },
40
+ video: { disabled: !1 },
41
+ image: { disabled: !1 }
42
+ }
43
+ },
44
+ choices: {
45
+ settings: !0,
46
+ label: "Choices",
47
+ inputConfiguration: {
48
+ audio: { disabled: !0 },
49
+ video: { disabled: !0 },
50
+ image: { disabled: !0 }
51
+ }
52
+ },
53
+ feedback: {
54
+ settings: !0,
55
+ label: "Feedback",
56
+ enabled: !0
57
+ },
58
+ prompt: {
59
+ settings: !0,
60
+ label: "Item Stem",
61
+ required: !1,
62
+ inputConfiguration: {
63
+ audio: { disabled: !1 },
64
+ video: { disabled: !1 },
65
+ image: { disabled: !1 }
66
+ }
67
+ },
68
+ numberedGuides: {
69
+ settings: !0,
70
+ label: "Numbered guides"
71
+ },
72
+ orientation: {
73
+ settings: !0,
74
+ label: "Orientation"
75
+ },
76
+ partialScoring: {
77
+ settings: !1,
78
+ label: "Allow Partial Scoring"
79
+ },
80
+ placementArea: {
81
+ settings: !0,
82
+ label: "Placement Area"
83
+ },
84
+ rationale: {
85
+ settings: !0,
86
+ label: "Rationale",
87
+ required: !1,
88
+ inputConfiguration: {
89
+ audio: { disabled: !1 },
90
+ video: { disabled: !1 },
91
+ image: { disabled: !1 }
92
+ }
93
+ },
94
+ removeTilesAfterPlacing: {
95
+ settings: !1,
96
+ label: "Remove Tiles after placing"
97
+ },
98
+ settingsPanelDisabled: !1,
99
+ scoringType: {
100
+ settings: !1,
101
+ label: "Scoring Type"
102
+ },
103
+ studentInstructions: {
104
+ settings: !1,
105
+ label: "Student Instructions"
106
+ },
107
+ targetLabel: {
108
+ settings: !0,
109
+ label: "Target label"
110
+ },
111
+ spellCheck: {
112
+ label: "Spellcheck",
113
+ settings: !1,
114
+ enabled: !0
115
+ },
116
+ teacherInstructions: {
117
+ settings: !0,
118
+ label: "Teacher Instructions",
119
+ required: !1,
120
+ inputConfiguration: {
121
+ audio: { disabled: !1 },
122
+ video: { disabled: !1 },
123
+ image: { disabled: !1 }
124
+ }
125
+ },
126
+ maxImageWidth: {
127
+ teacherInstructions: 300,
128
+ prompt: 300,
129
+ rationale: 300,
130
+ choicesWithPlacementArea: 240,
131
+ choicesWithoutPlacementArea: 300
132
+ },
133
+ maxImageHeight: {
134
+ teacherInstructions: 300,
135
+ prompt: 300,
136
+ rationale: 300,
137
+ choices: 150
138
+ },
139
+ withRubric: {
140
+ settings: !1,
141
+ label: "Add Rubric"
142
+ },
143
+ mathMlOptions: {
144
+ mmlOutput: !1,
145
+ mmlEditing: !1
146
+ },
147
+ language: {
148
+ settings: !1,
149
+ label: "Specify Language",
150
+ enabled: !1
151
+ },
152
+ languageChoices: {
153
+ label: "Language Choices",
154
+ options: []
155
+ }
156
+ }
157
+ };
158
+ //#endregion
159
+ export { e as default };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/placement-ordering/configure/src/design.jsx
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
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare class Design extends React.Component {
12
+ static propTypes: {
13
+ uploadSoundSupport: PropTypes.Requireable<object>;
14
+ };
15
+ static defaultProps: {};
16
+ constructor(props: any);
17
+ componentDidMount(): void;
18
+ onDragEnd: any;
19
+ render(): React.JSX.Element;
20
+ }
21
+ export default Design;
@@ -0,0 +1,273 @@
1
+ import e from "./choice-editor.js";
2
+ import { buildTiles as t, generateValidationMessage as n, normalizeIndex as r, updateResponseOrChoices as i } from "./utils.js";
3
+ import a from "react";
4
+ import { cloneDeep as o, isEmpty as s } from "@pie-element/shared-lodash";
5
+ import c from "debug";
6
+ import l from "prop-types";
7
+ import { styled as u } from "@mui/material/styles";
8
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
9
+ import { DragProvider as p } from "@pie-lib/drag";
10
+ import { get as m, set as h } from "nested-property";
11
+ import g from "pluralize";
12
+ import ee from "@mui/icons-material/Info";
13
+ import te from "@mui/material/Tooltip";
14
+ import { FeedbackConfig as ne, FormSection as _, InputContainer as v, layout as re, settings as y } from "@pie-lib/config-ui";
15
+ import b from "@pie-lib/editable-html-tip-tap";
16
+ //#region src/author/design.tsx
17
+ var x = c("@pie-element:placement-ordering:design"), { Panel: ie, toggle: S, radio: ae, dropdown: oe } = y, se = (e) => g.isPlural(e) ? {
18
+ singularLabel: g.singular(e),
19
+ pluralLabel: e
20
+ } : {
21
+ singularLabel: e,
22
+ pluralLabel: g(e)
23
+ }, C = u(v)(({ theme: e }) => ({
24
+ width: "100%",
25
+ paddingTop: e.spacing(2),
26
+ marginBottom: e.spacing(2)
27
+ })), ce = u("div")({
28
+ display: "grid",
29
+ gridAutoFlow: "column",
30
+ gridAutoColumns: "1fr",
31
+ gridGap: "8px"
32
+ }), le = u(_)(({ theme: e }) => ({
33
+ marginTop: 0,
34
+ marginBottom: e.spacing(2.5)
35
+ })), ue = u("div")({
36
+ display: "inline-flex",
37
+ position: "absolute"
38
+ }), de = u("div")(({ theme: e }) => ({
39
+ fontSize: e.typography.fontSize - 2,
40
+ color: e.palette.error.main,
41
+ paddingTop: e.spacing(1)
42
+ })), w = class extends a.Component {
43
+ static propTypes = { uploadSoundSupport: l.object };
44
+ static defaultProps = {};
45
+ constructor(e) {
46
+ super(e), this.applyUpdate = (e) => {
47
+ let { model: t, onModelChanged: n } = this.props;
48
+ n(e(o(t)));
49
+ }, this.changeHandler = (e, t) => (n) => {
50
+ x("[changeHandler] value: ", n);
51
+ let r = t ? m(n, t) : n;
52
+ this.applyUpdate((t) => (h(t, e, r), t));
53
+ }, this.onPromptChange = this.changeHandler("prompt"), this.onTeacherInstructionsChange = this.changeHandler("teacherInstructions"), this.onRationaleChange = this.changeHandler("rationale"), this.onChoiceAreaLabelChange = this.changeHandler("choiceLabel", "target.value"), this.onAnswerAreaLabelChange = this.changeHandler("targetLabel", "target.value"), this.onFeedbackChange = this.changeHandler("feedback"), this.onChoiceEditorChange = (e, t) => {
54
+ let { model: n, onModelChanged: r } = this.props, i = o(n);
55
+ i.choices = e, i.correctResponse = t, r(i);
56
+ };
57
+ }
58
+ componentDidMount() {
59
+ let { model: e, onModelChanged: t } = this.props || {}, { feedback: n } = e || {}, r = o(e);
60
+ n || (r.feedbackEnabled = !1, t(r));
61
+ }
62
+ onDragEnd = (e, t) => {
63
+ let { active: n, over: a } = e;
64
+ if (!a || !n) return;
65
+ let o = a.data.current, s = n.data.current, c = t.tiles.find((e) => e.id === s.id && e.type === s.type), l = o, u = {
66
+ ...c,
67
+ index: r(c, t)
68
+ }, d = {
69
+ ...l,
70
+ index: r(l, t)
71
+ }, { response: f, choices: p } = i(t.response, t.choices, u, d);
72
+ this.onChoiceEditorChange(p, f);
73
+ };
74
+ render() {
75
+ let { model: r, imageSupport: i, uploadSoundSupport: a, onModelChanged: o, configuration: c, onConfigurationChanged: l } = this.props, { baseInputConfiguration: u = {}, choiceLabel: m = {}, choices: h = {}, contentDimensions: g = {}, feedback: _ = {}, prompt: v = {}, placementArea: y = {}, maxImageWidth: x = {}, maxImageHeight: w = {}, numberedGuides: T = {}, orientation: E = {}, partialScoring: D = {}, rationale: O = {}, removeTilesAfterPlacing: k = {}, settingsPanelDisabled: fe, studentInstructions: A = {}, spellCheck: j = {}, scoringType: M = {}, targetLabel: N = {}, teacherInstructions: P = {}, withRubric: F = {}, mathMlOptions: I = {}, language: L = {}, languageChoices: R = {} } = c || {}, { choiceLabelEnabled: pe, errors: z, extraCSSRules: me, feedbackEnabled: he, promptEnabled: ge, rationaleEnabled: _e, spellCheckEnabled: B, teacherInstructionsEnabled: ve, toolbarEditorPosition: ye, correctResponse: V } = r || {}, { prompt: H, rationale: U, teacherInstructions: W } = z || {}, G = {
76
+ choices: r.choices,
77
+ response: !V || s(V) ? Array(r.choices.length) : V,
78
+ tiles: t(r.choices, V)
79
+ }, be = n(), { singularLabel: K = "", pluralLabel: q = "" } = h?.label && se(h.label) || {}, J = x && x.prompt, Y = w && w.prompt, X = x && r.placementArea ? x.choicesWithPlacementArea : x.choicesWithoutPlacementArea || J, Z = w && w.choices || Y, Q = { position: ye === "top" ? "top" : "bottom" }, xe = {
80
+ choiceLabelEnabled: m.settings && S(m.label),
81
+ placementArea: y.settings && S(y.label),
82
+ numberedGuides: T.settings && r.placementArea && S(T.label),
83
+ orientation: E.settings && ae(E.label, ["vertical", "horizontal"]),
84
+ removeTilesAfterPlacing: k.settings && S(k.label),
85
+ partialScoring: D.settings && S(D.label),
86
+ feedbackEnabled: _.settings && S(_.label),
87
+ "language.enabled": L.settings && S(L.label, !0),
88
+ language: L.settings && L.enabled && oe(R.label, R.options)
89
+ }, Se = {
90
+ teacherInstructionsEnabled: P.settings && S(P.label),
91
+ studentInstructionsEnabled: A.settings && S(A.label),
92
+ rationaleEnabled: O.settings && S(O.label),
93
+ promptEnabled: v.settings && S(v.label),
94
+ spellCheckEnabled: j.settings && S(j.label),
95
+ scoringType: M.settings && ae(M.label, ["auto", "rubric"]),
96
+ rubricEnabled: F?.settings && S(F?.label)
97
+ }, $ = (e = {}) => ({
98
+ ...u,
99
+ ...e
100
+ });
101
+ return /* @__PURE__ */ d(p, {
102
+ onDragEnd: (e) => this.onDragEnd(e, G),
103
+ children: /* @__PURE__ */ f(re.ConfigLayout, {
104
+ extraCSSRules: me,
105
+ dimensions: g,
106
+ hideSettings: fe,
107
+ settings: /* @__PURE__ */ d(ie, {
108
+ model: r,
109
+ configuration: c,
110
+ onChangeModel: (e) => o(e),
111
+ onChangeConfiguration: (e) => l(e, !0),
112
+ groups: {
113
+ Settings: xe,
114
+ Properties: Se
115
+ }
116
+ }),
117
+ children: [
118
+ ve && /* @__PURE__ */ f(C, {
119
+ label: P.label,
120
+ children: [/* @__PURE__ */ d(b, {
121
+ className: "prompt",
122
+ markup: r.teacherInstructions || "",
123
+ onChange: this.onTeacherInstructionsChange,
124
+ imageSupport: i,
125
+ nonEmpty: !1,
126
+ error: W,
127
+ toolbarOpts: Q,
128
+ pluginProps: $(P?.inputConfiguration),
129
+ spellCheck: B,
130
+ maxImageWidth: x && x.teacherInstructions || J,
131
+ maxImageHeight: w && w.teacherInstructions || Y,
132
+ uploadSoundSupport: a,
133
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
134
+ mathMlOptions: I
135
+ }), W && /* @__PURE__ */ d("div", {
136
+ className: "errorText",
137
+ children: W
138
+ })]
139
+ }),
140
+ ge && /* @__PURE__ */ f(C, {
141
+ label: v && v.label,
142
+ children: [/* @__PURE__ */ d(b, {
143
+ className: "prompt",
144
+ markup: r.prompt,
145
+ onChange: this.onPromptChange,
146
+ imageSupport: i,
147
+ error: H,
148
+ toolbarOpts: Q,
149
+ pluginProps: $(v?.inputConfiguration),
150
+ spellCheck: B,
151
+ maxImageWidth: x && x.prompt,
152
+ maxImageHeight: w && w.prompt,
153
+ uploadSoundSupport: a,
154
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
155
+ mathMlOptions: I
156
+ }), H && /* @__PURE__ */ d("div", {
157
+ className: "errorText",
158
+ children: H
159
+ })]
160
+ }),
161
+ /* @__PURE__ */ f(le, {
162
+ label: `Define ${q}`,
163
+ labelExtraStyle: { display: "inline-flex" },
164
+ children: [
165
+ /* @__PURE__ */ d(ue, { children: /* @__PURE__ */ d(te, {
166
+ slotProps: { tooltip: { sx: {
167
+ fontSize: 14,
168
+ whiteSpace: "pre",
169
+ maxWidth: "500px"
170
+ } } },
171
+ disableFocusListener: !0,
172
+ disableTouchListener: !0,
173
+ placement: "right",
174
+ title: be,
175
+ children: /* @__PURE__ */ d(ee, {
176
+ fontSize: "small",
177
+ color: "primary",
178
+ style: { marginLeft: "8px" }
179
+ })
180
+ }) }),
181
+ /* @__PURE__ */ f(ce, { children: [pe && /* @__PURE__ */ d(C, {
182
+ label: m && m.label && `${K} label`,
183
+ children: /* @__PURE__ */ d(b, {
184
+ ...r.placementArea && { autoWidthToolbar: !0 },
185
+ className: "prompt",
186
+ markup: r.choiceLabel,
187
+ onChange: this.onChoiceAreaLabelChange,
188
+ toolbarOpts: Q,
189
+ pluginProps: $(m?.inputConfiguration),
190
+ spellCheck: B,
191
+ maxImageWidth: X,
192
+ maxImageHeight: Z,
193
+ uploadSoundSupport: a,
194
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
195
+ mathMlOptions: I
196
+ })
197
+ }), N.settings && r.placementArea && /* @__PURE__ */ d(C, {
198
+ label: N && N.label && N.label,
199
+ children: /* @__PURE__ */ d(b, {
200
+ autoWidthToolbar: !0,
201
+ className: "prompt",
202
+ markup: r.targetLabel,
203
+ onChange: this.onAnswerAreaLabelChange,
204
+ toolbarOpts: Q,
205
+ spellCheck: B,
206
+ maxImageWidth: x && x.choicesWithPlacementArea || J,
207
+ maxImageHeight: Z,
208
+ uploadSoundSupport: a,
209
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
210
+ mathMlOptions: I
211
+ })
212
+ })] }),
213
+ h.settings && /* @__PURE__ */ d(e, {
214
+ correctResponse: V,
215
+ choices: r.choices,
216
+ onChange: this.onChoiceEditorChange,
217
+ imageSupport: i,
218
+ toolbarOpts: Q,
219
+ pluginProps: $(h?.inputConfiguration),
220
+ choicesLabel: h.label,
221
+ placementArea: r.placementArea,
222
+ singularChoiceLabel: K,
223
+ pluralChoiceLabel: q,
224
+ spellCheck: B,
225
+ maxImageWidth: X,
226
+ maxImageHeight: Z,
227
+ errors: z || {},
228
+ mathMlOptions: I,
229
+ ordering: G
230
+ })
231
+ ]
232
+ }),
233
+ _e && /* @__PURE__ */ f(C, {
234
+ label: O.label,
235
+ children: [/* @__PURE__ */ d(b, {
236
+ className: "prompt",
237
+ markup: r.rationale || "",
238
+ onChange: this.onRationaleChange,
239
+ imageSupport: i,
240
+ error: U,
241
+ toolbarOpts: Q,
242
+ pluginProps: $(O?.inputConfiguration),
243
+ spellCheck: B,
244
+ maxImageWidth: x && x.rationale || J,
245
+ maxImageHeight: w && w.rationale || Y,
246
+ uploadSoundSupport: a,
247
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
248
+ mathMlOptions: I
249
+ }), U && /* @__PURE__ */ d(de, { children: U })]
250
+ }),
251
+ he && /* @__PURE__ */ d(ne, {
252
+ feedback: r.feedback,
253
+ onChange: this.onFeedbackChange,
254
+ imageSupport: i,
255
+ toolbarOpts: Q
256
+ })
257
+ ]
258
+ })
259
+ });
260
+ }
261
+ };
262
+ w.defaultProps = {
263
+ onModelChanged: () => {},
264
+ onConfigurationChanged: () => {}
265
+ }, w.propTypes = {
266
+ model: l.object.isRequired,
267
+ configuration: l.object.isRequired,
268
+ onModelChanged: l.func,
269
+ onConfigurationChanged: l.func,
270
+ imageSupport: l.object
271
+ };
272
+ //#endregion
273
+ export { w as default };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/placement-ordering/configure/src/help.jsx
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
+ import React from 'react';
10
+ declare const Comp: () => React.JSX.Element;
11
+ export default Comp;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/placement-ordering/configure/src/index.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 addWeightToCorrectResponse: (correctResponse: any) => any;
10
+ /**
11
+ * assuming that the correct response will be set via ui, not via config,
12
+ * correctResponse (if not set) will be initialized with choices default order
13
+ */
14
+ export default class PlacementOrdering extends HTMLElement {
15
+ static createDefaultModel: (model?: {}) => {
16
+ choiceLabel: string;
17
+ choiceLabelEnabled: boolean;
18
+ choices: never[];
19
+ correctResponse: never[];
20
+ feedbackEnabled: boolean;
21
+ numberedGuides: boolean;
22
+ orientation: string;
23
+ partialScoring: boolean;
24
+ placementArea: boolean;
25
+ prompt: string;
26
+ promptEnabled: boolean;
27
+ rationale: string;
28
+ rationaleEnabled: boolean;
29
+ removeTilesAfterPlacing: boolean;
30
+ scoringType: string;
31
+ studentInstructionsEnabled: boolean;
32
+ targetLabel: string;
33
+ teacherInstructions: string;
34
+ teacherInstructionsEnabled: boolean;
35
+ toolbarEditorPosition: string;
36
+ };
37
+ constructor();
38
+ dispatchUpdate(reset: any): void;
39
+ set model(s: any);
40
+ set configuration(c: any);
41
+ insertSound(handler: any): void;
42
+ onDeleteSound(src: any, done: any): void;
43
+ _rerender(): void;
44
+ disconnectedCallback(): void;
45
+ }
@@ -0,0 +1,85 @@
1
+ import e from "./design.js";
2
+ import t from "./defaults.js";
3
+ import n from "react";
4
+ import { createRoot as r } from "react-dom/client";
5
+ import { defaults as i } from "@pie-element/shared-lodash";
6
+ import { DeleteImageEvent as a, DeleteSoundEvent as o, InsertImageEvent as s, InsertSoundEvent as c, ModelUpdatedEvent as l } from "@pie-element/shared-configure-events";
7
+ //#region src/author/index.ts
8
+ var u = (e, n) => ({
9
+ configuration: i(e, t.configuration),
10
+ model: n
11
+ }), d = (e) => e && e.map((e) => e.weight === void 0 ? {
12
+ id: e.id || e,
13
+ weight: 0
14
+ } : {
15
+ id: e.id,
16
+ weight: e.weight
17
+ }), f = class i extends HTMLElement {
18
+ static createDefaultModel = (e = {}) => {
19
+ let n = d(e.correctResponse) || ((e) => e && e.map((e) => ({
20
+ id: e.id,
21
+ weight: 0
22
+ })))(e.choices), r = {
23
+ ...t.model,
24
+ ...e
25
+ };
26
+ return n && (r.correctResponse = n), r;
27
+ };
28
+ constructor() {
29
+ super(), this._root = null, this._model = i.createDefaultModel(), this._configuration = t.configuration, this.onModelChanged = (e, t) => {
30
+ this._model = e, this._rerender(), this.dispatchUpdate(t);
31
+ }, this.onConfigurationChanged = (e) => {
32
+ this._configuration = u(e).configuration, this.onModelChanged(this._model), this._rerender();
33
+ }, this.insertImage = (e) => {
34
+ this.dispatchEvent(new s(e));
35
+ }, this.deleteImage = (e, t) => {
36
+ this.dispatchEvent(new a(e, t));
37
+ };
38
+ }
39
+ dispatchUpdate(e) {
40
+ this.dispatchEvent(new l(this._model, e));
41
+ }
42
+ set model(e) {
43
+ this._model = i.createDefaultModel(e), this._rerender();
44
+ }
45
+ set configuration(e) {
46
+ let n = u(e, this._model);
47
+ this.onModelChanged(n.model);
48
+ let r = {
49
+ ...t.configuration,
50
+ ...n.configuration
51
+ };
52
+ this._configuration = r, r?.language?.enabled ? r?.languageChoices?.options?.length && (this._model.language = r?.languageChoices.options[0].value) : r.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
53
+ value: this._model.language,
54
+ label: this._model.language
55
+ })) : delete this._model.language, this._rerender();
56
+ }
57
+ insertSound(e) {
58
+ this.dispatchEvent(new c(e));
59
+ }
60
+ onDeleteSound(e, t) {
61
+ this.dispatchEvent(new o(e, t));
62
+ }
63
+ _rerender() {
64
+ let t = n.createElement(e, {
65
+ model: this._model,
66
+ configuration: this._configuration,
67
+ onModelChanged: this.onModelChanged,
68
+ onConfigurationChanged: this.onConfigurationChanged,
69
+ imageSupport: {
70
+ add: this.insertImage,
71
+ delete: this.deleteImage
72
+ },
73
+ uploadSoundSupport: {
74
+ add: this.insertSound.bind(this),
75
+ delete: this.onDeleteSound.bind(this)
76
+ }
77
+ });
78
+ this._root ||= r(this), this._root.render(t);
79
+ }
80
+ disconnectedCallback() {
81
+ this._root && this._root.unmount();
82
+ }
83
+ };
84
+ //#endregion
85
+ export { d as addWeightToCorrectResponse, f as default };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/placement-ordering/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: () => string;
10
+ export declare function normalizeIndex(tile: any, ordering: any): any;
11
+ export declare function updateResponseOrChoices(response: any, choices: any, from: any, to: any): {
12
+ response: any;
13
+ choices: any;
14
+ };
15
+ export declare function buildTiles(choices: any, response: any): any;
@@ -0,0 +1,62 @@
1
+ import { cloneDeep as e } from "@pie-element/shared-lodash";
2
+ //#region src/author/utils.ts
3
+ var t = () => "Validation requirements:\nThere should be at least 3 tokens.\nThe tokens should not be empty and should be unique.\nThe correct ordering should not be identical to the initial ordering.";
4
+ function n(e, t) {
5
+ return e.type === "target" ? t.response.findIndex((t) => t.id === e.id) : e.type === "choice" ? t.choices.findIndex((t) => t.id === e.id) : -1;
6
+ }
7
+ function r(t, n, r, i) {
8
+ let { type: a, index: o } = r, { type: s, index: c } = i;
9
+ if (a === "target" && s === "target") {
10
+ let { movedItem: r, remainingItems: i } = (e(t) || []).reduce((e, t, n) => (n === o ? e.movedItem = t : e.remainingItems.push(t), e), {
11
+ movedItem: null,
12
+ remainingItems: []
13
+ });
14
+ return {
15
+ response: [
16
+ ...i.slice(0, c),
17
+ r,
18
+ ...i.slice(c)
19
+ ],
20
+ choices: n
21
+ };
22
+ }
23
+ if (a === "choice" && s === "choice") {
24
+ let { movedItem: a, remainingItems: o, toIndex: s } = (e(n) || []).reduce((e, t, n) => (t.id === r.id ? e.movedItem = t : e.remainingItems.push(t), t.id === i.id && (e.toIndex = n), e), {
25
+ movedItem: null,
26
+ remainingItems: [],
27
+ toIndex: null
28
+ });
29
+ return {
30
+ response: t,
31
+ choices: [
32
+ ...o.slice(0, s),
33
+ a,
34
+ ...o.slice(s)
35
+ ]
36
+ };
37
+ }
38
+ return {
39
+ response: t,
40
+ choices: n
41
+ };
42
+ }
43
+ function i(e, t) {
44
+ let n = t.map((t, n) => {
45
+ let r = t && t.id;
46
+ return {
47
+ type: "target",
48
+ ...e.find((e) => r != null && e.id === r),
49
+ draggable: !0,
50
+ index: n,
51
+ editable: !1
52
+ };
53
+ });
54
+ return e.map((e) => Object.assign({}, e, {
55
+ type: "choice",
56
+ droppable: !1,
57
+ draggable: !0,
58
+ editable: !0
59
+ })).concat(n);
60
+ }
61
+ //#endregion
62
+ export { i as buildTiles, t as generateValidationMessage, n as normalizeIndex, r as updateResponseOrChoices };