@pie-element/explicit-constructed-response 4.13.3-next.9 → 4.14.1-next.3

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.
@@ -35,10 +35,13 @@ var _controllerUtils = require("@pie-lib/controller-utils");
35
35
 
36
36
  var _defaults = _interopRequireDefault(require("./defaults"));
37
37
 
38
+ var _translator = _interopRequireDefault(require("@pie-lib/translator"));
39
+
38
40
  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; }
39
41
 
40
42
  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; }
41
43
 
44
+ var translator = _translator["default"].translator;
42
45
  var log = (0, _debug["default"])('explicit-constructed-response:controller');
43
46
 
44
47
  var prepareChoice = function prepareChoice(mode, defaultFeedback) {
@@ -111,7 +114,7 @@ exports.normalize = normalize;
111
114
  function model(question, session, env) {
112
115
  return new Promise( /*#__PURE__*/function () {
113
116
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(resolve) {
114
- var normalizedQuestion, defaultFeedback, _ref2, _ref2$value, value, preparChoiceFn, choices, feedback, showNote, _normalizedQuestion$m, maxLengthPerChoice, maxLengthPerChoiceEnabled, undefinedLengths, out;
117
+ var normalizedQuestion, defaultFeedback, _ref2, _ref2$value, value, preparChoiceFn, choices, feedback, showNote, note, _normalizedQuestion$m, maxLengthPerChoice, maxLengthPerChoiceEnabled, undefinedLengths, out;
115
118
 
116
119
  return _regenerator["default"].wrap(function _callee$(_context) {
117
120
  while (1) {
@@ -165,6 +168,14 @@ function model(question, session, env) {
165
168
  showNote = true;
166
169
  }
167
170
  });
171
+ note = normalizedQuestion.note;
172
+
173
+ if (!note) {
174
+ note = translator.t('common:commonCorrectAnswerWithAlternates', {
175
+ lng: normalizedQuestion.language
176
+ });
177
+ }
178
+
168
179
  _normalizedQuestion$m = normalizedQuestion.maxLengthPerChoice, maxLengthPerChoice = _normalizedQuestion$m === void 0 ? [] : _normalizedQuestion$m, maxLengthPerChoiceEnabled = normalizedQuestion.maxLengthPerChoiceEnabled;
169
180
  undefinedLengths = !maxLengthPerChoice.length; // calculate maxLengthPerChoice array if it is not defined or defined incorrectly
170
181
 
@@ -186,13 +197,14 @@ function model(question, session, env) {
186
197
  choices: choices,
187
198
  feedback: feedback,
188
199
  env: env,
189
- note: normalizedQuestion.note,
200
+ note: note,
190
201
  showNote: showNote,
191
202
  maxLengthPerChoice: maxLengthPerChoice,
192
203
  maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
193
204
  displayType: normalizedQuestion.displayType,
194
205
  playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,
195
- responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined
206
+ responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,
207
+ language: normalizedQuestion.language
196
208
  };
197
209
 
198
210
  if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
@@ -205,7 +217,7 @@ function model(question, session, env) {
205
217
 
206
218
  resolve(out);
207
219
 
208
- case 16:
220
+ case 18:
209
221
  case "end":
210
222
  return _context.stop();
211
223
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","getAdjustedLength","length","normalize","question","defaults","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","preparChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","showNote","values","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","Math","max","disabled","prompt","markup","note","displayType","playerSpellCheckEnabled","responseCorrect","getScore","undefined","role","rationale","teacherInstructions","getTextFromHTML","html","replace","trim","config","responseAreas","match","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","validate","maxResponseAreas","allChoicesErrors","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","some","errors","nbOfResponseAreas","responseAreasError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD,EAAOC,eAAP;AAAA,SAA2B,UAACC,MAAD,EAAY;AAClE,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADJ;AAEVC,MAAAA,KAAK,EAAEH,MAAM,CAACG;AAFJ,KAAZ;;AAKA,QAAIL,IAAI,KAAK,UAAb,EAAyB;AACvBG,MAAAA,GAAG,CAACG,OAAJ,GAAc,IAAd;AAEA,UAAMC,YAAY,GAAIL,MAAM,CAACM,QAAP,IAAmBN,MAAM,CAACM,QAAP,CAAgBC,IAApC,IAA6C,MAAlE;;AAEA,UAAIF,YAAY,KAAK,SAArB,EAAgC;AAC9BJ,QAAAA,GAAG,CAACK,QAAJ,GAAeP,eAAe,CAAC,SAAD,CAA9B;AACD,OAFD,MAEO,IAAIM,YAAY,KAAK,QAArB,EAA+B;AACpCJ,QAAAA,GAAG,CAACK,QAAJ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ourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport debug from 'debug';\nimport { partialScoring } from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n\nexport const normalize = (question) => ({\n ...defaults,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async (resolve) => {\n // this was added to treat an exception, when the model has choices without the \"value\" property\n // like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n const { value = {} } = session || {};\n\n const preparChoiceFn = prepareChoice(env.mode, defaultFeedback);\n\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, preparChoiceFn);\n\n return obj;\n },\n {},\n );\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n feedback = reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val = !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n );\n }\n\n let showNote = false;\n // check if a choice has an alternate\n Object.values(choices).forEach((choice) => {\n if (choice && choice.length > 1) {\n showNote = true;\n }\n });\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n env,\n note: normalizedQuestion.note,\n showNote,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n displayType: normalizedQuestion.displayType,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n}\n\nconst getTextFromHTML = (html) => {\n return (html || '').replace(/<\\/?[^>]+(>|$)/g, '');\n};\n\nexport const prepareVal = (html) => {\n const value = getTextFromHTML(html);\n\n return value.trim();\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const errors = {};\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choicesErrors = allChoicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["translator","Translator","log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","getAdjustedLength","length","normalize","question","defaults","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","preparChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","showNote","values","note","t","lng","language","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","Math","max","disabled","prompt","markup","displayType","playerSpellCheckEnabled","responseCorrect","getScore","undefined","role","rationale","teacherInstructions","getTextFromHTML","html","replace","trim","config","responseAreas","match","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","validate","maxResponseAreas","allChoicesErrors","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","some","errors","nbOfResponseAre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yBF,MAAzB,CAAeE,KAAf;;AAEA,UAAIA,KAAK,KAAK,EAAV,IAAgBA,KAAK,KAAK,aAA9B,EAA6C;AAC3C2F,QAAAA,aAAa,CAAC1F,KAAD,CAAb,GAAuB,8BAAvB;AACD,OAFD,MAEO;AACL,YAAM2F,eAAe,GAAGH,eAAe,CAACI,KAAhB,CAAsBjE,KAAK,GAAG,CAA9B,EAAiCkE,IAAjC,CAAsC,UAACxD,CAAD;AAAA,iBAAOA,CAAC,CAACtC,KAAF,KAAYA,KAAnB;AAAA,SAAtC,CAAxB;;AAEA,YAAI4F,eAAJ,EAAqB;AACnBD,UAAAA,aAAa,CAAC1F,KAAD,CAAb,GAAuB,2BAAvB;AACD;AACF;AACF,KAZD;;AAcA,QAAI,CAAC,yBAAQ0F,aAAR,CAAL,EAA6B;AAC3BJ,MAAAA,gBAAgB,CAAC9D,GAAD,CAAhB,GAAwBkE,aAAxB;AACD;AACF,GArBD;AAuBA,MAAMI,MAAM,GAAG,EAAf;AACA,MAAMC,iBAAiB,GAAG,CAAC1C,MAAM,CAACe,KAAP,CAAa,gBAAb,KAAkC,EAAnC,EAAuC7D,MAAjE;;AAEA,MAAIwF,iBAAiB,GAAGV,gBAAxB,EAA0C;AACxCS,IAAAA,MAAM,CAACE,kBAAP,0BAA4CX,gBAA5C;AACD,GAFD,MAEO,IAAIU,iBAAiB,GAAG,CAAxB,EAA2B;AAChCD,IAAAA,MAAM,CAACE,kBAAP,GAA4B,mDAA5B;AACD;;AAED,MAAI,CAAC,yBAAQV,gBAAR,CAAL,EAAgC;AAC9BQ,IAAAA,MAAM,CAACJ,aAAP,GAAuBJ,gBAAvB;AACD;;AAED,SAAOQ,MAAP;AACD,CA1CM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport debug from 'debug';\nimport { partialScoring } from '@pie-lib/controller-utils';\nimport defaults from './defaults';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n\nexport const normalize = (question) => ({\n ...defaults,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async (resolve) => {\n // this was added to treat an exception, when the model has choices without the \"value\" property\n // like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n const { value = {} } = session || {};\n\n const preparChoiceFn = prepareChoice(env.mode, defaultFeedback);\n\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, preparChoiceFn);\n\n return obj;\n },\n {},\n );\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n feedback = reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val = !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n );\n }\n\n let showNote = false;\n // check if a choice has an alternate\n Object.values(choices).forEach((choice) => {\n if (choice && choice.length > 1) {\n showNote = true;\n }\n });\n\n let { note } = normalizedQuestion;\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n }\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n env,\n note,\n showNote,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n displayType: normalizedQuestion.displayType,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n language: normalizedQuestion.language\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n}\n\nconst getTextFromHTML = (html) => {\n return (html || '').replace(/<\\/?[^>]+(>|$)/g, '');\n};\n\nexport const prepareVal = (html) => {\n const value = getTextFromHTML(html);\n\n return value.trim();\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const errors = {};\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choicesErrors = allChoicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/explicit-constructed-response-controller",
3
3
  "private": true,
4
- "version": "3.6.3",
4
+ "version": "3.7.0",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -9,6 +9,7 @@
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
11
  "@pie-lib/controller-utils": "^0.2.44",
12
+ "@pie-lib/translator": "^2.2.0",
12
13
  "debug": "^3.1.0",
13
14
  "lodash": "^4.17.15",
14
15
  "type-of": "^2.0.1"
@@ -263,6 +263,66 @@
263
263
  }
264
264
  }
265
265
  },
266
+ "language": {
267
+ "title": "ConfigurePropWithEnabled",
268
+ "type": "object",
269
+ "properties": {
270
+ "settings": {
271
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
272
+ "type": "boolean",
273
+ "title": "settings"
274
+ },
275
+ "label": {
276
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
277
+ "type": "string",
278
+ "title": "label"
279
+ },
280
+ "enabled": {
281
+ "description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
282
+ "type": "boolean",
283
+ "title": "enabled"
284
+ }
285
+ }
286
+ },
287
+ "languageChoices": {
288
+ "description": "Language choices configuration\nOnly available if language is enabled",
289
+ "type": "object",
290
+ "properties": {
291
+ "label": {
292
+ "type": "string",
293
+ "title": "label"
294
+ },
295
+ "options": {
296
+ "type": "array",
297
+ "items": {
298
+ "title": "ConfigureLanguageOptionsProp",
299
+ "type": "object",
300
+ "properties": {
301
+ "value": {
302
+ "description": "Value of the language option",
303
+ "type": "string",
304
+ "title": "value"
305
+ },
306
+ "label": {
307
+ "description": "Label of the language option",
308
+ "type": "string",
309
+ "title": "label"
310
+ }
311
+ },
312
+ "required": [
313
+ "label",
314
+ "value"
315
+ ]
316
+ },
317
+ "title": "options"
318
+ }
319
+ },
320
+ "required": [
321
+ "label",
322
+ "options"
323
+ ],
324
+ "title": "languageChoices"
325
+ },
266
326
  "showPrompt": {
267
327
  "description": "Determines whether prompt field will be displayed or not",
268
328
  "default": true,
@@ -379,6 +439,47 @@
379
439
  "title": "mmlEditing"
380
440
  }
381
441
  }
442
+ },
443
+ "ConfigurePropWithEnabled": {
444
+ "title": "ConfigurePropWithEnabled",
445
+ "type": "object",
446
+ "properties": {
447
+ "settings": {
448
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
449
+ "type": "boolean",
450
+ "title": "settings"
451
+ },
452
+ "label": {
453
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
454
+ "type": "string",
455
+ "title": "label"
456
+ },
457
+ "enabled": {
458
+ "description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
459
+ "type": "boolean",
460
+ "title": "enabled"
461
+ }
462
+ }
463
+ },
464
+ "ConfigureLanguageOptionsProp": {
465
+ "title": "ConfigureLanguageOptionsProp",
466
+ "type": "object",
467
+ "properties": {
468
+ "value": {
469
+ "description": "Value of the language option",
470
+ "type": "string",
471
+ "title": "value"
472
+ },
473
+ "label": {
474
+ "description": "Label of the language option",
475
+ "type": "string",
476
+ "title": "label"
477
+ }
478
+ },
479
+ "required": [
480
+ "label",
481
+ "value"
482
+ ]
382
483
  }
383
484
  },
384
485
  "$schema": "http://json-schema.org/draft-07/schema#"
@@ -198,6 +198,46 @@ Indicates if model should have mathML output instead of latex
198
198
 
199
199
  Indicates if mathML that's already in model should be editable
200
200
 
201
+ # `language` (object)
202
+
203
+ Properties of the `language` object:
204
+
205
+ ## `settings` (boolean)
206
+
207
+ Indicates if the item has to be displayed in the Settings Panel
208
+
209
+ ## `label` (string)
210
+
211
+ Indicates the label for the item that has to be displayed in the Settings Panel
212
+
213
+ ## `enabled` (boolean)
214
+
215
+ Indicates the value of the item if it affects config-ui
216
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
217
+
218
+ # `languageChoices` (object)
219
+
220
+ Language choices configuration
221
+ Only available if language is enabled
222
+
223
+ Properties of the `languageChoices` object:
224
+
225
+ ## `label` (string, required)
226
+
227
+ ## `options` (array, required)
228
+
229
+ The object is an array with all elements of the type `object`.
230
+
231
+ The array object has the following properties:
232
+
233
+ ### `value` (string, required)
234
+
235
+ Value of the language option
236
+
237
+ ### `label` (string, required)
238
+
239
+ Label of the language option
240
+
201
241
  # `showPrompt` (boolean)
202
242
 
203
243
  Determines whether prompt field will be displayed or not
@@ -294,4 +334,33 @@ Indicates if model should have mathML output instead of latex
294
334
 
295
335
  ### `mmlEditing` (number)
296
336
 
297
- Indicates if mathML that's already in model should be editable
337
+ Indicates if mathML that's already in model should be editable
338
+
339
+ ## `ConfigurePropWithEnabled` (object)
340
+
341
+ Properties of the `ConfigurePropWithEnabled` object:
342
+
343
+ ### `settings` (boolean)
344
+
345
+ Indicates if the item has to be displayed in the Settings Panel
346
+
347
+ ### `label` (string)
348
+
349
+ Indicates the label for the item that has to be displayed in the Settings Panel
350
+
351
+ ### `enabled` (boolean)
352
+
353
+ Indicates the value of the item if it affects config-ui
354
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
355
+
356
+ ## `ConfigureLanguageOptionsProp` (object)
357
+
358
+ Properties of the `ConfigureLanguageOptionsProp` object:
359
+
360
+ ### `value` (string, required)
361
+
362
+ Value of the language option
363
+
364
+ ### `label` (string, required)
365
+
366
+ Label of the language option
@@ -14,7 +14,6 @@ exports.model = (id, element) => ({
14
14
  },
15
15
  maxLengthPerChoice: [7, 10, 4],
16
16
  prompt: 'Complete the sentence',
17
- note: 'The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.',
18
17
  promptEnabled: true,
19
18
  toolbarEditorPosition: 'bottom',
20
19
  rubricEnabled: false,
@@ -136,6 +136,11 @@
136
136
  "type": "boolean",
137
137
  "title": "rubricEnabled"
138
138
  },
139
+ "language": {
140
+ "description": "Indicates the language of the component\nSupported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX",
141
+ "type": "string",
142
+ "title": "language"
143
+ },
139
144
  "id": {
140
145
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
141
146
  "type": "string",
@@ -217,6 +222,47 @@
217
222
  }
218
223
  }
219
224
  },
225
+ "ConfigurePropWithEnabled": {
226
+ "title": "ConfigurePropWithEnabled",
227
+ "type": "object",
228
+ "properties": {
229
+ "settings": {
230
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
231
+ "type": "boolean",
232
+ "title": "settings"
233
+ },
234
+ "label": {
235
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
236
+ "type": "string",
237
+ "title": "label"
238
+ },
239
+ "enabled": {
240
+ "description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
241
+ "type": "boolean",
242
+ "title": "enabled"
243
+ }
244
+ }
245
+ },
246
+ "ConfigureLanguageOptionsProp": {
247
+ "title": "ConfigureLanguageOptionsProp",
248
+ "type": "object",
249
+ "properties": {
250
+ "value": {
251
+ "description": "Value of the language option",
252
+ "type": "string",
253
+ "title": "value"
254
+ },
255
+ "label": {
256
+ "description": "Label of the language option",
257
+ "type": "string",
258
+ "title": "label"
259
+ }
260
+ },
261
+ "required": [
262
+ "label",
263
+ "value"
264
+ ]
265
+ },
220
266
  "Choice": {
221
267
  "title": "Choice",
222
268
  "type": "object",
@@ -93,6 +93,11 @@ The object is an array with all elements of the type `number`.
93
93
 
94
94
  Indicates if Rubric is enabled
95
95
 
96
+ # `language` (string)
97
+
98
+ Indicates the language of the component
99
+ Supported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX
100
+
96
101
  # `id` (string, required)
97
102
 
98
103
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -147,6 +152,35 @@ Indicates if model should have mathML output instead of latex
147
152
 
148
153
  Indicates if mathML that's already in model should be editable
149
154
 
155
+ ## `ConfigurePropWithEnabled` (object)
156
+
157
+ Properties of the `ConfigurePropWithEnabled` object:
158
+
159
+ ### `settings` (boolean)
160
+
161
+ Indicates if the item has to be displayed in the Settings Panel
162
+
163
+ ### `label` (string)
164
+
165
+ Indicates the label for the item that has to be displayed in the Settings Panel
166
+
167
+ ### `enabled` (boolean)
168
+
169
+ Indicates the value of the item if it affects config-ui
170
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
171
+
172
+ ## `ConfigureLanguageOptionsProp` (object)
173
+
174
+ Properties of the `ConfigureLanguageOptionsProp` object:
175
+
176
+ ### `value` (string, required)
177
+
178
+ Value of the language option
179
+
180
+ ### `label` (string, required)
181
+
182
+ Label of the language option
183
+
150
184
  ## `Choice` (object)
151
185
 
152
186
  Properties of the `Choice` object:
package/lib/index.js CHANGED
@@ -66,6 +66,7 @@ var InlineDropdown = /*#__PURE__*/function (_HTMLElement) {
66
66
  value: _this._session.value,
67
67
  feedback: _this._model.feedback,
68
68
  displayType: _this._model.displayType,
69
+ language: _this._model.language,
69
70
  onChange: _this.changeSession
70
71
  });
71
72
 
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","teacherInstructions","prompt","note","showNote","env","rationale","disabled","choices","markup","mode","maxLengthPerChoice","maxLengthPerChoiceEnabled","playerSpellCheckEnabled","value","feedback","displayType","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","setAttribute","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEqBA,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGAwBJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,mBAAmB,EAAE,MAAKN,MAAL,CAAYM,mBADE;AAEnCC,UAAAA,MAAM,EAAE,MAAKP,MAAL,CAAYO,MAFe;AAGnCC,UAAAA,IAAI,EAAE,MAAKR,MAAL,CAAYQ,IAHiB;AAInCC,UAAAA,QAAQ,EAAE,MAAKT,MAAL,CAAYS,QAJa;AAKnCC,UAAAA,GAAG,EAAE,MAAKV,MAAL,CAAYU,GALkB;AAMnCC,UAAAA,SAAS,EAAE,MAAKX,MAAL,CAAYW,SANY;AAOnCC,UAAAA,QAAQ,EAAE,MAAKZ,MAAL,CAAYY,QAPa;AAQnCC,UAAAA,OAAO,EAAE,MAAKb,MAAL,CAAYa,OARc;AASnCC,UAAAA,MAAM,EAAE,MAAKd,MAAL,CAAYc,MATe;AAUnCC,UAAAA,IAAI,EAAE,MAAKf,MAAL,CAAYe,IAViB;AAWnCC,UAAAA,kBAAkB,EAAE,MAAKhB,MAAL,CAAYgB,kBAXG;AAYnCC,UAAAA,yBAAyB,EAAE,MAAKjB,MAAL,CAAYiB,yBAZJ;AAanC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YAAlB,EAAgC,4BAAhC;AACA,WAAKA,YAAL,CAAkB,MAAlB,EAA0B,QAA1B;;AAEA,WAAKJ,OAAL;AACD;;;kDApEyCK,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport Main from './main';\n\nexport default class InlineDropdown extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model),\n );\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n teacherInstructions: this._model.teacherInstructions,\n prompt: this._model.prompt,\n note: this._model.note,\n showNote: this._model.showNote,\n env: this._model.env,\n rationale: this._model.rationale,\n disabled: this._model.disabled,\n choices: this._model.choices,\n markup: this._model.markup,\n mode: this._model.mode,\n maxLengthPerChoice: this._model.maxLengthPerChoice,\n maxLengthPerChoiceEnabled: this._model.maxLengthPerChoiceEnabled,\n playerSpellCheckEnabled: this._model.playerSpellCheckEnabled,\n value: this._session.value,\n feedback: this._model.feedback,\n displayType: this._model.displayType,\n onChange: this.changeSession,\n });\n\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.session && !!this.session.value));\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Fill in the Blank Question'); \n this.setAttribute('role', 'region');\n\n this._render();\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","teacherInstructions","prompt","note","showNote","env","rationale","disabled","choices","markup","mode","maxLengthPerChoice","maxLengthPerChoiceEnabled","playerSpellCheckEnabled","value","feedback","displayType","language","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","setAttribute","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEqBA,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGAwBJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,mBAAmB,EAAE,MAAKN,MAAL,CAAYM,mBADE;AAEnCC,UAAAA,MAAM,EAAE,MAAKP,MAAL,CAAYO,MAFe;AAGnCC,UAAAA,IAAI,EAAE,MAAKR,MAAL,CAAYQ,IAHiB;AAInCC,UAAAA,QAAQ,EAAE,MAAKT,MAAL,CAAYS,QAJa;AAKnCC,UAAAA,GAAG,EAAE,MAAKV,MAAL,CAAYU,GALkB;AAMnCC,UAAAA,SAAS,EAAE,MAAKX,MAAL,CAAYW,SANY;AAOnCC,UAAAA,QAAQ,EAAE,MAAKZ,MAAL,CAAYY,QAPa;AAQnCC,UAAAA,OAAO,EAAE,MAAKb,MAAL,CAAYa,OARc;AASnCC,UAAAA,MAAM,EAAE,MAAKd,MAAL,CAAYc,MATe;AAUnCC,UAAAA,IAAI,EAAE,MAAKf,MAAL,CAAYe,IAViB;AAWnCC,UAAAA,kBAAkB,EAAE,MAAKhB,MAAL,CAAYgB,kBAXG;AAYnCC,UAAAA,yBAAyB,EAAE,MAAKjB,MAAL,CAAYiB,yBAZJ;AAanCC,UAAAA,uBAAuB,EAAE,MAAKlB,MAAL,CAAYkB,uBAbF;AAcnCC,UAAAA,KAAK,EAAE,MAAKlB,QAAL,CAAckB,KAd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AkB,MAAlB,EAA0B,QAA1B;;AAEA,WAAKJ,OAAL;AACD;;;kDArEyCK,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport Main from './main';\n\nexport default class InlineDropdown extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model),\n );\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n teacherInstructions: this._model.teacherInstructions,\n prompt: this._model.prompt,\n note: this._model.note,\n showNote: this._model.showNote,\n env: this._model.env,\n rationale: this._model.rationale,\n disabled: this._model.disabled,\n choices: this._model.choices,\n markup: this._model.markup,\n mode: this._model.mode,\n maxLengthPerChoice: this._model.maxLengthPerChoice,\n maxLengthPerChoiceEnabled: this._model.maxLengthPerChoiceEnabled,\n playerSpellCheckEnabled: this._model.playerSpellCheckEnabled,\n value: this._session.value,\n feedback: this._model.feedback,\n displayType: this._model.displayType,\n language: this._model.language,\n onChange: this.changeSession,\n });\n\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.session && !!this.session.value));\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Fill in the Blank Question');\n this.setAttribute('role', 'region');\n\n this._render();\n }\n}\n"],"file":"index.js"}
package/lib/main.js CHANGED
@@ -43,10 +43,14 @@ var _styles = require("@material-ui/core/styles");
43
43
 
44
44
  var _classnames = _interopRequireDefault(require("classnames"));
45
45
 
46
+ var _translator = _interopRequireDefault(require("@pie-lib/translator"));
47
+
46
48
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
47
49
 
48
50
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
49
51
 
52
+ var translator = _translator["default"].translator;
53
+
50
54
  var Main = /*#__PURE__*/function (_React$Component) {
51
55
  (0, _inherits2["default"])(Main, _React$Component);
52
56
 
@@ -92,7 +96,10 @@ var Main = /*#__PURE__*/function (_React$Component) {
92
96
  (0, _createClass2["default"])(Main, [{
93
97
  key: "UNSAFE_componentWillReceiveProps",
94
98
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
95
- var maxLengthPerChoice = this.props.maxLengthPerChoice;
99
+ var _this$props = this.props,
100
+ maxLengthPerChoice = _this$props.maxLengthPerChoice,
101
+ language = _this$props.language;
102
+ var note = this.props.note;
96
103
 
97
104
  if ((0, _isEmpty["default"])(nextProps.feedback)) {
98
105
  this.setState({
@@ -108,6 +115,17 @@ var Main = /*#__PURE__*/function (_React$Component) {
108
115
 
109
116
  if (maxLengthPerChoice && !(0, _isEqual["default"])(maxLengthPerChoice, nextProps.maxLengthPerChoice)) {
110
117
  this.changeSession = this.getChangeSession(nextProps.maxLengthPerChoice);
118
+ } // check if the note is the default one for prev language and change to the default one for new language
119
+ // this check is necessary in order to diferanciate between default and authour defined note
120
+ // and only change between languages for default ones
121
+
122
+
123
+ if (note && language && language !== nextProps.language && note === translator.t('common:commonCorrectAnswerWithAlternates', {
124
+ lng: language
125
+ })) {
126
+ note = translator.t('common:commonCorrectAnswerWithAlternates', {
127
+ lng: nextProps.language
128
+ });
111
129
  }
112
130
  }
113
131
  }, {
@@ -116,21 +134,22 @@ var Main = /*#__PURE__*/function (_React$Component) {
116
134
  var _this$state = this.state,
117
135
  showCorrectAnswer = _this$state.showCorrectAnswer,
118
136
  value = _this$state.value;
119
- var _this$props = this.props,
120
- classes = _this$props.classes,
121
- mode = _this$props.mode,
122
- prompt = _this$props.prompt,
123
- rationale = _this$props.rationale,
124
- teacherInstructions = _this$props.teacherInstructions,
125
- note = _this$props.note,
126
- showNote = _this$props.showNote,
127
- env = _this$props.env,
128
- animationsDisabled = _this$props.animationsDisabled,
129
- alwaysShowCorrect = _this$props.alwaysShowCorrect,
130
- maxLengthPerChoice = _this$props.maxLengthPerChoice,
131
- maxLengthPerChoiceEnabled = _this$props.maxLengthPerChoiceEnabled,
132
- displayType = _this$props.displayType,
133
- playerSpellCheckEnabled = _this$props.playerSpellCheckEnabled;
137
+ var _this$props2 = this.props,
138
+ classes = _this$props2.classes,
139
+ mode = _this$props2.mode,
140
+ prompt = _this$props2.prompt,
141
+ rationale = _this$props2.rationale,
142
+ teacherInstructions = _this$props2.teacherInstructions,
143
+ note = _this$props2.note,
144
+ showNote = _this$props2.showNote,
145
+ env = _this$props2.env,
146
+ animationsDisabled = _this$props2.animationsDisabled,
147
+ alwaysShowCorrect = _this$props2.alwaysShowCorrect,
148
+ maxLengthPerChoice = _this$props2.maxLengthPerChoice,
149
+ maxLengthPerChoiceEnabled = _this$props2.maxLengthPerChoiceEnabled,
150
+ displayType = _this$props2.displayType,
151
+ playerSpellCheckEnabled = _this$props2.playerSpellCheckEnabled,
152
+ language = _this$props2.language;
134
153
 
135
154
  var _ref = env || {},
136
155
  role = _ref.role;
@@ -166,7 +185,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
166
185
  }), !alwaysShowCorrect && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
167
186
  show: mode === 'evaluate',
168
187
  toggled: showCorrectAnswer,
169
- onToggle: this.toggleShowCorrect
188
+ onToggle: this.toggleShowCorrect,
189
+ language: language
170
190
  }), /*#__PURE__*/_react["default"].createElement(_maskMarkup.ConstructedResponse, (0, _extends2["default"])({}, this.props, {
171
191
  onChange: this.onChange,
172
192
  showCorrectAnswer: showCorrectAnswer,
@@ -177,7 +197,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
177
197
  })), displayNote && /*#__PURE__*/_react["default"].createElement("div", {
178
198
  className: (0, _classnames["default"])(classes.note, 'note'),
179
199
  dangerouslySetInnerHTML: {
180
- __html: "<strong>Note:</strong> ".concat(note)
200
+ __html: note
181
201
  }
182
202
  }), rationale && (0, _renderUi.hasText)(rationale) && /*#__PURE__*/_react["default"].createElement("div", {
183
203
  className: classes.collapsible
@@ -212,7 +232,8 @@ exports.Main = Main;
212
232
  animationsDisabled: _propTypes["default"].bool,
213
233
  maxLengthPerChoice: _propTypes["default"].array,
214
234
  maxLengthPerChoiceEnabled: _propTypes["default"].bool,
215
- playerSpellCheckEnabled: _propTypes["default"].bool
235
+ playerSpellCheckEnabled: _propTypes["default"].bool,
236
+ language: _propTypes["default"].string
216
237
  });
217
238
  (0, _defineProperty2["default"])(Main, "defaultProps", {
218
239
  value: {}