@pie-element/drawing-response 3.9.8 → 3.9.10-beta.1443
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 +381 -0
- package/configure/CHANGELOG.md +363 -0
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/defaults.js +21 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/image-container.js +37 -21
- package/configure/lib/image-container.js.map +1 -1
- package/configure/lib/index.js +64 -11
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +65 -30
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +4 -4
- package/configure/src/__tests__/__snapshots__/image-container.test.jsx.snap +3 -2
- package/configure/src/__tests__/__snapshots__/root.test.jsx.snap +34 -14
- package/configure/src/__tests__/image-container.test.jsx +42 -35
- package/configure/src/__tests__/index.test.js +7 -7
- package/configure/src/__tests__/root.test.jsx +18 -18
- package/configure/src/button.jsx +4 -4
- package/configure/src/defaults.js +24 -5
- package/configure/src/image-container.jsx +80 -59
- package/configure/src/index.js +46 -14
- package/configure/src/root.jsx +71 -63
- package/controller/CHANGELOG.md +20 -0
- package/controller/lib/defaults.js.map +1 -1
- 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 +29 -19
- package/controller/src/defaults.js +2 -2
- package/controller/src/index.js +13 -14
- package/docs/config-schema.json +126 -0
- package/docs/config-schema.json.md +97 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +4 -2
- package/docs/demo/session.js +4 -4
- package/docs/pie-schema.json +60 -0
- package/docs/pie-schema.json.md +44 -0
- package/lib/drawing-response/button.js.map +1 -1
- package/lib/drawing-response/constants.js.map +1 -1
- package/lib/drawing-response/container.js +73 -22
- package/lib/drawing-response/container.js.map +1 -1
- package/lib/drawing-response/drawable-image.js +1 -0
- package/lib/drawing-response/drawable-image.js.map +1 -1
- package/lib/drawing-response/drawable-main.js +45 -15
- package/lib/drawing-response/drawable-main.js.map +1 -1
- package/lib/drawing-response/drawable-palette.js +6 -1
- package/lib/drawing-response/drawable-palette.js.map +1 -1
- package/lib/drawing-response/drawable-text.js +15 -5
- package/lib/drawing-response/drawable-text.js.map +1 -1
- package/lib/drawing-response/drawable-transformer.js.map +1 -1
- package/lib/drawing-response/factory.js.map +1 -1
- package/lib/drawing-response/icon.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/__tests__/drawing-index-test.jsx +4 -4
- package/src/drawing-response/__tests__/__snapshots__/container.test.jsx.snap +174 -290
- package/src/drawing-response/__tests__/__snapshots__/drawing-main.test.jsx.snap +26 -2
- package/src/drawing-response/__tests__/container.test.jsx +9 -2
- package/src/drawing-response/__tests__/drawable-helper.test.jsx +1 -1
- package/src/drawing-response/__tests__/drawing-main.test.jsx +74 -86
- package/src/drawing-response/button.jsx +5 -8
- package/src/drawing-response/constants.js +42 -34
- package/src/drawing-response/container.jsx +93 -70
- package/src/drawing-response/drawable-image.jsx +5 -4
- package/src/drawing-response/drawable-main.jsx +46 -17
- package/src/drawing-response/drawable-palette.jsx +18 -35
- package/src/drawing-response/drawable-text.jsx +34 -48
- package/src/drawing-response/drawable-transformer.jsx +3 -1
- package/src/drawing-response/factory.js +3 -11
- package/src/drawing-response/icon.jsx +19 -20
- package/src/drawing-response/index.jsx +9 -15
- package/src/index.js +8 -11
package/configure/src/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
ModelUpdatedEvent,
|
|
3
3
|
DeleteImageEvent,
|
|
4
4
|
InsertImageEvent,
|
|
5
|
+
InsertSoundEvent,
|
|
6
|
+
DeleteSoundEvent,
|
|
5
7
|
} from '@pie-framework/pie-configure-events';
|
|
6
8
|
|
|
7
9
|
import React from 'react';
|
|
@@ -14,25 +16,45 @@ import sensibleDefaults from './defaults';
|
|
|
14
16
|
const log = debug('hotspot:configure');
|
|
15
17
|
|
|
16
18
|
export default class DrawableResponseConfigure extends HTMLElement {
|
|
17
|
-
static createDefaultModel = (model = {}) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
static createDefaultModel = (model = {}, config) => {
|
|
20
|
+
const defaultModel = {
|
|
21
|
+
...sensibleDefaults.model,
|
|
22
|
+
...model,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (config?.withRubric?.forceEnabled && !defaultModel.rubricEnabled) {
|
|
26
|
+
defaultModel.rubricEnabled = true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return defaultModel;
|
|
30
|
+
};
|
|
21
31
|
|
|
22
32
|
constructor() {
|
|
23
33
|
super();
|
|
24
|
-
this._model = DrawableResponseConfigure.createDefaultModel();
|
|
25
34
|
this._configuration = sensibleDefaults.configuration;
|
|
35
|
+
this._model = DrawableResponseConfigure.createDefaultModel({}, this._configuration);
|
|
26
36
|
this.onModelChanged = this.onModelChanged.bind(this);
|
|
27
37
|
}
|
|
28
38
|
|
|
39
|
+
verifyRubric = async (c) => {
|
|
40
|
+
const { withRubric = {} } = c || {};
|
|
41
|
+
|
|
42
|
+
if (withRubric?.forceEnabled && !this._model.rubricEnabled) {
|
|
43
|
+
this._model.rubricEnabled = true;
|
|
44
|
+
this.dispatchEvent(new ModelUpdatedEvent(this._model));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
29
48
|
set model(s) {
|
|
30
|
-
this._model = DrawableResponseConfigure.createDefaultModel(s);
|
|
49
|
+
this._model = DrawableResponseConfigure.createDefaultModel(s, this._configuration);
|
|
31
50
|
this._render();
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
set configuration(c) {
|
|
35
54
|
this._configuration = c;
|
|
55
|
+
|
|
56
|
+
this.verifyRubric(this._configuration);
|
|
57
|
+
|
|
36
58
|
this._render();
|
|
37
59
|
}
|
|
38
60
|
|
|
@@ -49,13 +71,10 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
49
71
|
};
|
|
50
72
|
|
|
51
73
|
onConfigurationChanged = (c) => {
|
|
52
|
-
if (!c.backgroundImage.enabled) {
|
|
53
|
-
this.onModelChanged({
|
|
54
|
-
...this._model,
|
|
55
|
-
imageUrl: ''
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
74
|
this._configuration = c;
|
|
75
|
+
|
|
76
|
+
this.verifyRubric(this._configuration);
|
|
77
|
+
|
|
59
78
|
this._render();
|
|
60
79
|
};
|
|
61
80
|
|
|
@@ -67,8 +86,17 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
67
86
|
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
68
87
|
};
|
|
69
88
|
|
|
89
|
+
insertSound(handler) {
|
|
90
|
+
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
onDeleteSound(src, done) {
|
|
94
|
+
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
95
|
+
}
|
|
96
|
+
|
|
70
97
|
_render() {
|
|
71
98
|
log('_render');
|
|
99
|
+
|
|
72
100
|
let element = React.createElement(Root, {
|
|
73
101
|
model: this._model,
|
|
74
102
|
configuration: this._configuration,
|
|
@@ -76,8 +104,12 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
76
104
|
onConfigurationChanged: this.onConfigurationChanged,
|
|
77
105
|
imageSupport: {
|
|
78
106
|
add: this.insertImage,
|
|
79
|
-
delete: this.onDeleteImage
|
|
80
|
-
}
|
|
107
|
+
delete: this.onDeleteImage,
|
|
108
|
+
},
|
|
109
|
+
uploadSoundSupport: {
|
|
110
|
+
add: this.insertSound.bind(this),
|
|
111
|
+
delete: this.onDeleteSound.bind(this),
|
|
112
|
+
},
|
|
81
113
|
});
|
|
82
114
|
ReactDOM.render(element, this);
|
|
83
115
|
}
|
package/configure/src/root.jsx
CHANGED
|
@@ -11,70 +11,74 @@ 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
|
-
onModelChanged({
|
|
19
|
-
...update,
|
|
20
|
-
prompt
|
|
21
|
-
});
|
|
18
|
+
onModelChanged({ ...update, prompt });
|
|
22
19
|
};
|
|
23
20
|
|
|
24
|
-
onTeacherInstructionsChanged = teacherInstructions => {
|
|
21
|
+
onTeacherInstructionsChanged = (teacherInstructions) => {
|
|
25
22
|
const { model, onModelChanged } = this.props;
|
|
26
23
|
|
|
27
|
-
onModelChanged({
|
|
28
|
-
...model,
|
|
29
|
-
teacherInstructions
|
|
30
|
-
});
|
|
24
|
+
onModelChanged({ ...model, teacherInstructions });
|
|
31
25
|
};
|
|
32
26
|
|
|
33
27
|
onUpdateImageDimension = (dimensions) => {
|
|
34
28
|
const { model, onModelChanged } = this.props;
|
|
35
29
|
|
|
36
|
-
onModelChanged({
|
|
37
|
-
...model,
|
|
38
|
-
imageDimensions: dimensions
|
|
39
|
-
});
|
|
30
|
+
onModelChanged({ ...model, imageDimensions: dimensions });
|
|
40
31
|
};
|
|
41
32
|
|
|
42
|
-
onImageUpload = imageUrl => {
|
|
33
|
+
onImageUpload = (imageUrl) => {
|
|
43
34
|
const { model, onModelChanged } = this.props;
|
|
44
35
|
|
|
45
|
-
onModelChanged({
|
|
46
|
-
...model,
|
|
47
|
-
imageUrl
|
|
48
|
-
});
|
|
36
|
+
onModelChanged({ ...model, imageUrl });
|
|
49
37
|
};
|
|
50
38
|
|
|
51
39
|
render() {
|
|
40
|
+
const { classes, configuration, imageSupport, model, onConfigurationChanged, onModelChanged, uploadSoundSupport } =
|
|
41
|
+
this.props;
|
|
52
42
|
const {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
43
|
+
backgroundImage = {},
|
|
44
|
+
maxImageWidth = {},
|
|
45
|
+
maxImageHeight = {},
|
|
46
|
+
prompt = {},
|
|
47
|
+
settingsPanelDisabled,
|
|
48
|
+
spellCheck = {},
|
|
49
|
+
teacherInstructions = {},
|
|
50
|
+
withRubric = {},
|
|
51
|
+
} = configuration || {};
|
|
52
|
+
const {
|
|
53
|
+
backgroundImageEnabled,
|
|
54
|
+
promptEnabled,
|
|
55
|
+
spellCheckEnabled,
|
|
56
|
+
teacherInstructionsEnabled,
|
|
57
|
+
toolbarEditorPosition,
|
|
58
|
+
} = model || {};
|
|
59
|
+
|
|
60
|
+
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
61
|
+
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
62
|
+
|
|
63
|
+
const toolbarOpts = {
|
|
64
|
+
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const panelSettings = {
|
|
68
|
+
backgroundImageEnabled: backgroundImage.settings && toggle(backgroundImage.label),
|
|
69
|
+
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const panelProperties = {
|
|
73
|
+
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
74
|
+
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
75
|
+
rubricEnabled: !withRubric?.forceEnabled && withRubric?.settings && toggle(withRubric?.label),
|
|
76
|
+
};
|
|
74
77
|
|
|
75
78
|
return (
|
|
76
79
|
<div className={classes.base}>
|
|
77
80
|
<layout.ConfigLayout
|
|
81
|
+
hideSettings={settingsPanelDisabled}
|
|
78
82
|
settings={
|
|
79
83
|
<Panel
|
|
80
84
|
model={model}
|
|
@@ -82,33 +86,26 @@ export class Root extends React.Component {
|
|
|
82
86
|
configuration={configuration}
|
|
83
87
|
onChangeConfiguration={onConfigurationChanged}
|
|
84
88
|
groups={{
|
|
85
|
-
Settings:
|
|
86
|
-
|
|
87
|
-
backgroundImage.settings &&
|
|
88
|
-
toggle(backgroundImage.label, true),
|
|
89
|
-
promptEnabled: prompt.settings && toggle(prompt.label)
|
|
90
|
-
},
|
|
91
|
-
Properties: {
|
|
92
|
-
teacherInstructionsEnabled:
|
|
93
|
-
teacherInstructions.settings &&
|
|
94
|
-
toggle(teacherInstructions.label)
|
|
95
|
-
}
|
|
89
|
+
Settings: panelSettings,
|
|
90
|
+
Properties: panelProperties,
|
|
96
91
|
}}
|
|
97
92
|
/>
|
|
98
93
|
}
|
|
99
94
|
>
|
|
100
95
|
<div className={classes.regular}>
|
|
101
96
|
{teacherInstructionsEnabled && (
|
|
102
|
-
<InputContainer
|
|
103
|
-
label={teacherInstructions.label}
|
|
104
|
-
className={classes.prompt}
|
|
105
|
-
>
|
|
97
|
+
<InputContainer label={teacherInstructions.label} className={classes.prompt}>
|
|
106
98
|
<EditableHtml
|
|
107
99
|
markup={model.teacherInstructions || ''}
|
|
108
100
|
onChange={this.onTeacherInstructionsChanged}
|
|
109
101
|
imageSupport={imageSupport}
|
|
110
102
|
nonEmpty={false}
|
|
111
103
|
toolbarOpts={toolbarOpts}
|
|
104
|
+
spellCheck={spellCheckEnabled}
|
|
105
|
+
maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}
|
|
106
|
+
maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}
|
|
107
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
108
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
112
109
|
/>
|
|
113
110
|
</InputContainer>
|
|
114
111
|
)}
|
|
@@ -119,11 +116,17 @@ export class Root extends React.Component {
|
|
|
119
116
|
markup={model.prompt}
|
|
120
117
|
onChange={this.onPromptChanged}
|
|
121
118
|
toolbarOpts={toolbarOpts}
|
|
119
|
+
spellCheck={spellCheckEnabled}
|
|
120
|
+
imageSupport={imageSupport}
|
|
121
|
+
maxImageWidth={defaultImageMaxWidth}
|
|
122
|
+
maxImageHeight={defaultImageMaxHeight}
|
|
123
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
124
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
122
125
|
/>
|
|
123
126
|
</InputContainer>
|
|
124
127
|
)}
|
|
125
128
|
|
|
126
|
-
{
|
|
129
|
+
{backgroundImageEnabled && (
|
|
127
130
|
<div>
|
|
128
131
|
<Typography className={classes.label} variant="subheading">
|
|
129
132
|
Define Background Image
|
|
@@ -133,6 +136,7 @@ export class Root extends React.Component {
|
|
|
133
136
|
imageUrl={model.imageUrl}
|
|
134
137
|
onUpdateImageDimension={this.onUpdateImageDimension}
|
|
135
138
|
onImageUpload={this.onImageUpload}
|
|
139
|
+
imageDimensions={model.imageDimensions}
|
|
136
140
|
/>
|
|
137
141
|
</div>
|
|
138
142
|
)}
|
|
@@ -143,20 +147,20 @@ export class Root extends React.Component {
|
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
const styles = theme => ({
|
|
150
|
+
const styles = (theme) => ({
|
|
147
151
|
base: {
|
|
148
|
-
marginTop: theme.spacing.unit * 3
|
|
152
|
+
marginTop: theme.spacing.unit * 3,
|
|
149
153
|
},
|
|
150
154
|
label: {
|
|
151
|
-
marginTop: theme.spacing.unit * 4
|
|
155
|
+
marginTop: theme.spacing.unit * 4,
|
|
152
156
|
},
|
|
153
157
|
prompt: {
|
|
154
158
|
paddingTop: theme.spacing.unit * 2,
|
|
155
|
-
width: '100%'
|
|
159
|
+
width: '100%',
|
|
156
160
|
},
|
|
157
161
|
regular: {
|
|
158
|
-
marginBottom: theme.spacing.unit * 3
|
|
159
|
-
}
|
|
162
|
+
marginBottom: theme.spacing.unit * 3,
|
|
163
|
+
},
|
|
160
164
|
});
|
|
161
165
|
|
|
162
166
|
Root.propTypes = {
|
|
@@ -165,7 +169,11 @@ Root.propTypes = {
|
|
|
165
169
|
model: PropTypes.object.isRequired,
|
|
166
170
|
imageSupport: PropTypes.shape({
|
|
167
171
|
add: PropTypes.func,
|
|
168
|
-
delete: PropTypes.func
|
|
172
|
+
delete: PropTypes.func,
|
|
173
|
+
}),
|
|
174
|
+
uploadSoundSupport: PropTypes.shape({
|
|
175
|
+
add: PropTypes.func,
|
|
176
|
+
delete: PropTypes.func,
|
|
169
177
|
}),
|
|
170
178
|
onModelChanged: PropTypes.func.isRequired,
|
|
171
179
|
onConfigurationChanged: PropTypes.func.isRequired,
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/drawing-response-controller@3.2.8...@pie-element/drawing-response-controller@3.2.9) (2022-12-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* PD-1642 toggle backgroundImageEnabled property instead of just config property, keep image link in model ([6661854](https://github.com/pie-framework/pie-elements/commit/6661854ab93f801d19b8cc8014f89ea8e5d83848))
|
|
12
|
+
* tests ([b196414](https://github.com/pie-framework/pie-elements/commit/b196414b2d019dfdbd8ea6bfc996b47c2f152cb0))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [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)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## [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
27
|
|
|
8
28
|
**Note:** Version bump only for package @pie-element/drawing-response-controller
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["prompt","imageUrl","imageDimensions","height","width"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,6BADK;AAEbC,EAAAA,QAAQ,EAAE,EAFG;AAGbC,EAAAA,eAAe,EAAE;AACfC,IAAAA,MAAM,EAAE,CADO;AAEfC,IAAAA,KAAK,EAAE;AAFQ;AAHJ,C","sourcesContent":["export default {\n prompt: 'This is the question prompt',\n imageUrl: '',\n imageDimensions: {\n height: 0,\n width: 0
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["prompt","imageUrl","imageDimensions","height","width"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,6BADK;AAEbC,EAAAA,QAAQ,EAAE,EAFG;AAGbC,EAAAA,eAAe,EAAE;AACfC,IAAAA,MAAM,EAAE,CADO;AAEfC,IAAAA,KAAK,EAAE;AAFQ;AAHJ,C","sourcesContent":["export default {\n prompt: 'This is the question prompt',\n imageUrl: '',\n imageDimensions: {\n height: 0,\n width: 0,\n },\n};\n"],"file":"defaults.js"}
|
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,CAACC,QAAD;AAAA;AACvBC,IAAAA,aAAa,EAAE,IADQ;AAEvBC,IAAAA,0BAA0B,EAAE,IAFL;AAGvBC,IAAAA,0BAA0B,EAAE,IAHL;AAIvBC,IAAAA,sBAAsB,EAAE;AAJD,KAKpBJ,QALoB;AAAA,CAAlB;;;;AAQA,SAASK,KAAT,CAAeL,QAAf,EAAyBM,OAAzB,EAAkCC,GAAlC,EAAuC;AAC5C,MAAMC,kBAAkB,GAAGT,SAAS,CAACC,QAAD,CAApC;AACA,MAAQS,QAAR,GAAqFD,kBAArF,CAAQC,QAAR;AAAA,MAAkBC,eAAlB,GAAqFF,kBAArF,CAAkBE,eAAlB;AAAA,MAAmCC,MAAnC,GAAqFH,kBAArF,CAAmCG,MAAnC;AAAA,MAA2CV,aAA3C,GAAqFO,kBAArF,CAA2CP,aAA3C;AAAA,MAA0DG,sBAA1D,GAAqFI,kBAArF,CAA0DJ,sBAA1D;AAEA,SAAO,IAAIQ,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9B,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,GACtBM,kBAAkB,CAACU,mBADG,GAEtB,IAFJ;AAGD,KAJD,MAIO;AACLJ,MAAAA,GAAG,CAACI,mBAAJ,GAA0B,IAA1B;AACD;;AAEDL,IAAAA,OAAO,CAACC,GAAD,CAAP;AACD,GAnBM,CAAP;AAoBD;;AAEM,IAAMK,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,MAACd,KAAD,uEAAS,EAAT;AAAA,SAChC,IAAIO,OAAJ,CAAY,UAACC,OAAD,EAAa;AACvBA,IAAAA,OAAO,iCACFO,oBADE,GAEFf,KAFE,EAAP;AAID,GALD,CADgC;AAAA,CAA3B;;;;AAQA;AAAiB;AAARgB,OAAT,GAAsC;AAC3C,SAAO,IAAIT,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9Bf,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 { imageUrl, imageDimensions, prompt, promptEnabled, backgroundImageEnabled } = 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\n ? normalizedQuestion.teacherInstructions\n : 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
|
@@ -10,9 +10,10 @@ describe('controller', () => {
|
|
|
10
10
|
imageUrl: '',
|
|
11
11
|
imageDimensions: {
|
|
12
12
|
height: 0,
|
|
13
|
-
width: 0
|
|
13
|
+
width: 0,
|
|
14
14
|
},
|
|
15
|
-
teacherInstructions: 'Teacher Instructions'
|
|
15
|
+
teacherInstructions: 'Teacher Instructions',
|
|
16
|
+
backgroundImageEnabled: true,
|
|
16
17
|
};
|
|
17
18
|
});
|
|
18
19
|
|
|
@@ -48,7 +49,7 @@ describe('controller', () => {
|
|
|
48
49
|
});
|
|
49
50
|
|
|
50
51
|
it('gather mode promptEnabled: true', async () => {
|
|
51
|
-
result = await model(question, {}, { mode: 'gather'});
|
|
52
|
+
result = await model(question, {}, { mode: 'gather' });
|
|
52
53
|
|
|
53
54
|
expect(result).toEqual({
|
|
54
55
|
disabled: false,
|
|
@@ -56,12 +57,13 @@ 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
|
|
|
63
65
|
it('gather mode promptEnabled: false', async () => {
|
|
64
|
-
result = await model({ ...question, promptEnabled: false }, {}, { mode: 'gather'});
|
|
66
|
+
result = await model({ ...question, promptEnabled: false }, {}, { mode: 'gather' });
|
|
65
67
|
|
|
66
68
|
expect(result).toEqual({
|
|
67
69
|
disabled: false,
|
|
@@ -69,13 +71,13 @@ 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
|
|
|
76
|
-
|
|
77
79
|
it('view mode, student role', async () => {
|
|
78
|
-
result = await model(question, {}, { mode: 'view'});
|
|
80
|
+
result = await model(question, {}, { mode: 'view' });
|
|
79
81
|
|
|
80
82
|
expect(result).toEqual({
|
|
81
83
|
disabled: true,
|
|
@@ -83,12 +85,13 @@ describe('controller', () => {
|
|
|
83
85
|
imageUrl: question.imageUrl,
|
|
84
86
|
imageDimensions: question.imageDimensions,
|
|
85
87
|
prompt: question.prompt,
|
|
86
|
-
teacherInstructions: null
|
|
88
|
+
teacherInstructions: null,
|
|
89
|
+
backgroundImageEnabled: question.backgroundImageEnabled,
|
|
87
90
|
});
|
|
88
91
|
});
|
|
89
92
|
|
|
90
93
|
it('view mode, instructor role and teacherInstructions enabled', async () => {
|
|
91
|
-
result = await model(question, {}, { mode: 'view', role: 'instructor'});
|
|
94
|
+
result = await model(question, {}, { mode: 'view', role: 'instructor' });
|
|
92
95
|
|
|
93
96
|
expect(result).toEqual({
|
|
94
97
|
disabled: true,
|
|
@@ -96,7 +99,8 @@ describe('controller', () => {
|
|
|
96
99
|
imageUrl: question.imageUrl,
|
|
97
100
|
imageDimensions: question.imageDimensions,
|
|
98
101
|
prompt: question.prompt,
|
|
99
|
-
teacherInstructions: question.teacherInstructions
|
|
102
|
+
teacherInstructions: question.teacherInstructions,
|
|
103
|
+
backgroundImageEnabled: question.backgroundImageEnabled,
|
|
100
104
|
});
|
|
101
105
|
});
|
|
102
106
|
|
|
@@ -104,7 +108,8 @@ describe('controller', () => {
|
|
|
104
108
|
result = await model(
|
|
105
109
|
{ ...question, teacherInstructionsEnabled: false },
|
|
106
110
|
{},
|
|
107
|
-
{ mode: 'evaluate', role: 'instructor'}
|
|
111
|
+
{ mode: 'evaluate', role: 'instructor' },
|
|
112
|
+
);
|
|
108
113
|
|
|
109
114
|
expect(result).toEqual({
|
|
110
115
|
disabled: true,
|
|
@@ -112,12 +117,13 @@ 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
|
|
|
119
125
|
it('evaluate mode, student role', async () => {
|
|
120
|
-
result = await model(question, {}, { mode: 'evaluate'});
|
|
126
|
+
result = await model(question, {}, { mode: 'evaluate' });
|
|
121
127
|
|
|
122
128
|
expect(result).toEqual({
|
|
123
129
|
disabled: true,
|
|
@@ -125,12 +131,13 @@ 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
|
|
|
132
139
|
it('evaluate mode, instructor role and teacherInstructions enabled', async () => {
|
|
133
|
-
result = await model(question, {}, { mode: 'evaluate', role: 'instructor'});
|
|
140
|
+
result = await model(question, {}, { mode: 'evaluate', role: 'instructor' });
|
|
134
141
|
|
|
135
142
|
expect(result).toEqual({
|
|
136
143
|
disabled: true,
|
|
@@ -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
|
|
|
@@ -146,7 +154,8 @@ describe('controller', () => {
|
|
|
146
154
|
result = await model(
|
|
147
155
|
{ ...question, teacherInstructionsEnabled: false },
|
|
148
156
|
{},
|
|
149
|
-
{ mode: 'view', role: 'instructor'}
|
|
157
|
+
{ mode: 'view', role: 'instructor' },
|
|
158
|
+
);
|
|
150
159
|
|
|
151
160
|
expect(result).toEqual({
|
|
152
161
|
disabled: true,
|
|
@@ -154,7 +163,8 @@ describe('controller', () => {
|
|
|
154
163
|
imageUrl: question.imageUrl,
|
|
155
164
|
imageDimensions: question.imageDimensions,
|
|
156
165
|
prompt: question.prompt,
|
|
157
|
-
teacherInstructions: null
|
|
166
|
+
teacherInstructions: null,
|
|
167
|
+
backgroundImageEnabled: question.backgroundImageEnabled,
|
|
158
168
|
});
|
|
159
169
|
});
|
|
160
170
|
});
|