@pie-element/select-text 11.0.1 → 11.0.2-esm.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.
@@ -972,17 +972,47 @@ function isEmpty(value) {
972
972
 
973
973
  var isEmpty_1 = isEmpty;
974
974
 
975
- const defaults$1 = {
976
- correct: { type: 'default', default: 'Correct', custom: 'Correct' },
977
- incorrect: { type: 'default', default: 'Incorrect', custom: 'Incorrect' },
978
- partial: { type: 'default', default: 'Nearly', custom: 'Nearly' },
975
+ function _defineProperty(obj, key, value) {
976
+ if (key in obj) {
977
+ Object.defineProperty(obj, key, {
978
+ value: value,
979
+ enumerable: true,
980
+ configurable: true,
981
+ writable: true
982
+ });
983
+ } else {
984
+ obj[key] = value;
985
+ }
986
+
987
+ return obj;
988
+ }
989
+
990
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
991
+
992
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).forEach(function (key) { _defineProperty(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; }
993
+
994
+ var defaults$1 = {
995
+ correct: {
996
+ type: 'default',
997
+ default: 'Correct',
998
+ custom: 'Correct'
999
+ },
1000
+ incorrect: {
1001
+ type: 'default',
1002
+ default: 'Incorrect',
1003
+ custom: 'Incorrect'
1004
+ },
1005
+ partial: {
1006
+ type: 'default',
1007
+ default: 'Nearly',
1008
+ custom: 'Nearly'
1009
+ },
979
1010
  unanswered: {
980
1011
  type: 'default',
981
1012
  default: 'You have not entered a response',
982
- custom: 'You have not entered a response',
983
- },
1013
+ custom: 'You have not entered a response'
1014
+ }
984
1015
  };
985
-
986
1016
  /**
987
1017
  * @typedef {Object} FeedbackConfig
988
1018
  * @property {'default'|'none'|'custom'} type
@@ -995,64 +1025,45 @@ const defaults$1 = {
995
1025
  * @property {FeedbackConfig} partial
996
1026
  */
997
1027
 
998
- const normalizeCorrectness = (c) => {
1028
+ var normalizeCorrectness = c => {
999
1029
  if (c === 'partially-correct') {
1000
1030
  return 'partial';
1001
1031
  }
1032
+
1002
1033
  return c;
1003
1034
  };
1004
-
1005
1035
  /**
1006
1036
  * Get the feedback for the correctness
1007
1037
  *
1008
1038
  * @param {'correct'|'incorrect'|'partial'} correctness
1009
1039
  * @param {Feedback} feedback
1010
1040
  */
1011
- const getFeedbackForCorrectness = (correctness, feedback) =>
1012
- new Promise((resolve) => {
1013
- feedback = { ...defaults$1, ...feedback };
1014
- correctness = normalizeCorrectness(correctness);
1015
- const fb = feedback[correctness] || defaults$1[correctness] || {};
1016
- const d = defaults$1[correctness] || {};
1017
- getFeedback(fb, d[fb.type || 'default']).then((result) => resolve(result));
1018
- });
1019
1041
 
1042
+
1043
+ var getFeedbackForCorrectness = (correctness, feedback) => new Promise(resolve => {
1044
+ feedback = _objectSpread(_objectSpread({}, defaults$1), feedback);
1045
+ correctness = normalizeCorrectness(correctness);
1046
+ var fb = feedback[correctness] || defaults$1[correctness] || {};
1047
+ var d = defaults$1[correctness] || {};
1048
+ getFeedback(fb, d[fb.type || 'default']).then(result => resolve(result));
1049
+ });
1020
1050
  /**
1021
1051
  * Get the feedback from a {FeedbackConfig}
1022
1052
  *
1023
1053
  * @param {FeedbackConfig} feedback
1024
1054
  * @param {string} fallback
1025
1055
  */
1026
- const getFeedback = (feedback, fallback) =>
1027
- new Promise((resolve) => {
1028
- if (!feedback || feedback.type === 'none') {
1029
- resolve(undefined);
1030
- return;
1031
- }
1032
- feedback = feedback || {};
1033
- const out = feedback[feedback.type] || fallback;
1034
- resolve(out);
1035
- });
1036
-
1037
- const enabled = (config, env, defaultValue) => {
1038
- // if model.partialScoring = false
1039
- // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
1040
- // else if model.partialScoring = true || undefined
1041
- // - if env.partialScoring = false, use dichotomous scoring
1042
- // - else if env.partialScoring = true, use partial scoring
1043
- config = config || {};
1044
- env = env || {};
1045
-
1046
- if (config.partialScoring === false) {
1047
- return false;
1048
- }
1049
1056
 
1050
- if (env.partialScoring === false) {
1051
- return false;
1057
+ var getFeedback = (feedback, fallback) => new Promise(resolve => {
1058
+ if (!feedback || feedback.type === 'none') {
1059
+ resolve(undefined);
1060
+ return;
1052
1061
  }
1053
1062
 
1054
- return typeof defaultValue === 'boolean' ? defaultValue : true;
1055
- };
1063
+ feedback = feedback || {};
1064
+ var out = feedback[feedback.type] || fallback;
1065
+ resolve(out);
1066
+ }); // TODO: should replace getFeedbackForCorrectness
1056
1067
 
1057
1068
  var getNative = _getNative;
1058
1069
 
@@ -1717,8 +1728,33 @@ var Symbol = _Symbol;
1717
1728
  var symbolProto = Symbol ? Symbol.prototype : undefined;
1718
1729
  symbolProto ? symbolProto.toString : undefined;
1719
1730
 
1720
- // eslint-disable-next-line no-console
1721
- const lg = (n) => console[n].bind(console, 'controller-utils:');
1731
+ var enabled = (config, env, defaultValue) => {
1732
+ // if model.partialScoring = false
1733
+ // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
1734
+ // else if model.partialScoring = true || undefined
1735
+ // - if env.partialScoring = false, use dichotomous scoring
1736
+ // - else if env.partialScoring = true, use partial scoring
1737
+ config = config || {};
1738
+ env = env || {};
1739
+
1740
+ if (config.partialScoring === false) {
1741
+ return false;
1742
+ }
1743
+
1744
+ if (env.partialScoring === false) {
1745
+ return false;
1746
+ }
1747
+
1748
+ return typeof defaultValue === 'boolean' ? defaultValue : true;
1749
+ };
1750
+
1751
+ var partialScoring = /*#__PURE__*/Object.freeze({
1752
+ __proto__: null,
1753
+ enabled: enabled
1754
+ });
1755
+
1756
+ var lg = n => console[n].bind(console, 'controller-utils:');
1757
+
1722
1758
  lg('debug');
1723
1759
  lg('log');
1724
1760
  lg('warn');
@@ -1814,11 +1850,11 @@ const outcome = (question, session, env) =>
1814
1850
  if (env.mode !== 'evaluate') {
1815
1851
  resolve({ score: undefined, completed: undefined });
1816
1852
  } else {
1817
- const enabled$1 = enabled(question, env, true);
1853
+ const enabled = partialScoring.enabled(question, env, true);
1818
1854
  const totalCorrect = question.tokens.filter((t) => t.correct);
1819
1855
  const score = getPartialScore(question, session, totalCorrect);
1820
1856
  resolve({
1821
- score: enabled$1 ? score : score === 1 ? 1 : 0,
1857
+ score: enabled ? score : score === 1 ? 1 : 0,
1822
1858
  });
1823
1859
  }
1824
1860
  });