@pie-lib/controller-utils 0.22.3-next.2 → 0.22.3-next.208

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,144 +3,100 @@
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
- ## [0.22.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.22.1...@pie-lib/controller-utils@0.22.2) (2025-11-27)
7
-
8
-
9
- ### Bug Fixes
10
-
11
- * **controller-utils:** update debug PD-5248 ([b238a16](https://github.com/pie-framework/pie-lib/commit/b238a16acf55cc7b9316965a10a27a4f9ab4c220))
6
+ # [1.0.0-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.22.3-next.0...@pie-lib/controller-utils@1.0.0-next.0) (2026-01-19)
12
7
 
8
+ **Note:** Version bump only for package @pie-lib/controller-utils
13
9
 
14
10
 
15
11
 
16
12
 
17
- ## [0.22.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.18.0...@pie-lib/controller-utils@0.22.1) (2025-10-22)
18
13
 
19
- **Note:** Version bump only for package @pie-lib/controller-utils
14
+ ## [0.22.3-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.36.0-mui-update.0...@pie-lib/controller-utils@0.22.3-next.0) (2026-01-19)
20
15
 
21
16
 
17
+ ### Bug Fixes
22
18
 
19
+ * **controller-utils:** update debug PD-5248 ([b238a16](https://github.com/pie-framework/pie-lib/commit/b238a16acf55cc7b9316965a10a27a4f9ab4c220))
23
20
 
24
21
 
25
- # [0.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.21.0...@pie-lib/controller-utils@0.22.0) (2025-10-16)
26
22
 
27
- **Note:** Version bump only for package @pie-lib/controller-utils
28
23
 
29
24
 
25
+ ## [0.22.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.22.1...@pie-lib/controller-utils@0.22.2) (2025-11-27)
30
26
 
27
+ ### Bug Fixes
31
28
 
29
+ - **controller-utils:** update debug PD-5248 ([b238a16](https://github.com/pie-framework/pie-lib/commit/b238a16acf55cc7b9316965a10a27a4f9ab4c220))
32
30
 
33
- # [0.21.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.18.0...@pie-lib/controller-utils@0.21.0) (2025-10-16)
31
+ ## [0.22.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.18.0...@pie-lib/controller-utils@0.22.1) (2025-10-22)
34
32
 
35
33
  **Note:** Version bump only for package @pie-lib/controller-utils
36
34
 
35
+ # [0.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.21.0...@pie-lib/controller-utils@0.22.0) (2025-10-16)
37
36
 
37
+ **Note:** Version bump only for package @pie-lib/controller-utils
38
38
 
39
+ # [0.21.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.18.0...@pie-lib/controller-utils@0.21.0) (2025-10-16)
39
40
 
41
+ **Note:** Version bump only for package @pie-lib/controller-utils
40
42
 
41
43
  # [0.20.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.18.0...@pie-lib/controller-utils@0.20.0) (2025-10-16)
42
44
 
43
45
  **Note:** Version bump only for package @pie-lib/controller-utils
44
46
 
45
-
46
-
47
-
48
-
49
47
  # [0.19.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.18.0...@pie-lib/controller-utils@0.19.0) (2025-10-16)
50
48
 
51
49
  **Note:** Version bump only for package @pie-lib/controller-utils
52
50
 
53
-
54
-
55
-
56
-
57
51
  # [0.18.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.44...@pie-lib/controller-utils@0.18.0) (2025-09-25)
58
52
 
59
-
60
53
  ### Bug Fixes
61
54
 
62
- * fixed pie-lib/icons import [PD-5126] ([dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f))
63
-
55
+ - fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
64
56
 
65
57
  ### Features
66
58
 
67
- * split pie-toolbox into multiple packages [PD-5126] ([7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2))
68
-
69
-
70
-
71
-
59
+ - split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
72
60
 
73
61
  # [0.17.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.16.0...@pie-lib/controller-utils@0.17.0) (2025-09-18)
74
62
 
75
63
  **Note:** Version bump only for package @pie-lib/controller-utils
76
64
 
77
-
78
-
79
-
80
-
81
65
  # [0.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.15.0...@pie-lib/controller-utils@0.16.0) (2025-09-18)
82
66
 
83
67
  **Note:** Version bump only for package @pie-lib/controller-utils
84
68
 
85
-
86
-
87
-
88
-
89
69
  # [0.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.44...@pie-lib/controller-utils@0.15.0) (2025-09-18)
90
70
 
91
-
92
71
  ### Bug Fixes
93
72
 
94
- * fixed pie-lib/icons import [PD-5126] ([dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f))
95
-
73
+ - fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
96
74
 
97
75
  ### Features
98
76
 
99
- * split pie-toolbox into multiple packages [PD-5126] ([7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2))
100
-
101
-
102
-
103
-
77
+ - split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
104
78
 
105
79
  # [0.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.13.0...@pie-lib/controller-utils@0.14.0) (2025-09-17)
106
80
 
107
81
  **Note:** Version bump only for package @pie-lib/controller-utils
108
82
 
109
-
110
-
111
-
112
-
113
83
  # [0.13.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.12.0...@pie-lib/controller-utils@0.13.0) (2025-09-17)
114
84
 
115
85
  **Note:** Version bump only for package @pie-lib/controller-utils
116
86
 
117
-
118
-
119
-
120
-
121
87
  # [0.12.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.11.1...@pie-lib/controller-utils@0.12.0) (2025-09-17)
122
88
 
123
89
  **Note:** Version bump only for package @pie-lib/controller-utils
124
90
 
125
-
126
-
127
-
128
-
129
91
  ## [0.11.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.44...@pie-lib/controller-utils@0.11.1) (2025-08-11)
130
92
 
131
-
132
93
  ### Bug Fixes
133
94
 
134
- * fixed pie-lib/icons import [PD-5126] ([dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f))
135
-
95
+ - fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
136
96
 
137
97
  ### Features
138
98
 
139
- * split pie-toolbox into multiple packages [PD-5126] ([7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2))
140
-
141
-
142
-
143
-
99
+ - split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
144
100
 
145
101
  # [0.11.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.44...@pie-lib/controller-utils@0.11.0) (2025-08-07)
146
102
 
package/lib/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -18,14 +17,8 @@ Object.defineProperty(exports, "lockChoices", {
18
17
  }
19
18
  });
20
19
  exports.partialScoring = void 0;
21
-
22
20
  var partialScoring = _interopRequireWildcard(require("./partial-scoring"));
23
-
24
21
  exports.partialScoring = partialScoring;
25
-
26
22
  var _persistence = require("./persistence");
27
-
28
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
-
30
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
31
24
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;AAEA","sourcesContent":["import * as partialScoring from './partial-scoring';\n\nexport { lockChoices, getShuffledChoices } from './persistence';\nexport { partialScoring };\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["partialScoring","_interopRequireWildcard","require","exports","_persistence","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor"],"sources":["../src/index.js"],"sourcesContent":["import * as partialScoring from './partial-scoring';\n\nexport { lockChoices, getShuffledChoices } from './persistence';\nexport { partialScoring };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAoDC,OAAA,CAAAH,cAAA,GAAAA,cAAA;AAEpD,IAAAI,YAAA,GAAAF,OAAA;AAAgE,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,wBAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAAP,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAM,EAAA,EAAAP,CAAA,IAAAC,CAAA,CAAAM,EAAA,IAAAd,CAAA,CAAAc,EAAA,WAAAN,CAAA,KAAAR,CAAA,EAAAC,CAAA","ignoreList":[]}
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.enabled = void 0;
7
-
8
- var enabled = function enabled(config, env, defaultValue) {
7
+ var enabled = exports.enabled = function enabled(config, env, defaultValue) {
9
8
  // if model.partialScoring = false
10
9
  // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
11
10
  // else if model.partialScoring = true || undefined
@@ -13,17 +12,12 @@ var enabled = function enabled(config, env, defaultValue) {
13
12
  // - else if env.partialScoring = true, use partial scoring
14
13
  config = config || {};
15
14
  env = env || {};
16
-
17
15
  if (config.partialScoring === false) {
18
16
  return false;
19
17
  }
20
-
21
18
  if (env.partialScoring === false) {
22
19
  return false;
23
20
  }
24
-
25
21
  return typeof defaultValue === 'boolean' ? defaultValue : true;
26
22
  };
27
-
28
- exports.enabled = enabled;
29
23
  //# sourceMappingURL=partial-scoring.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/partial-scoring.js"],"names":["enabled","config","env","defaultValue","partialScoring"],"mappings":";;;;;;;AAAO,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,MAAD,EAASC,GAAT,EAAcC,YAAd,EAA+B;AACpD;AACA;AACA;AACA;AACA;AACAF,EAAAA,MAAM,GAAGA,MAAM,IAAI,EAAnB;AACAC,EAAAA,GAAG,GAAGA,GAAG,IAAI,EAAb;;AAEA,MAAID,MAAM,CAACG,cAAP,KAA0B,KAA9B,EAAqC;AACnC,WAAO,KAAP;AACD;;AAED,MAAIF,GAAG,CAACE,cAAJ,KAAuB,KAA3B,EAAkC;AAChC,WAAO,KAAP;AACD;;AAED,SAAO,OAAOD,YAAP,KAAwB,SAAxB,GAAoCA,YAApC,GAAmD,IAA1D;AACD,CAlBM","sourcesContent":["export const enabled = (config, env, defaultValue) => {\n // if model.partialScoring = false\n // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring\n // else if model.partialScoring = true || undefined\n // - if env.partialScoring = false, use dichotomous scoring\n // - else if env.partialScoring = true, use partial scoring\n config = config || {};\n env = env || {};\n\n if (config.partialScoring === false) {\n return false;\n }\n\n if (env.partialScoring === false) {\n return false;\n }\n\n return typeof defaultValue === 'boolean' ? defaultValue : true;\n};\n"],"file":"partial-scoring.js"}
1
+ {"version":3,"file":"partial-scoring.js","names":["enabled","exports","config","env","defaultValue","partialScoring"],"sources":["../src/partial-scoring.js"],"sourcesContent":["export const enabled = (config, env, defaultValue) => {\n // if model.partialScoring = false\n // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring\n // else if model.partialScoring = true || undefined\n // - if env.partialScoring = false, use dichotomous scoring\n // - else if env.partialScoring = true, use partial scoring\n config = config || {};\n env = env || {};\n\n if (config.partialScoring === false) {\n return false;\n }\n\n if (env.partialScoring === false) {\n return false;\n }\n\n return typeof defaultValue === 'boolean' ? defaultValue : true;\n};\n"],"mappings":";;;;;;AAAO,IAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,SAAVA,OAAOA,CAAIE,MAAM,EAAEC,GAAG,EAAEC,YAAY,EAAK;EACpD;EACA;EACA;EACA;EACA;EACAF,MAAM,GAAGA,MAAM,IAAI,CAAC,CAAC;EACrBC,GAAG,GAAGA,GAAG,IAAI,CAAC,CAAC;EAEf,IAAID,MAAM,CAACG,cAAc,KAAK,KAAK,EAAE;IACnC,OAAO,KAAK;EACd;EAEA,IAAIF,GAAG,CAACE,cAAc,KAAK,KAAK,EAAE;IAChC,OAAO,KAAK;EACd;EAEA,OAAO,OAAOD,YAAY,KAAK,SAAS,GAAGA,YAAY,GAAG,IAAI;AAChE,CAAC","ignoreList":[]}
@@ -1,50 +1,36 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.lockChoices = exports.getShuffledChoices = exports.compact = void 0;
9
-
10
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
-
12
9
  var _get = _interopRequireDefault(require("lodash/get"));
13
-
14
10
  var _shuffle = _interopRequireDefault(require("lodash/shuffle"));
15
-
16
11
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
17
-
18
12
  // eslint-disable-next-line no-console
19
13
  var lg = function lg(n) {
20
14
  return console[n].bind(console, 'controller-utils:');
21
15
  };
22
-
23
16
  var debug = lg('debug');
24
17
  var log = lg('log');
25
18
  var warn = lg('warn');
26
19
  var error = lg('error');
27
-
28
- var compact = function compact(arr) {
20
+ var compact = exports.compact = function compact(arr) {
29
21
  if (Array.isArray(arr)) {
30
22
  return arr.filter(function (v) {
31
23
  return v !== null && v !== undefined;
32
24
  });
33
25
  }
34
-
35
26
  return arr;
36
27
  };
37
-
38
- exports.compact = compact;
39
-
40
- var getShuffledChoices = function getShuffledChoices(choices, session, updateSession, choiceKey) {
28
+ var getShuffledChoices = exports.getShuffledChoices = function getShuffledChoices(choices, session, updateSession, choiceKey) {
41
29
  return new Promise(function (resolve) {
42
30
  var _session$data;
43
-
44
31
  log('updateSession type: ', (0, _typeof2["default"])(updateSession));
45
32
  log('session: ', session);
46
- var currentShuffled = compact((session === null || session === void 0 ? void 0 : (_session$data = session.data) === null || _session$data === void 0 ? void 0 : _session$data.shuffledValues) || (session === null || session === void 0 ? void 0 : session.shuffledValues) || []);
47
-
33
+ var currentShuffled = compact((session === null || session === void 0 || (_session$data = session.data) === null || _session$data === void 0 ? void 0 : _session$data.shuffledValues) || (session === null || session === void 0 ? void 0 : session.shuffledValues) || []);
48
34
  if (!session) {
49
35
  // eslint-disable-next-line quotes
50
36
  warn("unable to save shuffled choices because there's no session.");
@@ -58,7 +44,6 @@ var getShuffledChoices = function getShuffledChoices(choices, session, updateSes
58
44
  })));
59
45
  } else {
60
46
  var shuffledChoices = (0, _shuffle["default"])(choices);
61
-
62
47
  if (updateSession && typeof updateSession === 'function') {
63
48
  try {
64
49
  //Note: session.id refers to the id of the element within a session
@@ -67,14 +52,14 @@ var getShuffledChoices = function getShuffledChoices(choices, session, updateSes
67
52
  }));
68
53
  log('try to save shuffledValues to session...', shuffledValues);
69
54
  log('call updateSession... ', session.id, session.element);
70
-
71
55
  if ((0, _isEmpty["default"])(shuffledValues)) {
72
56
  error("shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ".concat(JSON.stringify(shuffledChoices), ", key: ").concat(choiceKey));
73
57
  } else {
74
58
  updateSession(session.id, session.element, {
75
59
  shuffledValues: shuffledValues
76
60
  })["catch"](function (e) {
77
- return (// eslint-disable-next-line no-console
61
+ return (
62
+ // eslint-disable-next-line no-console
78
63
  console.error('update session failed for: ', session.id, e)
79
64
  );
80
65
  });
@@ -85,13 +70,14 @@ var getShuffledChoices = function getShuffledChoices(choices, session, updateSes
85
70
  }
86
71
  } else {
87
72
  warn('unable to save shuffled choices, shuffle will happen every time.');
88
- } //save this shuffle to the session for later retrieval
89
-
73
+ }
90
74
 
75
+ //save this shuffle to the session for later retrieval
91
76
  resolve(shuffledChoices);
92
77
  }
93
78
  });
94
79
  };
80
+
95
81
  /**
96
82
  * If we return:
97
83
  * - true - that means that the order of the choices will be ordinal (as is created in the configure item)
@@ -102,37 +88,26 @@ var getShuffledChoices = function getShuffledChoices(choices, session, updateSes
102
88
  * @param env - env to check if we should lock order
103
89
  * @returns {boolean}
104
90
  */
105
-
106
-
107
- exports.getShuffledChoices = getShuffledChoices;
108
-
109
- var lockChoices = function lockChoices(model, session, env) {
91
+ var lockChoices = exports.lockChoices = function lockChoices(model, session, env) {
110
92
  if (model.lockChoiceOrder) {
111
93
  return true;
112
94
  }
113
-
114
95
  log('lockChoiceOrder: ', (0, _get["default"])(env, ['@pie-element', 'lockChoiceOrder'], false));
115
-
116
96
  if ((0, _get["default"])(env, ['@pie-element', 'lockChoiceOrder'], false)) {
117
97
  return true;
118
98
  }
119
-
120
99
  var role = (0, _get["default"])(env, 'role', 'student');
121
-
122
100
  if (role === 'instructor') {
123
101
  // TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
124
-
125
102
  /*const alreadyShuffled = hasShuffledValues(session);
126
103
  if (alreadyShuffled) {
127
104
  return false;
128
105
  }
129
106
  return true;*/
130
107
  return true;
131
- } // here it's a student, so don't lock and it will shuffle if needs be
132
-
108
+ }
133
109
 
110
+ // here it's a student, so don't lock and it will shuffle if needs be
134
111
  return false;
135
112
  };
136
-
137
- exports.lockChoices = lockChoices;
138
113
  //# sourceMappingURL=persistence.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/persistence.js"],"names":["lg","n","console","bind","debug","log","warn","error","compact","arr","Array","isArray","filter","v","undefined","getShuffledChoices","choices","session","updateSession","choiceKey","Promise","resolve","currentShuffled","data","shuffledValues","map","find","c","shuffledChoices","id","element","JSON","stringify","e","lockChoices","model","env","lockChoiceOrder","role"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;AACA,IAAMA,EAAE,GAAG,SAALA,EAAK,CAACC,CAAD;AAAA,SAAOC,OAAO,CAACD,CAAD,CAAP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,MAuBO;AACL3B,QAAAA,IAAI,CAAC,kEAAD,CAAJ;AACD,OA5BI,CA8BL;;;AACAe,MAAAA,OAAO,CAACO,eAAD,CAAP;AACD;AACF,GA9CD,CADgC;AAAA,CAA3B;AAiDP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,IAAMM,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD,EAAQlB,OAAR,EAAiBmB,GAAjB,EAAyB;AAClD,MAAID,KAAK,CAACE,eAAV,EAA2B;AACzB,WAAO,IAAP;AACD;;AAEDhC,EAAAA,GAAG,CAAC,mBAAD,EAAsB,qBAAI+B,GAAJ,EAAS,CAAC,cAAD,EAAiB,iBAAjB,CAAT,EAA8C,KAA9C,CAAtB,CAAH;;AAEA,MAAI,qBAAIA,GAAJ,EAAS,CAAC,cAAD,EAAiB,iBAAjB,CAAT,EAA8C,KAA9C,CAAJ,EAA0D;AACxD,WAAO,IAAP;AACD;;AAED,MAAME,IAAI,GAAG,qBAAIF,GAAJ,EAAS,MAAT,EAAiB,SAAjB,CAAb;;AAEA,MAAIE,IAAI,KAAK,YAAb,EAA2B;AACzB;;AACA;AACJ;AACA;AACA;AACA;AAGI,WAAO,IAAP;AACD,GAvBiD,CAyBlD;;;AACA,SAAO,KAAP;AACD,CA3BM","sourcesContent":["import get from 'lodash/get';\nimport shuffle from 'lodash/shuffle';\nimport isEmpty from 'lodash/isEmpty';\n\n// eslint-disable-next-line no-console\nconst lg = (n) => console[n].bind(console, 'controller-utils:');\nconst debug = lg('debug');\nconst log = lg('log');\nconst warn = lg('warn');\nconst error = lg('error');\n\nexport const compact = (arr) => {\n if (Array.isArray(arr)) {\n return arr.filter((v) => v !== null && v !== undefined);\n }\n\n return arr;\n};\n\nexport const getShuffledChoices = (choices, session, updateSession, choiceKey) =>\n new Promise((resolve) => {\n log('updateSession type: ', typeof updateSession);\n log('session: ', session);\n\n const currentShuffled = compact(session?.data?.shuffledValues || session?.shuffledValues || []);\n\n if (!session) {\n // eslint-disable-next-line quotes\n warn(\"unable to save shuffled choices because there's no session.\");\n resolve(undefined);\n } else if (!isEmpty(currentShuffled)) {\n debug('use shuffledValues to sort the choices...', currentShuffled);\n resolve(compact(currentShuffled.map((v) => choices.find((c) => c[choiceKey] === v))));\n } else {\n const shuffledChoices = shuffle(choices);\n\n if (updateSession && typeof updateSession === 'function') {\n try {\n //Note: session.id refers to the id of the element within a session\n const shuffledValues = compact(shuffledChoices.map((c) => c[choiceKey]));\n log('try to save shuffledValues to session...', shuffledValues);\n log('call updateSession... ', session.id, session.element);\n\n if (isEmpty(shuffledValues)) {\n error(\n `shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(\n shuffledChoices,\n )}, key: ${choiceKey}`,\n );\n } else {\n updateSession(session.id, session.element, { shuffledValues }).catch((e) =>\n // eslint-disable-next-line no-console\n console.error('update session failed for: ', session.id, e),\n );\n }\n } catch (e) {\n warn('unable to save shuffled order for choices');\n error(e);\n }\n } else {\n warn('unable to save shuffled choices, shuffle will happen every time.');\n }\n\n //save this shuffle to the session for later retrieval\n resolve(shuffledChoices);\n }\n });\n\n/**\n * If we return:\n * - true - that means that the order of the choices will be ordinal (as is created in the configure item)\n * - false - that means the getShuffledChoices above will be called and that in turn means that we either\n * return the shuffled values on the session (if any exists) or we shuffle the choices\n * @param model - model to check if we should lock order\n * @param session - session to check if we should lock order\n * @param env - env to check if we should lock order\n * @returns {boolean}\n */\nexport const lockChoices = (model, session, env) => {\n if (model.lockChoiceOrder) {\n return true;\n }\n\n log('lockChoiceOrder: ', get(env, ['@pie-element', 'lockChoiceOrder'], false));\n\n if (get(env, ['@pie-element', 'lockChoiceOrder'], false)) {\n return true;\n }\n\n const role = get(env, 'role', 'student');\n\n if (role === 'instructor') {\n // TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then\n /*const alreadyShuffled = hasShuffledValues(session);\n\n if (alreadyShuffled) {\n return false;\n }\n\n return true;*/\n return true;\n }\n\n // here it's a student, so don't lock and it will shuffle if needs be\n return false;\n};\n"],"file":"persistence.js"}
1
+ {"version":3,"file":"persistence.js","names":["_get","_interopRequireDefault","require","_shuffle","_isEmpty","lg","n","console","bind","debug","log","warn","error","compact","exports","arr","Array","isArray","filter","v","undefined","getShuffledChoices","choices","session","updateSession","choiceKey","Promise","resolve","_session$data","_typeof2","currentShuffled","data","shuffledValues","isEmpty","map","find","c","shuffledChoices","shuffle","id","element","concat","JSON","stringify","e","lockChoices","model","env","lockChoiceOrder","get","role"],"sources":["../src/persistence.js"],"sourcesContent":["import get from 'lodash/get';\nimport shuffle from 'lodash/shuffle';\nimport isEmpty from 'lodash/isEmpty';\n\n// eslint-disable-next-line no-console\nconst lg = (n) => console[n].bind(console, 'controller-utils:');\nconst debug = lg('debug');\nconst log = lg('log');\nconst warn = lg('warn');\nconst error = lg('error');\n\nexport const compact = (arr) => {\n if (Array.isArray(arr)) {\n return arr.filter((v) => v !== null && v !== undefined);\n }\n\n return arr;\n};\n\nexport const getShuffledChoices = (choices, session, updateSession, choiceKey) =>\n new Promise((resolve) => {\n log('updateSession type: ', typeof updateSession);\n log('session: ', session);\n\n const currentShuffled = compact(session?.data?.shuffledValues || session?.shuffledValues || []);\n\n if (!session) {\n // eslint-disable-next-line quotes\n warn(\"unable to save shuffled choices because there's no session.\");\n resolve(undefined);\n } else if (!isEmpty(currentShuffled)) {\n debug('use shuffledValues to sort the choices...', currentShuffled);\n resolve(compact(currentShuffled.map((v) => choices.find((c) => c[choiceKey] === v))));\n } else {\n const shuffledChoices = shuffle(choices);\n\n if (updateSession && typeof updateSession === 'function') {\n try {\n //Note: session.id refers to the id of the element within a session\n const shuffledValues = compact(shuffledChoices.map((c) => c[choiceKey]));\n log('try to save shuffledValues to session...', shuffledValues);\n log('call updateSession... ', session.id, session.element);\n\n if (isEmpty(shuffledValues)) {\n error(\n `shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(\n shuffledChoices,\n )}, key: ${choiceKey}`,\n );\n } else {\n updateSession(session.id, session.element, { shuffledValues }).catch((e) =>\n // eslint-disable-next-line no-console\n console.error('update session failed for: ', session.id, e),\n );\n }\n } catch (e) {\n warn('unable to save shuffled order for choices');\n error(e);\n }\n } else {\n warn('unable to save shuffled choices, shuffle will happen every time.');\n }\n\n //save this shuffle to the session for later retrieval\n resolve(shuffledChoices);\n }\n });\n\n/**\n * If we return:\n * - true - that means that the order of the choices will be ordinal (as is created in the configure item)\n * - false - that means the getShuffledChoices above will be called and that in turn means that we either\n * return the shuffled values on the session (if any exists) or we shuffle the choices\n * @param model - model to check if we should lock order\n * @param session - session to check if we should lock order\n * @param env - env to check if we should lock order\n * @returns {boolean}\n */\nexport const lockChoices = (model, session, env) => {\n if (model.lockChoiceOrder) {\n return true;\n }\n\n log('lockChoiceOrder: ', get(env, ['@pie-element', 'lockChoiceOrder'], false));\n\n if (get(env, ['@pie-element', 'lockChoiceOrder'], false)) {\n return true;\n }\n\n const role = get(env, 'role', 'student');\n\n if (role === 'instructor') {\n // TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then\n /*const alreadyShuffled = hasShuffledValues(session);\n\n if (alreadyShuffled) {\n return false;\n }\n\n return true;*/\n return true;\n }\n\n // here it's a student, so don't lock and it will shuffle if needs be\n return false;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA;AACA,IAAMG,EAAE,GAAG,SAALA,EAAEA,CAAIC,CAAC;EAAA,OAAKC,OAAO,CAACD,CAAC,CAAC,CAACE,IAAI,CAACD,OAAO,EAAE,mBAAmB,CAAC;AAAA;AAC/D,IAAME,KAAK,GAAGJ,EAAE,CAAC,OAAO,CAAC;AACzB,IAAMK,GAAG,GAAGL,EAAE,CAAC,KAAK,CAAC;AACrB,IAAMM,IAAI,GA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A;AACA;AACO,IAAMQ,WAAW,GAAA/B,OAAA,CAAA+B,WAAA,GAAG,SAAdA,WAAWA,CAAIC,KAAK,EAAEvB,OAAO,EAAEwB,GAAG,EAAK;EAClD,IAAID,KAAK,CAACE,eAAe,EAAE;IACzB,OAAO,IAAI;EACb;EAEAtC,GAAG,CAAC,mBAAmB,EAAE,IAAAuC,eAAG,EAACF,GAAG,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,EAAE,KAAK,CAAC,CAAC;EAE9E,IAAI,IAAAE,eAAG,EAACF,GAAG,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,EAAE,KAAK,CAAC,EAAE;IACxD,OAAO,IAAI;EACb;EAEA,IAAMG,IAAI,GAAG,IAAAD,eAAG,EAACF,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC;EAExC,IAAIG,IAAI,KAAK,YAAY,EAAE;IACzB;IACA;AACJ;AACA;AACA;AACA;IAGI,OAAO,IAAI;EACb;;EAEA;EACA,OAAO,KAAK;AACd,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/controller-utils",
3
- "version": "0.22.3-next.2+9ae1017d",
3
+ "version": "0.22.3-next.208+14442f94",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -14,13 +14,5 @@
14
14
  "scripts": {},
15
15
  "author": "",
16
16
  "license": "ISC",
17
- "gitHead": "9ae1017d80207591d7570de6d6153fa476f3b18b",
18
- "exports": {
19
- ".": {
20
- "require": "./lib/index.js",
21
- "import": "./src/index.js",
22
- "default": "./lib/index.js"
23
- },
24
- "./esm": "./esm/index.js"
25
- }
17
+ "gitHead": "14442f9403cc03107f383dc38850d86933c6ec26"
26
18
  }