@pie-lib/controller-utils 0.2.26 → 0.2.27
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 +13 -122
- package/lib/index.js +9 -5
- package/lib/index.js.map +1 -1
- package/lib/partial-scoring.js +2 -2
- package/lib/partial-scoring.js.map +1 -1
- package/lib/persistence.js +5 -5
- package/lib/persistence.js.map +1 -1
- package/package.json +2 -2
- package/src/persistence.js +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.2.
|
|
6
|
+
## [0.2.27](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.26...@pie-lib/controller-utils@0.2.27) (2022-11-23)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
9
9
|
|
|
@@ -11,241 +11,132 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
## [0.2.
|
|
14
|
+
## [0.2.26](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.24...@pie-lib/controller-utils@0.2.26) (2021-06-25)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
17
17
|
|
|
18
|
+
## [0.2.24](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.23...@pie-lib/controller-utils@0.2.24) (2021-02-15)
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
21
21
|
|
|
22
22
|
## [0.2.23](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.21...@pie-lib/controller-utils@0.2.23) (2021-02-15)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
26
|
## [0.2.21](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.20...@pie-lib/controller-utils@0.2.21) (2020-08-25)
|
|
31
27
|
|
|
32
28
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
30
|
## [0.2.20](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.19...@pie-lib/controller-utils@0.2.20) (2020-08-25)
|
|
39
31
|
|
|
40
32
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
34
|
## [0.2.19](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.18...@pie-lib/controller-utils@0.2.19) (2020-08-11)
|
|
47
35
|
|
|
48
36
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
38
|
## [0.2.18](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.17...@pie-lib/controller-utils@0.2.18) (2020-04-14)
|
|
55
39
|
|
|
56
40
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
57
41
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
42
|
## [0.2.17](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.16...@pie-lib/controller-utils@0.2.17) (2020-04-08)
|
|
63
43
|
|
|
64
44
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
65
45
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
46
|
## [0.2.16](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.15...@pie-lib/controller-utils@0.2.16) (2020-03-31)
|
|
71
47
|
|
|
72
|
-
|
|
73
48
|
### Bug Fixes
|
|
74
49
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
50
|
+
- rm ExportNamespaceSpecifier ([970e2ed](https://github.com/pie-framework/pie-lib/commit/970e2ed))
|
|
80
51
|
|
|
81
52
|
## [0.2.15](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.14...@pie-lib/controller-utils@0.2.15) (2020-03-31)
|
|
82
53
|
|
|
83
54
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
84
55
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
56
|
## [0.2.14](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.13...@pie-lib/controller-utils@0.2.14) (2020-03-31)
|
|
90
57
|
|
|
91
58
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
92
59
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
60
|
## [0.2.13](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.12...@pie-lib/controller-utils@0.2.13) (2020-03-30)
|
|
98
61
|
|
|
99
62
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
100
63
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
64
|
## [0.2.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.11...@pie-lib/controller-utils@0.2.12) (2020-03-30)
|
|
106
65
|
|
|
107
66
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
108
67
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
68
|
## [0.2.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.10...@pie-lib/controller-utils@0.2.11) (2020-03-30)
|
|
114
69
|
|
|
115
70
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
116
71
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
72
|
## [0.2.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.9...@pie-lib/controller-utils@0.2.10) (2020-03-30)
|
|
122
73
|
|
|
123
74
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
124
75
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
76
|
## [0.2.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.8...@pie-lib/controller-utils@0.2.9) (2020-03-30)
|
|
130
77
|
|
|
131
78
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
132
79
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
80
|
## [0.2.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.7...@pie-lib/controller-utils@0.2.8) (2020-03-30)
|
|
138
81
|
|
|
139
82
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
140
83
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
84
|
## [0.2.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.6...@pie-lib/controller-utils@0.2.7) (2020-03-30)
|
|
146
85
|
|
|
147
|
-
|
|
148
86
|
### Bug Fixes
|
|
149
87
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
88
|
+
- add module prop to package.json ([694b106](https://github.com/pie-framework/pie-lib/commit/694b106))
|
|
155
89
|
|
|
156
90
|
## [0.2.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.5...@pie-lib/controller-utils@0.2.6) (2020-03-29)
|
|
157
91
|
|
|
158
|
-
|
|
159
92
|
### Bug Fixes
|
|
160
93
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
94
|
+
- add module prop to package.json ([8a1b445](https://github.com/pie-framework/pie-lib/commit/8a1b445))
|
|
166
95
|
|
|
167
96
|
## [0.2.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.4...@pie-lib/controller-utils@0.2.5) (2020-01-27)
|
|
168
97
|
|
|
169
98
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
170
99
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
100
|
## [0.2.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.3...@pie-lib/controller-utils@0.2.4) (2020-01-16)
|
|
176
101
|
|
|
177
|
-
|
|
178
102
|
### Bug Fixes
|
|
179
103
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
104
|
+
- Updated using the given documentation. ([14c7b98](https://github.com/pie-framework/pie-lib/commit/14c7b98))
|
|
185
105
|
|
|
186
106
|
## [0.2.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.2...@pie-lib/controller-utils@0.2.3) (2019-11-18)
|
|
187
107
|
|
|
188
|
-
|
|
189
108
|
### Bug Fixes
|
|
190
109
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
110
|
+
- allow number 0 to be used as value in shuffledValues ([874127c](https://github.com/pie-framework/pie-lib/commit/874127c))
|
|
196
111
|
|
|
197
112
|
## [0.2.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.1...@pie-lib/controller-utils@0.2.2) (2019-10-15)
|
|
198
113
|
|
|
199
|
-
|
|
200
114
|
### Bug Fixes
|
|
201
115
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
116
|
+
- rm async ([3e96db3](https://github.com/pie-framework/pie-lib/commit/3e96db3))
|
|
207
117
|
|
|
208
118
|
## [0.2.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.2.0...@pie-lib/controller-utils@0.2.1) (2019-10-10)
|
|
209
119
|
|
|
210
|
-
|
|
211
120
|
### Bug Fixes
|
|
212
121
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
122
|
+
- fix handling and saving of bad shuffled values [ch4723](<[186ff87](https://github.com/pie-framework/pie-lib/commit/186ff87)>)
|
|
218
123
|
|
|
219
124
|
# [0.2.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.1.2...@pie-lib/controller-utils@0.2.0) (2019-08-30)
|
|
220
125
|
|
|
221
|
-
|
|
222
126
|
### Features
|
|
223
127
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
128
|
+
- implement a shuffle/persistence reusable method ([33cc7f3](https://github.com/pie-framework/pie-lib/commit/33cc7f3))
|
|
229
129
|
|
|
230
130
|
## [0.1.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.1.1...@pie-lib/controller-utils@0.1.2) (2019-04-05)
|
|
231
131
|
|
|
232
132
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
233
133
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
134
|
## [0.1.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.1.0...@pie-lib/controller-utils@0.1.1) (2019-04-04)
|
|
239
135
|
|
|
240
136
|
**Note:** Version bump only for package @pie-lib/controller-utils
|
|
241
137
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
138
|
# 0.1.0 (2019-04-02)
|
|
247
139
|
|
|
248
|
-
|
|
249
140
|
### Features
|
|
250
141
|
|
|
251
|
-
|
|
142
|
+
- new package controller-utils ([0994a4b](https://github.com/pie-framework/pie-lib/commit/0994a4b))
|
package/lib/index.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "getShuffledChoices", {
|
|
7
9
|
enumerable: true,
|
|
8
10
|
get: function get() {
|
|
9
|
-
return _persistence.
|
|
11
|
+
return _persistence.getShuffledChoices;
|
|
10
12
|
}
|
|
11
13
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "lockChoices", {
|
|
13
15
|
enumerable: true,
|
|
14
16
|
get: function get() {
|
|
15
|
-
return _persistence.
|
|
17
|
+
return _persistence.lockChoices;
|
|
16
18
|
}
|
|
17
19
|
});
|
|
18
20
|
exports.partialScoring = void 0;
|
|
@@ -23,5 +25,7 @@ exports.partialScoring = partialScoring;
|
|
|
23
25
|
|
|
24
26
|
var _persistence = require("./persistence");
|
|
25
27
|
|
|
26
|
-
function
|
|
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; }
|
|
27
31
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA","sourcesContent":["import * as partialScoring from './partial-scoring';\nexport { lockChoices, getShuffledChoices } from './persistence';\nexport { partialScoring };\n"],"file":"index.js"}
|
package/lib/partial-scoring.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,8 +9,6 @@ exports.enabled = void 0;
|
|
|
7
9
|
|
|
8
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
11
|
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
12
|
var enabled = function enabled(config, env, defaultValue) {
|
|
13
13
|
// if model.partialScoring = false
|
|
14
14
|
// - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/partial-scoring.js"],"names":["enabled","config","env","defaultValue","partialScoring","_","isBoolean"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/partial-scoring.js"],"names":["enabled","config","env","defaultValue","partialScoring","_","isBoolean"],"mappings":";;;;;;;;;AAAA;;AAEO,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,SAAOC,mBAAEC,SAAF,CAAYH,YAAZ,IAA4BA,YAA5B,GAA2C,IAAlD;AACD,CAlBM","sourcesContent":["import _ from 'lodash';\n\nexport 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 _.isBoolean(defaultValue) ? defaultValue : true;\n};\n"],"file":"partial-scoring.js"}
|
package/lib/persistence.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.lockChoices = exports.getShuffledChoices = exports.compact = void 0;
|
|
7
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
8
12
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
9
13
|
|
|
10
14
|
var _shuffle = _interopRequireDefault(require("lodash/shuffle"));
|
|
@@ -15,10 +19,6 @@ var _isNull = _interopRequireDefault(require("lodash/isNull"));
|
|
|
15
19
|
|
|
16
20
|
var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
|
|
17
21
|
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
21
|
-
|
|
22
22
|
// eslint-disable-next-line no-console
|
|
23
23
|
var lg = function lg(n) {
|
|
24
24
|
return console[n].bind(console, 'controller-utils:');
|
|
@@ -43,7 +43,7 @@ exports.compact = compact;
|
|
|
43
43
|
|
|
44
44
|
var getShuffledChoices = function getShuffledChoices(choices, session, updateSession, choiceKey) {
|
|
45
45
|
return new Promise(function (resolve) {
|
|
46
|
-
log('updateSession type: ',
|
|
46
|
+
log('updateSession type: ', (0, _typeof2["default"])(updateSession));
|
|
47
47
|
log('session: ', session);
|
|
48
48
|
var currentShuffled = compact((session || {}).shuffledValues);
|
|
49
49
|
|
package/lib/persistence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/persistence.js"],"names":["lg","n","console","bind","debug","log","warn","error","compact","arr","Array","isArray","filter","v","getShuffledChoices","choices","session","updateSession","choiceKey","Promise","resolve","currentShuffled","shuffledValues","undefined","map","find","c","shuffledChoices","id","element","JSON","stringify","e","hasShuffledValues","s","lockChoices","model","env","lockChoiceOrder","role"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/persistence.js"],"names":["lg","n","console","bind","debug","log","warn","error","compact","arr","Array","isArray","filter","v","getShuffledChoices","choices","session","updateSession","choiceKey","Promise","resolve","currentShuffled","shuffledValues","undefined","map","find","c","shuffledChoices","id","element","JSON","stringify","e","hasShuffledValues","s","lockChoices","model","env","lockChoiceOrder","role"],"mappings":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,CAACyB,CAAD,CAAL;AACD;AACF,OAtBD,MAsBO;AACL1B,QAAAA,IAAI,CAAC,kEAAD,CAAJ;AACD,OA3BI,CA4BL;;;AACAc,MAAAA,OAAO,CAACO,eAAD,CAAP;AACD;AACF,GA5CD,CADgC;AAAA,CAA3B;;;;AA+CP,IAAMM,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,CAAD;AAAA,SAAO,CAAC,CAAC,CAACA,CAAC,IAAI,EAAN,EAAUZ,cAAnB;AAAA,CAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,IAAMa,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD,EAAQpB,OAAR,EAAiBqB,GAAjB,EAAyB;AAClD,MAAID,KAAK,CAACE,eAAV,EAA2B;AACzB,WAAO,IAAP;AACD;;AAEDjC,EAAAA,GAAG,CAAC,mBAAD,EAAsB,qBAAIgC,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';\nimport isNull from 'lodash/isNull';\nimport isUndefined from 'lodash/isUndefined';\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) => !isNull(v) && !isUndefined(v));\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 || {}).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...', session.shuffledValues);\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 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 //save this shuffle to the session for later retrieval\n resolve(shuffledChoices);\n }\n });\n\nconst hasShuffledValues = (s) => !!(s || {}).shuffledValues;\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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/controller-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"scripts": {},
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "f81076118e63884db5f5d65a41cff9aad111137e"
|
|
18
18
|
}
|
package/src/persistence.js
CHANGED
|
@@ -5,21 +5,21 @@ import isNull from 'lodash/isNull';
|
|
|
5
5
|
import isUndefined from 'lodash/isUndefined';
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line no-console
|
|
8
|
-
const lg = n => console[n].bind(console, 'controller-utils:');
|
|
8
|
+
const lg = (n) => console[n].bind(console, 'controller-utils:');
|
|
9
9
|
const debug = lg('debug');
|
|
10
10
|
const log = lg('log');
|
|
11
11
|
const warn = lg('warn');
|
|
12
12
|
const error = lg('error');
|
|
13
13
|
|
|
14
|
-
export const compact = arr => {
|
|
14
|
+
export const compact = (arr) => {
|
|
15
15
|
if (Array.isArray(arr)) {
|
|
16
|
-
return arr.filter(v => !isNull(v) && !isUndefined(v));
|
|
16
|
+
return arr.filter((v) => !isNull(v) && !isUndefined(v));
|
|
17
17
|
}
|
|
18
18
|
return arr;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export const getShuffledChoices = (choices, session, updateSession, choiceKey) =>
|
|
22
|
-
new Promise(resolve => {
|
|
22
|
+
new Promise((resolve) => {
|
|
23
23
|
log('updateSession type: ', typeof updateSession);
|
|
24
24
|
log('session: ', session);
|
|
25
25
|
|
|
@@ -31,26 +31,26 @@ export const getShuffledChoices = (choices, session, updateSession, choiceKey) =
|
|
|
31
31
|
resolve(undefined);
|
|
32
32
|
} else if (!isEmpty(currentShuffled)) {
|
|
33
33
|
debug('use shuffledValues to sort the choices...', session.shuffledValues);
|
|
34
|
-
resolve(compact(currentShuffled.map(v => choices.find(c => c[choiceKey] === v))));
|
|
34
|
+
resolve(compact(currentShuffled.map((v) => choices.find((c) => c[choiceKey] === v))));
|
|
35
35
|
} else {
|
|
36
36
|
const shuffledChoices = shuffle(choices);
|
|
37
37
|
|
|
38
38
|
if (updateSession && typeof updateSession === 'function') {
|
|
39
39
|
try {
|
|
40
40
|
//Note: session.id refers to the id of the element within a session
|
|
41
|
-
const shuffledValues = compact(shuffledChoices.map(c => c[choiceKey]));
|
|
41
|
+
const shuffledValues = compact(shuffledChoices.map((c) => c[choiceKey]));
|
|
42
42
|
log('try to save shuffledValues to session...', shuffledValues);
|
|
43
43
|
log('call updateSession... ', session.id, session.element);
|
|
44
44
|
if (isEmpty(shuffledValues)) {
|
|
45
45
|
error(
|
|
46
46
|
`shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(
|
|
47
|
-
shuffledChoices
|
|
48
|
-
)}, key: ${choiceKey}
|
|
47
|
+
shuffledChoices,
|
|
48
|
+
)}, key: ${choiceKey}`,
|
|
49
49
|
);
|
|
50
50
|
} else {
|
|
51
|
-
updateSession(session.id, session.element, { shuffledValues }).catch(e =>
|
|
51
|
+
updateSession(session.id, session.element, { shuffledValues }).catch((e) =>
|
|
52
52
|
// eslint-disable-next-line no-console
|
|
53
|
-
console.error('update session failed for: ', session.id, e)
|
|
53
|
+
console.error('update session failed for: ', session.id, e),
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
} catch (e) {
|
|
@@ -65,7 +65,7 @@ export const getShuffledChoices = (choices, session, updateSession, choiceKey) =
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
const hasShuffledValues = s => !!(s || {}).shuffledValues;
|
|
68
|
+
const hasShuffledValues = (s) => !!(s || {}).shuffledValues;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* If we return:
|