@pie-element/hotspot 4.10.10 → 4.10.11-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 +349 -0
- package/configure/CHANGELOG.md +311 -0
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/defaults.js +23 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/hotspot-container.js +28 -19
- package/configure/lib/hotspot-container.js.map +1 -1
- package/configure/lib/hotspot-drawable.js +3 -3
- package/configure/lib/hotspot-drawable.js.map +1 -1
- package/configure/lib/hotspot-palette.js.map +1 -1
- package/configure/lib/hotspot-polygon.js.map +1 -1
- package/configure/lib/hotspot-rectangle.js.map +1 -1
- package/configure/lib/index.js +16 -2
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +129 -38
- package/configure/lib/root.js.map +1 -1
- package/configure/lib/upload-control.js.map +1 -1
- package/configure/lib/utils.js +15 -3
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +4 -4
- package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +1 -1
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +56 -4
- package/configure/src/__tests__/hotspot-container.test.js +98 -71
- package/configure/src/__tests__/hotspot-drawable.test.js +48 -49
- package/configure/src/__tests__/index.test.js +28 -51
- package/configure/src/__tests__/root.test.js +162 -82
- package/configure/src/__tests__/utils.test.js +112 -98
- package/configure/src/button.jsx +4 -4
- package/configure/src/defaults.js +35 -18
- package/configure/src/hotspot-container.jsx +99 -98
- package/configure/src/hotspot-drawable.jsx +56 -56
- package/configure/src/hotspot-palette.jsx +12 -25
- package/configure/src/hotspot-polygon.jsx +20 -22
- package/configure/src/hotspot-rectangle.jsx +5 -15
- package/configure/src/index.js +32 -18
- package/configure/src/root.jsx +116 -60
- package/configure/src/upload-control.jsx +9 -20
- package/configure/src/utils.js +51 -22
- package/controller/CHANGELOG.md +23 -0
- package/controller/lib/defaults.js +2 -2
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +39 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +2 -2
- package/controller/src/__tests__/index.test.js +29 -50
- package/controller/src/defaults.js +5 -9
- package/controller/src/index.js +47 -33
- package/controller/src/utils.js +9 -6
- package/docs/config-schema.json +217 -0
- package/docs/config-schema.json.md +169 -0
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +53 -35
- package/docs/demo/session.js +2 -2
- package/docs/pie-schema.json +49 -0
- package/docs/pie-schema.json.md +36 -0
- package/lib/hotspot/container.js +24 -6
- package/lib/hotspot/container.js.map +1 -1
- package/lib/hotspot/icons.js.map +1 -1
- package/lib/hotspot/image.js.map +1 -1
- package/lib/hotspot/index.js +65 -5
- package/lib/hotspot/index.js.map +1 -1
- package/lib/hotspot/polygon.js +45 -19
- package/lib/hotspot/polygon.js.map +1 -1
- package/lib/hotspot/rectangle.js +45 -19
- package/lib/hotspot/rectangle.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/session-updater.js.map +1 -1
- package/package.json +6 -4
- package/src/__tests__/__snapshots__/{container-test.jsx.snap → container.test.jsx.snap} +8 -0
- package/src/__tests__/__snapshots__/image.test.jsx.snap +43 -0
- package/src/__tests__/__snapshots__/{polygon-test.jsx.snap → polygon.test.jsx.snap} +11 -0
- package/src/__tests__/__snapshots__/{rectangle-test.jsx.snap → rectangle.test.jsx.snap} +11 -0
- package/src/__tests__/container.test.jsx +214 -0
- package/src/__tests__/{image-test.jsx → image.test.jsx} +2 -2
- package/src/__tests__/polygon.test.jsx +235 -0
- package/src/__tests__/rectangle.test.jsx +237 -0
- package/src/__tests__/{session-updater-test.jsx → session-updater.test.jsx} +22 -31
- package/src/hotspot/container.jsx +40 -23
- package/src/hotspot/icons.js +4 -2
- package/src/hotspot/image.jsx +4 -8
- package/src/hotspot/index.jsx +73 -33
- package/src/hotspot/polygon.jsx +48 -30
- package/src/hotspot/rectangle.jsx +48 -30
- package/src/index.js +10 -18
- package/src/session-updater.js +1 -1
- package/src/__tests__/__snapshots__/image-test.jsx.snap +0 -21
- package/src/__tests__/container-test.jsx +0 -143
- package/src/__tests__/polygon-test.jsx +0 -77
- package/src/__tests__/rectangle-test.jsx +0 -78
package/src/hotspot/polygon.jsx
CHANGED
|
@@ -14,10 +14,10 @@ class PolygonComponent extends React.Component {
|
|
|
14
14
|
getPolygonCenter = (points) => {
|
|
15
15
|
const x = points.map(({ x }) => x);
|
|
16
16
|
const y = points.map(({ y }) => y);
|
|
17
|
-
const minX = Math.min.apply
|
|
18
|
-
const maxX = Math.max.apply
|
|
19
|
-
const minY = Math.min.apply
|
|
20
|
-
const maxY = Math.max.apply
|
|
17
|
+
const minX = Math.min.apply(null, x);
|
|
18
|
+
const maxX = Math.max.apply(null, x);
|
|
19
|
+
const minY = Math.min.apply(null, y);
|
|
20
|
+
const maxY = Math.max.apply(null, y);
|
|
21
21
|
return [(minX + maxX) / 2, (minY + maxY) / 2];
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -51,9 +51,11 @@ class PolygonComponent extends React.Component {
|
|
|
51
51
|
document.body.style.cursor = 'default';
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
getEvaluateOutlineColor = (isCorrect, outlineColor) =>
|
|
54
|
+
getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>
|
|
55
|
+
markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';
|
|
55
56
|
|
|
56
|
-
getOutlineWidth = (selected, strokeWidth) =>
|
|
57
|
+
getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>
|
|
58
|
+
markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;
|
|
57
59
|
|
|
58
60
|
render() {
|
|
59
61
|
const {
|
|
@@ -65,37 +67,56 @@ class PolygonComponent extends React.Component {
|
|
|
65
67
|
selected,
|
|
66
68
|
points,
|
|
67
69
|
evaluateText,
|
|
68
|
-
strokeWidth
|
|
70
|
+
strokeWidth,
|
|
71
|
+
scale,
|
|
72
|
+
markAsCorrect,
|
|
73
|
+
showCorrectEnabled,
|
|
69
74
|
} = this.props;
|
|
70
75
|
|
|
71
76
|
const outlineColorParsed = isEvaluateMode
|
|
72
|
-
? this.getEvaluateOutlineColor(isCorrect, outlineColor)
|
|
77
|
+
? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)
|
|
73
78
|
: outlineColor;
|
|
74
|
-
const outlineWidth = this.getOutlineWidth(selected, strokeWidth);
|
|
79
|
+
const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);
|
|
75
80
|
|
|
76
81
|
const pointsParsed = this.parsePointsForKonva(points);
|
|
77
82
|
const center = this.getPolygonCenter(points);
|
|
78
83
|
const iconX = center[0];
|
|
79
84
|
const iconY = center[1];
|
|
80
85
|
|
|
81
|
-
//
|
|
82
|
-
// Correctly
|
|
83
|
-
//
|
|
84
|
-
// Incorrectly
|
|
86
|
+
// "Show Correct Answer" Enabled:
|
|
87
|
+
// - Correctly Selected: white checkmark in green circle
|
|
88
|
+
// - Correctly Not Selected: none
|
|
89
|
+
// - Incorrectly Selected: none
|
|
90
|
+
// - Incorrectly Not Selected: white checkmark in green circle
|
|
91
|
+
// "Show Correct Answer" Disabled:
|
|
92
|
+
// - Correctly Selected:
|
|
93
|
+
// - white checkmark in green circle
|
|
94
|
+
// - heavy outline, as on “Gather”
|
|
95
|
+
// - Correctly Not Selected: none
|
|
96
|
+
// - Incorrectly Selected:
|
|
97
|
+
// - white "X" in red circle
|
|
98
|
+
// - heavy outline around the selection should appear in red
|
|
99
|
+
// - Incorrectly Not Selected: white "X" in red circle
|
|
85
100
|
let iconSrc;
|
|
86
101
|
|
|
87
|
-
if (
|
|
88
|
-
if (isCorrect) {
|
|
102
|
+
if (showCorrectEnabled) {
|
|
103
|
+
if ((selected && isCorrect) || (!selected && !isCorrect)) {
|
|
89
104
|
iconSrc = faCorrect;
|
|
90
|
-
}
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
if (selected) {
|
|
108
|
+
if (isCorrect) {
|
|
109
|
+
iconSrc = faCorrect;
|
|
110
|
+
} else {
|
|
111
|
+
iconSrc = faWrong;
|
|
112
|
+
}
|
|
113
|
+
} else if (!isCorrect) {
|
|
91
114
|
iconSrc = faWrong;
|
|
92
115
|
}
|
|
93
|
-
} else if (!isCorrect) {
|
|
94
|
-
iconSrc = faWrong;
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
return (
|
|
98
|
-
<Group>
|
|
119
|
+
<Group scaleX={scale} scaleY={scale}>
|
|
99
120
|
<Line
|
|
100
121
|
points={pointsParsed}
|
|
101
122
|
closed={true}
|
|
@@ -109,14 +130,7 @@ class PolygonComponent extends React.Component {
|
|
|
109
130
|
onMouseLeave={this.handleMouseLeave}
|
|
110
131
|
onMouseEnter={this.handleMouseEnter}
|
|
111
132
|
/>
|
|
112
|
-
{
|
|
113
|
-
<Image
|
|
114
|
-
src={iconSrc}
|
|
115
|
-
x={iconX}
|
|
116
|
-
y={iconY}
|
|
117
|
-
tooltip={evaluateText}
|
|
118
|
-
/>
|
|
119
|
-
): null}
|
|
133
|
+
{isEvaluateMode && iconSrc ? <Image src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}
|
|
120
134
|
</Group>
|
|
121
135
|
);
|
|
122
136
|
}
|
|
@@ -126,7 +140,7 @@ const styles = () => ({
|
|
|
126
140
|
base: {
|
|
127
141
|
cursor: 'pointer',
|
|
128
142
|
opacity: 0.5,
|
|
129
|
-
position: 'relative'
|
|
143
|
+
position: 'relative',
|
|
130
144
|
},
|
|
131
145
|
});
|
|
132
146
|
|
|
@@ -142,12 +156,16 @@ PolygonComponent.propTypes = {
|
|
|
142
156
|
points: PropTypes.array.isRequired,
|
|
143
157
|
selected: PropTypes.bool.isRequired,
|
|
144
158
|
evaluateText: PropTypes.string,
|
|
145
|
-
strokeWidth: PropTypes.number
|
|
159
|
+
strokeWidth: PropTypes.number,
|
|
160
|
+
scale: PropTypes.number,
|
|
161
|
+
markAsCorrect: PropTypes.bool.isRequired,
|
|
162
|
+
showCorrectEnabled: PropTypes.bool.isRequired,
|
|
146
163
|
};
|
|
147
164
|
|
|
148
165
|
PolygonComponent.defaultProps = {
|
|
149
166
|
evaluateText: null,
|
|
150
|
-
strokeWidth: 5
|
|
167
|
+
strokeWidth: 5,
|
|
168
|
+
scale: 1,
|
|
151
169
|
};
|
|
152
170
|
|
|
153
171
|
export default withStyles(styles)(PolygonComponent);
|
|
@@ -32,9 +32,11 @@ class RectComponent extends React.Component {
|
|
|
32
32
|
document.body.style.cursor = 'default';
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
getEvaluateOutlineColor = (isCorrect, outlineColor) =>
|
|
35
|
+
getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>
|
|
36
|
+
markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';
|
|
36
37
|
|
|
37
|
-
getOutlineWidth = (selected, strokeWidth) =>
|
|
38
|
+
getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>
|
|
39
|
+
markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;
|
|
38
40
|
|
|
39
41
|
render() {
|
|
40
42
|
const {
|
|
@@ -49,36 +51,55 @@ class RectComponent extends React.Component {
|
|
|
49
51
|
x,
|
|
50
52
|
y,
|
|
51
53
|
evaluateText,
|
|
52
|
-
strokeWidth
|
|
54
|
+
strokeWidth,
|
|
55
|
+
scale,
|
|
56
|
+
markAsCorrect,
|
|
57
|
+
showCorrectEnabled,
|
|
53
58
|
} = this.props;
|
|
54
59
|
|
|
55
60
|
const outlineColorParsed = isEvaluateMode
|
|
56
|
-
? this.getEvaluateOutlineColor(isCorrect, outlineColor)
|
|
61
|
+
? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)
|
|
57
62
|
: outlineColor;
|
|
58
63
|
|
|
59
|
-
const outlineWidth = this.getOutlineWidth(selected, strokeWidth);
|
|
60
|
-
|
|
61
|
-
const iconX =
|
|
62
|
-
const iconY =
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
// Correctly
|
|
66
|
-
//
|
|
67
|
-
// Incorrectly
|
|
64
|
+
const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);
|
|
65
|
+
|
|
66
|
+
const iconX = x + width / 2 - 10;
|
|
67
|
+
const iconY = y + height / 2 - 10;
|
|
68
|
+
|
|
69
|
+
// "Show Correct Answer" Enabled:
|
|
70
|
+
// - Correctly Selected: white checkmark in green circle
|
|
71
|
+
// - Correctly Not Selected: none
|
|
72
|
+
// - Incorrectly Selected: none
|
|
73
|
+
// - Incorrectly Not Selected: white checkmark in green circle
|
|
74
|
+
// "Show Correct Answer" Disabled:
|
|
75
|
+
// - Correctly Selected:
|
|
76
|
+
// - white checkmark in green circle
|
|
77
|
+
// - heavy outline, as on “Gather”
|
|
78
|
+
// - Correctly Not Selected: none
|
|
79
|
+
// - Incorrectly Selected:
|
|
80
|
+
// - white "X" in red circle
|
|
81
|
+
// - heavy outline around the selection should appear in red
|
|
82
|
+
// - Incorrectly Not Selected: white "X" in red circle
|
|
68
83
|
let iconSrc;
|
|
69
84
|
|
|
70
|
-
if (
|
|
71
|
-
if (isCorrect) {
|
|
85
|
+
if (showCorrectEnabled) {
|
|
86
|
+
if ((selected && isCorrect) || (!selected && !isCorrect)) {
|
|
72
87
|
iconSrc = faCorrect;
|
|
73
|
-
}
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
if (selected) {
|
|
91
|
+
if (isCorrect) {
|
|
92
|
+
iconSrc = faCorrect;
|
|
93
|
+
} else {
|
|
94
|
+
iconSrc = faWrong;
|
|
95
|
+
}
|
|
96
|
+
} else if (!isCorrect) {
|
|
74
97
|
iconSrc = faWrong;
|
|
75
98
|
}
|
|
76
|
-
} else if (!isCorrect) {
|
|
77
|
-
iconSrc = faWrong;
|
|
78
99
|
}
|
|
79
100
|
|
|
80
101
|
return (
|
|
81
|
-
<Group>
|
|
102
|
+
<Group scaleX={scale} scaleY={scale}>
|
|
82
103
|
<Rect
|
|
83
104
|
classes={classes.base}
|
|
84
105
|
width={width}
|
|
@@ -94,14 +115,7 @@ class RectComponent extends React.Component {
|
|
|
94
115
|
x={x}
|
|
95
116
|
y={y}
|
|
96
117
|
/>
|
|
97
|
-
{
|
|
98
|
-
<Image
|
|
99
|
-
src={iconSrc}
|
|
100
|
-
x={iconX}
|
|
101
|
-
y={iconY}
|
|
102
|
-
tooltip={evaluateText}
|
|
103
|
-
/>
|
|
104
|
-
): null}
|
|
118
|
+
{isEvaluateMode && iconSrc ? <Image src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}
|
|
105
119
|
</Group>
|
|
106
120
|
);
|
|
107
121
|
}
|
|
@@ -111,7 +125,7 @@ const styles = () => ({
|
|
|
111
125
|
base: {
|
|
112
126
|
cursor: 'pointer',
|
|
113
127
|
opacity: 0.5,
|
|
114
|
-
position: 'relative'
|
|
128
|
+
position: 'relative',
|
|
115
129
|
},
|
|
116
130
|
});
|
|
117
131
|
|
|
@@ -130,13 +144,17 @@ RectComponent.propTypes = {
|
|
|
130
144
|
x: PropTypes.number.isRequired,
|
|
131
145
|
y: PropTypes.number.isRequired,
|
|
132
146
|
evaluateText: PropTypes.string,
|
|
133
|
-
strokeWidth: PropTypes.number
|
|
147
|
+
strokeWidth: PropTypes.number,
|
|
148
|
+
scale: PropTypes.number,
|
|
149
|
+
markAsCorrect: PropTypes.bool.isRequired,
|
|
150
|
+
showCorrectEnabled: PropTypes.bool.isRequired,
|
|
134
151
|
};
|
|
135
152
|
|
|
136
153
|
RectComponent.defaultProps = {
|
|
137
154
|
isCorrect: false,
|
|
138
155
|
evaluateText: null,
|
|
139
|
-
strokeWidth: 5
|
|
156
|
+
strokeWidth: 5,
|
|
157
|
+
scale: 1,
|
|
140
158
|
};
|
|
141
159
|
|
|
142
160
|
export default withStyles(styles)(RectComponent);
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
4
|
-
import {
|
|
5
|
-
SessionChangedEvent,
|
|
6
|
-
ModelSetEvent
|
|
7
|
-
} from '@pie-framework/pie-player-events';
|
|
4
|
+
import { SessionChangedEvent, ModelSetEvent } from '@pie-framework/pie-player-events';
|
|
8
5
|
|
|
9
6
|
import HotspotComponent from './hotspot';
|
|
10
7
|
import { updateSessionValue } from './session-updater';
|
|
@@ -13,13 +10,7 @@ export default class Hotspot extends HTMLElement {
|
|
|
13
10
|
set model(m) {
|
|
14
11
|
this._model = m;
|
|
15
12
|
|
|
16
|
-
this.dispatchEvent(
|
|
17
|
-
new ModelSetEvent(
|
|
18
|
-
this.tagName.toLowerCase(),
|
|
19
|
-
this.isComplete(),
|
|
20
|
-
!!this._model
|
|
21
|
-
)
|
|
22
|
-
);
|
|
13
|
+
this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
|
|
23
14
|
this._render();
|
|
24
15
|
}
|
|
25
16
|
|
|
@@ -28,9 +19,7 @@ export default class Hotspot extends HTMLElement {
|
|
|
28
19
|
return false;
|
|
29
20
|
}
|
|
30
21
|
|
|
31
|
-
return (
|
|
32
|
-
Array.isArray(this._session.answers) && this._session.answers.length > 0
|
|
33
|
-
);
|
|
22
|
+
return Array.isArray(this._session.answers) && this._session.answers.length > 0;
|
|
34
23
|
}
|
|
35
24
|
|
|
36
25
|
set session(s) {
|
|
@@ -42,12 +31,14 @@ export default class Hotspot extends HTMLElement {
|
|
|
42
31
|
this._render();
|
|
43
32
|
}
|
|
44
33
|
|
|
34
|
+
get session() {
|
|
35
|
+
return this._session;
|
|
36
|
+
}
|
|
37
|
+
|
|
45
38
|
onSelectChoice(data) {
|
|
46
39
|
updateSessionValue(this._session, this._model, data);
|
|
47
40
|
|
|
48
|
-
this.dispatchEvent(
|
|
49
|
-
new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete())
|
|
50
|
-
);
|
|
41
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
51
42
|
|
|
52
43
|
this._render();
|
|
53
44
|
}
|
|
@@ -61,8 +52,9 @@ export default class Hotspot extends HTMLElement {
|
|
|
61
52
|
const el = React.createElement(HotspotComponent, {
|
|
62
53
|
model: this._model,
|
|
63
54
|
session: this._session,
|
|
64
|
-
onSelectChoice: this.onSelectChoice.bind(this)
|
|
55
|
+
onSelectChoice: this.onSelectChoice.bind(this),
|
|
65
56
|
});
|
|
57
|
+
|
|
66
58
|
ReactDOM.render(el, this, () => {
|
|
67
59
|
renderMath(this);
|
|
68
60
|
});
|
package/src/session-updater.js
CHANGED
|
@@ -4,7 +4,7 @@ export function updateSessionValue(session, model, data) {
|
|
|
4
4
|
session.answers = session.answers || [];
|
|
5
5
|
|
|
6
6
|
if (!selected) {
|
|
7
|
-
session.answers = session.answers.filter(answer => answer.id !== id);
|
|
7
|
+
session.answers = session.answers.filter((answer) => answer.id !== id);
|
|
8
8
|
} else {
|
|
9
9
|
const item = { id };
|
|
10
10
|
if (multipleCorrect) {
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Image snapshots image renders 1`] = `
|
|
4
|
-
<Image
|
|
5
|
-
height={20}
|
|
6
|
-
image={null}
|
|
7
|
-
width={20}
|
|
8
|
-
x={5}
|
|
9
|
-
y={5}
|
|
10
|
-
/>
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
exports[`Image snapshots x y position renders 1`] = `
|
|
14
|
-
<Image
|
|
15
|
-
height={20}
|
|
16
|
-
image={null}
|
|
17
|
-
width={20}
|
|
18
|
-
x={10}
|
|
19
|
-
y={10}
|
|
20
|
-
/>
|
|
21
|
-
`;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { shallow } from 'enzyme';
|
|
4
|
-
import toJson from 'enzyme-to-json';
|
|
5
|
-
import Konva from 'konva';
|
|
6
|
-
|
|
7
|
-
import Container, { Container as ContainerComp } from '../hotspot/container';
|
|
8
|
-
import HotspotComponent from '../hotspot/index';
|
|
9
|
-
|
|
10
|
-
Konva.isBrowser = false;
|
|
11
|
-
|
|
12
|
-
describe('HotspotComponent', () => {
|
|
13
|
-
describe('renders', () => {
|
|
14
|
-
let wrapper;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
wrapper = props => shallow(<HotspotComponent {...props} />);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('snapshot', () => {
|
|
21
|
-
let w = wrapper();
|
|
22
|
-
|
|
23
|
-
expect(w).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('snapshot with rationale', () => {
|
|
27
|
-
let w = wrapper({ rationale: 'This is rationale' });
|
|
28
|
-
|
|
29
|
-
expect(w).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('snapshot with padding having a size accordingly to strokeWidth', () => {
|
|
33
|
-
let w = shallow(<ContainerComp
|
|
34
|
-
strokeWidth={50}
|
|
35
|
-
classes={{}}
|
|
36
|
-
dimensions={{ width: 100, height: 100 }}
|
|
37
|
-
onSelectChoice={jest.fn()}
|
|
38
|
-
disabled={false}
|
|
39
|
-
hotspotColor='#000'
|
|
40
|
-
outlineColor='#FAFAFA'
|
|
41
|
-
imageUrl='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw8PEA8PDw8PDxAPDg8PDw0PDw8PDw8QFREWFhURFRUYHSggGBomHRUVITEhJSkrLi4uFx8zODMsNyg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e0G9s9dpU5HWY0vNJ3CqLTnkzGZmZ3Iy2SqzWSirMD2WZ5zcmYALTKAhmSFMygUvMoSWS5pthjLHaZshioJlQhMCZgEGQHMIbMIIMgeEEGA2YDKYFgkFiiQWrIyOIBkF1LgcHoes8/Pjtjt82n6qFle36HoZ14c1ckbg0WbgBKF1FIdSp7iY2jcES88+gIdaz0J6zVXvZZl000wexKV+VeT7zKI68kVa7S9fUorT7T1u1YYw8/q3LMSZw3nctlfDO0wVS5l0M9hlVlsmQqgew3TztNmwLRo2GZkm0MqkYzKBnsabIRktaZwksdhmyGKomVCEwJmBMwCDIhgYDqZENmEEGA8BlgXLMVWCQWCRRzCjmAwMgsW3HDcj+08/Lhtit14wWTHI5HrOvDnrkj7hBN4dRyMQirxbSYCv6GcmaJrO1N4NQAd3Uzp4Vf45a7T6O3faMYno2tDCXB1NmWPpOSzZTwzM0xZqXMqqHMooslFcaH/2Q=='
|
|
42
|
-
isEvaluateMode={false}
|
|
43
|
-
session={{ answers: [{ id: '1' }, { id: '2' }] }}
|
|
44
|
-
shapes={{
|
|
45
|
-
rectangles: [
|
|
46
|
-
{
|
|
47
|
-
id: '1',
|
|
48
|
-
correct: true,
|
|
49
|
-
x: 0,
|
|
50
|
-
y: 0,
|
|
51
|
-
width: 80,
|
|
52
|
-
height: 80
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
polygons: []
|
|
56
|
-
}}
|
|
57
|
-
/>);
|
|
58
|
-
|
|
59
|
-
expect(w).toMatchSnapshot();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('Container', () => {
|
|
65
|
-
let onSelectChoice, wrapper;
|
|
66
|
-
|
|
67
|
-
const mkWrapper = (opts = {}) => {
|
|
68
|
-
opts = _.extend(
|
|
69
|
-
{
|
|
70
|
-
classes: {
|
|
71
|
-
base: 'base'
|
|
72
|
-
},
|
|
73
|
-
dimensions: {
|
|
74
|
-
height: 0,
|
|
75
|
-
width: 0
|
|
76
|
-
},
|
|
77
|
-
disabled: false,
|
|
78
|
-
hotspotColor: 'rgba(137, 183, 244, 0.65)',
|
|
79
|
-
imageUrl: '',
|
|
80
|
-
isEvaluateMode: false,
|
|
81
|
-
outlineColor: 'blue',
|
|
82
|
-
session: { answers: [] },
|
|
83
|
-
shapes: {
|
|
84
|
-
rectangles: [],
|
|
85
|
-
polygons: []
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
opts
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
return shallow(<Container {...opts} onSelectChoice={onSelectChoice}/>);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
beforeEach(() => {
|
|
95
|
-
onSelectChoice = jest.fn();
|
|
96
|
-
wrapper = mkWrapper();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('snapshots', () => {
|
|
100
|
-
describe('outline color', () => {
|
|
101
|
-
it('renders', () => {
|
|
102
|
-
const wrapper = mkWrapper({ outlineColor: 'red' });
|
|
103
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
describe('hotspot color', () => {
|
|
108
|
-
it('renders', () => {
|
|
109
|
-
const wrapper = mkWrapper({ hotspotColor: 'rgba(217, 30, 24, 0.65)' });
|
|
110
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe('image', () => {
|
|
115
|
-
it('renders', () => {
|
|
116
|
-
const wrapper = mkWrapper({ imageUrl: 'https://picsum.photos/id/102/200/300' });
|
|
117
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('shapes', () => {
|
|
122
|
-
it('renders', () => {
|
|
123
|
-
const wrapper = mkWrapper({
|
|
124
|
-
shapes: {
|
|
125
|
-
rectangles: [
|
|
126
|
-
{ id: '1', x: 5, y: 5, width: 5, height: 5 },
|
|
127
|
-
{ id: '2', x: 25, y: 25, width: 5, height: 5 }
|
|
128
|
-
],
|
|
129
|
-
polygons: [
|
|
130
|
-
{ id: '3', points: [{ x: 94, y: 4 }, { x: 89, y: 4 }, { x: 36, y: 40 }] }
|
|
131
|
-
]
|
|
132
|
-
},
|
|
133
|
-
imageUrl: 'https://picsum.photos/id/102/200/300',
|
|
134
|
-
dimensions: {
|
|
135
|
-
width: 200,
|
|
136
|
-
height: 300
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { shallow } from 'enzyme';
|
|
4
|
-
import toJson from 'enzyme-to-json';
|
|
5
|
-
import Konva from 'konva';
|
|
6
|
-
|
|
7
|
-
import Polygon from '../hotspot/polygon';
|
|
8
|
-
|
|
9
|
-
Konva.isBrowser = false;
|
|
10
|
-
|
|
11
|
-
describe('Polygon', () => {
|
|
12
|
-
let onClick, wrapper;
|
|
13
|
-
|
|
14
|
-
const mkWrapper = (opts = {}) => {
|
|
15
|
-
opts = _.extend(
|
|
16
|
-
{
|
|
17
|
-
classes: {
|
|
18
|
-
base: 'base'
|
|
19
|
-
},
|
|
20
|
-
height: 200,
|
|
21
|
-
hotspotColor: 'rgba(137, 183, 244, 0.65)',
|
|
22
|
-
id: '1',
|
|
23
|
-
isCorrect: false,
|
|
24
|
-
isEvaluateMode: false,
|
|
25
|
-
evaluateText: null,
|
|
26
|
-
disabled: false,
|
|
27
|
-
outlineColor: 'blue',
|
|
28
|
-
selected: false,
|
|
29
|
-
points: [{ x: 94, y: 4 }, { x: 89, y: 4 }, { x: 36, y: 40 }]
|
|
30
|
-
},
|
|
31
|
-
opts
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return shallow(<Polygon {...opts} onClick={onClick} />);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
onClick = jest.fn();
|
|
39
|
-
wrapper = mkWrapper();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('snapshots', () => {
|
|
43
|
-
describe('outline color', () => {
|
|
44
|
-
it('renders', () => {
|
|
45
|
-
const wrapper = mkWrapper({ outlineColor: 'red' });
|
|
46
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('outline width', () => {
|
|
51
|
-
it('renders with default border width', () => {
|
|
52
|
-
const wrapper = mkWrapper();
|
|
53
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('renders with given border width', () => {
|
|
57
|
-
const wrapper = mkWrapper({ strokeWidth: 10 });
|
|
58
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
describe('hotspot color', () => {
|
|
64
|
-
it('renders', () => {
|
|
65
|
-
const wrapper = mkWrapper({ hotspotColor: 'rgba(217, 30, 24, 0.65)' });
|
|
66
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('evaluate with correct answer', () => {
|
|
71
|
-
it('renders', () => {
|
|
72
|
-
const wrapper = mkWrapper({ isEvaluateMode: true, isCorrect: true, evaluateText: 'Correctly\nselected' });
|
|
73
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { shallow } from 'enzyme';
|
|
4
|
-
import toJson from 'enzyme-to-json';
|
|
5
|
-
import Konva from 'konva';
|
|
6
|
-
|
|
7
|
-
import Rectangle from '../hotspot/rectangle';
|
|
8
|
-
|
|
9
|
-
Konva.isBrowser = false;
|
|
10
|
-
|
|
11
|
-
describe('Rectangle', () => {
|
|
12
|
-
let onClick, wrapper;
|
|
13
|
-
|
|
14
|
-
const mkWrapper = (opts = {}) => {
|
|
15
|
-
opts = _.extend(
|
|
16
|
-
{
|
|
17
|
-
classes: {
|
|
18
|
-
base: 'base'
|
|
19
|
-
},
|
|
20
|
-
height: 200,
|
|
21
|
-
hotspotColor: 'rgba(137, 183, 244, 0.65)',
|
|
22
|
-
id: '1',
|
|
23
|
-
isCorrect: false,
|
|
24
|
-
isEvaluateMode: false,
|
|
25
|
-
evaluateText: null,
|
|
26
|
-
disabled: false,
|
|
27
|
-
outlineColor: 'blue',
|
|
28
|
-
selected: false,
|
|
29
|
-
width: 300,
|
|
30
|
-
x: 5,
|
|
31
|
-
y: 5
|
|
32
|
-
},
|
|
33
|
-
opts
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return shallow(<Rectangle {...opts} onClick={onClick} />);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
onClick = jest.fn();
|
|
41
|
-
wrapper = mkWrapper();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('snapshots', () => {
|
|
45
|
-
describe('outline color', () => {
|
|
46
|
-
it('renders', () => {
|
|
47
|
-
const wrapper = mkWrapper({ outlineColor: 'red' });
|
|
48
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('outline width', () => {
|
|
53
|
-
it('renders with default border width', () => {
|
|
54
|
-
const wrapper = mkWrapper();
|
|
55
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('renders with given border width', () => {
|
|
59
|
-
const wrapper = mkWrapper({ strokeWidth: 10 });
|
|
60
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('hotspot color', () => {
|
|
65
|
-
it('renders', () => {
|
|
66
|
-
const wrapper = mkWrapper({ hotspotColor: 'rgba(217, 30, 24, 0.65)' });
|
|
67
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('evaluate with correct answer', () => {
|
|
72
|
-
it('renders', () => {
|
|
73
|
-
const wrapper = mkWrapper({ isEvaluateMode: true, isCorrect: true, evaluateText: 'Correctly\nselected' });
|
|
74
|
-
expect(toJson(wrapper)).toMatchSnapshot();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|