@pie-element/drawing-response 3.9.13 → 3.9.16
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/CHANGELOG.md +24 -0
- package/configure/CHANGELOG.md +24 -0
- package/configure/lib/defaults.js +8 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/image-container.js +16 -10
- package/configure/lib/image-container.js.map +1 -1
- package/configure/lib/index.js +2 -8
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +17 -9
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +3 -3
- package/configure/src/__tests__/__snapshots__/image-container.test.jsx.snap +2 -2
- package/configure/src/__tests__/__snapshots__/root.test.jsx.snap +7 -14
- package/configure/src/defaults.js +8 -2
- package/configure/src/image-container.jsx +75 -46
- package/configure/src/index.js +0 -6
- package/configure/src/root.jsx +31 -24
- package/controller/CHANGELOG.md +8 -0
- package/controller/lib/index.js +13 -7
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/__tests__/index.test.js +18 -9
- package/controller/src/index.js +4 -1
- package/docs/config-schema.json +16 -0
- package/docs/config-schema.json.md +12 -0
- package/docs/demo/generate.js +1 -0
- package/docs/pie-schema.json +12 -0
- package/docs/pie-schema.json.md +8 -0
- package/lib/drawing-response/container.js +57 -11
- package/lib/drawing-response/container.js.map +1 -1
- package/lib/drawing-response/drawable-image.js +2 -1
- package/lib/drawing-response/drawable-image.js.map +1 -1
- package/lib/drawing-response/drawable-main.js +28 -12
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-text.js +4 -4
- package/lib/drawing-response/drawable-text.js.map +1 -1
- package/lib/drawing-response/index.js +3 -0
- package/lib/drawing-response/index.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +18 -2
- package/src/drawing-response/__tests__/__snapshots__/drawing-main.test.jsx.snap +12 -2
- package/src/drawing-response/__tests__/container.test.jsx +7 -0
- package/src/drawing-response/__tests__/drawing-main.test.jsx +2 -1
- package/src/drawing-response/container.jsx +40 -2
- package/src/drawing-response/drawable-image.jsx +2 -1
- package/src/drawing-response/drawable-main.jsx +24 -10
- package/src/drawing-response/drawable-text.jsx +1 -1
- package/src/drawing-response/index.jsx +3 -1
- package/src/index.js +5 -0
|
@@ -13,11 +13,11 @@ export class ImageContainer extends Component {
|
|
|
13
13
|
constructor(props) {
|
|
14
14
|
super(props);
|
|
15
15
|
this.state = {
|
|
16
|
-
maxImageWidth:
|
|
17
|
-
maxImageHeight:
|
|
16
|
+
maxImageWidth: "100%",
|
|
17
|
+
maxImageHeight: "auto",
|
|
18
18
|
dragEnabled: true,
|
|
19
19
|
dropzoneActive: false,
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
componentDidMount() {
|
|
@@ -26,7 +26,7 @@ export class ImageContainer extends Component {
|
|
|
26
26
|
const { height, width } = positionInfo;
|
|
27
27
|
this.setState({
|
|
28
28
|
maxImageWidth: width,
|
|
29
|
-
maxImageHeight: height
|
|
29
|
+
maxImageHeight: height,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -46,7 +46,7 @@ export class ImageContainer extends Component {
|
|
|
46
46
|
this.handleFileRead(file);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
makeDropzoneActive= () => this.setState({ dropzoneActive: true });
|
|
49
|
+
makeDropzoneActive = () => this.setState({ dropzoneActive: true });
|
|
50
50
|
|
|
51
51
|
makeDropzoneInactive = () => this.setState({ dropzoneActive: false });
|
|
52
52
|
|
|
@@ -90,7 +90,7 @@ export class ImageContainer extends Component {
|
|
|
90
90
|
|
|
91
91
|
const dimensions = {
|
|
92
92
|
height: offsetHeight,
|
|
93
|
-
width: offsetWidth
|
|
93
|
+
width: offsetWidth,
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
this.setState({ dimensions });
|
|
@@ -117,20 +117,30 @@ export class ImageContainer extends Component {
|
|
|
117
117
|
|
|
118
118
|
startResizing = (e) => {
|
|
119
119
|
const box = this.image;
|
|
120
|
-
const { maxImageWidth } = this.state;
|
|
120
|
+
const { maxImageWidth, dimensions } = this.state;
|
|
121
121
|
|
|
122
122
|
const bounds = e.target.getBoundingClientRect();
|
|
123
123
|
const x = e.clientX - bounds.left;
|
|
124
124
|
const y = e.clientY - bounds.top;
|
|
125
125
|
|
|
126
|
+
const imageAspectRatio = dimensions.width / dimensions.height;
|
|
127
|
+
|
|
126
128
|
const fitsContainer = x <= maxImageWidth + 5;
|
|
127
129
|
const hasMinimumWidth = x > 150 && y > 150;
|
|
128
130
|
|
|
131
|
+
const keepAspectRatioWidth = x > y ? x : 'auto';
|
|
132
|
+
const keepAspectRatioHeight = x > y ? 'auto' : y;
|
|
133
|
+
|
|
129
134
|
if (fitsContainer && hasMinimumWidth) {
|
|
130
135
|
box.style.width = `${x}px`;
|
|
131
|
-
box.style.height = `${
|
|
136
|
+
box.style.height = `${x/imageAspectRatio}px`;
|
|
132
137
|
|
|
133
|
-
this.setState({
|
|
138
|
+
this.setState({
|
|
139
|
+
dimensions: {
|
|
140
|
+
height:x/imageAspectRatio,
|
|
141
|
+
width:x,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
this.handleDisableDrag();
|
|
@@ -141,60 +151,79 @@ export class ImageContainer extends Component {
|
|
|
141
151
|
|
|
142
152
|
return (
|
|
143
153
|
<div>
|
|
144
|
-
<Button
|
|
145
|
-
label={label}
|
|
146
|
-
onClick={this.handleInputClick}
|
|
147
|
-
/>
|
|
154
|
+
<Button label={label} onClick={this.handleInputClick} />
|
|
148
155
|
<input
|
|
149
156
|
accept="image/*"
|
|
150
157
|
className={classes.input}
|
|
151
158
|
onChange={this.handleUploadImage}
|
|
152
|
-
ref={ref => {
|
|
159
|
+
ref={(ref) => {
|
|
160
|
+
this.input = ref;
|
|
161
|
+
}}
|
|
153
162
|
type="file"
|
|
154
163
|
/>
|
|
155
164
|
</div>
|
|
156
|
-
)
|
|
165
|
+
);
|
|
157
166
|
}
|
|
158
167
|
|
|
159
168
|
render() {
|
|
160
|
-
const {
|
|
161
|
-
classes,
|
|
162
|
-
imageUrl
|
|
163
|
-
} = this.props;
|
|
169
|
+
const { classes, imageUrl } = this.props;
|
|
164
170
|
const {
|
|
165
171
|
dropzoneActive,
|
|
166
172
|
dragEnabled,
|
|
167
173
|
maxImageHeight,
|
|
168
|
-
maxImageWidth
|
|
174
|
+
maxImageWidth,
|
|
175
|
+
dimensions,
|
|
169
176
|
} = this.state;
|
|
170
177
|
|
|
171
178
|
return (
|
|
172
|
-
<div className={classes.base}
|
|
173
|
-
<div
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
<div className={classes.base}>
|
|
180
|
+
<div
|
|
181
|
+
className={`${classes.box} ${
|
|
182
|
+
dropzoneActive ? classes.boxActive : ''
|
|
183
|
+
}`}
|
|
184
|
+
{...(dragEnabled
|
|
185
|
+
? {
|
|
186
|
+
onDragExit: this.handleOnDragExit,
|
|
187
|
+
onDragLeave: this.handleOnDragExit,
|
|
188
|
+
onDragOver: this.handleOnDragOver,
|
|
189
|
+
onDrop: this.handleOnDrop,
|
|
190
|
+
}
|
|
191
|
+
: {})}
|
|
180
192
|
>
|
|
181
193
|
<div className={classes.toolbar}>
|
|
182
|
-
{this.renderUploadControl(
|
|
194
|
+
{this.renderUploadControl(
|
|
195
|
+
imageUrl ? 'Replace Image' : 'Upload Image'
|
|
196
|
+
)}
|
|
183
197
|
</div>
|
|
184
198
|
|
|
185
|
-
<div
|
|
199
|
+
<div
|
|
200
|
+
ref={(ref) => {
|
|
201
|
+
this.imageSection = ref;
|
|
202
|
+
}}
|
|
203
|
+
className={classes.drawableHeight}
|
|
204
|
+
>
|
|
186
205
|
{imageUrl ? (
|
|
187
206
|
<div className={classes.imageContainer}>
|
|
188
207
|
<img
|
|
189
208
|
className={classes.image}
|
|
190
209
|
height="auto"
|
|
191
210
|
onLoad={this.handleOnImageLoad}
|
|
192
|
-
ref={ref => {
|
|
211
|
+
ref={(ref) => {
|
|
212
|
+
this.image = ref;
|
|
213
|
+
}}
|
|
193
214
|
src={imageUrl}
|
|
194
|
-
style={{
|
|
195
|
-
|
|
215
|
+
style={{
|
|
216
|
+
maxWidth: maxImageWidth,
|
|
217
|
+
maxHeight: maxImageHeight
|
|
218
|
+
}}
|
|
219
|
+
alt=""
|
|
220
|
+
/>
|
|
221
|
+
<div
|
|
222
|
+
ref={(ref) => {
|
|
223
|
+
this.resize = ref;
|
|
224
|
+
}}
|
|
225
|
+
className={classes.resize}
|
|
196
226
|
/>
|
|
197
|
-
<div ref={ref => { this.resize = ref; }} className={classes.resize} />
|
|
198
227
|
</div>
|
|
199
228
|
) : (
|
|
200
229
|
<div className={`${classes.drawableHeight} ${classes.centered}`}>
|
|
@@ -210,25 +239,25 @@ export class ImageContainer extends Component {
|
|
|
210
239
|
}
|
|
211
240
|
}
|
|
212
241
|
|
|
213
|
-
const styles = theme => ({
|
|
242
|
+
const styles = (theme) => ({
|
|
214
243
|
base: {
|
|
215
|
-
marginTop: theme.spacing.unit * 2
|
|
244
|
+
marginTop: theme.spacing.unit * 2,
|
|
216
245
|
},
|
|
217
246
|
box: {
|
|
218
247
|
border: '1px solid #E0E1E6',
|
|
219
|
-
borderRadius: '5px'
|
|
248
|
+
borderRadius: '5px',
|
|
220
249
|
},
|
|
221
250
|
boxActive: {
|
|
222
|
-
border: '1px solid #0032C2'
|
|
251
|
+
border: '1px solid #0032C2',
|
|
223
252
|
},
|
|
224
253
|
centered: {
|
|
225
254
|
alignItems: 'center',
|
|
226
255
|
display: 'flex',
|
|
227
256
|
flexDirection: 'column',
|
|
228
|
-
justifyContent: 'center'
|
|
257
|
+
justifyContent: 'center',
|
|
229
258
|
},
|
|
230
259
|
drawableHeight: {
|
|
231
|
-
minHeight: 350
|
|
260
|
+
minHeight: 350,
|
|
232
261
|
},
|
|
233
262
|
image: {
|
|
234
263
|
alignItems: 'center',
|
|
@@ -237,7 +266,7 @@ const styles = theme => ({
|
|
|
237
266
|
},
|
|
238
267
|
imageContainer: {
|
|
239
268
|
position: 'relative',
|
|
240
|
-
width: 'fit-content'
|
|
269
|
+
width: 'fit-content',
|
|
241
270
|
},
|
|
242
271
|
resize: {
|
|
243
272
|
borderBottom: '1px solid #727272',
|
|
@@ -247,10 +276,10 @@ const styles = theme => ({
|
|
|
247
276
|
height: '10px',
|
|
248
277
|
position: 'absolute',
|
|
249
278
|
right: '-10px',
|
|
250
|
-
width: '10px'
|
|
279
|
+
width: '10px',
|
|
251
280
|
},
|
|
252
281
|
input: {
|
|
253
|
-
display: 'none'
|
|
282
|
+
display: 'none',
|
|
254
283
|
},
|
|
255
284
|
toolbar: {
|
|
256
285
|
backgroundColor: '#ECEDF1',
|
|
@@ -258,15 +287,15 @@ const styles = theme => ({
|
|
|
258
287
|
borderTopLeftRadius: '5px',
|
|
259
288
|
borderTopRightRadius: '5px',
|
|
260
289
|
display: 'flex',
|
|
261
|
-
padding: '12px 8px'
|
|
262
|
-
}
|
|
290
|
+
padding: '12px 8px',
|
|
291
|
+
},
|
|
263
292
|
});
|
|
264
293
|
|
|
265
294
|
ImageContainer.propTypes = {
|
|
266
295
|
classes: PropTypes.object.isRequired,
|
|
267
296
|
imageUrl: PropTypes.string.isRequired,
|
|
268
297
|
onImageUpload: PropTypes.func.isRequired,
|
|
269
|
-
onUpdateImageDimension: PropTypes.func.isRequired
|
|
298
|
+
onUpdateImageDimension: PropTypes.func.isRequired,
|
|
270
299
|
};
|
|
271
300
|
|
|
272
301
|
export default withStyles(styles)(ImageContainer);
|
package/configure/src/index.js
CHANGED
|
@@ -49,12 +49,6 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
onConfigurationChanged = (c) => {
|
|
52
|
-
if (!c.backgroundImage.enabled) {
|
|
53
|
-
this.onModelChanged({
|
|
54
|
-
...this._model,
|
|
55
|
-
imageUrl: ''
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
52
|
this._configuration = c;
|
|
59
53
|
this._render();
|
|
60
54
|
};
|
package/configure/src/root.jsx
CHANGED
|
@@ -11,22 +11,22 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
11
11
|
const { Panel, toggle } = settings;
|
|
12
12
|
|
|
13
13
|
export class Root extends React.Component {
|
|
14
|
-
onPromptChanged = prompt => {
|
|
14
|
+
onPromptChanged = (prompt) => {
|
|
15
15
|
const { model, onModelChanged } = this.props;
|
|
16
16
|
const update = cloneDeep(model);
|
|
17
17
|
|
|
18
18
|
onModelChanged({
|
|
19
19
|
...update,
|
|
20
|
-
prompt
|
|
20
|
+
prompt,
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
onTeacherInstructionsChanged = teacherInstructions => {
|
|
24
|
+
onTeacherInstructionsChanged = (teacherInstructions) => {
|
|
25
25
|
const { model, onModelChanged } = this.props;
|
|
26
26
|
|
|
27
27
|
onModelChanged({
|
|
28
28
|
...model,
|
|
29
|
-
teacherInstructions
|
|
29
|
+
teacherInstructions,
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -35,16 +35,16 @@ export class Root extends React.Component {
|
|
|
35
35
|
|
|
36
36
|
onModelChanged({
|
|
37
37
|
...model,
|
|
38
|
-
imageDimensions: dimensions
|
|
38
|
+
imageDimensions: dimensions,
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
onImageUpload = imageUrl => {
|
|
42
|
+
onImageUpload = (imageUrl) => {
|
|
43
43
|
const { model, onModelChanged } = this.props;
|
|
44
44
|
|
|
45
45
|
onModelChanged({
|
|
46
46
|
...model,
|
|
47
|
-
imageUrl
|
|
47
|
+
imageUrl,
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -55,11 +55,15 @@ export class Root extends React.Component {
|
|
|
55
55
|
model,
|
|
56
56
|
imageSupport,
|
|
57
57
|
onConfigurationChanged,
|
|
58
|
-
onModelChanged
|
|
58
|
+
onModelChanged,
|
|
59
59
|
} = this.props;
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const {
|
|
61
|
+
backgroundImage = {},
|
|
62
|
+
prompt = {},
|
|
63
|
+
teacherInstructions = {},
|
|
64
|
+
spellCheck = {},
|
|
65
|
+
} = configuration || {};
|
|
66
|
+
const { teacherInstructionsEnabled, promptEnabled, spellCheckEnabled, backgroundImageEnabled } =
|
|
63
67
|
model || {};
|
|
64
68
|
const toolbarOpts = {};
|
|
65
69
|
|
|
@@ -83,16 +87,16 @@ export class Root extends React.Component {
|
|
|
83
87
|
onChangeConfiguration={onConfigurationChanged}
|
|
84
88
|
groups={{
|
|
85
89
|
Settings: {
|
|
86
|
-
|
|
87
|
-
backgroundImage.settings &&
|
|
88
|
-
toggle(backgroundImage.label, true),
|
|
90
|
+
backgroundImageEnabled: backgroundImage.settings && toggle(backgroundImage.label),
|
|
89
91
|
promptEnabled: prompt.settings && toggle(prompt.label)
|
|
90
92
|
},
|
|
91
93
|
Properties: {
|
|
92
94
|
teacherInstructionsEnabled:
|
|
93
95
|
teacherInstructions.settings &&
|
|
94
|
-
toggle(teacherInstructions.label)
|
|
95
|
-
|
|
96
|
+
toggle(teacherInstructions.label),
|
|
97
|
+
spellCheckEnabled:
|
|
98
|
+
spellCheck.settings && toggle(spellCheck.label),
|
|
99
|
+
},
|
|
96
100
|
}}
|
|
97
101
|
/>
|
|
98
102
|
}
|
|
@@ -109,6 +113,7 @@ export class Root extends React.Component {
|
|
|
109
113
|
imageSupport={imageSupport}
|
|
110
114
|
nonEmpty={false}
|
|
111
115
|
toolbarOpts={toolbarOpts}
|
|
116
|
+
spellCheck={spellCheckEnabled}
|
|
112
117
|
/>
|
|
113
118
|
</InputContainer>
|
|
114
119
|
)}
|
|
@@ -119,11 +124,13 @@ export class Root extends React.Component {
|
|
|
119
124
|
markup={model.prompt}
|
|
120
125
|
onChange={this.onPromptChanged}
|
|
121
126
|
toolbarOpts={toolbarOpts}
|
|
127
|
+
spellCheck={spellCheckEnabled}
|
|
128
|
+
imageSupport={imageSupport}
|
|
122
129
|
/>
|
|
123
130
|
</InputContainer>
|
|
124
131
|
)}
|
|
125
132
|
|
|
126
|
-
{
|
|
133
|
+
{backgroundImageEnabled && (
|
|
127
134
|
<div>
|
|
128
135
|
<Typography className={classes.label} variant="subheading">
|
|
129
136
|
Define Background Image
|
|
@@ -143,20 +150,20 @@ export class Root extends React.Component {
|
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
|
|
146
|
-
const styles = theme => ({
|
|
153
|
+
const styles = (theme) => ({
|
|
147
154
|
base: {
|
|
148
|
-
marginTop: theme.spacing.unit * 3
|
|
155
|
+
marginTop: theme.spacing.unit * 3,
|
|
149
156
|
},
|
|
150
157
|
label: {
|
|
151
|
-
marginTop: theme.spacing.unit * 4
|
|
158
|
+
marginTop: theme.spacing.unit * 4,
|
|
152
159
|
},
|
|
153
160
|
prompt: {
|
|
154
161
|
paddingTop: theme.spacing.unit * 2,
|
|
155
|
-
width: '100%'
|
|
162
|
+
width: '100%',
|
|
156
163
|
},
|
|
157
164
|
regular: {
|
|
158
|
-
marginBottom: theme.spacing.unit * 3
|
|
159
|
-
}
|
|
165
|
+
marginBottom: theme.spacing.unit * 3,
|
|
166
|
+
},
|
|
160
167
|
});
|
|
161
168
|
|
|
162
169
|
Root.propTypes = {
|
|
@@ -165,7 +172,7 @@ Root.propTypes = {
|
|
|
165
172
|
model: PropTypes.object.isRequired,
|
|
166
173
|
imageSupport: PropTypes.shape({
|
|
167
174
|
add: PropTypes.func,
|
|
168
|
-
delete: PropTypes.func
|
|
175
|
+
delete: PropTypes.func,
|
|
169
176
|
}),
|
|
170
177
|
onModelChanged: PropTypes.func.isRequired,
|
|
171
178
|
onConfigurationChanged: PropTypes.func.isRequired,
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.2.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.7...@pie-element/drawing-response-controller@3.2.8) (2022-03-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [3.2.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.2...@pie-element/drawing-response-controller@3.2.4) (2021-11-11)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
package/controller/lib/index.js
CHANGED
|
@@ -5,9 +5,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.createDefaultModel = void 0;
|
|
8
9
|
exports.model = model;
|
|
10
|
+
exports.normalize = void 0;
|
|
9
11
|
exports.outcome = outcome;
|
|
10
|
-
exports.createDefaultModel = exports.normalize = void 0;
|
|
11
12
|
|
|
12
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
14
|
|
|
@@ -15,9 +16,9 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
15
16
|
|
|
16
17
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
17
18
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
20
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
22
|
|
|
22
23
|
var log = (0, _debug["default"])('pie-elements:drawing-response:controller');
|
|
23
24
|
|
|
@@ -25,7 +26,8 @@ var normalize = function normalize(question) {
|
|
|
25
26
|
return _objectSpread({
|
|
26
27
|
promptEnabled: true,
|
|
27
28
|
teacherInstructionsEnabled: true,
|
|
28
|
-
studentInstructionsEnabled: true
|
|
29
|
+
studentInstructionsEnabled: true,
|
|
30
|
+
backgroundImageEnabled: true
|
|
29
31
|
}, question);
|
|
30
32
|
};
|
|
31
33
|
|
|
@@ -36,14 +38,16 @@ function model(question, session, env) {
|
|
|
36
38
|
var imageUrl = normalizedQuestion.imageUrl,
|
|
37
39
|
imageDimensions = normalizedQuestion.imageDimensions,
|
|
38
40
|
prompt = normalizedQuestion.prompt,
|
|
39
|
-
promptEnabled = normalizedQuestion.promptEnabled
|
|
41
|
+
promptEnabled = normalizedQuestion.promptEnabled,
|
|
42
|
+
backgroundImageEnabled = normalizedQuestion.backgroundImageEnabled;
|
|
40
43
|
return new Promise(function (resolve) {
|
|
41
44
|
var out = {
|
|
42
45
|
disabled: env.mode !== 'gather',
|
|
43
46
|
mode: env.mode,
|
|
44
47
|
imageDimensions: imageDimensions,
|
|
45
48
|
imageUrl: imageUrl,
|
|
46
|
-
prompt: promptEnabled ? prompt : null
|
|
49
|
+
prompt: promptEnabled ? prompt : null,
|
|
50
|
+
backgroundImageEnabled: backgroundImageEnabled
|
|
47
51
|
};
|
|
48
52
|
|
|
49
53
|
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
@@ -65,7 +69,9 @@ var createDefaultModel = function createDefaultModel() {
|
|
|
65
69
|
|
|
66
70
|
exports.createDefaultModel = createDefaultModel;
|
|
67
71
|
|
|
68
|
-
function
|
|
72
|
+
function
|
|
73
|
+
/*config, session*/
|
|
74
|
+
outcome() {
|
|
69
75
|
return new Promise(function (resolve) {
|
|
70
76
|
log('outcome...');
|
|
71
77
|
resolve({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","model","session","env","normalizedQuestion","imageUrl","imageDimensions","prompt","Promise","resolve","out","disabled","mode","role","teacherInstructions","createDefaultModel","defaults","outcome","score","completed","note"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","backgroundImageEnabled","model","session","env","normalizedQuestion","imageUrl","imageDimensions","prompt","Promise","resolve","out","disabled","mode","role","teacherInstructions","createDefaultModel","defaults","outcome","score","completed","note"],"mappings":";;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,QAAQ;AAAA;AAC/BC,IAAAA,aAAa,EAAE,IADgB;AAE/BC,IAAAA,0BAA0B,EAAE,IAFG;AAG/BC,IAAAA,0BAA0B,EAAE,IAHG;AAI/BC,IAAAA,sBAAsB,EAAE;AAJO,KAK5BJ,QAL4B;AAAA,CAA1B;;;;AAQA,SAASK,KAAT,CAAeL,QAAf,EAAyBM,OAAzB,EAAkCC,GAAlC,EAAuC;AAC5C,MAAMC,kBAAkB,GAAGT,SAAS,CAACC,QAAD,CAApC;AACA,MACES,QADF,GAMID,kBANJ,CACEC,QADF;AAAA,MAEEC,eAFF,GAMIF,kBANJ,CAEEE,eAFF;AAAA,MAGEC,MAHF,GAMIH,kBANJ,CAGEG,MAHF;AAAA,MAIEV,aAJF,GAMIO,kBANJ,CAIEP,aAJF;AAAA,MAKEG,sBALF,GAMII,kBANJ,CAKEJ,sBALF;AAQA,SAAO,IAAIQ,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5B,QAAMC,GAAG,GAAG;AACVC,MAAAA,QAAQ,EAAER,GAAG,CAACS,IAAJ,KAAa,QADb;AAEVA,MAAAA,IAAI,EAAET,GAAG,CAACS,IAFA;AAGVN,MAAAA,eAAe,EAAfA,eAHU;AAIVD,MAAAA,QAAQ,EAARA,QAJU;AAKVE,MAAAA,MAAM,EAAEV,aAAa,GAAGU,MAAH,GAAY,IALvB;AAMVP,MAAAA,sBAAsB,EAAtBA;AANU,KAAZ;;AASA,QAAIG,GAAG,CAACU,IAAJ,KAAa,YAAb,KAA8BV,GAAG,CAACS,IAAJ,KAAa,MAAb,IAAuBT,GAAG,CAACS,IAAJ,KAAa,UAAlE,CAAJ,EAAmF;AACjFF,MAAAA,GAAG,CAACI,mBAAJ,GAA0BV,kBAAkB,CAACN,0BAAnB,GAAgDM,kBAAkB,CAACU,mBAAnE,GAAyF,IAAnH;AACD,KAFD,MAEO;AACLJ,MAAAA,GAAG,CAACI,mBAAJ,GAA0B,IAA1B;AACD;;AAEDL,IAAAA,OAAO,CAACC,GAAD,CAAP;AACD,GAjBM,CAAP;AAkBD;;AAEM,IAAMK,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,MAACd,KAAD,uEAAS,EAAT;AAAA,SAChC,IAAIO,OAAJ,CAAY,UAAAC,OAAO,EAAI;AACrBA,IAAAA,OAAO,iCACFO,oBADE,GAEFf,KAFE,EAAP;AAID,GALD,CADgC;AAAA,CAA3B;;;;AAQA;AAAiB;AAARgB,OAAT,GAAsC;AAC3C,SAAO,IAAIT,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5Bf,IAAAA,GAAG,CAAC,YAAD,CAAH;AACAe,IAAAA,OAAO,CAAC;AACNS,MAAAA,KAAK,EAAE,CADD;AAENC,MAAAA,SAAS,EAAE,KAFL;AAGNC,MAAAA,IAAI,EAAE;AAHA,KAAD,CAAP;AAKD,GAPM,CAAP;AAQD","sourcesContent":["import debug from 'debug';\nimport defaults from './defaults';\n\nconst log = debug('pie-elements:drawing-response:controller');\n\nexport const normalize = question => ({\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n backgroundImageEnabled: true,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n imageDimensions,\n prompt,\n promptEnabled,\n backgroundImageEnabled\n } = normalizedQuestion;\n\n return new Promise(resolve => {\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n imageDimensions,\n imageUrl,\n prompt: promptEnabled ? prompt : null,\n backgroundImageEnabled\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;\n } else {\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise(resolve => {\n resolve({\n ...defaults,\n ...model,\n })\n });\n\nexport function outcome(/*config, session*/) {\n return new Promise(resolve => {\n log('outcome...');\n resolve({\n score: 0,\n completed: 'n/a',\n note: 'Requires manual scoring'\n });\n });\n}\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
|
@@ -12,7 +12,8 @@ describe('controller', () => {
|
|
|
12
12
|
height: 0,
|
|
13
13
|
width: 0
|
|
14
14
|
},
|
|
15
|
-
teacherInstructions: 'Teacher Instructions'
|
|
15
|
+
teacherInstructions: 'Teacher Instructions',
|
|
16
|
+
backgroundImageEnabled: true
|
|
16
17
|
};
|
|
17
18
|
});
|
|
18
19
|
|
|
@@ -56,7 +57,8 @@ describe('controller', () => {
|
|
|
56
57
|
imageUrl: question.imageUrl,
|
|
57
58
|
imageDimensions: question.imageDimensions,
|
|
58
59
|
prompt: question.prompt,
|
|
59
|
-
teacherInstructions: null
|
|
60
|
+
teacherInstructions: null,
|
|
61
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
60
62
|
});
|
|
61
63
|
});
|
|
62
64
|
|
|
@@ -69,7 +71,8 @@ describe('controller', () => {
|
|
|
69
71
|
imageUrl: question.imageUrl,
|
|
70
72
|
imageDimensions: question.imageDimensions,
|
|
71
73
|
prompt: null,
|
|
72
|
-
teacherInstructions: null
|
|
74
|
+
teacherInstructions: null,
|
|
75
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
73
76
|
});
|
|
74
77
|
});
|
|
75
78
|
|
|
@@ -83,7 +86,8 @@ describe('controller', () => {
|
|
|
83
86
|
imageUrl: question.imageUrl,
|
|
84
87
|
imageDimensions: question.imageDimensions,
|
|
85
88
|
prompt: question.prompt,
|
|
86
|
-
teacherInstructions: null
|
|
89
|
+
teacherInstructions: null,
|
|
90
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
87
91
|
});
|
|
88
92
|
});
|
|
89
93
|
|
|
@@ -96,7 +100,8 @@ describe('controller', () => {
|
|
|
96
100
|
imageUrl: question.imageUrl,
|
|
97
101
|
imageDimensions: question.imageDimensions,
|
|
98
102
|
prompt: question.prompt,
|
|
99
|
-
teacherInstructions: question.teacherInstructions
|
|
103
|
+
teacherInstructions: question.teacherInstructions,
|
|
104
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
100
105
|
});
|
|
101
106
|
});
|
|
102
107
|
|
|
@@ -112,7 +117,8 @@ describe('controller', () => {
|
|
|
112
117
|
imageUrl: question.imageUrl,
|
|
113
118
|
imageDimensions: question.imageDimensions,
|
|
114
119
|
prompt: question.prompt,
|
|
115
|
-
teacherInstructions: null
|
|
120
|
+
teacherInstructions: null,
|
|
121
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
116
122
|
});
|
|
117
123
|
});
|
|
118
124
|
|
|
@@ -125,7 +131,8 @@ describe('controller', () => {
|
|
|
125
131
|
imageUrl: question.imageUrl,
|
|
126
132
|
imageDimensions: question.imageDimensions,
|
|
127
133
|
prompt: question.prompt,
|
|
128
|
-
teacherInstructions: null
|
|
134
|
+
teacherInstructions: null,
|
|
135
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
129
136
|
});
|
|
130
137
|
});
|
|
131
138
|
|
|
@@ -138,7 +145,8 @@ describe('controller', () => {
|
|
|
138
145
|
imageUrl: question.imageUrl,
|
|
139
146
|
imageDimensions: question.imageDimensions,
|
|
140
147
|
prompt: question.prompt,
|
|
141
|
-
teacherInstructions: question.teacherInstructions
|
|
148
|
+
teacherInstructions: question.teacherInstructions,
|
|
149
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
142
150
|
});
|
|
143
151
|
});
|
|
144
152
|
|
|
@@ -154,7 +162,8 @@ describe('controller', () => {
|
|
|
154
162
|
imageUrl: question.imageUrl,
|
|
155
163
|
imageDimensions: question.imageDimensions,
|
|
156
164
|
prompt: question.prompt,
|
|
157
|
-
teacherInstructions: null
|
|
165
|
+
teacherInstructions: null,
|
|
166
|
+
backgroundImageEnabled: question.backgroundImageEnabled
|
|
158
167
|
});
|
|
159
168
|
});
|
|
160
169
|
});
|
package/controller/src/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export const normalize = question => ({
|
|
|
7
7
|
promptEnabled: true,
|
|
8
8
|
teacherInstructionsEnabled: true,
|
|
9
9
|
studentInstructionsEnabled: true,
|
|
10
|
+
backgroundImageEnabled: true,
|
|
10
11
|
...question,
|
|
11
12
|
});
|
|
12
13
|
|
|
@@ -16,7 +17,8 @@ export function model(question, session, env) {
|
|
|
16
17
|
imageUrl,
|
|
17
18
|
imageDimensions,
|
|
18
19
|
prompt,
|
|
19
|
-
promptEnabled
|
|
20
|
+
promptEnabled,
|
|
21
|
+
backgroundImageEnabled
|
|
20
22
|
} = normalizedQuestion;
|
|
21
23
|
|
|
22
24
|
return new Promise(resolve => {
|
|
@@ -26,6 +28,7 @@ export function model(question, session, env) {
|
|
|
26
28
|
imageDimensions,
|
|
27
29
|
imageUrl,
|
|
28
30
|
prompt: promptEnabled ? prompt : null,
|
|
31
|
+
backgroundImageEnabled
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
package/docs/config-schema.json
CHANGED
|
@@ -40,6 +40,22 @@
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
+
"spellCheck": {
|
|
44
|
+
"title": "ConfigureProp",
|
|
45
|
+
"type": "object",
|
|
46
|
+
"properties": {
|
|
47
|
+
"settings": {
|
|
48
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"title": "settings"
|
|
51
|
+
},
|
|
52
|
+
"label": {
|
|
53
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
54
|
+
"type": "string",
|
|
55
|
+
"title": "label"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
43
59
|
"studentInstructions": {
|
|
44
60
|
"title": "ConfigureProp",
|
|
45
61
|
"type": "object",
|
|
@@ -31,6 +31,18 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
31
31
|
|
|
32
32
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
33
33
|
|
|
34
|
+
# `spellCheck` (object)
|
|
35
|
+
|
|
36
|
+
Properties of the `spellCheck` object:
|
|
37
|
+
|
|
38
|
+
## `settings` (boolean)
|
|
39
|
+
|
|
40
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
41
|
+
|
|
42
|
+
## `label` (string)
|
|
43
|
+
|
|
44
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
45
|
+
|
|
34
46
|
# `studentInstructions` (object)
|
|
35
47
|
|
|
36
48
|
Properties of the `studentInstructions` object:
|