@pie-lib/controller-utils 0.29.1-mui-update.0 → 0.31.0-mui-update.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,55 +3,29 @@
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.29.1-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.29.0-mui-update.0...@pie-lib/controller-utils@0.29.1-mui-update.0) (2025-11-20)
7
-
8
- **Note:** Version bump only for package @pie-lib/controller-utils
9
-
10
-
11
-
12
-
13
-
14
- # [0.29.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.28.0-mui-update.0...@pie-lib/controller-utils@0.29.0-mui-update.0) (2025-11-20)
15
-
16
- **Note:** Version bump only for package @pie-lib/controller-utils
17
-
18
-
19
-
20
-
21
-
22
- # [0.28.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.27.0-mui-update.0...@pie-lib/controller-utils@0.28.0-mui-update.0) (2025-11-20)
23
-
24
- **Note:** Version bump only for package @pie-lib/controller-utils
25
-
26
-
27
-
28
-
29
-
30
- # [0.27.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.26.0-mui-update.0...@pie-lib/controller-utils@0.27.0-mui-update.0) (2025-11-19)
31
-
32
- **Note:** Version bump only for package @pie-lib/controller-utils
6
+ # [0.31.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.30.0-mui-update.0...@pie-lib/controller-utils@0.31.0-mui-update.0) (2025-12-02)
33
7
 
34
8
 
9
+ ### Features
35
10
 
11
+ * sync latest changes from dev ([c936e9c](https://github.com/pie-framework/pie-lib/commit/c936e9c7f9e095e7d9b9805ac2bf72bd271e05f1))
36
12
 
37
13
 
38
- # [0.26.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.25.0-mui-update.0...@pie-lib/controller-utils@0.26.0-mui-update.0) (2025-11-18)
39
14
 
40
- **Note:** Version bump only for package @pie-lib/controller-utils
41
15
 
42
16
 
17
+ ## [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)
43
18
 
44
19
 
20
+ ### Bug Fixes
45
21
 
46
- # [0.25.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.24.0-mui-update.0...@pie-lib/controller-utils@0.25.0-mui-update.0) (2025-11-18)
47
-
48
- **Note:** Version bump only for package @pie-lib/controller-utils
22
+ * **controller-utils:** update debug PD-5248 ([b238a16](https://github.com/pie-framework/pie-lib/commit/b238a16acf55cc7b9316965a10a27a4f9ab4c220))
49
23
 
50
24
 
51
25
 
52
26
 
53
27
 
54
- # [0.24.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.23.0-mui-update.0...@pie-lib/controller-utils@0.24.0-mui-update.0) (2025-11-17)
28
+ ## [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)
55
29
 
56
30
  **Note:** Version bump only for package @pie-lib/controller-utils
57
31
 
@@ -59,7 +33,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
59
33
 
60
34
 
61
35
 
62
- # [0.23.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.22.0-mui-update.0...@pie-lib/controller-utils@0.23.0-mui-update.0) (2025-11-05)
36
+ # [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)
63
37
 
64
38
  **Note:** Version bump only for package @pie-lib/controller-utils
65
39
 
@@ -67,7 +41,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
67
41
 
68
42
 
69
43
 
70
- # [0.22.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.21.0-mui-update.0...@pie-lib/controller-utils@0.22.0-mui-update.0) (2025-11-03)
44
+ # [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)
71
45
 
72
46
  **Note:** Version bump only for package @pie-lib/controller-utils
73
47
 
@@ -75,7 +49,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
75
49
 
76
50
 
77
51
 
78
- # [0.21.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.19.0-mui-update.0...@pie-lib/controller-utils@0.21.0-mui-update.0) (2025-11-03)
52
+ # [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)
79
53
 
80
54
  **Note:** Version bump only for package @pie-lib/controller-utils
81
55
 
@@ -83,7 +57,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
83
57
 
84
58
 
85
59
 
86
- # [0.19.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/controller-utils@0.18.0...@pie-lib/controller-utils@0.19.0-mui-update.0) (2025-10-31)
60
+ # [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)
87
61
 
88
62
  **Note:** Version bump only for package @pie-lib/controller-utils
89
63
 
@@ -36,8 +36,7 @@ var getShuffledChoices = exports.getShuffledChoices = function getShuffledChoice
36
36
  warn("unable to save shuffled choices because there's no session.");
37
37
  resolve(undefined);
38
38
  } else if (!(0, _isEmpty["default"])(currentShuffled)) {
39
- var _session$data2;
40
- debug('use shuffledValues to sort the choices...', (_session$data2 = session.data) === null || _session$data2 === void 0 ? void 0 : _session$data2.shuffledValues);
39
+ debug('use shuffledValues to sort the choices...', currentShuffled);
41
40
  resolve(compact(currentShuffled.map(function (v) {
42
41
  return choices.find(function (c) {
43
42
  return c[choiceKey] === v;
@@ -72,6 +71,7 @@ var getShuffledChoices = exports.getShuffledChoices = function getShuffledChoice
72
71
  } else {
73
72
  warn('unable to save shuffled choices, shuffle will happen every time.');
74
73
  }
74
+
75
75
  //save this shuffle to the session for later retrieval
76
76
  resolve(shuffledChoices);
77
77
  }
@@ -1 +1 @@
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","_session$data2","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 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...', session.data?.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\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,G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AACiB,EAAE,EAAEK,CAAC;cAAC;YAAA,CAC7D,CAAC;UACH;QACF,CAAC,CAAC,OAAOA,CAAC,EAAE;UACVlC,IAAI,CAAC,2CAA2C,CAAC;UACjDC,KAAK,CAACiC,CAAC,CAAC;QACV;MACF,CAAC,MAAM;QACLlC,IAAI,CAAC,kEAAkE,CAAC;MAC1E;MACA;MACAgB,OAAO,CAACW,eAAe,CAAC;IAC1B;EACF,CAAC,CAAC;AAAA;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMQ,WAAW,GAAAhC,OAAA,CAAAgC,WAAA,GAAG,SAAdA,WAAWA,CAAIC,KAAK,EAAExB,OAAO,EAAEyB,GAAG,EAAK;EAClD,IAAID,KAAK,CAACE,eAAe,EAAE;IACzB,OAAO,IAAI;EACb;EAEAvC,GAAG,CAAC,mBAAmB,EAAE,IAAAwC,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":[]}
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,GAAGN,EAAE,CAAC,MAAM,CAAC;AACvB,IAAMO,KAAK,GAAGP,EAAE,CAAC,OAAO,CAAC;AAElB,IAAMQ,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,SAAVA,OAAOA,CAAIE,GAAG,EAAK;EAC9B,IAAIC,KAAK,CAACC,OAAO,CAACF,GAAG,CAAC,EAAE;IACtB,OAAOA,GAAG,CAACG,MAAM,CAAC,UAACC,CAAC;MAAA,OAAKA,CAAC,KAAK,IAAI,IAAIA,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9E,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.29.1-mui-update.0",
3
+ "version": "0.31.0-mui-update.0",
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": "5483c45ebef918678f098167fecdde7190b291dd"
17
+ "gitHead": "23a7cb8864b947778ac7e6dffdc6fa4a74af5927"
18
18
  }
@@ -13,6 +13,7 @@ export const compact = (arr) => {
13
13
  if (Array.isArray(arr)) {
14
14
  return arr.filter((v) => v !== null && v !== undefined);
15
15
  }
16
+
16
17
  return arr;
17
18
  };
18
19
 
@@ -28,7 +29,7 @@ export const getShuffledChoices = (choices, session, updateSession, choiceKey) =
28
29
  warn("unable to save shuffled choices because there's no session.");
29
30
  resolve(undefined);
30
31
  } else if (!isEmpty(currentShuffled)) {
31
- debug('use shuffledValues to sort the choices...', session.data?.shuffledValues);
32
+ debug('use shuffledValues to sort the choices...', currentShuffled);
32
33
  resolve(compact(currentShuffled.map((v) => choices.find((c) => c[choiceKey] === v))));
33
34
  } else {
34
35
  const shuffledChoices = shuffle(choices);
@@ -39,6 +40,7 @@ export const getShuffledChoices = (choices, session, updateSession, choiceKey) =
39
40
  const shuffledValues = compact(shuffledChoices.map((c) => c[choiceKey]));
40
41
  log('try to save shuffledValues to session...', shuffledValues);
41
42
  log('call updateSession... ', session.id, session.element);
43
+
42
44
  if (isEmpty(shuffledValues)) {
43
45
  error(
44
46
  `shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(
@@ -58,6 +60,7 @@ export const getShuffledChoices = (choices, session, updateSession, choiceKey) =
58
60
  } else {
59
61
  warn('unable to save shuffled choices, shuffle will happen every time.');
60
62
  }
63
+
61
64
  //save this shuffle to the session for later retrieval
62
65
  resolve(shuffledChoices);
63
66
  }