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