@pie-element/hotspot 7.3.2-next.7 → 7.4.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 CHANGED
@@ -3,6 +3,22 @@
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
+ # [7.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@7.3.1...@pie-element/hotspot@7.4.0) (2025-01-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4555, PD-4660, PD-4426, PD-4607, PD-4394, PD-4521 ([e4928b4](https://github.com/pie-framework/pie-elements/commit/e4928b4f9ac268a892b382045f76ae4eac6b458e))
12
+
13
+
14
+ ### Features
15
+
16
+ * add tests for session changed operation PD-4665 ([0a2d562](https://github.com/pie-framework/pie-elements/commit/0a2d562da49116a15baa47d0cbf7942eaddbf065))
17
+
18
+
19
+
20
+
21
+
6
22
  ## [7.3.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot@7.3.0...@pie-element/hotspot@7.3.1) (2024-12-20)
7
23
 
8
24
 
@@ -3,6 +3,17 @@
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
+ ## [7.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@7.1.6...@pie-element/hotspot-configure@7.1.7) (2025-01-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4555, PD-4660, PD-4426, PD-4607, PD-4394, PD-4521 ([e4928b4](https://github.com/pie-framework/pie-elements/commit/e4928b4f9ac268a892b382045f76ae4eac6b458e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-configure@7.1.5...@pie-element/hotspot-configure@7.1.6) (2024-12-20)
7
18
 
8
19
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot-configure",
3
3
  "private": true,
4
- "version": "7.1.6",
4
+ "version": "7.1.7",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -10,7 +10,7 @@
10
10
  "@material-ui/core": "^3.9.2",
11
11
  "@material-ui/icons": "^3.0.2",
12
12
  "@pie-framework/pie-configure-events": "^1.3.0",
13
- "@pie-lib/pie-toolbox": "2.5.0",
13
+ "@pie-lib/pie-toolbox": "2.6.0",
14
14
  "classnames": "^2.2.6",
15
15
  "debug": "^3.1.0",
16
16
  "konva": "^3.2.4",
@@ -3,6 +3,17 @@
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
+ ## [5.2.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@5.2.1...@pie-element/hotspot-controller@5.2.2) (2025-01-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4555, PD-4660, PD-4426, PD-4607, PD-4394, PD-4521 ([e4928b4](https://github.com/pie-framework/pie-elements/commit/e4928b4f9ac268a892b382045f76ae4eac6b458e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [5.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/hotspot-controller@5.2.0...@pie-element/hotspot-controller@5.2.1) (2024-12-20)
7
18
 
8
19
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot-controller",
3
3
  "private": true,
4
- "version": "5.2.1",
4
+ "version": "5.2.2",
5
5
  "description": "",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -11,7 +11,7 @@
11
11
  "main": "lib/index.js",
12
12
  "module": "src/index.js",
13
13
  "dependencies": {
14
- "@pie-lib/pie-toolbox": "2.5.0",
14
+ "@pie-lib/pie-toolbox": "2.6.0",
15
15
  "debug": "^4.1.1",
16
16
  "lodash": "^4.17.15"
17
17
  }
@@ -8,7 +8,10 @@ exports.updateSessionValue = updateSessionValue;
8
8
  function updateSessionValue(session, model, data) {
9
9
  var id = data.id,
10
10
  selected = data.selected;
11
- var multipleCorrect = model.multipleCorrect;
11
+
12
+ var _ref = model || {},
13
+ multipleCorrect = _ref.multipleCorrect;
14
+
12
15
  session.answers = session.answers || [];
13
16
 
14
17
  if (!selected) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/session-updater.js"],"names":["updateSessionValue","session","model","data","id","selected","multipleCorrect","answers","filter","answer","item","push"],"mappings":";;;;;;;AAAO,SAASA,kBAAT,CAA4BC,OAA5B,EAAqCC,KAArC,EAA4CC,IAA5C,EAAkD;AACvD,MAAQC,EAAR,GAAyBD,IAAzB,CAAQC,EAAR;AAAA,MAAYC,QAAZ,GAAyBF,IAAzB,CAAYE,QAAZ;AACA,MAAQC,eAAR,GAA4BJ,KAA5B,CAAQI,eAAR;AACAL,EAAAA,OAAO,CAACM,OAAR,GAAkBN,OAAO,CAACM,OAAR,IAAmB,EAArC;;AAEA,MAAI,CAACF,QAAL,EAAe;AACbJ,IAAAA,OAAO,CAACM,OAAR,GAAkBN,OAAO,CAACM,OAAR,CAAgBC,MAAhB,CAAuB,UAACC,MAAD;AAAA,aAAYA,MAAM,CAACL,EAAP,KAAcA,EAA1B;AAAA,KAAvB,CAAlB;AACD,GAFD,MAEO;AACL,QAAMM,IAAI,GAAG;AAAEN,MAAAA,EAAE,EAAFA;AAAF,KAAb;;AACA,QAAIE,eAAJ,EAAqB;AACnBL,MAAAA,OAAO,CAACM,OAAR,CAAgBI,IAAhB,CAAqBD,IAArB;AACD,KAFD,MAEO;AACLT,MAAAA,OAAO,CAACM,OAAR,GAAkB,CAACG,IAAD,CAAlB;AACD;AACF;AACF","sourcesContent":["export function updateSessionValue(session, model, data) {\n const { id, selected } = data;\n const { multipleCorrect } = model;\n session.answers = session.answers || [];\n\n if (!selected) {\n session.answers = session.answers.filter((answer) => answer.id !== id);\n } else {\n const item = { id };\n if (multipleCorrect) {\n session.answers.push(item);\n } else {\n session.answers = [item];\n }\n }\n}\n"],"file":"session-updater.js"}
1
+ {"version":3,"sources":["../src/session-updater.js"],"names":["updateSessionValue","session","model","data","id","selected","multipleCorrect","answers","filter","answer","item","push"],"mappings":";;;;;;;AAAO,SAASA,kBAAT,CAA4BC,OAA5B,EAAqCC,KAArC,EAA4CC,IAA5C,EAAkD;AACvD,MAAQC,EAAR,GAAyBD,IAAzB,CAAQC,EAAR;AAAA,MAAYC,QAAZ,GAAyBF,IAAzB,CAAYE,QAAZ;;AACA,aAA4BH,KAAK,IAAI,EAArC;AAAA,MAAQI,eAAR,QAAQA,eAAR;;AACAL,EAAAA,OAAO,CAACM,OAAR,GAAkBN,OAAO,CAACM,OAAR,IAAmB,EAArC;;AAEA,MAAI,CAACF,QAAL,EAAe;AACbJ,IAAAA,OAAO,CAACM,OAAR,GAAkBN,OAAO,CAACM,OAAR,CAAgBC,MAAhB,CAAuB,UAACC,MAAD;AAAA,aAAYA,MAAM,CAACL,EAAP,KAAcA,EAA1B;AAAA,KAAvB,CAAlB;AACD,GAFD,MAEO;AACL,QAAMM,IAAI,GAAG;AAAEN,MAAAA,EAAE,EAAFA;AAAF,KAAb;;AACA,QAAIE,eAAJ,EAAqB;AACnBL,MAAAA,OAAO,CAACM,OAAR,CAAgBI,IAAhB,CAAqBD,IAArB;AACD,KAFD,MAEO;AACLT,MAAAA,OAAO,CAACM,OAAR,GAAkB,CAACG,IAAD,CAAlB;AACD;AACF;AACF","sourcesContent":["export function updateSessionValue(session, model, data) {\n const { id, selected } = data;\n const { multipleCorrect } = model || {};\n session.answers = session.answers || [];\n\n if (!selected) {\n session.answers = session.answers.filter((answer) => answer.id !== id);\n } else {\n const item = { id };\n if (multipleCorrect) {\n session.answers.push(item);\n } else {\n session.answers = [item];\n }\n }\n}\n"],"file":"session-updater.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot",
3
- "version": "7.3.2-next.7+b1fff343d",
3
+ "version": "7.4.0",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.3",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
- "@pie-lib/pie-toolbox": "2.5.0",
12
+ "@pie-lib/pie-toolbox": "2.6.0",
13
13
  "konva": "^3.2.5",
14
14
  "prop-types": "^15.6.1",
15
15
  "react": "^16.8.1",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "author": "pie framework developers",
20
20
  "license": "ISC",
21
- "gitHead": "b1fff343d21ce4961603c15c842d439dc47139b6",
21
+ "gitHead": "67c7ce92d1e5e2e3bba47606b7004e094caba59e",
22
22
  "scripts": {
23
23
  "postpublish": "../../scripts/postpublish"
24
24
  },
@@ -0,0 +1,81 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`hotspot renders snapshot 1`] = `
4
+ <HotspotComponent
5
+ classes={
6
+ Object {
7
+ "collapsible": "HotspotComponent-collapsible-2",
8
+ "main": "HotspotComponent-main-1",
9
+ "prompt": "HotspotComponent-prompt-3",
10
+ }
11
+ }
12
+ model={
13
+ Object {
14
+ "dimensions": Object {
15
+ "height": 0,
16
+ "width": 0,
17
+ },
18
+ "shapes": Object {
19
+ "circles": Array [],
20
+ "polygons": Array [],
21
+ "rectangles": Array [],
22
+ },
23
+ }
24
+ }
25
+ session={Object {}}
26
+ />
27
+ `;
28
+
29
+ exports[`hotspot renders snapshot with rationale 1`] = `
30
+ <HotspotComponent
31
+ classes={
32
+ Object {
33
+ "collapsible": "HotspotComponent-collapsible-2",
34
+ "main": "HotspotComponent-main-1",
35
+ "prompt": "HotspotComponent-prompt-3",
36
+ }
37
+ }
38
+ model={
39
+ Object {
40
+ "dimensions": Object {
41
+ "height": 0,
42
+ "width": 0,
43
+ },
44
+ "rationale": "This is rationale",
45
+ "shapes": Object {
46
+ "circles": Array [],
47
+ "polygons": Array [],
48
+ "rectangles": Array [],
49
+ },
50
+ }
51
+ }
52
+ session={Object {}}
53
+ />
54
+ `;
55
+
56
+ exports[`hotspot renders snapshot with teacherInstructions 1`] = `
57
+ <HotspotComponent
58
+ classes={
59
+ Object {
60
+ "collapsible": "HotspotComponent-collapsible-2",
61
+ "main": "HotspotComponent-main-1",
62
+ "prompt": "HotspotComponent-prompt-3",
63
+ }
64
+ }
65
+ model={
66
+ Object {
67
+ "dimensions": Object {
68
+ "height": 0,
69
+ "width": 0,
70
+ },
71
+ "shapes": Object {
72
+ "circles": Array [],
73
+ "polygons": Array [],
74
+ "rectangles": Array [],
75
+ },
76
+ "teacherInstructions": "These are teacher instructions",
77
+ }
78
+ }
79
+ session={Object {}}
80
+ />
81
+ `;
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';
4
+ import HotspotComponent from '../hotspot';
5
+ import Hotspot from '../index';
6
+
7
+ jest.mock('@pie-lib/pie-toolbox/math-rendering-accessible', () => ({ renderMath: jest.fn() }));
8
+
9
+ describe('hotspot', () => {
10
+ describe('renders', () => {
11
+ let wrapper = (props) => {
12
+ let defaultProps = {
13
+ model: {
14
+ dimensions: { height: 0, width: 0 },
15
+ shapes: { rectangles: [], polygons: [], circles: [] },
16
+ ...props,
17
+ },
18
+ session: {},
19
+ classes: {},
20
+ };
21
+
22
+ return shallow(<HotspotComponent {...defaultProps} />);
23
+ };
24
+
25
+ it('snapshot', () => {
26
+ const w = wrapper();
27
+ expect(w).toMatchSnapshot();
28
+ });
29
+
30
+ it('snapshot with rationale', () => {
31
+ const w = wrapper({ rationale: 'This is rationale' });
32
+ expect(w).toMatchSnapshot();
33
+ });
34
+
35
+ it('snapshot with teacherInstructions', () => {
36
+ const w = wrapper({ teacherInstructions: 'These are teacher instructions' });
37
+ expect(w).toMatchSnapshot();
38
+ });
39
+ });
40
+
41
+ describe('events', () => {
42
+ describe('model', () => {
43
+ it('dispatches model set event', () => {
44
+ const el = new Hotspot();
45
+ el.tagName = 'hotspot-el';
46
+ el.model = {};
47
+ expect(el.dispatchEvent).toBeCalledWith(new ModelSetEvent('hotspot-el', false, true));
48
+ });
49
+ });
50
+
51
+ describe('onSelectChoice', () => {
52
+ it('dispatches session changed event - add answer', () => {
53
+ const el = new Hotspot();
54
+ el.tagName = 'hotspot-el';
55
+ el.session = { answers: [] };
56
+ el.onSelectChoice({ id: '1', selected: true });
57
+ expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', true));
58
+ });
59
+
60
+ it('dispatches session changed event - remove answer', () => {
61
+ const el = new Hotspot();
62
+ el.tagName = 'hotspot-el';
63
+ el.session = { answers: [{ id: '1' }] };
64
+ el.onSelectChoice({ id: '1', selected: false });
65
+ expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', false));
66
+ });
67
+
68
+ it('dispatches session changed event - add/remove answer', () => {
69
+ const el = new Hotspot();
70
+ el.tagName = 'hotspot-el';
71
+ el.session = { answers: [{ id: '1' }] };
72
+ el.onSelectChoice({ id: '2', selected: true });
73
+ expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', true));
74
+
75
+ el.onSelectChoice({ id: '1', selected: false });
76
+ expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', true));
77
+
78
+ el.onSelectChoice({ id: '2', selected: false });
79
+ expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('hotspot-el', false));
80
+ });
81
+ });
82
+ });
83
+ });
@@ -1,6 +1,6 @@
1
1
  export function updateSessionValue(session, model, data) {
2
2
  const { id, selected } = data;
3
- const { multipleCorrect } = model;
3
+ const { multipleCorrect } = model || {};
4
4
  session.answers = session.answers || [];
5
5
 
6
6
  if (!selected) {