@pie-element/extended-text-entry 6.5.3 → 6.5.4-next.1008

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.
@@ -1,330 +0,0 @@
1
- import {_dll_pie_lib__config_ui, _dll_pie_lib__editable_html, _dll_pie_framework__pie_configure_events} from "../../shared-config@^1.8.13/module/index.js";
2
- import {_dll_material_ui__core_styles, _dll_react, _dll_prop_types, _dll_material_ui__core, _dll_react_dom} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
3
- const React = _dll_react;
4
- const PropTypes = _dll_prop_types;
5
- const {Typography: Typography} = _dll_material_ui__core;
6
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
7
- const {FeedbackSelector: FeedbackSelector} = _dll_pie_lib__config_ui;
8
- const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
9
- const {settings: settings} = _dll_pie_lib__config_ui;
10
- const {layout: layout} = _dll_pie_lib__config_ui;
11
- const EditableHtml = _dll_pie_lib__editable_html;
12
- const {ALL_PLUGINS: ALL_PLUGINS} = _dll_pie_lib__editable_html;
13
- const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/packages/extended-text-entry/configure/src/main.jsx";
14
- const {Panel, toggle, numberFields, dropdown} = settings;
15
- const defaultFeedback = {
16
- type: 'default',
17
- default: 'Your answer has been submitted'
18
- };
19
- class Main extends React.Component {
20
- static __initStatic() {
21
- this.propTypes = {
22
- onModelChanged: PropTypes.func.isRequired,
23
- onConfigurationChanged: PropTypes.func,
24
- model: PropTypes.object.isRequired,
25
- configuration: PropTypes.object.isRequired,
26
- imageSupport: PropTypes.object.isRequired,
27
- classes: PropTypes.object.isRequired
28
- };
29
- }
30
- constructor(props) {
31
- super(props);
32
- Main.prototype.__init.call(this);
33
- Main.prototype.__init2.call(this);
34
- Main.prototype.__init3.call(this);
35
- this.state = {
36
- setDimensions: true
37
- };
38
- }
39
- __init() {
40
- this.onPromptChange = markup => {
41
- const {onModelChanged, model} = this.props;
42
- onModelChanged({
43
- ...model,
44
- prompt: markup
45
- });
46
- };
47
- }
48
- __init2() {
49
- this.changeFeedback = feedback => {
50
- const {model, onModelChanged} = this.props;
51
- const update = {
52
- ...model,
53
- feedback
54
- };
55
- onModelChanged(update);
56
- };
57
- }
58
- __init3() {
59
- this.changeTeacherInstructions = teacherInstructions => {
60
- const {model, onModelChanged} = this.props;
61
- const update = {
62
- ...model,
63
- teacherInstructions
64
- };
65
- onModelChanged(update);
66
- };
67
- }
68
- render() {
69
- const {model, classes, onModelChanged, configuration, onConfigurationChanged, imageSupport} = this.props;
70
- const {multiple = {}, feedback = {}, teacherInstructions = {}, prompt = {}, studentInstructions = {}, mathInput = {}, dimensions = {}, equationEditor = {}} = configuration || ({});
71
- const {teacherInstructionsEnabled, promptEnabled, feedbackEnabled} = model || ({});
72
- return React.createElement(layout.ConfigLayout, {
73
- settings: React.createElement(Panel, {
74
- model: model,
75
- configuration: configuration,
76
- onChangeModel: model => onModelChanged(model),
77
- onChangeConfiguration: config => onConfigurationChanged(config),
78
- groups: {
79
- 'Settings': {
80
- mathInput: mathInput.settings && toggle(mathInput.label),
81
- equationEditor: equationEditor.enabled && model.mathInput && dropdown(equationEditor.label, ['Grade 1 - 2', 'Grade 3 - 5', 'Grade 6 - 7', 'Grade 8 - HS', 'geometry', 'advanced-algebra', 'statistics', 'everything']),
82
- dimensions: numberFields(dimensions.label, {
83
- width: {
84
- label: 'Width (px)',
85
- suffix: 'px',
86
- min: 100,
87
- max: 500
88
- },
89
- height: {
90
- label: 'Height (px)',
91
- suffix: 'px',
92
- min: 100,
93
- max: 500
94
- }
95
- }),
96
- 'multiple.enabled': multiple.settings && toggle(multiple.label, true),
97
- promptEnabled: prompt.settings && toggle(prompt.label),
98
- feedbackEnabled: feedback.settings && toggle(feedback.label)
99
- },
100
- 'Properties': {
101
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
102
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label)
103
- }
104
- },
105
- __self: this,
106
- __source: {
107
- fileName: _jsxFileName,
108
- lineNumber: 75
109
- }
110
- }),
111
- __self: this,
112
- __source: {
113
- fileName: _jsxFileName,
114
- lineNumber: 73
115
- }
116
- }, React.createElement('div', {
117
- __self: this,
118
- __source: {
119
- fileName: _jsxFileName,
120
- lineNumber: 123
121
- }
122
- }, teacherInstructionsEnabled && React.createElement(InputContainer, {
123
- label: teacherInstructions.label,
124
- className: classes.promptContainer,
125
- __self: this,
126
- __source: {
127
- fileName: _jsxFileName,
128
- lineNumber: 126
129
- }
130
- }, React.createElement(EditableHtml, {
131
- className: classes.prompt,
132
- markup: model.teacherInstructions || '',
133
- onChange: this.changeTeacherInstructions,
134
- imageSupport: imageSupport,
135
- nonEmpty: false,
136
- __self: this,
137
- __source: {
138
- fileName: _jsxFileName,
139
- lineNumber: 127
140
- }
141
- })), React.createElement('br', {
142
- __self: this,
143
- __source: {
144
- fileName: _jsxFileName,
145
- lineNumber: 137
146
- }
147
- }), promptEnabled && React.createElement(InputContainer, {
148
- label: prompt.label,
149
- className: classes.promptContainer,
150
- __self: this,
151
- __source: {
152
- fileName: _jsxFileName,
153
- lineNumber: 140
154
- }
155
- }, React.createElement(EditableHtml, {
156
- activePlugins: ALL_PLUGINS,
157
- className: classes.prompt,
158
- markup: model.prompt || '',
159
- onChange: this.onPromptChange,
160
- imageSupport: imageSupport,
161
- nonEmpty: false,
162
- __self: this,
163
- __source: {
164
- fileName: _jsxFileName,
165
- lineNumber: 141
166
- }
167
- })), feedbackEnabled && React.createElement(React.Fragment, {
168
- __self: this,
169
- __source: {
170
- fileName: _jsxFileName,
171
- lineNumber: 154
172
- }
173
- }, React.createElement(Typography, {
174
- className: classes.header,
175
- variant: "subheading",
176
- __self: this,
177
- __source: {
178
- fileName: _jsxFileName,
179
- lineNumber: 155
180
- }
181
- }, "Feedback"), React.createElement(FeedbackSelector, {
182
- label: "When submitted, show",
183
- feedback: model.feedback || defaultFeedback,
184
- onChange: this.changeFeedback,
185
- __self: this,
186
- __source: {
187
- fileName: _jsxFileName,
188
- lineNumber: 159
189
- }
190
- }))));
191
- }
192
- }
193
- Main.__initStatic();
194
- var Main$1 = withStyles(theme => ({
195
- header: {
196
- paddingBottom: theme.spacing.unit
197
- },
198
- promptContainer: {
199
- paddingTop: theme.spacing.unit * 2,
200
- marginBottom: theme.spacing.unit * 2,
201
- width: '100%'
202
- },
203
- promptInput: {
204
- width: '100%',
205
- marginBottom: theme.spacing.unit
206
- },
207
- field: {
208
- width: '200px'
209
- }
210
- }))(Main);
211
- var defaults = {
212
- model: {
213
- dimensions: {
214
- height: 100,
215
- width: 500
216
- },
217
- prompt: 'This is the question prompt',
218
- mathInput: false,
219
- equationEditor: 'everything',
220
- feedbackEnabled: true,
221
- rationaleEnabled: true,
222
- promptEnabled: true,
223
- teacherInstructionsEnabled: true,
224
- studentInstructionsEnabled: true
225
- },
226
- configuration: {
227
- dimensions: {
228
- settings: true,
229
- label: 'Text-Entry Display Size'
230
- },
231
- equationEditor: {
232
- settings: false,
233
- label: 'Equation Editor',
234
- enabled: true
235
- },
236
- feedback: {
237
- settings: true,
238
- label: 'Feedback'
239
- },
240
- mathInput: {
241
- settings: true,
242
- label: 'Student response can include math notation',
243
- enabled: false
244
- },
245
- multiple: {
246
- settings: false,
247
- label: 'Multiple Parts',
248
- enabled: false
249
- },
250
- studentInstructions: {
251
- settings: false,
252
- label: 'Student Instructions'
253
- },
254
- prompt: {
255
- settings: true,
256
- label: 'Prompt'
257
- },
258
- teacherInstructions: {
259
- settings: true,
260
- label: 'Teacher Instructions'
261
- }
262
- }
263
- };
264
- const {ModelUpdatedEvent: ModelUpdatedEvent} = _dll_pie_framework__pie_configure_events;
265
- const {DeleteImageEvent: DeleteImageEvent} = _dll_pie_framework__pie_configure_events;
266
- const {InsertImageEvent: InsertImageEvent} = _dll_pie_framework__pie_configure_events;
267
- const React$1 = _dll_react;
268
- const ReactDOM = _dll_react_dom;
269
- class ExtendedTextEntry extends HTMLElement {
270
- static __initStatic() {
271
- this.createDefaultModel = (model = {}) => ({
272
- ...defaults.model,
273
- ...model
274
- });
275
- }
276
- constructor() {
277
- super();
278
- this._model = ExtendedTextEntry.createDefaultModel();
279
- this._configuration = defaults.configuration;
280
- }
281
- set model(m) {
282
- this._model = ExtendedTextEntry.createDefaultModel(m);
283
- this.render();
284
- }
285
- set configuration(c) {
286
- this._configuration = {
287
- ...defaults.configuration,
288
- ...c
289
- };
290
- this.render();
291
- }
292
- onModelChanged(m) {
293
- this._model = m;
294
- this.render();
295
- this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
296
- }
297
- onConfigurationChanged(c) {
298
- this._configuration = {
299
- ...defaults.configuration,
300
- ...c
301
- };
302
- if (this._model) {
303
- this.onModelChanged(this._model);
304
- }
305
- this.render();
306
- }
307
- insertImage(handler) {
308
- this.dispatchEvent(new InsertImageEvent(handler));
309
- }
310
- onDeleteImage(src, done) {
311
- this.dispatchEvent(new DeleteImageEvent(src, done));
312
- }
313
- render() {
314
- if (this._model) {
315
- const element = React$1.createElement(Main$1, {
316
- model: this._model,
317
- configuration: this._configuration,
318
- onModelChanged: this.onModelChanged.bind(this),
319
- onConfigurationChanged: this.onConfigurationChanged.bind(this),
320
- imageSupport: {
321
- add: this.insertImage.bind(this),
322
- delete: this.onDeleteImage.bind(this)
323
- }
324
- });
325
- ReactDOM.render(element, this);
326
- }
327
- }
328
- }
329
- ExtendedTextEntry.__initStatic();
330
- export default ExtendedTextEntry;
@@ -1,95 +0,0 @@
1
- /**
2
- * Get the feedback from a {FeedbackConfig}
3
- *
4
- * @param {FeedbackConfig} feedback
5
- * @param {string} fallback
6
- */
7
- const getFeedback = (feedback, fallback) =>
8
- new Promise(resolve => {
9
- if (!feedback || feedback.type === 'none') {
10
- resolve(undefined);
11
- return;
12
- }
13
- feedback = feedback || {};
14
- const out = feedback[feedback.type] || fallback;
15
- resolve(out);
16
- });
17
-
18
- var defaults = {
19
- dimensions: {
20
- height: 100,
21
- width: 500,
22
- }
23
- };
24
-
25
- async function createDefaultModel(model = {}) {
26
-
27
- return {
28
- ...defaults,
29
- ...model,
30
- };
31
- }
32
-
33
- const normalize = question => ({
34
- ...defaults,
35
- feedbackEnabled: true,
36
- rationaleEnabled: true,
37
- promptEnabled: true,
38
- teacherInstructionsEnabled: true,
39
- studentInstructionsEnabled: true,
40
- ...question,
41
- });
42
-
43
-
44
- async function model(question, session, env) {
45
- const normalizedQuestion = normalize(question);
46
-
47
- const fb =
48
- env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled
49
- ? getFeedback(normalizedQuestion.feedback, 'Your answer has been submitted')
50
- : Promise.resolve(undefined);
51
-
52
- let teacherInstructions = null;
53
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
54
- teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
55
- } else {
56
- teacherInstructions = null;
57
- }
58
-
59
- let equationEditor = normalizedQuestion.equationEditor || 'everything';
60
-
61
- switch (normalizedQuestion.equationEditor) {
62
- case 'Grade 1 - 2':
63
- equationEditor = 1;
64
- break;
65
- case 'Grade 3 - 5':
66
- equationEditor = 3;
67
- break;
68
- case 'Grade 6 - 7':
69
- equationEditor = 6;
70
- break;
71
- case 'Grade 8 - HS':
72
- equationEditor = 8;
73
- break;
74
- }
75
-
76
- return fb.then(feedback => ({
77
- prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
78
- dimensions: normalizedQuestion.dimensions,
79
- disabled: env.mode !== 'gather',
80
- feedback,
81
- teacherInstructions,
82
- mathInput: normalizedQuestion.mathInput,
83
- equationEditor
84
- }));
85
- }
86
-
87
- async function outcome(/*question, session, env*/) {
88
- return {
89
- score: 0,
90
- completed: 'n/a',
91
- note: 'Requires manual scoring'
92
- };
93
- }
94
-
95
- export { createDefaultModel, model, normalize, outcome };
package/module/demo.js DELETED
@@ -1,34 +0,0 @@
1
- import Configure from './configure.js';
2
- import Element from './element.js';
3
- import * as controller from './controller.js';
4
-
5
- var model = (id, element) => ({
6
- id,
7
- element,
8
- feedback: { type: 'default', default: 'this is default feedback' },
9
- prompt: 'This is the question prompt',
10
- promptEnabled: true,
11
- mathInput: false
12
- });
13
-
14
- var generate = {
15
- model: model
16
- };
17
-
18
- const { model: model$1 } = generate;
19
- var config = {
20
- elements: {
21
- 'extended-text-entry': '../..'
22
- },
23
- models: [model$1('1', 'extended-text-entry')]
24
- };
25
-
26
- //Note: demo-el is a custom element loaded in the markup.
27
- customElements.whenDefined('demo-el').then(() => {
28
- config.models.forEach(m => {
29
- const de = document.createElement('demo-el');
30
- document.body.appendChild(de);
31
- de.def = { tagName: m.element, Element, Configure, controller };
32
- de.model = m;
33
- });
34
- });