@pie-lib/feedback 0.24.2-next.11 → 0.24.2-next.172
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 -55
- package/esm/index.js +15 -25
- package/esm/index.js.map +1 -1
- package/lib/index.js +16 -36
- package/lib/index.js.map +1 -1
- package/package.json +2 -10
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
|
-
|
|
6
|
+
# [1.0.0-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.24.2-next.0...@pie-lib/feedback@1.0.0-next.0) (2026-01-19)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## [0.24.2-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.38.0-mui-update.0...@pie-lib/feedback@0.24.2-next.0) (2026-01-19)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
17
17
|
|
|
@@ -19,117 +19,75 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## [0.24.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.20.0...@pie-lib/feedback@0.24.1) (2025-10-22)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
25
25
|
|
|
26
|
+
# [0.24.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.23.0...@pie-lib/feedback@0.24.0) (2025-10-16)
|
|
26
27
|
|
|
28
|
+
**Note:** Version bump only for package @pie-lib/feedback
|
|
27
29
|
|
|
30
|
+
# [0.23.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.20.0...@pie-lib/feedback@0.23.0) (2025-10-16)
|
|
28
31
|
|
|
32
|
+
**Note:** Version bump only for package @pie-lib/feedback
|
|
29
33
|
|
|
30
34
|
# [0.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.20.0...@pie-lib/feedback@0.22.0) (2025-10-16)
|
|
31
35
|
|
|
32
36
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
38
|
# [0.21.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.20.0...@pie-lib/feedback@0.21.0) (2025-10-16)
|
|
39
39
|
|
|
40
40
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
42
|
# [0.20.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.4.43...@pie-lib/feedback@0.20.0) (2025-09-25)
|
|
47
43
|
|
|
48
|
-
|
|
49
44
|
### Bug Fixes
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
53
47
|
|
|
54
48
|
### Features
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
61
51
|
|
|
62
52
|
# [0.19.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.18.0...@pie-lib/feedback@0.19.0) (2025-09-18)
|
|
63
53
|
|
|
64
54
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
56
|
# [0.18.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.17.0...@pie-lib/feedback@0.18.0) (2025-09-18)
|
|
71
57
|
|
|
72
58
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
73
59
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
60
|
# [0.17.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.4.43...@pie-lib/feedback@0.17.0) (2025-09-18)
|
|
79
61
|
|
|
80
|
-
|
|
81
62
|
### Bug Fixes
|
|
82
63
|
|
|
83
|
-
|
|
84
|
-
|
|
64
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
85
65
|
|
|
86
66
|
### Features
|
|
87
67
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
93
69
|
|
|
94
70
|
# [0.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.15.0...@pie-lib/feedback@0.16.0) (2025-09-17)
|
|
95
71
|
|
|
96
72
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
97
73
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
74
|
# [0.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.14.0...@pie-lib/feedback@0.15.0) (2025-09-17)
|
|
103
75
|
|
|
104
76
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
105
77
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
78
|
# [0.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.13.1...@pie-lib/feedback@0.14.0) (2025-09-17)
|
|
111
79
|
|
|
112
80
|
**Note:** Version bump only for package @pie-lib/feedback
|
|
113
81
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
82
|
## [0.13.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.4.43...@pie-lib/feedback@0.13.1) (2025-08-11)
|
|
119
83
|
|
|
120
|
-
|
|
121
84
|
### Bug Fixes
|
|
122
85
|
|
|
123
|
-
|
|
124
|
-
|
|
86
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
125
87
|
|
|
126
88
|
### Features
|
|
127
89
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
90
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
133
91
|
|
|
134
92
|
# [0.13.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/feedback@0.4.43...@pie-lib/feedback@0.13.0) (2025-08-07)
|
|
135
93
|
|
package/esm/index.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
function _extends() {
|
|
2
|
-
_extends = Object.assign
|
|
3
|
-
for (var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
for (var key in source) {
|
|
7
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
8
|
-
target[key] = source[key];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
2
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
3
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
4
|
+
var t = arguments[e];
|
|
5
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
11
6
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return _extends.apply(this, arguments);
|
|
7
|
+
return n;
|
|
8
|
+
}, _extends.apply(null, arguments);
|
|
17
9
|
}
|
|
18
10
|
|
|
19
11
|
const defaults = {
|
|
@@ -38,6 +30,7 @@ const defaults = {
|
|
|
38
30
|
custom: 'You have not entered a response'
|
|
39
31
|
}
|
|
40
32
|
};
|
|
33
|
+
|
|
41
34
|
/**
|
|
42
35
|
* @typedef {Object} FeedbackConfig
|
|
43
36
|
* @property {'default'|'none'|'custom'} type
|
|
@@ -54,17 +47,15 @@ const normalizeCorrectness = c => {
|
|
|
54
47
|
if (c === 'partially-correct') {
|
|
55
48
|
return 'partial';
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
return c;
|
|
59
51
|
};
|
|
52
|
+
|
|
60
53
|
/**
|
|
61
54
|
* Get the feedback for the correctness
|
|
62
55
|
*
|
|
63
56
|
* @param {'correct'|'incorrect'|'partial'} correctness
|
|
64
57
|
* @param {Feedback} feedback
|
|
65
58
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
59
|
const getFeedbackForCorrectness = (correctness, feedback) => new Promise(resolve => {
|
|
69
60
|
feedback = _extends({}, defaults, feedback);
|
|
70
61
|
correctness = normalizeCorrectness(correctness);
|
|
@@ -72,50 +63,49 @@ const getFeedbackForCorrectness = (correctness, feedback) => new Promise(resolve
|
|
|
72
63
|
const d = defaults[correctness] || {};
|
|
73
64
|
getFeedback(fb, d[fb.type || 'default']).then(result => resolve(result));
|
|
74
65
|
});
|
|
66
|
+
|
|
75
67
|
/**
|
|
76
68
|
* Get the feedback from a {FeedbackConfig}
|
|
77
69
|
*
|
|
78
70
|
* @param {FeedbackConfig} feedback
|
|
79
71
|
* @param {string} fallback
|
|
80
72
|
*/
|
|
81
|
-
|
|
82
73
|
const getFeedback = (feedback, fallback) => new Promise(resolve => {
|
|
83
74
|
if (!feedback || feedback.type === 'none') {
|
|
84
75
|
resolve(undefined);
|
|
85
76
|
return;
|
|
86
77
|
}
|
|
87
|
-
|
|
88
78
|
feedback = feedback || {};
|
|
89
79
|
const out = feedback[feedback.type] || fallback;
|
|
90
80
|
resolve(out);
|
|
91
|
-
});
|
|
81
|
+
});
|
|
92
82
|
|
|
83
|
+
// TODO: should replace getFeedbackForCorrectness
|
|
93
84
|
/**
|
|
94
85
|
* Get feedback for correctness
|
|
95
86
|
* @param {'correct'|'incorrect'|'partial'} correctness
|
|
96
87
|
* @param {Feedback} feedback
|
|
97
88
|
*/
|
|
98
|
-
|
|
99
89
|
const getActualFeedbackForCorrectness = (correctness, feedback) => {
|
|
100
|
-
feedback = _extends({}, defaults, feedback);
|
|
90
|
+
feedback = _extends({}, defaults, feedback);
|
|
101
91
|
|
|
92
|
+
// normalize correctness
|
|
102
93
|
correctness = correctness === 'partially-correct' ? 'partial' : correctness;
|
|
103
94
|
const defaultFeedback = defaults[correctness] || {};
|
|
104
95
|
const fb = feedback[correctness] || defaultFeedback;
|
|
105
96
|
return getActualFeedback(fb, defaultFeedback[fb.type || 'default']);
|
|
106
|
-
};
|
|
97
|
+
};
|
|
107
98
|
|
|
99
|
+
// TODO: should replace getFeedback
|
|
108
100
|
/**
|
|
109
101
|
* Get the feedback from a {FeedbackConfig}
|
|
110
102
|
* @param {FeedbackConfig} feedback
|
|
111
103
|
* @param {string} fallback
|
|
112
104
|
*/
|
|
113
|
-
|
|
114
105
|
const getActualFeedback = (feedback, fallback) => {
|
|
115
106
|
if (!feedback || feedback.type === 'none') {
|
|
116
107
|
return undefined;
|
|
117
108
|
}
|
|
118
|
-
|
|
119
109
|
return feedback[feedback.type] || fallback;
|
|
120
110
|
};
|
|
121
111
|
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["export const defaults = {\n correct: { type: 'default', default: 'Correct', custom: 'Correct' },\n incorrect: { type: 'default', default: 'Incorrect', custom: 'Incorrect' },\n partial: { type: 'default', default: 'Nearly', custom: 'Nearly' },\n unanswered: {\n type: 'default',\n default: 'You have not entered a response',\n custom: 'You have not entered a response',\n },\n};\n\n/**\n * @typedef {Object} FeedbackConfig\n * @property {'default'|'none'|'custom'} type\n * @property {string} default\n * @property {string} custom\n *\n * @typedef {Object} Feedback\n * @property {FeedbackConfig} correct\n * @property {FeedbackConfig} incorrect\n * @property {FeedbackConfig} partial\n */\n\nconst normalizeCorrectness = (c) => {\n if (c === 'partially-correct') {\n return 'partial';\n }\n return c;\n};\n\n/**\n * Get the feedback for the correctness\n *\n * @param {'correct'|'incorrect'|'partial'} correctness\n * @param {Feedback} feedback\n */\nexport const getFeedbackForCorrectness = (correctness, feedback) =>\n new Promise((resolve) => {\n feedback = { ...defaults, ...feedback };\n correctness = normalizeCorrectness(correctness);\n const fb = feedback[correctness] || defaults[correctness] || {};\n const d = defaults[correctness] || {};\n getFeedback(fb, d[fb.type || 'default']).then((result) => resolve(result));\n });\n\n/**\n * Get the feedback from a {FeedbackConfig}\n *\n * @param {FeedbackConfig} feedback\n * @param {string} fallback\n */\nexport const getFeedback = (feedback, fallback) =>\n new Promise((resolve) => {\n if (!feedback || feedback.type === 'none') {\n resolve(undefined);\n return;\n }\n feedback = feedback || {};\n const out = feedback[feedback.type] || fallback;\n resolve(out);\n });\n\n// TODO: should replace getFeedbackForCorrectness\n/**\n * Get feedback for correctness\n * @param {'correct'|'incorrect'|'partial'} correctness\n * @param {Feedback} feedback\n */\nexport const getActualFeedbackForCorrectness = (correctness, feedback) => {\n feedback = { ...defaults, ...feedback };\n\n // normalize correctness\n correctness = correctness === 'partially-correct' ? 'partial' : correctness;\n\n const defaultFeedback = defaults[correctness] || {};\n const fb = feedback[correctness] || defaultFeedback;\n\n return getActualFeedback(fb, defaultFeedback[fb.type || 'default']);\n};\n\n// TODO: should replace getFeedback\n/**\n * Get the feedback from a {FeedbackConfig}\n * @param {FeedbackConfig} feedback\n * @param {string} fallback\n */\nexport const getActualFeedback = (feedback, fallback) => {\n if (!feedback || feedback.type === 'none') {\n return undefined;\n }\n\n return feedback[feedback.type] || fallback;\n};\n"],"names":["defaults","correct","type","default","custom","incorrect","partial","unanswered","normalizeCorrectness","c","getFeedbackForCorrectness","correctness","feedback","Promise","resolve","fb","d","getFeedback","then","result","fallback","undefined","out","getActualFeedbackForCorrectness","defaultFeedback","getActualFeedback"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["export const defaults = {\n correct: { type: 'default', default: 'Correct', custom: 'Correct' },\n incorrect: { type: 'default', default: 'Incorrect', custom: 'Incorrect' },\n partial: { type: 'default', default: 'Nearly', custom: 'Nearly' },\n unanswered: {\n type: 'default',\n default: 'You have not entered a response',\n custom: 'You have not entered a response',\n },\n};\n\n/**\n * @typedef {Object} FeedbackConfig\n * @property {'default'|'none'|'custom'} type\n * @property {string} default\n * @property {string} custom\n *\n * @typedef {Object} Feedback\n * @property {FeedbackConfig} correct\n * @property {FeedbackConfig} incorrect\n * @property {FeedbackConfig} partial\n */\n\nconst normalizeCorrectness = (c) => {\n if (c === 'partially-correct') {\n return 'partial';\n }\n return c;\n};\n\n/**\n * Get the feedback for the correctness\n *\n * @param {'correct'|'incorrect'|'partial'} correctness\n * @param {Feedback} feedback\n */\nexport const getFeedbackForCorrectness = (correctness, feedback) =>\n new Promise((resolve) => {\n feedback = { ...defaults, ...feedback };\n correctness = normalizeCorrectness(correctness);\n const fb = feedback[correctness] || defaults[correctness] || {};\n const d = defaults[correctness] || {};\n getFeedback(fb, d[fb.type || 'default']).then((result) => resolve(result));\n });\n\n/**\n * Get the feedback from a {FeedbackConfig}\n *\n * @param {FeedbackConfig} feedback\n * @param {string} fallback\n */\nexport const getFeedback = (feedback, fallback) =>\n new Promise((resolve) => {\n if (!feedback || feedback.type === 'none') {\n resolve(undefined);\n return;\n }\n feedback = feedback || {};\n const out = feedback[feedback.type] || fallback;\n resolve(out);\n });\n\n// TODO: should replace getFeedbackForCorrectness\n/**\n * Get feedback for correctness\n * @param {'correct'|'incorrect'|'partial'} correctness\n * @param {Feedback} feedback\n */\nexport const getActualFeedbackForCorrectness = (correctness, feedback) => {\n feedback = { ...defaults, ...feedback };\n\n // normalize correctness\n correctness = correctness === 'partially-correct' ? 'partial' : correctness;\n\n const defaultFeedback = defaults[correctness] || {};\n const fb = feedback[correctness] || defaultFeedback;\n\n return getActualFeedback(fb, defaultFeedback[fb.type || 'default']);\n};\n\n// TODO: should replace getFeedback\n/**\n * Get the feedback from a {FeedbackConfig}\n * @param {FeedbackConfig} feedback\n * @param {string} fallback\n */\nexport const getActualFeedback = (feedback, fallback) => {\n if (!feedback || feedback.type === 'none') {\n return undefined;\n }\n\n return feedback[feedback.type] || fallback;\n};\n"],"names":["defaults","correct","type","default","custom","incorrect","partial","unanswered","normalizeCorrectness","c","getFeedbackForCorrectness","correctness","feedback","Promise","resolve","_extends","fb","d","getFeedback","then","result","fallback","undefined","out","getActualFeedbackForCorrectness","defaultFeedback","getActualFeedback"],"mappings":";;;;;;;;;;AAAO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,OAAO,EAAE;AAAEC,IAAAA,IAAI,EAAE,SAAS;AAAEC,IAAAA,OAAO,EAAE,SAAS;AAAEC,IAAAA,MAAM,EAAE;GAAW;AACnEC,EAAAA,SAAS,EAAE;AAAEH,IAAAA,IAAI,EAAE,SAAS;AAAEC,IAAAA,OAAO,EAAE,WAAW;AAAEC,IAAAA,MAAM,EAAE;GAAa;AACzEE,EAAAA,OAAO,EAAE;AAAEJ,IAAAA,IAAI,EAAE,SAAS;AAAEC,IAAAA,OAAO,EAAE,QAAQ;AAAEC,IAAAA,MAAM,EAAE;GAAU;AACjEG,EAAAA,UAAU,EAAE;AACVL,IAAAA,IAAI,EAAE,SAAS;AACfC,IAAAA,OAAO,EAAE,iC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AO,CAACS,GAAG,CAAC;AACd,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;MACaC,+BAA+B,GAAGA,CAACb,WAAW,EAAEC,QAAQ,KAAK;AACxEA,EAAAA,QAAQ,GAAAG,QAAA,CAAA,EAAA,EAAQf,QAAQ,EAAKY,QAAQ,CAAE;;AAEvC;AACAD,EAAAA,WAAW,GAAGA,WAAW,KAAK,mBAAmB,GAAG,SAAS,GAAGA,WAAW;EAE3E,MAAMc,eAAe,GAAGzB,QAAQ,CAACW,WAAW,CAAC,IAAI,EAAE;AACnD,EAAA,MAAMK,EAAE,GAAGJ,QAAQ,CAACD,WAAW,CAAC,IAAIc,eAAe;AAEnD,EAAA,OAAOC,iBAAiB,CAACV,EAAE,EAAES,eAAe,CAACT,EAAE,CAACd,IAAI,IAAI,SAAS,CAAC,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;MACawB,iBAAiB,GAAGA,CAACd,QAAQ,EAAES,QAAQ,KAAK;EACvD,IAAI,CAACT,QAAQ,IAAIA,QAAQ,CAACV,IAAI,KAAK,MAAM,EAAE;AACzC,IAAA,OAAOoB,SAAS;AAClB,EAAA;AAEA,EAAA,OAAOV,QAAQ,CAACA,QAAQ,CAACV,IAAI,CAAC,IAAImB,QAAQ;AAC5C;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
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.getFeedbackForCorrectness = exports.getFeedback = exports.getActualFeedbackForCorrectness = exports.getActualFeedback = exports.defaults = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
|
-
var defaults = {
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
var defaults = exports.defaults = {
|
|
17
12
|
correct: {
|
|
18
13
|
type: 'default',
|
|
19
14
|
"default": 'Correct',
|
|
@@ -35,6 +30,7 @@ var defaults = {
|
|
|
35
30
|
custom: 'You have not entered a response'
|
|
36
31
|
}
|
|
37
32
|
};
|
|
33
|
+
|
|
38
34
|
/**
|
|
39
35
|
* @typedef {Object} FeedbackConfig
|
|
40
36
|
* @property {'default'|'none'|'custom'} type
|
|
@@ -47,24 +43,20 @@ var defaults = {
|
|
|
47
43
|
* @property {FeedbackConfig} partial
|
|
48
44
|
*/
|
|
49
45
|
|
|
50
|
-
exports.defaults = defaults;
|
|
51
|
-
|
|
52
46
|
var normalizeCorrectness = function normalizeCorrectness(c) {
|
|
53
47
|
if (c === 'partially-correct') {
|
|
54
48
|
return 'partial';
|
|
55
49
|
}
|
|
56
|
-
|
|
57
50
|
return c;
|
|
58
51
|
};
|
|
52
|
+
|
|
59
53
|
/**
|
|
60
54
|
* Get the feedback for the correctness
|
|
61
55
|
*
|
|
62
56
|
* @param {'correct'|'incorrect'|'partial'} correctness
|
|
63
57
|
* @param {Feedback} feedback
|
|
64
58
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var getFeedbackForCorrectness = function getFeedbackForCorrectness(correctness, feedback) {
|
|
59
|
+
var getFeedbackForCorrectness = exports.getFeedbackForCorrectness = function getFeedbackForCorrectness(correctness, feedback) {
|
|
68
60
|
return new Promise(function (resolve) {
|
|
69
61
|
feedback = _objectSpread(_objectSpread({}, defaults), feedback);
|
|
70
62
|
correctness = normalizeCorrectness(correctness);
|
|
@@ -75,63 +67,51 @@ var getFeedbackForCorrectness = function getFeedbackForCorrectness(correctness,
|
|
|
75
67
|
});
|
|
76
68
|
});
|
|
77
69
|
};
|
|
70
|
+
|
|
78
71
|
/**
|
|
79
72
|
* Get the feedback from a {FeedbackConfig}
|
|
80
73
|
*
|
|
81
74
|
* @param {FeedbackConfig} feedback
|
|
82
75
|
* @param {string} fallback
|
|
83
76
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
exports.getFeedbackForCorrectness = getFeedbackForCorrectness;
|
|
87
|
-
|
|
88
|
-
var getFeedback = function getFeedback(feedback, fallback) {
|
|
77
|
+
var getFeedback = exports.getFeedback = function getFeedback(feedback, fallback) {
|
|
89
78
|
return new Promise(function (resolve) {
|
|
90
79
|
if (!feedback || feedback.type === 'none') {
|
|
91
80
|
resolve(undefined);
|
|
92
81
|
return;
|
|
93
82
|
}
|
|
94
|
-
|
|
95
83
|
feedback = feedback || {};
|
|
96
84
|
var out = feedback[feedback.type] || fallback;
|
|
97
85
|
resolve(out);
|
|
98
86
|
});
|
|
99
|
-
};
|
|
87
|
+
};
|
|
100
88
|
|
|
89
|
+
// TODO: should replace getFeedbackForCorrectness
|
|
101
90
|
/**
|
|
102
91
|
* Get feedback for correctness
|
|
103
92
|
* @param {'correct'|'incorrect'|'partial'} correctness
|
|
104
93
|
* @param {Feedback} feedback
|
|
105
94
|
*/
|
|
95
|
+
var getActualFeedbackForCorrectness = exports.getActualFeedbackForCorrectness = function getActualFeedbackForCorrectness(correctness, feedback) {
|
|
96
|
+
feedback = _objectSpread(_objectSpread({}, defaults), feedback);
|
|
106
97
|
|
|
107
|
-
|
|
108
|
-
exports.getFeedback = getFeedback;
|
|
109
|
-
|
|
110
|
-
var getActualFeedbackForCorrectness = function getActualFeedbackForCorrectness(correctness, feedback) {
|
|
111
|
-
feedback = _objectSpread(_objectSpread({}, defaults), feedback); // normalize correctness
|
|
112
|
-
|
|
98
|
+
// normalize correctness
|
|
113
99
|
correctness = correctness === 'partially-correct' ? 'partial' : correctness;
|
|
114
100
|
var defaultFeedback = defaults[correctness] || {};
|
|
115
101
|
var fb = feedback[correctness] || defaultFeedback;
|
|
116
102
|
return getActualFeedback(fb, defaultFeedback[fb.type || 'default']);
|
|
117
|
-
};
|
|
103
|
+
};
|
|
118
104
|
|
|
105
|
+
// TODO: should replace getFeedback
|
|
119
106
|
/**
|
|
120
107
|
* Get the feedback from a {FeedbackConfig}
|
|
121
108
|
* @param {FeedbackConfig} feedback
|
|
122
109
|
* @param {string} fallback
|
|
123
110
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
exports.getActualFeedbackForCorrectness = getActualFeedbackForCorrectness;
|
|
127
|
-
|
|
128
|
-
var getActualFeedback = function getActualFeedback(feedback, fallback) {
|
|
111
|
+
var getActualFeedback = exports.getActualFeedback = function getActualFeedback(feedback, fallback) {
|
|
129
112
|
if (!feedback || feedback.type === 'none') {
|
|
130
113
|
return undefined;
|
|
131
114
|
}
|
|
132
|
-
|
|
133
115
|
return feedback[feedback.type] || fallback;
|
|
134
116
|
};
|
|
135
|
-
|
|
136
|
-
exports.getActualFeedback = getActualFeedback;
|
|
137
117
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["defaults","exports","correct","type","custom","incorrect","partial","unanswered","normalizeCorrectness","c","getFeedbackForCorrectness","correctness","feedback","Promise","resolve","_objectSpread","fb","d","getFeedback","then","result","fallback","undefined","out","getActualFeedbackForCorrectness","defaultFeedback","getActualFeedback"],"sources":["../src/index.js"],"sourcesContent":["export const defaults = {\n correct: { type: 'default', default: 'Correct', custom: 'Correct' },\n incorrect: { type: 'default', default: 'Incorrect', custom: 'Incorrect' },\n partial: { type: 'default', default: 'Nearly', custom: 'Nearly' },\n unanswered: {\n type: 'default',\n default: 'You have not entered a response',\n custom: 'You have not entered a response',\n },\n};\n\n/**\n * @typedef {Object} FeedbackConfig\n * @property {'default'|'none'|'custom'} type\n * @property {string} default\n * @property {string} custom\n *\n * @typedef {Object} Feedback\n * @property {FeedbackConfig} correct\n * @property {FeedbackConfig} incorrect\n * @property {FeedbackConfig} partial\n */\n\nconst normalizeCorrectness = (c) => {\n if (c === 'partially-correct') {\n return 'partial';\n }\n return c;\n};\n\n/**\n * Get the feedback for the correctness\n *\n * @param {'correct'|'incorrect'|'partial'} correctness\n * @param {Feedback} feedback\n */\nexport const getFeedbackForCorrectness = (correctness, feedback) =>\n new Promise((resolve) => {\n feedback = { ...defaults, ...feedback };\n correctness = normalizeCorrectness(correctness);\n const fb = feedback[correctness] || defaults[correctness] || {};\n const d = defaults[correctness] || {};\n getFeedback(fb, d[fb.type || 'default']).then((result) => resolve(result));\n });\n\n/**\n * Get the feedback from a {FeedbackConfig}\n *\n * @param {FeedbackConfig} feedback\n * @param {string} fallback\n */\nexport const getFeedback = (feedback, fallback) =>\n new Promise((resolve) => {\n if (!feedback || feedback.type === 'none') {\n resolve(undefined);\n return;\n }\n feedback = feedback || {};\n const out = feedback[feedback.type] || fallback;\n resolve(out);\n });\n\n// TODO: should replace getFeedbackForCorrectness\n/**\n * Get feedback for correctness\n * @param {'correct'|'incorrect'|'partial'} correctness\n * @param {Feedback} feedback\n */\nexport const getActualFeedbackForCorrectness = (correctness, feedback) => {\n feedback = { ...defaults, ...feedback };\n\n // normalize correctness\n correctness = correctness === 'partially-correct' ? 'partial' : correctness;\n\n const defaultFeedback = defaults[correctness] || {};\n const fb = feedback[correctness] || defaultFeedback;\n\n return getActualFeedback(fb, defaultFeedback[fb.type || 'default']);\n};\n\n// TODO: should replace getFeedback\n/**\n * Get the feedback from a {FeedbackConfig}\n * @param {FeedbackConfig} feedback\n * @param {string} fallback\n */\nexport const getActualFeedback = (feedback, fallback) => {\n if (!feedback || feedback.type === 'none') {\n return undefined;\n }\n\n return feedback[feedback.type] || fallback;\n};\n"],"mappings":";;;;;;;;;;AAAO,IAAMA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACtBE,OAAO,EAAE;IAAEC,IAAI,EAAE,SAAS;IAAE,WAAS,SAAS;IAAEC,MAAM,EAAE;EAAU,CAAC;EACnEC,SAAS,EAAE;IAAEF,IAAI,EAAE,SAAS;IAAE,WAAS,WAAW;IAAEC,MAAM,EAAE;EAAY,CAAC;EACzEE,OAAO,EAAE;IAAEH,IAAI,EAAE,SAAS;IAAE,WAAS,QAAQ;IAAEC,MAAM,EAAE;EAAS,CAAC;EACjEG,UAAU,EAAE;IACVJ,IAAI,EAAE,SAAS;IACf,WAAS,iCAAiC;IAC1CC,MAAM,EAAE;EACV;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMI,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAIC,CAAC,EAAK;EAClC,IAAIA,CAAC,KAAK,mBAAmB,EAAE;IAC7B,OAAO,SAAS;EAClB;EACA,OAAOA,CAAC;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,IAAMC,yBAAyB,GAAAT,OAAA,CAAAS,yBAAA,GAAG,SAA5BA,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A,KAAQf,QAAQ,GAAKY,QAAQ,CAAE;;EAEvC;EACAD,WAAW,GAAGA,WAAW,KAAK,mBAAmB,GAAG,SAAS,GAAGA,WAAW;EAE3E,IAAMc,eAAe,GAAGzB,QAAQ,CAACW,WAAW,CAAC,IAAI,CAAC,CAAC;EACnD,IAAMK,EAAE,GAAGJ,QAAQ,CAACD,WAAW,CAAC,IAAIc,eAAe;EAEnD,OAAOC,iBAAiB,CAACV,EAAE,EAAES,eAAe,CAACT,EAAE,CAACb,IAAI,IAAI,SAAS,CAAC,CAAC;AACrE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,IAAMuB,iBAAiB,GAAAzB,OAAA,CAAAyB,iBAAA,GAAG,SAApBA,iBAAiBA,CAAId,QAAQ,EAAES,QAAQ,EAAK;EACvD,IAAI,CAACT,QAAQ,IAAIA,QAAQ,CAACT,IAAI,KAAK,MAAM,EAAE;IACzC,OAAOmB,SAAS;EAClB;EAEA,OAAOV,QAAQ,CAACA,QAAQ,CAACT,IAAI,CAAC,IAAIkB,QAAQ;AAC5C,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/feedback",
|
|
3
|
-
"version": "0.24.2-next.
|
|
3
|
+
"version": "0.24.2-next.172+60a96cde",
|
|
4
4
|
"description": "Feedback utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -10,13 +10,5 @@
|
|
|
10
10
|
"scripts": {},
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
|
-
"gitHead": "
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"require": "./lib/index.js",
|
|
17
|
-
"import": "./src/index.js",
|
|
18
|
-
"default": "./lib/index.js"
|
|
19
|
-
},
|
|
20
|
-
"./esm": "./esm/index.js"
|
|
21
|
-
}
|
|
13
|
+
"gitHead": "60a96cde0ec65f6b1cac0ae329aa33a0abc50d05"
|
|
22
14
|
}
|