@pie-element/hotspot 10.0.0-beta.0 → 10.0.0-next.0
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 +0 -11
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/defaults.js +3 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/hotspot-circle.js +0 -1
- package/configure/lib/hotspot-circle.js.map +1 -1
- package/configure/lib/hotspot-drawable.js +5 -5
- package/configure/lib/hotspot-drawable.js.map +1 -1
- package/configure/lib/hotspot-polygon.js +1 -2
- package/configure/lib/hotspot-polygon.js.map +1 -1
- package/configure/lib/hotspot-rectangle.js +0 -1
- package/configure/lib/hotspot-rectangle.js.map +1 -1
- package/configure/lib/root.js +4 -4
- package/configure/lib/root.js.map +1 -1
- package/configure/lib/utils.js +2 -3
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +8 -8
- package/configure/src/__tests__/DeleteWidget.test.jsx +366 -0
- package/configure/src/__tests__/button.test.jsx +198 -0
- package/configure/src/__tests__/hotspot-circle.test.jsx +259 -0
- package/configure/src/__tests__/hotspot-palette.test.jsx +71 -0
- package/configure/src/__tests__/image-konva.test.jsx +226 -0
- package/configure/src/defaults.js +1 -0
- package/configure/src/hotspot-circle.jsx +0 -1
- package/configure/src/hotspot-drawable.jsx +1 -1
- package/configure/src/hotspot-polygon.jsx +0 -1
- package/configure/src/hotspot-rectangle.jsx +0 -1
- package/configure/src/root.jsx +1 -1
- package/configure/src/utils.js +1 -1
- package/controller/CHANGELOG.md +0 -11
- package/controller/lib/index.js +2 -2
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +3 -5
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +3 -3
- package/controller/src/index.js +1 -1
- package/controller/src/utils.js +1 -2
- package/lib/hotspot/circle.js +1 -2
- package/lib/hotspot/circle.js.map +1 -1
- package/lib/hotspot/polygon.js +0 -1
- package/lib/hotspot/polygon.js.map +1 -1
- package/lib/hotspot/rectangle.js +0 -1
- package/lib/hotspot/rectangle.js.map +1 -1
- package/package.json +10 -10
- package/src/hotspot/__tests__/circle.test.jsx +464 -0
- package/src/hotspot/__tests__/container.test.jsx +546 -0
- package/src/hotspot/__tests__/image-konva-tooltip.test.jsx +510 -0
- package/src/hotspot/__tests__/polygon.test.jsx +502 -0
- package/src/hotspot/__tests__/rectangle.test.jsx +418 -0
- package/src/hotspot/circle.jsx +0 -1
- package/src/hotspot/polygon.jsx +0 -1
- package/src/hotspot/rectangle.jsx +0 -1
- package/configure/node_modules/debug/CHANGELOG.md +0 -395
- package/configure/node_modules/debug/LICENSE +0 -19
- package/configure/node_modules/debug/README.md +0 -437
- package/configure/node_modules/debug/node.js +0 -1
- package/configure/node_modules/debug/package.json +0 -51
- package/configure/node_modules/debug/src/browser.js +0 -180
- package/configure/node_modules/debug/src/common.js +0 -249
- package/configure/node_modules/debug/src/index.js +0 -12
- package/configure/node_modules/debug/src/node.js +0 -177
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitFor } from '@testing-library/react';
|
|
3
|
+
import Konva from 'konva';
|
|
4
|
+
import ImageComponent from '../image-konva';
|
|
5
|
+
|
|
6
|
+
Konva.isBrowser = false;
|
|
7
|
+
|
|
8
|
+
jest.mock('react-konva', () => {
|
|
9
|
+
const React = require('react');
|
|
10
|
+
return {
|
|
11
|
+
Image: (props) => React.createElement('div', { 'data-testid': 'image', ...props }),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('ImageComponent', () => {
|
|
16
|
+
let defaultProps;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
defaultProps = {
|
|
20
|
+
src: 'test-image.png',
|
|
21
|
+
x: 100,
|
|
22
|
+
y: 150,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('rendering', () => {
|
|
27
|
+
it('should render without crashing', () => {
|
|
28
|
+
const { container } = render(<ImageComponent {...defaultProps} />);
|
|
29
|
+
expect(container).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should render Image component', () => {
|
|
33
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} />);
|
|
34
|
+
expect(getByTestId('image')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should render with correct position', () => {
|
|
38
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} x={200} y={250} />);
|
|
39
|
+
const image = getByTestId('image');
|
|
40
|
+
expect(image).toHaveAttribute('x', '200');
|
|
41
|
+
expect(image).toHaveAttribute('y', '250');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should render with fixed dimensions', () => {
|
|
45
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} />);
|
|
46
|
+
const image = getByTestId('image');
|
|
47
|
+
expect(image).toHaveAttribute('width', '20');
|
|
48
|
+
expect(image).toHaveAttribute('height', '20');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should render at origin (0, 0)', () => {
|
|
52
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} x={0} y={0} />);
|
|
53
|
+
const image = getByTestId('image');
|
|
54
|
+
expect(image).toHaveAttribute('x', '0');
|
|
55
|
+
expect(image).toHaveAttribute('y', '0');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('image loading', () => {
|
|
60
|
+
it('should load image on mount', async () => {
|
|
61
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} />);
|
|
62
|
+
|
|
63
|
+
const image = getByTestId('image');
|
|
64
|
+
expect(image).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should call loadImage on mount', () => {
|
|
68
|
+
const { container } = render(<ImageComponent {...defaultProps} src="custom-image.jpg" />);
|
|
69
|
+
|
|
70
|
+
expect(container).toBeTruthy();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('component lifecycle', () => {
|
|
75
|
+
it('should reload image when src changes', async () => {
|
|
76
|
+
const { rerender, container } = render(<ImageComponent {...defaultProps} src="image1.png" />);
|
|
77
|
+
|
|
78
|
+
expect(container).toBeTruthy();
|
|
79
|
+
|
|
80
|
+
rerender(<ImageComponent {...defaultProps} src="image2.png" />);
|
|
81
|
+
|
|
82
|
+
expect(container).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should not reload image when src stays the same', async () => {
|
|
86
|
+
const { rerender, getByTestId } = render(<ImageComponent {...defaultProps} src="same-image.png" />);
|
|
87
|
+
|
|
88
|
+
const image = getByTestId('image');
|
|
89
|
+
expect(image).toBeInTheDocument();
|
|
90
|
+
|
|
91
|
+
rerender(<ImageComponent {...defaultProps} src="same-image.png" x={200} y={250} />);
|
|
92
|
+
|
|
93
|
+
const updatedImage = getByTestId('image');
|
|
94
|
+
expect(updatedImage).toHaveAttribute('x', '200');
|
|
95
|
+
expect(updatedImage).toHaveAttribute('y', '250');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should clean up event listener on unmount', () => {
|
|
99
|
+
const { unmount } = render(<ImageComponent {...defaultProps} />);
|
|
100
|
+
|
|
101
|
+
expect(() => {
|
|
102
|
+
unmount();
|
|
103
|
+
}).not.toThrow();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should handle multiple mount/unmount cycles', () => {
|
|
107
|
+
const { unmount } = render(<ImageComponent {...defaultProps} />);
|
|
108
|
+
unmount();
|
|
109
|
+
|
|
110
|
+
expect(() => {
|
|
111
|
+
render(<ImageComponent {...defaultProps} />);
|
|
112
|
+
}).not.toThrow();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('position updates', () => {
|
|
117
|
+
it('should update x position', () => {
|
|
118
|
+
const { getByTestId, rerender } = render(<ImageComponent {...defaultProps} x={100} />);
|
|
119
|
+
let image = getByTestId('image');
|
|
120
|
+
expect(image).toHaveAttribute('x', '100');
|
|
121
|
+
|
|
122
|
+
rerender(<ImageComponent {...defaultProps} x={200} />);
|
|
123
|
+
image = getByTestId('image');
|
|
124
|
+
expect(image).toHaveAttribute('x', '200');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should update y position', () => {
|
|
128
|
+
const { getByTestId, rerender } = render(<ImageComponent {...defaultProps} y={150} />);
|
|
129
|
+
let image = getByTestId('image');
|
|
130
|
+
expect(image).toHaveAttribute('y', '150');
|
|
131
|
+
|
|
132
|
+
rerender(<ImageComponent {...defaultProps} y={250} />);
|
|
133
|
+
image = getByTestId('image');
|
|
134
|
+
expect(image).toHaveAttribute('y', '250');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should update both x and y positions', () => {
|
|
138
|
+
const { getByTestId, rerender } = render(<ImageComponent {...defaultProps} x={100} y={150} />);
|
|
139
|
+
let image = getByTestId('image');
|
|
140
|
+
expect(image).toHaveAttribute('x', '100');
|
|
141
|
+
expect(image).toHaveAttribute('y', '150');
|
|
142
|
+
|
|
143
|
+
rerender(<ImageComponent {...defaultProps} x={300} y={400} />);
|
|
144
|
+
image = getByTestId('image');
|
|
145
|
+
expect(image).toHaveAttribute('x', '300');
|
|
146
|
+
expect(image).toHaveAttribute('y', '400');
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('edge cases', () => {
|
|
151
|
+
it('should handle negative positions', () => {
|
|
152
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} x={-50} y={-75} />);
|
|
153
|
+
const image = getByTestId('image');
|
|
154
|
+
expect(image).toHaveAttribute('x', '-50');
|
|
155
|
+
expect(image).toHaveAttribute('y', '-75');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should handle very large positions', () => {
|
|
159
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} x={10000} y={20000} />);
|
|
160
|
+
const image = getByTestId('image');
|
|
161
|
+
expect(image).toHaveAttribute('x', '10000');
|
|
162
|
+
expect(image).toHaveAttribute('y', '20000');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should handle data URI as src', () => {
|
|
166
|
+
const dataUri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
|
|
167
|
+
const { container } = render(<ImageComponent {...defaultProps} src={dataUri} />);
|
|
168
|
+
|
|
169
|
+
expect(container).toBeTruthy();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should handle SVG as src', () => {
|
|
173
|
+
const { container } = render(<ImageComponent {...defaultProps} src="icon.svg" />);
|
|
174
|
+
expect(container).toBeTruthy();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should handle empty src', () => {
|
|
178
|
+
const { container } = render(<ImageComponent {...defaultProps} src="" />);
|
|
179
|
+
expect(container).toBeTruthy();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('should handle URL with query parameters', () => {
|
|
183
|
+
const srcWithParams = 'image.png?width=100&height=100';
|
|
184
|
+
const { container } = render(<ImageComponent {...defaultProps} src={srcWithParams} />);
|
|
185
|
+
|
|
186
|
+
expect(container).toBeTruthy();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should handle relative paths', () => {
|
|
190
|
+
const { container } = render(<ImageComponent {...defaultProps} src="./images/icon.png" />);
|
|
191
|
+
expect(container).toBeTruthy();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should handle absolute paths', () => {
|
|
195
|
+
const { container } = render(<ImageComponent {...defaultProps} src="/assets/icon.png" />);
|
|
196
|
+
expect(container).toBeTruthy();
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('image state', () => {
|
|
201
|
+
it('should initially render without image loaded', () => {
|
|
202
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} />);
|
|
203
|
+
const image = getByTestId('image');
|
|
204
|
+
expect(image).toBeInTheDocument();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('should render component regardless of image load state', () => {
|
|
208
|
+
const { getByTestId } = render(<ImageComponent {...defaultProps} />);
|
|
209
|
+
const image = getByTestId('image');
|
|
210
|
+
expect(image).toBeInTheDocument();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe('error handling', () => {
|
|
215
|
+
it('should handle image load error gracefully', () => {
|
|
216
|
+
const { container } = render(<ImageComponent {...defaultProps} src="nonexistent.png" />);
|
|
217
|
+
|
|
218
|
+
const imgElements = document.querySelectorAll('img[src="nonexistent.png"]');
|
|
219
|
+
imgElements.forEach(img => {
|
|
220
|
+
img.dispatchEvent(new Event('error'));
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
expect(container).toBeTruthy();
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Layer, Stage } from 'react-konva';
|
|
4
|
-
import cloneDeep from 'lodash
|
|
4
|
+
import { cloneDeep } from 'lodash-es';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
|
|
7
7
|
import Rectangle from './hotspot-rectangle';
|
package/configure/src/root.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { settings, layout, InputContainer, NumberTextField } from '@pie-lib/config-ui';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import EditableHtml from '@pie-lib/editable-html';
|
|
4
|
+
import EditableHtml from '@pie-lib/editable-html-tip-tap';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import Typography from '@mui/material/Typography';
|
|
7
7
|
import Info from '@mui/icons-material/Info';
|
package/configure/src/utils.js
CHANGED
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
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
|
-
## [6.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@6.3.2...@pie-element/hotspot-controller@6.3.3) (2025-11-27)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* bump libs PD-5274, PD-5211, PD-5248 ([7610b25](https://github.com/pie-framework/pie-elements/commit/7610b25423956b6492f33322513b3430051fca77))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
6
|
## [6.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@6.3.1...@pie-element/hotspot-controller@6.3.2) (2025-10-22)
|
|
18
7
|
|
|
19
8
|
|
package/controller/lib/index.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.normalize = void 0;
|
|
|
10
10
|
exports.outcome = outcome;
|
|
11
11
|
exports.validate = void 0;
|
|
12
12
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
-
var
|
|
13
|
+
var _lodashEs = require("lodash-es");
|
|
14
14
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
15
15
|
var _utils = require("./utils");
|
|
16
16
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
@@ -160,7 +160,7 @@ const getScore = (config, session, env = {}) => {
|
|
|
160
160
|
function outcome(config, session, env = {}) {
|
|
161
161
|
return new Promise(resolve => {
|
|
162
162
|
log('outcome...');
|
|
163
|
-
if (!session || (0,
|
|
163
|
+
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
164
164
|
resolve({
|
|
165
165
|
score: 0,
|
|
166
166
|
empty: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_debug","_interopRequireDefault","require","_isEmpty","_controllerUtils","_utils","_defaults","log","debug","normalize","question","defaults","exports","model","session","env","normalizedQuestion","imageUrl","dimensions","hotspotColor","hoverOutlineColor","selectedHotspotColor","multipleCorrect","outlineColor","partialScoring","prompt","shapes","language","fontSizeFactor","autoplayAudioEnabled","completeAudioEnabled","customAudioButton","rectangles","polygons","circles","shouldIncludeCorrectResponse","mode","role","Promise","resolve","out","disabled","map","index","correct","rectProps","polyProps","circleProps","responseCorrect","isResponseCorrect","undefined","extraCSSRules","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","promptEnabled","strokeWidth","createDefaultModel","getScore","config","answers","partialScoringEnabled","enabled","correctAnswers","selectedChoices","choices","correctChoices","filter","choice","forEach","shape","selected","answer","id","correctlySelected","extraAnswers","length","total","str","toFixed","parseFloat","outcome","isEmpty","score","empty","returnShapesCorrect","i","push","createCorrectResponseSession","rectangleCorrect","polygonsCorrect","circlesCorrect","getInnerText","html","replaceAll","getContent","replace","validate","minShapes","maxShapes","maxSelections","errors","field","required","allShapes","Object","values","reduce","acc","nbOfSelections","nbOfShapes","selections"],"sources":["../src/index.js"],"sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nimport { isResponseCorrect } from './utils';\n\nimport defaults from './defaults';\n\nconst log = debug('pie-elements:hotspot:controller');\n\nexport const normalize = (question) => ({\n ...defaults,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n dimensions,\n hotspotColor,\n hoverOutlineColor,\n selectedHotspotColor,\n multipleCorrect,\n outlineColor,\n partialScoring,\n prompt,\n shapes,\n language,\n fontSizeFactor,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n } = normalizedQuestion;\n const { rectangles, polygons, circles } = shapes || {};\n\n const shouldIncludeCorrectResponse = env.mode === 'evaluate' || (env.role === 'instructor' && env.mode === 'view');\n\n return new Promise((resolve) => {\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n dimensions,\n imageUrl,\n outlineColor,\n hotspotColor,\n hoverOutlineColor,\n selectedHotspotColor,\n multipleCorrect,\n partialScoring,\n language,\n fontSizeFactor,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n shapes: {\n ...shapes,\n // eslint-disable-next-line no-unused-vars\n rectangles: (rectangles || []).map(({ index, correct, ...rectProps }) =>\n shouldIncludeCorrectResponse ? { correct, ...rectProps } : { ...rectProps },\n ),\n // eslint-disable-next-line no-unused-vars\n polygons: (polygons || []).map(({ index, correct, ...polyProps }) =>\n shouldIncludeCorrectResponse ? { correct, ...polyProps } : { ...polyProps },\n ),\n // eslint-disable-next-line no-unused-vars\n circles: (circles || []).map(({ index, correct, ...circleProps }) =>\n shouldIncludeCorrectResponse ? { correct, ...circleProps } : { ...circleProps },\n ),\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n out.prompt = normalizedQuestion.promptEnabled ? prompt : null;\n out.strokeWidth = normalizedQuestion.strokeWidth;\n\n resolve(out);\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst getScore = (config, session, env = {}) => {\n const { answers } = session || {};\n\n if (!config.shapes || (!config.shapes.rectangles && !config.shapes.polygons && !config.shapes.circles)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [], circles = [] } = {} } = config;\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n if (!partialScoringEnabled) {\n return isResponseCorrect(config, session) ? 1 : 0;\n }\n\n let correctAnswers = 0;\n let selectedChoices = 0;\n\n const choices = [...rectangles, ...polygons, ...circles];\n\n const correctChoices = choices.filter((choice) => choice.correct);\n\n choices.forEach((shape) => {\n const selected = answers && answers.filter((answer) => answer.id === shape.id)[0];\n const correctlySelected = shape.correct && selected;\n\n if (selected) {\n selectedChoices += 1;\n }\n\n if (correctlySelected) {\n correctAnswers += 1;\n }\n });\n\n const extraAnswers = selectedChoices > correctChoices.length ? selectedChoices - correctChoices.length : 0;\n\n const total = correctChoices.length === 0 ? 1 : correctChoices.length;\n const str = ((correctAnswers - extraAnswers) / total).toFixed(2);\n\n return str < 0 ? 0 : parseFloat(str);\n};\n\nexport function outcome(config, session, env = {}) {\n return new Promise((resolve) => {\n log('outcome...');\n\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (session.answers) {\n const score = getScore(config, session, env);\n resolve({ score });\n } else {\n resolve({ score: 0, empty: true });\n }\n });\n}\n\nconst returnShapesCorrect = (shapes) => {\n let answers = [];\n\n shapes.forEach((i) => {\n const { correct, id } = i;\n if (correct) {\n answers.push({ id });\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { shapes: { rectangles = [], circles = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n const circlesCorrect = returnShapesCorrect(circles);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect, ...circlesCorrect],\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { shapes } = model;\n const { minShapes = 2, maxShapes, maxSelections } = config;\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);\n\n const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);\n\n const nbOfShapes = (allShapes || []).length;\n\n if (nbOfShapes < minShapes) {\n errors.shapes = `There should be at least ${minShapes} shapes defined.`;\n } else if (nbOfShapes > maxShapes) {\n errors.shapes = `No more than ${maxShapes} shapes should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selections = 'There should be at least 1 shape selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selections = `No more than ${maxSelections} shapes should be selected.`;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,MAAMK,GAAG,GAAG,IAAAC,cAAK,EAAC,iCAAiC,CAAC;AAE7C,MAAMC,SAAS,GAAIC,QAAQ,KAAM;EACtC,GAAGC,iBAAQ;EACX,GAAGD;AACL,CAAC,CAAC;AAACE,OAAA,CAAAH,SAAA,GAAAA,SAAA;AAEI,SAASI,KAAKA,CAACH,QAAQ,EAAEI,OAAO,EAAEC,GAAG,EAAE;EAC5C,MAAMC,kBAAkB,GAAGP,SAAS,CAACC,QAAQ,CAAC;EAC9C,MAAM;IACJO,QAAQ;IACRC,UAAU;IACVC,YAAY;IACZC,iBAAiB;IACjBC,oBAAoB;IACpBC,eAAe;IACfC,YAAY;IACZC,cAAc;IACdC,MAAM;IACNC,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,oBAAoB;IACp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G,4CAA4C;EAClE,CAAC,MAAM,IAAIF,cAAc,GAAGT,aAAa,EAAE;IACzCC,MAAM,CAACU,UAAU,GAAG,gBAAgBX,aAAa,6BAA6B;EAChF;EAEA,OAAOC,MAAM;AACf,CAAC;AAAC1F,OAAA,CAAAsF,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_debug","_interopRequireDefault","require","_lodashEs","_controllerUtils","_utils","_defaults","log","debug","normalize","question","defaults","exports","model","session","env","normalizedQuestion","imageUrl","dimensions","hotspotColor","hoverOutlineColor","selectedHotspotColor","multipleCorrect","outlineColor","partialScoring","prompt","shapes","language","fontSizeFactor","autoplayAudioEnabled","completeAudioEnabled","customAudioButton","rectangles","polygons","circles","shouldIncludeCorrectResponse","mode","role","Promise","resolve","out","disabled","map","index","correct","rectProps","polyProps","circleProps","responseCorrect","isResponseCorrect","undefined","extraCSSRules","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","promptEnabled","strokeWidth","createDefaultModel","getScore","config","answers","partialScoringEnabled","enabled","correctAnswers","selectedChoices","choices","correctChoices","filter","choice","forEach","shape","selected","answer","id","correctlySelected","extraAnswers","length","total","str","toFixed","parseFloat","outcome","isEmpty","score","empty","returnShapesCorrect","i","push","createCorrectResponseSession","rectangleCorrect","polygonsCorrect","circlesCorrect","getInnerText","html","replaceAll","getContent","replace","validate","minShapes","maxShapes","maxSelections","errors","field","required","allShapes","Object","values","reduce","acc","nbOfSelections","nbOfShapes","selections"],"sources":["../src/index.js"],"sourcesContent":["import debug from 'debug';\nimport { isEmpty } from 'lodash-es';\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nimport { isResponseCorrect } from './utils';\n\nimport defaults from './defaults';\n\nconst log = debug('pie-elements:hotspot:controller');\n\nexport const normalize = (question) => ({\n ...defaults,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n dimensions,\n hotspotColor,\n hoverOutlineColor,\n selectedHotspotColor,\n multipleCorrect,\n outlineColor,\n partialScoring,\n prompt,\n shapes,\n language,\n fontSizeFactor,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n } = normalizedQuestion;\n const { rectangles, polygons, circles } = shapes || {};\n\n const shouldIncludeCorrectResponse = env.mode === 'evaluate' || (env.role === 'instructor' && env.mode === 'view');\n\n return new Promise((resolve) => {\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n dimensions,\n imageUrl,\n outlineColor,\n hotspotColor,\n hoverOutlineColor,\n selectedHotspotColor,\n multipleCorrect,\n partialScoring,\n language,\n fontSizeFactor,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n shapes: {\n ...shapes,\n // eslint-disable-next-line no-unused-vars\n rectangles: (rectangles || []).map(({ index, correct, ...rectProps }) =>\n shouldIncludeCorrectResponse ? { correct, ...rectProps } : { ...rectProps },\n ),\n // eslint-disable-next-line no-unused-vars\n polygons: (polygons || []).map(({ index, correct, ...polyProps }) =>\n shouldIncludeCorrectResponse ? { correct, ...polyProps } : { ...polyProps },\n ),\n // eslint-disable-next-line no-unused-vars\n circles: (circles || []).map(({ index, correct, ...circleProps }) =>\n shouldIncludeCorrectResponse ? { correct, ...circleProps } : { ...circleProps },\n ),\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n out.prompt = normalizedQuestion.promptEnabled ? prompt : null;\n out.strokeWidth = normalizedQuestion.strokeWidth;\n\n resolve(out);\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst getScore = (config, session, env = {}) => {\n const { answers } = session || {};\n\n if (!config.shapes || (!config.shapes.rectangles && !config.shapes.polygons && !config.shapes.circles)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [], circles = [] } = {} } = config;\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n if (!partialScoringEnabled) {\n return isResponseCorrect(config, session) ? 1 : 0;\n }\n\n let correctAnswers = 0;\n let selectedChoices = 0;\n\n const choices = [...rectangles, ...polygons, ...circles];\n\n const correctChoices = choices.filter((choice) => choice.correct);\n\n choices.forEach((shape) => {\n const selected = answers && answers.filter((answer) => answer.id === shape.id)[0];\n const correctlySelected = shape.correct && selected;\n\n if (selected) {\n selectedChoices += 1;\n }\n\n if (correctlySelected) {\n correctAnswers += 1;\n }\n });\n\n const extraAnswers = selectedChoices > correctChoices.length ? selectedChoices - correctChoices.length : 0;\n\n const total = correctChoices.length === 0 ? 1 : correctChoices.length;\n const str = ((correctAnswers - extraAnswers) / total).toFixed(2);\n\n return str < 0 ? 0 : parseFloat(str);\n};\n\nexport function outcome(config, session, env = {}) {\n return new Promise((resolve) => {\n log('outcome...');\n\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (session.answers) {\n const score = getScore(config, session, env);\n resolve({ score });\n } else {\n resolve({ score: 0, empty: true });\n }\n });\n}\n\nconst returnShapesCorrect = (shapes) => {\n let answers = [];\n\n shapes.forEach((i) => {\n const { correct, id } = i;\n if (correct) {\n answers.push({ id });\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { shapes: { rectangles = [], circles = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n const circlesCorrect = returnShapesCorrect(circles);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect, ...circlesCorrect],\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { shapes } = model;\n const { minShapes = 2, maxShapes, maxSelections } = config;\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);\n\n const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);\n\n const nbOfShapes = (allShapes || []).length;\n\n if (nbOfShapes < minShapes) {\n errors.shapes = `There should be at least ${minShapes} shapes defined.`;\n } else if (nbOfShapes > maxShapes) {\n errors.shapes = `No more than ${maxShapes} shapes should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selections = 'There should be at least 1 shape selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selections = `No more than ${maxSelections} shapes should be selected.`;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,MAAMK,GAAG,GAAG,IAAAC,cAAK,EAAC,iCAAiC,CAAC;AAE7C,MAAMC,SAAS,GAAIC,QAAQ,KAAM;EACtC,GAAGC,iBAAQ;EACX,GAAGD;AACL,CAAC,CAAC;AAACE,OAAA,CAAAH,SAAA,GAAAA,SAAA;AAEI,SAASI,KAAKA,CAACH,QAAQ,EAAEI,OAA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GAAGZ,SAAS,EAAE;IAC1BG,MAAM,CAAC5E,MAAM,GAAG,4BAA4ByE,SAAS,kBAAkB;EACzE,CAAC,MAAM,IAAIY,UAAU,GAAGX,SAAS,EAAE;IACjCE,MAAM,CAAC5E,MAAM,GAAG,gBAAgB0E,SAAS,4BAA4B;EACvE;EAEA,IAAIU,cAAc,GAAG,CAAC,EAAE;IACtBR,MAAM,CAACU,UAAU,GAAG,4CAA4C;EAClE,CAAC,MAAM,IAAIF,cAAc,GAAGT,aAAa,EAAE;IACzCC,MAAM,CAACU,UAAU,GAAG,gBAAgBX,aAAa,6BAA6B;EAChF;EAEA,OAAOC,MAAM;AACf,CAAC;AAAC1F,OAAA,CAAAsF,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/controller/lib/utils.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.isResponseCorrect = exports.getCorrectResponse = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
10
8
|
const getCorrectResponse = choices => choices.filter(c => c.correct).map(c => c.id).sort();
|
|
11
9
|
exports.getCorrectResponse = getCorrectResponse;
|
|
12
10
|
const isResponseCorrect = (question, session) => {
|
|
@@ -19,12 +17,12 @@ const isResponseCorrect = (question, session) => {
|
|
|
19
17
|
} = question;
|
|
20
18
|
const choices = [...rectangles, ...polygons, ...circles];
|
|
21
19
|
let correctResponseIds = getCorrectResponse(choices);
|
|
22
|
-
if (!session || (0,
|
|
20
|
+
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
23
21
|
return false;
|
|
24
22
|
}
|
|
25
23
|
if (session.answers && session.answers.length) {
|
|
26
24
|
let answerIds = (session.answers || []).map(a => a.id);
|
|
27
|
-
return (0,
|
|
25
|
+
return (0, _lodashEs.isEqual)(answerIds.sort(), correctResponseIds);
|
|
28
26
|
} else if (!(correctResponseIds && correctResponseIds.length)) {
|
|
29
27
|
return true;
|
|
30
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_lodashEs","require","getCorrectResponse","choices","filter","c","correct","map","id","sort","exports","isResponseCorrect","question","session","shapes","rectangles","polygons","circles","correctResponseIds","isEmpty","answers","length","answerIds","a","isEqual"],"sources":["../src/utils.js"],"sourcesContent":["import { isEmpty, isEqual } from 'lodash-es';\n\nexport const getCorrectResponse = (choices) =>\n choices\n .filter((c) => c.correct)\n .map((c) => c.id)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n const {\n shapes: { rectangles = [], polygons = [], circles = [] },\n } = question;\n const choices = [...rectangles, ...polygons, ...circles];\n let correctResponseIds = getCorrectResponse(choices);\n\n if (!session || isEmpty(session)) {\n return false;\n }\n\n if (session.answers && session.answers.length) {\n let answerIds = (session.answers || []).map((a) => a.id);\n\n return isEqual(answerIds.sort(), correctResponseIds);\n } else if (!(correctResponseIds && correctResponseIds.length)) {\n return true;\n }\n\n return false;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAIC,OAAO,IACxCA,OAAO,CACJC,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,CAAC,CACxBC,GAAG,CAAEF,CAAC,IAAKA,CAAC,CAACG,EAAE,CAAC,CAChBC,IAAI,CAAC,CAAC;AAACC,OAAA,CAAAR,kBAAA,GAAAA,kBAAA;AAEL,MAAMS,iBAAiB,GAAGA,CAACC,QAAQ,EAAEC,OAAO,KAAK;EACtD,MAAM;IACJC,MAAM,EAAE;MAAEC,UAAU,GAAG,EAAE;MAAEC,QAAQ,GAAG,EAAE;MAAEC,OAAO,GAAG;IAAG;EACzD,CAAC,GAAGL,QAAQ;EACZ,MAAMT,OAAO,GAAG,CAAC,GAAGY,UAAU,EAAE,GAAGC,QAAQ,EAAE,GAAGC,OAAO,CAAC;EACxD,IAAIC,kBAAkB,GAAGhB,kBAAkB,CAACC,OAAO,CAAC;EAEpD,IAAI,CAACU,OAAO,IAAI,IAAAM,iBAAO,EAACN,OAAO,CAAC,EAAE;IAChC,OAAO,KAAK;EACd;EAEA,IAAIA,OAAO,CAACO,OAAO,IAAIP,OAAO,CAACO,OAAO,CAACC,MAAM,EAAE;IAC7C,IAAIC,SAAS,GAAG,CAACT,OAAO,CAACO,OAAO,IAAI,EAAE,EAAEb,GAAG,CAAEgB,CAAC,IAAKA,CAAC,CAACf,EAAE,CAAC;IAExD,OAAO,IAAAgB,iBAAO,EAACF,SAAS,CAACb,IAAI,CAAC,CAAC,EAAES,kBAAkB,CAAC;EACtD,CAAC,MAAM,IAAI,EAAEA,kBAAkB,IAAIA,kBAAkB,CAACG,MAAM,CAAC,EAAE;IAC7D,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd,CAAC;AAACX,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/controller/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "7.0.0-beta.
|
|
4
|
+
"version": "7.0.0-beta.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"main": "lib/index.js",
|
|
12
12
|
"module": "src/index.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@pie-lib/controller-utils": "
|
|
14
|
+
"@pie-lib/controller-utils": "1.1.1-next.1",
|
|
15
15
|
"debug": "^4.1.1",
|
|
16
|
-
"lodash": "^4.17.
|
|
16
|
+
"lodash-es": "^4.17.23"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/controller/src/index.js
CHANGED
package/controller/src/utils.js
CHANGED
package/lib/hotspot/circle.js
CHANGED
|
@@ -117,8 +117,7 @@ class CircleComponent extends _react.default.Component {
|
|
|
117
117
|
onMouseLeave: this.handleMouseLeave,
|
|
118
118
|
onMouseEnter: this.handleMouseEnter,
|
|
119
119
|
x: x,
|
|
120
|
-
y: y
|
|
121
|
-
opacity: 0.5
|
|
120
|
+
y: y
|
|
122
121
|
}), isEvaluateMode && iconSrc ? /*#__PURE__*/_react.default.createElement(_imageKonvaTooltip.default, {
|
|
123
122
|
src: iconSrc,
|
|
124
123
|
x: iconX,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle.js","names":["_react","_interopRequireDefault","require","_propTypes","_reactKonva","_imageKonvaTooltip","_icons","CircleComponent","React","Component","constructor","props","_defineProperty2","default","e","onClick","id","selected","disabled","cancelBubble","selector","document","body","style","cursor","setState","hovered","isCorrect","markAsCorrect","outlineColor","showCorrectEnabled","strokeWidth","state","render","radius","hotspotColor","isEvaluateMode","hoverOutlineColor","x","y","evaluateText","scale","selectedHotspotColor","outlineColorParsed","getEvaluateOutlineColor","outlineWidth","getOutlineWidth","iconX","iconY","iconSrc","faCorrect","faWrong","useHoveredStyle","createElement","Group","scaleX","scaleY","Rect","width","height","stroke","Circle","fill","handleClick","onTap","draggable","onMouseLeave","handleMouseLeave","onMouseEnter","handleMouseEnter","opacity","src","tooltip","propTypes","PropTypes","number","isRequired","string","oneOfType","bool","func","defaultProps","_default","exports"],"sources":["../../src/hotspot/circle.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Circle, Group, Rect } from 'react-konva';\nimport ImageComponent from './image-konva-tooltip';\nimport { faCorrect, faWrong } from './icons';\n\nclass CircleComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n hovered: false,\n };\n }\n\n handleClick = (e) => {\n const { onClick, id, selected, disabled } = this.props;\n\n if (!disabled) {\n e.cancelBubble = true;\n onClick({ id, selected: !selected, selector: 'Mouse' });\n }\n };\n\n handleMouseEnter = () => {\n const { disabled } = this.props;\n\n if (!disabled) {\n document.body.style.cursor = 'pointer';\n }\n this.setState({ hovered: true });\n };\n\n handleMouseLeave = () => {\n document.body.style.cursor = 'default';\n this.setState({ hovered: false });\n };\n\n getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>\n markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';\n\n getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>\n markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;\n\n render() {\n const {\n radius,\n hotspotColor,\n isCorrect,\n isEvaluateMode,\n hoverOutlineColor,\n outlineColor,\n selected,\n x,\n y,\n evaluateText,\n strokeWidth,\n scale,\n markAsCorrect,\n selectedHotspotColor,\n showCorrectEnabled,\n } = this.props;\n\n const { hovered } = this.state;\n\n const outlineColorParsed = isEvaluateMode\n ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)\n : outlineColor;\n\n const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);\n\n const iconX = x - 10;\n const iconY = y - 10; // Adjust position for the icon\n\n let iconSrc;\n if (showCorrectEnabled) {\n if ((selected && isCorrect) || (!selected && !isCorrect)) {\n iconSrc = faCorrect;\n }\n } else {\n if (selected) {\n if (isCorrect) {\n iconSrc = faCorrect;\n } else {\n iconSrc = faWrong;\n }\n } else if (!isCorrect) {\n iconSrc = faWrong;\n }\n }\n\n const useHoveredStyle = hovered && hoverOutlineColor;\n\n return (\n <Group scaleX={scale} scaleY={scale}>\n {useHoveredStyle && (\n <Rect\n x={x - radius}\n y={y - radius}\n width={radius * 2}\n height={radius * 2}\n stroke={selected ? 'transparent' : hoverOutlineColor}\n strokeWidth={strokeWidth}\n />\n )}\n <Circle\n radius={radius}\n fill={selected && selectedHotspotColor ? selectedHotspotColor : hotspotColor}\n onClick={this.handleClick}\n onTap={this.handleClick}\n draggable={false}\n stroke={useHoveredStyle && !selected ? 'transparent' : outlineColorParsed}\n strokeWidth={useHoveredStyle && !selected ? 0 : outlineWidth}\n onMouseLeave={this.handleMouseLeave}\n onMouseEnter={this.handleMouseEnter}\n x={x}\n y={y}\n opacity={0.5}\n />\n {isEvaluateMode && iconSrc ? <ImageComponent src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}\n </Group>\n );\n }\n}\n\nCircleComponent.propTypes = {\n radius: PropTypes.number.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n isCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n isEvaluateMode: PropTypes.bool.isRequired,\n disabled: PropTypes.bool.isRequired,\n hoverOutlineColor: PropTypes.string,\n onClick: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n selected: PropTypes.bool.isRequired,\n x: PropTypes.number.isRequired,\n y: PropTypes.number.isRequired,\n evaluateText: PropTypes.string,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n selectedHotspotColor: PropTypes.string,\n markAsCorrect: PropTypes.bool.isRequired,\n showCorrectEnabled: PropTypes.bool.isRequired,\n};\n\nCircleComponent.defaultProps = {\n isCorrect: false,\n evaluateText: null,\n strokeWidth: 5,\n scale: 1,\n};\n\nexport default CircleComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,eAAe,SAASC,cAAK,CAACC,SAAS,CAAC;EAC5CC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,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ACC,MAAM,CAACC,UAAU;EACnCzC,YAAY,EAAEuC,kBAAS,CAACG,MAAM,CAACD,UAAU;EACzC5D,EAAE,EAAE0D,kBAAS,CAACG,MAAM,CAACD,UAAU;EAC/BjD,SAAS,EAAE+C,kBAAS,CAACI,SAAS,CAAC,CAACJ,kBAAS,CAACK,IAAI,EAAEL,kBAAS,CAACG,MAAM,CAAC,CAAC;EAClEzC,cAAc,EAAEsC,kBAAS,CAACK,IAAI,CAACH,UAAU;EACzC1D,QAAQ,EAAEwD,kBAAS,CAACK,IAAI,CAACH,UAAU;EACnCvC,iBAAiB,EAAEqC,kBAAS,CAACG,MAAM;EACnC9D,OAAO,EAAE2D,kBAAS,CAACM,IAAI,CAACJ,UAAU;EAClC/C,YAAY,EAAE6C,kBAAS,CAACG,MAAM,CAACD,UAAU;EACzC3D,QAAQ,EAAEyD,kBAAS,CAACK,IAAI,CAACH,UAAU;EACnCtC,CAAC,EAAEoC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC9BrC,CAAC,EAAEmC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC9BpC,YAAY,EAAEkC,kBAAS,CAACG,MAAM;EAC9B9C,WAAW,EAAE2C,kBAAS,CAACC,MAAM;EAC7BlC,KAAK,EAAEiC,kBAAS,CAACC,MAAM;EACvBjC,oBAAoB,EAAEgC,kBAAS,CAACG,MAAM;EACtCjD,aAAa,EAAE8C,kBAAS,CAACK,IAAI,CAACH,UAAU;EACxC9C,kBAAkB,EAAE4C,kBAAS,CAACK,IAAI,CAACH;AACrC,CAAC;AAEDrE,eAAe,CAAC0E,YAAY,GAAG;EAC7BtD,SAAS,EAAE,KAAK;EAChBa,YAAY,EAAE,IAAI;EAClBT,WAAW,EAAE,CAAC;EACdU,KAAK,EAAE;AACT,CAAC;AAAC,IAAAyC,QAAA,GAAAC,OAAA,CAAAtE,OAAA,GAEaN,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"circle.js","names":["_react","_interopRequireDefault","require","_propTypes","_reactKonva","_imageKonvaTooltip","_icons","CircleComponent","React","Component","constructor","props","_defineProperty2","default","e","onClick","id","selected","disabled","cancelBubble","selector","document","body","style","cursor","setState","hovered","isCorrect","markAsCorrect","outlineColor","showCorrectEnabled","strokeWidth","state","render","radius","hotspotColor","isEvaluateMode","hoverOutlineColor","x","y","evaluateText","scale","selectedHotspotColor","outlineColorParsed","getEvaluateOutlineColor","outlineWidth","getOutlineWidth","iconX","iconY","iconSrc","faCorrect","faWrong","useHoveredStyle","createElement","Group","scaleX","scaleY","Rect","width","height","stroke","Circle","fill","handleClick","onTap","draggable","onMouseLeave","handleMouseLeave","onMouseEnter","handleMouseEnter","src","tooltip","propTypes","PropTypes","number","isRequired","string","oneOfType","bool","func","defaultProps","_default","exports"],"sources":["../../src/hotspot/circle.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Circle, Group, Rect } from 'react-konva';\nimport ImageComponent from './image-konva-tooltip';\nimport { faCorrect, faWrong } from './icons';\n\nclass CircleComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n hovered: false,\n };\n }\n\n handleClick = (e) => {\n const { onClick, id, selected, disabled } = this.props;\n\n if (!disabled) {\n e.cancelBubble = true;\n onClick({ id, selected: !selected, selector: 'Mouse' });\n }\n };\n\n handleMouseEnter = () => {\n const { disabled } = this.props;\n\n if (!disabled) {\n document.body.style.cursor = 'pointer';\n }\n this.setState({ hovered: true });\n };\n\n handleMouseLeave = () => {\n document.body.style.cursor = 'default';\n this.setState({ hovered: false });\n };\n\n getEvaluateOutlineColor = (isCorrect, markAsCorrect, outlineColor) =>\n markAsCorrect ? 'green' : isCorrect ? outlineColor : 'red';\n\n getOutlineWidth = (showCorrectEnabled, selected, markAsCorrect, strokeWidth) =>\n markAsCorrect || (!markAsCorrect && !showCorrectEnabled && selected) ? strokeWidth : 0;\n\n render() {\n const {\n radius,\n hotspotColor,\n isCorrect,\n isEvaluateMode,\n hoverOutlineColor,\n outlineColor,\n selected,\n x,\n y,\n evaluateText,\n strokeWidth,\n scale,\n markAsCorrect,\n selectedHotspotColor,\n showCorrectEnabled,\n } = this.props;\n\n const { hovered } = this.state;\n\n const outlineColorParsed = isEvaluateMode\n ? this.getEvaluateOutlineColor(isCorrect, markAsCorrect, outlineColor)\n : outlineColor;\n\n const outlineWidth = this.getOutlineWidth(showCorrectEnabled, selected, markAsCorrect, strokeWidth);\n\n const iconX = x - 10;\n const iconY = y - 10; // Adjust position for the icon\n\n let iconSrc;\n if (showCorrectEnabled) {\n if ((selected && isCorrect) || (!selected && !isCorrect)) {\n iconSrc = faCorrect;\n }\n } else {\n if (selected) {\n if (isCorrect) {\n iconSrc = faCorrect;\n } else {\n iconSrc = faWrong;\n }\n } else if (!isCorrect) {\n iconSrc = faWrong;\n }\n }\n\n const useHoveredStyle = hovered && hoverOutlineColor;\n\n return (\n <Group scaleX={scale} scaleY={scale}>\n {useHoveredStyle && (\n <Rect\n x={x - radius}\n y={y - radius}\n width={radius * 2}\n height={radius * 2}\n stroke={selected ? 'transparent' : hoverOutlineColor}\n strokeWidth={strokeWidth}\n />\n )}\n <Circle\n radius={radius}\n fill={selected && selectedHotspotColor ? selectedHotspotColor : hotspotColor}\n onClick={this.handleClick}\n onTap={this.handleClick}\n draggable={false}\n stroke={useHoveredStyle && !selected ? 'transparent' : outlineColorParsed}\n strokeWidth={useHoveredStyle && !selected ? 0 : outlineWidth}\n onMouseLeave={this.handleMouseLeave}\n onMouseEnter={this.handleMouseEnter}\n x={x}\n y={y}\n />\n {isEvaluateMode && iconSrc ? <ImageComponent src={iconSrc} x={iconX} y={iconY} tooltip={evaluateText} /> : null}\n </Group>\n );\n }\n}\n\nCircleComponent.propTypes = {\n radius: PropTypes.number.isRequired,\n hotspotColor: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n isCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n isEvaluateMode: PropTypes.bool.isRequired,\n disabled: PropTypes.bool.isRequired,\n hoverOutlineColor: PropTypes.string,\n onClick: PropTypes.func.isRequired,\n outlineColor: PropTypes.string.isRequired,\n selected: PropTypes.bool.isRequired,\n x: PropTypes.number.isRequired,\n y: PropTypes.number.isRequired,\n evaluateText: PropTypes.string,\n strokeWidth: PropTypes.number,\n scale: PropTypes.number,\n selectedHotspotColor: PropTypes.string,\n markAsCorrect: PropTypes.bool.isRequired,\n showCorrectEnabled: PropTypes.bool.isRequired,\n};\n\nCircleComponent.defaultProps = {\n isCorrect: false,\n evaluateText: null,\n strokeWidth: 5,\n scale: 1,\n};\n\nexport default CircleComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,eAAe,SAASC,cAAK,CAACC,SAAS,CAAC;EAC5CC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,uBAMAC,CAAC,IAAK;MACnB,MAAM;QAAEC,OAAO;QAAEC,EAAE;QAAEC,QAAQ;QAAEC;MAAS,CAAC,GAAG,IAAI,CAACP,KAAK;MAEtD,IAAI,CAACO,QAAQ,EAAE;QACbJ,CAAC,CAACK,YAAY,GAAG,IAAI;QACrBJ,OAAO,CAAC;UAAEC,EAAE;UAAEC,QAAQ,EAAE,CAACA,QAAQ;UAAEG,QAAQ,EAAE;QAAQ,CAAC,CAAC;MACzD;IACF,CAAC;IAAA,IAAAR,gBAAA,CAAAC,OAAA,4BAEkB,MAAM;MACvB,MAAM;QAAEK;MAAS,CAAC,GAAG,IAAI,CAACP,KAAK;MAE/B,IAAI,CAACO,QAAQ,EAAE;QACbG,QAAQ,CAACC,IAAI,CAACC,KAAK,CAACC,MAAM,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CAAC,EAAEmC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC9BpC,CAAC,EAAEkC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC9BnC,YAAY,EAAEiC,kBAAS,CAACG,MAAM;EAC9B7C,WAAW,EAAE0C,kBAAS,CAACC,MAAM;EAC7BjC,KAAK,EAAEgC,kBAAS,CAACC,MAAM;EACvBhC,oBAAoB,EAAE+B,kBAAS,CAACG,MAAM;EACtChD,aAAa,EAAE6C,kBAAS,CAACK,IAAI,CAACH,UAAU;EACxC7C,kBAAkB,EAAE2C,kBAAS,CAACK,IAAI,CAACH;AACrC,CAAC;AAEDpE,eAAe,CAACyE,YAAY,GAAG;EAC7BrD,SAAS,EAAE,KAAK;EAChBa,YAAY,EAAE,IAAI;EAClBT,WAAW,EAAE,CAAC;EACdU,KAAK,EAAE;AACT,CAAC;AAAC,IAAAwC,QAAA,GAAAC,OAAA,CAAArE,OAAA,GAEaN,eAAe","ignoreList":[]}
|
package/lib/hotspot/polygon.js
CHANGED
|
@@ -166,7 +166,6 @@ class PolygonComponent extends _react.default.Component {
|
|
|
166
166
|
strokeWidth: useHoveredStyle && !selected ? 0 : outlineWidth,
|
|
167
167
|
onMouseLeave: this.handleMouseLeave,
|
|
168
168
|
onMouseEnter: this.handleMouseEnter,
|
|
169
|
-
opacity: 0.5,
|
|
170
169
|
cursor: "pointer",
|
|
171
170
|
position: "relative"
|
|
172
171
|
}), isEvaluateMode && iconSrc ? /*#__PURE__*/_react.default.createElement(_imageKonvaTooltip.default, {
|