@pie-element/match 4.7.3-next.137 → 4.7.3-next.1370
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 +292 -0
- package/configure/CHANGELOG.md +269 -0
- package/configure/lib/add-row.js +1 -1
- package/configure/lib/add-row.js.map +1 -1
- package/configure/lib/answer-config-block.js +73 -14
- package/configure/lib/answer-config-block.js.map +1 -1
- package/configure/lib/common.js +5 -1
- package/configure/lib/common.js.map +1 -1
- package/configure/lib/configure.js +58 -11
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +22 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +52 -7
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/lib/index.js +18 -4
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/row.js +46 -9
- package/configure/lib/row.js.map +1 -1
- package/configure/package.json +5 -5
- package/configure/utils.js +11 -0
- package/controller/CHANGELOG.md +51 -0
- package/controller/lib/index.js +48 -5
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +110 -0
- package/docs/config-schema.json.md +85 -1
- package/docs/demo/generate.js +2 -1
- package/docs/pie-schema.json +38 -0
- package/docs/pie-schema.json.md +28 -0
- package/lib/answer-grid.js +5 -6
- package/lib/answer-grid.js.map +1 -1
- package/lib/index.js +7 -2
- package/lib/index.js.map +1 -1
- package/lib/main.js +11 -17
- package/lib/main.js.map +1 -1
- package/package.json +5 -5
package/controller/lib/index.js
CHANGED
|
@@ -5,9 +5,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.createCorrectResponseSession = void 0;
|
|
8
9
|
exports.createDefaultModel = createDefaultModel;
|
|
9
10
|
exports.model = model;
|
|
10
|
-
exports.
|
|
11
|
+
exports.validate = exports.outcome = exports.normalize = void 0;
|
|
11
12
|
|
|
12
13
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
14
|
|
|
@@ -29,9 +30,9 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
29
30
|
|
|
30
31
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
31
32
|
|
|
32
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
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; }
|
|
33
34
|
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
35
|
+
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; }
|
|
35
36
|
|
|
36
37
|
var log = (0, _debug["default"])('@pie-element:match:controller');
|
|
37
38
|
|
|
@@ -48,9 +49,18 @@ var getResponseCorrectness = function getResponseCorrectness(model, answers) {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
var totalCorrectAnswers = checkboxMode ? getTotalCorrectAnswers(model) : getTotalCorrect(model);
|
|
51
|
-
var correctAnswers
|
|
52
|
+
var correctAnswers;
|
|
53
|
+
var incorrectAnswers = 0;
|
|
54
|
+
|
|
55
|
+
if (checkboxMode) {
|
|
56
|
+
var checkboxes = getCheckboxes(rows, answers);
|
|
57
|
+
correctAnswers = checkboxes.correctAnswers;
|
|
58
|
+
incorrectAnswers = checkboxes.incorrectAnswers;
|
|
59
|
+
} else {
|
|
60
|
+
correctAnswers = getCorrectRadios(rows, answers);
|
|
61
|
+
}
|
|
52
62
|
|
|
53
|
-
if (totalCorrectAnswers === correctAnswers) {
|
|
63
|
+
if (totalCorrectAnswers === correctAnswers && !incorrectAnswers) {
|
|
54
64
|
return 'correct';
|
|
55
65
|
} else if (correctAnswers === 0) {
|
|
56
66
|
return 'incorrect';
|
|
@@ -318,4 +328,37 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
318
328
|
};
|
|
319
329
|
|
|
320
330
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
331
|
+
|
|
332
|
+
var validate = function validate() {
|
|
333
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
334
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
335
|
+
var rows = model.rows,
|
|
336
|
+
choiceMode = model.choiceMode;
|
|
337
|
+
var rowsErrors = {};
|
|
338
|
+
(rows || []).forEach(function (row) {
|
|
339
|
+
var id = row.id,
|
|
340
|
+
_row$values = row.values,
|
|
341
|
+
values = _row$values === void 0 ? [] : _row$values;
|
|
342
|
+
var hasCorrectResponse = false;
|
|
343
|
+
values.forEach(function (value) {
|
|
344
|
+
if (value) {
|
|
345
|
+
hasCorrectResponse = true;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
if (!hasCorrectResponse) {
|
|
350
|
+
rowsErrors[id] = 'No correct response defined.';
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
var errors = {};
|
|
354
|
+
|
|
355
|
+
if (!(0, _isEmpty["default"])(rowsErrors)) {
|
|
356
|
+
errors.rowsErrors = rowsErrors;
|
|
357
|
+
errors.correctResponseError = choiceMode === 'radio' ? 'There should be a correct response defined for every row.' : 'There should be at least one correct response defined for every row.';
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return errors;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
exports.validate = validate;
|
|
321
364
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","getResponseCorrectness","model","answers","env","isPartialScoring","partialScoring","enabled","rows","checkboxMode","choiceMode","Object","keys","length","totalCorrectAnswers","getTotalCorrectAnswers","getTotalCorrect","correctAnswers","getCheckboxes","getCorrectRadios","getCorrectness","question","mode","incorrectAnswers","forEach","row","answer","id","values","v","i","matchingTable","layout","noOfTotalCorrectAnswers","value","getPartialScore","totalCorrect","total","extraAnswers","score","parseFloat","toFixed","getOutComeScore","correctness","outcome","session","Promise","resolve","undefined","completed","empty","out","createDefaultModel","defaults","normalize","feedbackEnabled","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","updateSession","normalizedQuestion","correctResponse","correctInfo","lockChoiceOrder","fb","feedback","then","allowFeedback","prompt","config","shuffled","disabled","view","role","teacherInstructions","rationale","assign","createCorrectResponseSession","r"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;;;;;AAFA,IAAMA,GAAG,GAAG,uBAAM,+BAAN,CAAZ;;AAIA,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAyB,CAACC,KAAD,EAAQC,OAAR,EAA8B;AAAA,MAAbC,GAAa,uEAAP,EAAO;;AAC3D,MAAMC,gBAAgB,GAAGC,gCAAeC,OAAf,CAAuBL,KAAvB,EAA8BE,GAA9B,CAAzB;;AACA,MAAMI,IAAI,GAAGN,KAAK,CAACM,IAAnB;AACA,MAAMC,YAAY,GAAGP,KAAK,CAACQ,UAAN,KAAqB,UAA1C;;AAEA,MAAI,CAACP,OAAD,IAAYQ,MAAM,CAACC,IAAP,CAAYT,OAAZ,EAAqBU,MAArB,KAAgC,CAAhD,EAAmD;AACjD,WA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,OAAO,EAAI;AAC5B,QAAI3C,GAAG,CAACkB,IAAJ,KAAa,UAAb,IAA2BlB,GAAG,CAACsE,IAAJ,KAAa,YAA5C,EAA0D;AAAA,UAChDlE,IADgD,GACvCa,QADuC,CAChDb,IADgD;AAExD,UAAML,OAAO,GAAG,EAAhB;AAEAK,MAAAA,IAAI,CAACgB,OAAL,CAAa,UAAAuD,CAAC,EAAI;AAChB5E,QAAAA,OAAO,CAAC4E,CAAC,CAACpD,EAAH,CAAP,GAAgBoD,CAAC,CAACnD,MAAlB;AACD,OAFD;AAIAmB,MAAAA,OAAO,CAAC;AACN5C,QAAAA,OAAO,EAAPA,OADM;AAENwB,QAAAA,EAAE,EAAE;AAFE,OAAD,CAAP;AAID,KAZD,MAYO;AACLoB,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAhBM,CAAP;AAiBD,CAlBM","sourcesContent":["import isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport debug from 'debug';\n\nconst log = debug('@pie-element:match:controller');\n\nimport defaults from './defaults';\n\nconst getResponseCorrectness = (model, answers, env = {}) => {\n const isPartialScoring = partialScoring.enabled(model, env);\n const rows = model.rows;\n const checkboxMode = model.choiceMode === 'checkbox';\n\n if (!answers || Object.keys(answers).length === 0) {\n return 'unanswered';\n }\n\n const totalCorrectAnswers = checkboxMode ? getTotalCorrectAnswers(model) : getTotalCorrect(model);\n const correctAnswers = checkboxMode\n ? getCheckboxes(rows, answers).correctAnswers\n : getCorrectRadios(rows, answers);\n\n if (totalCorrectAnswers === correctAnswers) {\n return 'correct';\n } else if (correctAnswers === 0) {\n return 'incorrect';\n } else if (isPartialScoring) {\n return 'partial';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectness = (question, env, answers = {}) => {\n if (env.mode === 'evaluate') {\n return getResponseCorrectness(question, answers, env);\n }\n};\n\nconst getCheckboxes = (rows, answers) => {\n let correctAnswers = 0;\n let incorrectAnswers = 0;\n\n rows.forEach(row => {\n const answer = answers[row.id];\n\n if (answer) {\n row.values.forEach((v, i) => {\n if (answer[i] && answer[i] === v ) {\n correctAnswers += 1;\n } else if (answer[i] && answer[i] !== v ){\n incorrectAnswers += 1;\n }\n });\n }\n });\n\n return { correctAnswers, incorrectAnswers };\n};\n\nconst getCorrectRadios = (rows, answers) => {\n let correctAnswers = 0;\n\n rows.forEach(row => {\n if (isEqual(row.values, answers[row.id])) {\n correctAnswers += 1;\n }\n });\n\n return correctAnswers;\n};\n\nconst getTotalCorrect = question => {\n const checkboxMode = question.choiceMode === 'checkbox';\n const matchingTable = checkboxMode ? question.layout - 1 : 1;\n return (question.rows.length || 0) * matchingTable;\n};\n\nconst getTotalCorrectAnswers = question => {\n let noOfTotalCorrectAnswers = 0;\n\n question.rows.forEach(row => {\n row.values.forEach(value => {\n if(value) {\n noOfTotalCorrectAnswers += 1;\n }\n });\n });\n\n return noOfTotalCorrectAnswers;\n};\n\nconst getPartialScore = (question, answers) => {\n const checkboxMode = question.choiceMode === 'checkbox';\n\n if(checkboxMode) {\n const { correctAnswers, incorrectAnswers } = getCheckboxes(question.rows, answers);\n const totalCorrect = getTotalCorrectAnswers(question);\n\n const total = totalCorrect === 0 ? 1 : totalCorrect;\n\n if (correctAnswers + incorrectAnswers > totalCorrect) {\n const extraAnswers = (correctAnswers + incorrectAnswers) - totalCorrect;\n const score = parseFloat(((correctAnswers - extraAnswers) / total).toFixed(2));\n\n return score < 0 ? 0 : score;\n } else {\n return parseFloat((correctAnswers / total).toFixed(2));\n }\n } else {\n const correctAnswers = getCorrectRadios(question.rows, answers);\n const totalCorrect = getTotalCorrect(question) === 0 ? 1 : getTotalCorrect(question);\n\n return parseFloat((correctAnswers / totalCorrect).toFixed(2));\n }\n};\n\nconst getOutComeScore = (question, env, answers = {}) => {\n const correctness = getCorrectness(question, env, answers);\n const isPartialScoring = partialScoring.enabled(question, env);\n\n return correctness === 'correct'\n ? 1\n : correctness === 'partial' && isPartialScoring\n ? getPartialScore(question, answers)\n : 0;\n};\n\nexport const outcome = (question, session, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n const out = {\n score: getOutComeScore(question, env, session.answers)\n };\n\n resolve(out);\n }\n });\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => {\n resolve({\n ...defaults,\n ...model\n });\n });\n}\n\nexport const normalize = question => ({\n feedbackEnabled: true,\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport function model(question, session, env, updateSession) {\n return new Promise(async resolve => {\n const normalizedQuestion = cloneDeep(normalize(question));\n let correctness, score;\n\n if ((!session || isEmpty(session)) && env.mode === 'evaluate') {\n correctness = 'unanswered';\n score = '0%';\n } else {\n correctness = getCorrectness(normalizedQuestion, env, session && session.answers);\n score = `${getOutComeScore(normalizedQuestion, env, session && session.answers) *\n 100}%`;\n }\n\n const correctResponse = {};\n const correctInfo = {\n score,\n correctness\n };\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n normalizedQuestion.rows = await getShuffledChoices(\n normalizedQuestion.rows,\n session,\n updateSession,\n 'id'\n );\n }\n\n normalizedQuestion.rows.forEach(row => {\n correctResponse[row.id] = row.values;\n\n if (env.mode !== 'evaluate') {\n delete row.values;\n }\n });\n\n const fb =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? getFeedbackForCorrectness(correctInfo.correctness, normalizedQuestion.feedback)\n : Promise.resolve(undefined);\n\n fb.then(feedback => {\n const out = {\n allowFeedback: normalizedQuestion.feedbackEnabled,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n config: {\n ...normalizedQuestion,\n shuffled: !normalizedQuestion.lockChoiceOrder\n },\n feedback,\n disabled: env.mode !== 'gather',\n view: env.mode === 'view'\n };\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n out.config.rationale = null;\n out.config.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate') {\n Object.assign(out, {\n correctResponse,\n correctness: correctInfo,\n });\n }\n\n log('out: ', out);\n resolve(out);\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { rows } = question;\n const answers = {};\n\n rows.forEach(r => {\n answers[r.id] = r.values;\n });\n\n resolve({\n answers,\n id: '1'\n });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","getResponseCorrectness","model","answers","env","isPartialScoring","partialScoring","enabled","rows","checkboxMode","choiceMode","Object","keys","length","totalCorrectAnswers","getTotalCorrectAnswers","getTotalCorrect","correctAnswers","incorrectAnswers","checkboxes","getCheckboxes","getCorrectRadios","getCorrectness","question","mode","forEach","row","answer","id","values","v","i","matchingTable","layout","noOfTotalCorrectAnswers","value","getPartialScore","totalCorrect","total","extraAnswers","score","parseFloat","toFixed","getOutComeScore","correctness","outcome","session","Promise","resolve","undefined","completed","empty","out","createDefaultModel","defaults","normalize","feedbackEnabled","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","updateSession","normalizedQuestion","correctResponse","correctInfo","lockChoiceOrder","fb","feedback","then","allowFeedback","prompt","config","shuffled","disabled","view","role","teacherInstructions","rationale","assign","createCorrectResponseSession","r","validate","rowsErrors","hasCorrectResponse","errors","correctResponseError"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;;;;;AAFA,IAAMA,GAAG,GAAG,uBAAM,+BAAN,CAAZ;;AAIA,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAyB,CAACC,KAAD,EAAQC,OAAR,EAA8B;AAAA,MAAbC,GAAa,uEAAP,EAAO;;AAC3D,MAAMC,gBAAgB,GAAGC,gCAAeC,OAAf,CAAuBL,KAAvB,EAA8BE,GAA9B,CAAzB;;AACA,MAAMI,IAAI,GAAGN,KAAK,CAACM,IAAnB;AACA,MAAMC,YAAY,GAAGP,KAAK,CAACQ,UAAN,KAAqB,UAA1C;;AAEA,MAAI,CAACP,OAAD,IAAYQ,MAAM,CAACC,IAAP,CAAYT,OAAZ,EAAqBU,MAArB,KAAgC,CAAhD,EAAmD;AACjD,WAAO,YAAP;AACD;;AAED,MAAMC,mBAAmB,GAAGL,YAAY,GAAGM,sBAAsB,CAACb,KAAD,CAAzB,GAAmCc,eAAe,CAACd,KAAD,CAA1F;AACA,MAAIe,cAAJ;AACA,MAAIC,gBAAgB,GAAG,CAAvB;;AAEA,MAAIT,YAAJ,EAAkB;AAChB,QAAMU,UAAU,GAAGC,aAAa,CAACZ,IAAD,EAAOL,OAAP,CAAhC;AAEAc,IAAAA,cAAc,GAAGE,UAAU,CAACF,cAA5B;AACAC,IAAAA,gBAAgB,GAAGC,UAAU,CAACD,gBAA9B;AACD,GALD,MAKO;AACLD,IAAAA,cAAc,GAAGI,gBAAgB,CAACb,IAAD,EAAOL,OAAP,CAAjC;AACD;;AAED,MAAIW,mBAAmB,KAAKG,cAAxB,IAA0C,CAACC,gBAA/C,EAAiE;AAC/D,WAAO,SAAP;AACD,GAFD,MAEO,IAAID,cAAc,KAAK,CAAvB,EAA0B;AAC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pty';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport debug from 'debug';\n\nconst log = debug('@pie-element:match:controller');\n\nimport defaults from './defaults';\n\nconst getResponseCorrectness = (model, answers, env = {}) => {\n const isPartialScoring = partialScoring.enabled(model, env);\n const rows = model.rows;\n const checkboxMode = model.choiceMode === 'checkbox';\n\n if (!answers || Object.keys(answers).length === 0) {\n return 'unanswered';\n }\n\n const totalCorrectAnswers = checkboxMode ? getTotalCorrectAnswers(model) : getTotalCorrect(model);\n let correctAnswers;\n let incorrectAnswers = 0;\n\n if (checkboxMode) {\n const checkboxes = getCheckboxes(rows, answers);\n\n correctAnswers = checkboxes.correctAnswers;\n incorrectAnswers = checkboxes.incorrectAnswers;\n } else {\n correctAnswers = getCorrectRadios(rows, answers);\n }\n\n if (totalCorrectAnswers === correctAnswers && !incorrectAnswers) {\n return 'correct';\n } else if (correctAnswers === 0) {\n return 'incorrect';\n } else if (isPartialScoring) {\n return 'partial';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectness = (question, env, answers = {}) => {\n if (env.mode === 'evaluate') {\n return getResponseCorrectness(question, answers, env);\n }\n};\n\nconst getCheckboxes = (rows, answers) => {\n let correctAnswers = 0;\n let incorrectAnswers = 0;\n\n rows.forEach(row => {\n const answer = answers[row.id];\n\n if (answer) {\n row.values.forEach((v, i) => {\n if (answer[i] && answer[i] === v) {\n correctAnswers += 1;\n } else if (answer[i] && answer[i] !== v) {\n incorrectAnswers += 1;\n }\n });\n }\n });\n\n return { correctAnswers, incorrectAnswers };\n};\n\nconst getCorrectRadios = (rows, answers) => {\n let correctAnswers = 0;\n\n rows.forEach(row => {\n if (isEqual(row.values, answers[row.id])) {\n correctAnswers += 1;\n }\n });\n\n return correctAnswers;\n};\n\nconst getTotalCorrect = question => {\n const checkboxMode = question.choiceMode === 'checkbox';\n const matchingTable = checkboxMode ? question.layout - 1 : 1;\n return (question.rows.length || 0) * matchingTable;\n};\n\nconst getTotalCorrectAnswers = question => {\n let noOfTotalCorrectAnswers = 0;\n\n question.rows.forEach(row => {\n row.values.forEach(value => {\n if (value) {\n noOfTotalCorrectAnswers += 1;\n }\n });\n });\n\n return noOfTotalCorrectAnswers;\n};\n\nconst getPartialScore = (question, answers) => {\n const checkboxMode = question.choiceMode === 'checkbox';\n\n if (checkboxMode) {\n const { correctAnswers, incorrectAnswers } = getCheckboxes(question.rows, answers);\n const totalCorrect = getTotalCorrectAnswers(question);\n\n const total = totalCorrect === 0 ? 1 : totalCorrect;\n\n if (correctAnswers + incorrectAnswers > totalCorrect) {\n const extraAnswers = (correctAnswers + incorrectAnswers) - totalCorrect;\n const score = parseFloat(((correctAnswers - extraAnswers) / total).toFixed(2));\n\n return score < 0 ? 0 : score;\n } else {\n return parseFloat((correctAnswers / total).toFixed(2));\n }\n } else {\n const correctAnswers = getCorrectRadios(question.rows, answers);\n const totalCorrect = getTotalCorrect(question) === 0 ? 1 : getTotalCorrect(question);\n\n return parseFloat((correctAnswers / totalCorrect).toFixed(2));\n }\n};\n\nconst getOutComeScore = (question, env, answers = {}) => {\n const correctness = getCorrectness(question, env, answers);\n const isPartialScoring = partialScoring.enabled(question, env);\n\n return correctness === 'correct'\n ? 1\n : correctness === 'partial' && isPartialScoring\n ? getPartialScore(question, answers)\n : 0;\n};\n\nexport const outcome = (question, session, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n const out = {\n score: getOutComeScore(question, env, session.answers)\n };\n\n resolve(out);\n }\n });\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => {\n resolve({\n ...defaults,\n ...model\n });\n });\n}\n\nexport const normalize = question => ({\n feedbackEnabled: true,\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport function model(question, session, env, updateSession) {\n return new Promise(async resolve => {\n const normalizedQuestion = cloneDeep(normalize(question));\n let correctness, score;\n\n if ((!session || isEmpty(session)) && env.mode === 'evaluate') {\n correctness = 'unanswered';\n score = '0%';\n } else {\n correctness = getCorrectness(normalizedQuestion, env, session && session.answers);\n score = `${getOutComeScore(normalizedQuestion, env, session && session.answers) *\n 100}%`;\n }\n\n const correctResponse = {};\n const correctInfo = {\n score,\n correctness\n };\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n normalizedQuestion.rows = await getShuffledChoices(\n normalizedQuestion.rows,\n session,\n updateSession,\n 'id'\n );\n }\n\n normalizedQuestion.rows.forEach(row => {\n correctResponse[row.id] = row.values;\n\n if (env.mode !== 'evaluate') {\n delete row.values;\n }\n });\n\n const fb =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? getFeedbackForCorrectness(correctInfo.correctness, normalizedQuestion.feedback)\n : Promise.resolve(undefined);\n\n fb.then(feedback => {\n const out = {\n allowFeedback: normalizedQuestion.feedbackEnabled,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n config: {\n ...normalizedQuestion,\n shuffled: !normalizedQuestion.lockChoiceOrder\n },\n feedback,\n disabled: env.mode !== 'gather',\n view: env.mode === 'view'\n };\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n out.config.rationale = null;\n out.config.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate') {\n Object.assign(out, {\n correctResponse,\n correctness: correctInfo,\n });\n }\n\n log('out: ', out);\n resolve(out);\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { rows } = question;\n const answers = {};\n\n rows.forEach(r => {\n answers[r.id] = r.values;\n });\n\n resolve({\n answers,\n id: '1'\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { rows, choiceMode } = model;\n const rowsErrors = {};\n\n (rows || []).forEach(row => {\n const { id, values = [] } = row;\n let hasCorrectResponse = false;\n\n values.forEach(value => {\n if (value) {\n hasCorrectResponse = true;\n }\n });\n\n if (!hasCorrectResponse) {\n rowsErrors[id] = 'No correct response defined.';\n }\n });\n\n const errors = {};\n\n if (!isEmpty(rowsErrors)) {\n errors.rowsErrors = rowsErrors;\n errors.correctResponseError = choiceMode === 'radio'\n ? 'There should be a correct response defined for every row.'\n : 'There should be at least one correct response defined for every row.';\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/docs/config-schema.json
CHANGED
|
@@ -131,6 +131,22 @@
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
|
+
"spellCheck": {
|
|
135
|
+
"title": "ConfigureProp",
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"settings": {
|
|
139
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
140
|
+
"type": "boolean",
|
|
141
|
+
"title": "settings"
|
|
142
|
+
},
|
|
143
|
+
"label": {
|
|
144
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
145
|
+
"type": "string",
|
|
146
|
+
"title": "label"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
134
150
|
"rationale": {
|
|
135
151
|
"title": "ConfigureProp",
|
|
136
152
|
"type": "object",
|
|
@@ -195,6 +211,74 @@
|
|
|
195
211
|
}
|
|
196
212
|
}
|
|
197
213
|
},
|
|
214
|
+
"maxImageWidth": {
|
|
215
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
216
|
+
"type": "object",
|
|
217
|
+
"properties": {
|
|
218
|
+
"teacherInstructions": {
|
|
219
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
220
|
+
"type": "number",
|
|
221
|
+
"title": "teacherInstructions"
|
|
222
|
+
},
|
|
223
|
+
"prompt": {
|
|
224
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
225
|
+
"type": "number",
|
|
226
|
+
"title": "prompt"
|
|
227
|
+
},
|
|
228
|
+
"rationale": {
|
|
229
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
230
|
+
"type": "number",
|
|
231
|
+
"title": "rationale"
|
|
232
|
+
},
|
|
233
|
+
"rowTitles": {
|
|
234
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
235
|
+
"type": "number",
|
|
236
|
+
"title": "rowTitles"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
"maxImageHeight": {
|
|
241
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
242
|
+
"type": "object",
|
|
243
|
+
"properties": {
|
|
244
|
+
"teacherInstructions": {
|
|
245
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
246
|
+
"type": "number",
|
|
247
|
+
"title": "teacherInstructions"
|
|
248
|
+
},
|
|
249
|
+
"prompt": {
|
|
250
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
251
|
+
"type": "number",
|
|
252
|
+
"title": "prompt"
|
|
253
|
+
},
|
|
254
|
+
"rationale": {
|
|
255
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
256
|
+
"type": "number",
|
|
257
|
+
"title": "rationale"
|
|
258
|
+
},
|
|
259
|
+
"rowTitles": {
|
|
260
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
261
|
+
"type": "number",
|
|
262
|
+
"title": "rowTitles"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"withRubric": {
|
|
267
|
+
"title": "ConfigureProp",
|
|
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
|
+
}
|
|
281
|
+
},
|
|
198
282
|
"showPrompt": {
|
|
199
283
|
"description": "Determines whether prompt field will be displayed or not",
|
|
200
284
|
"default": true,
|
|
@@ -230,6 +314,32 @@
|
|
|
230
314
|
"title": "label"
|
|
231
315
|
}
|
|
232
316
|
}
|
|
317
|
+
},
|
|
318
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
319
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
320
|
+
"type": "object",
|
|
321
|
+
"properties": {
|
|
322
|
+
"teacherInstructions": {
|
|
323
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
324
|
+
"type": "number",
|
|
325
|
+
"title": "teacherInstructions"
|
|
326
|
+
},
|
|
327
|
+
"prompt": {
|
|
328
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
329
|
+
"type": "number",
|
|
330
|
+
"title": "prompt"
|
|
331
|
+
},
|
|
332
|
+
"rationale": {
|
|
333
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
334
|
+
"type": "number",
|
|
335
|
+
"title": "rationale"
|
|
336
|
+
},
|
|
337
|
+
"rowTitles": {
|
|
338
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
339
|
+
"type": "number",
|
|
340
|
+
"title": "rowTitles"
|
|
341
|
+
}
|
|
342
|
+
}
|
|
233
343
|
}
|
|
234
344
|
},
|
|
235
345
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
@@ -98,6 +98,18 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
98
98
|
|
|
99
99
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
100
100
|
|
|
101
|
+
# `spellCheck` (object)
|
|
102
|
+
|
|
103
|
+
Properties of the `spellCheck` object:
|
|
104
|
+
|
|
105
|
+
## `settings` (boolean)
|
|
106
|
+
|
|
107
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
108
|
+
|
|
109
|
+
## `label` (string)
|
|
110
|
+
|
|
111
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
112
|
+
|
|
101
113
|
# `rationale` (object)
|
|
102
114
|
|
|
103
115
|
Properties of the `rationale` object:
|
|
@@ -146,6 +158,58 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
146
158
|
|
|
147
159
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
148
160
|
|
|
161
|
+
# `maxImageWidth` (object)
|
|
162
|
+
|
|
163
|
+
Properties of the `maxImageWidth` object:
|
|
164
|
+
|
|
165
|
+
## `teacherInstructions` (number)
|
|
166
|
+
|
|
167
|
+
Indicates the max dimension for images in teacher instructions
|
|
168
|
+
|
|
169
|
+
## `prompt` (number)
|
|
170
|
+
|
|
171
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
172
|
+
|
|
173
|
+
## `rationale` (number)
|
|
174
|
+
|
|
175
|
+
Indicates the max dimension for images in rationale
|
|
176
|
+
|
|
177
|
+
## `rowTitles` (number)
|
|
178
|
+
|
|
179
|
+
Indicates the max dimension for images in row labels
|
|
180
|
+
|
|
181
|
+
# `maxImageHeight` (object)
|
|
182
|
+
|
|
183
|
+
Properties of the `maxImageHeight` object:
|
|
184
|
+
|
|
185
|
+
## `teacherInstructions` (number)
|
|
186
|
+
|
|
187
|
+
Indicates the max dimension for images in teacher instructions
|
|
188
|
+
|
|
189
|
+
## `prompt` (number)
|
|
190
|
+
|
|
191
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
192
|
+
|
|
193
|
+
## `rationale` (number)
|
|
194
|
+
|
|
195
|
+
Indicates the max dimension for images in rationale
|
|
196
|
+
|
|
197
|
+
## `rowTitles` (number)
|
|
198
|
+
|
|
199
|
+
Indicates the max dimension for images in row labels
|
|
200
|
+
|
|
201
|
+
# `withRubric` (object)
|
|
202
|
+
|
|
203
|
+
Properties of the `withRubric` 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
|
+
|
|
149
213
|
# `showPrompt` (boolean)
|
|
150
214
|
|
|
151
215
|
Determines whether prompt field will be displayed or not
|
|
@@ -180,4 +244,24 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
180
244
|
|
|
181
245
|
### `label` (string)
|
|
182
246
|
|
|
183
|
-
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
247
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
248
|
+
|
|
249
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
250
|
+
|
|
251
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
252
|
+
|
|
253
|
+
### `teacherInstructions` (number)
|
|
254
|
+
|
|
255
|
+
Indicates the max dimension for images in teacher instructions
|
|
256
|
+
|
|
257
|
+
### `prompt` (number)
|
|
258
|
+
|
|
259
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
260
|
+
|
|
261
|
+
### `rationale` (number)
|
|
262
|
+
|
|
263
|
+
Indicates the max dimension for images in rationale
|
|
264
|
+
|
|
265
|
+
### `rowTitles` (number)
|
|
266
|
+
|
|
267
|
+
Indicates the max dimension for images in row labels
|
package/docs/demo/generate.js
CHANGED
package/docs/pie-schema.json
CHANGED
|
@@ -288,6 +288,11 @@
|
|
|
288
288
|
"type": "boolean",
|
|
289
289
|
"title": "rationaleEnabled"
|
|
290
290
|
},
|
|
291
|
+
"spellCheckEnabled": {
|
|
292
|
+
"description": "Indicates if spellcheck is enabled for the author. Default value is true",
|
|
293
|
+
"type": "boolean",
|
|
294
|
+
"title": "spellCheckEnabled"
|
|
295
|
+
},
|
|
291
296
|
"studentInstructionsEnabled": {
|
|
292
297
|
"description": "Indicates if Student Instructions are enabled",
|
|
293
298
|
"type": "boolean",
|
|
@@ -308,6 +313,11 @@
|
|
|
308
313
|
"type": "string",
|
|
309
314
|
"title": "toolbarEditorPosition"
|
|
310
315
|
},
|
|
316
|
+
"rubricEnabled": {
|
|
317
|
+
"description": "Indicates if Rubric is enabled",
|
|
318
|
+
"type": "boolean",
|
|
319
|
+
"title": "rubricEnabled"
|
|
320
|
+
},
|
|
311
321
|
"id": {
|
|
312
322
|
"description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
|
|
313
323
|
"type": "string",
|
|
@@ -329,6 +339,8 @@
|
|
|
329
339
|
"rationale",
|
|
330
340
|
"rationaleEnabled",
|
|
331
341
|
"rows",
|
|
342
|
+
"rubricEnabled",
|
|
343
|
+
"spellCheckEnabled",
|
|
332
344
|
"studentInstructionsEnabled",
|
|
333
345
|
"teacherInstructionsEnabled"
|
|
334
346
|
],
|
|
@@ -349,6 +361,32 @@
|
|
|
349
361
|
}
|
|
350
362
|
}
|
|
351
363
|
},
|
|
364
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
365
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
366
|
+
"type": "object",
|
|
367
|
+
"properties": {
|
|
368
|
+
"teacherInstructions": {
|
|
369
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
370
|
+
"type": "number",
|
|
371
|
+
"title": "teacherInstructions"
|
|
372
|
+
},
|
|
373
|
+
"prompt": {
|
|
374
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
375
|
+
"type": "number",
|
|
376
|
+
"title": "prompt"
|
|
377
|
+
},
|
|
378
|
+
"rationale": {
|
|
379
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
380
|
+
"type": "number",
|
|
381
|
+
"title": "rationale"
|
|
382
|
+
},
|
|
383
|
+
"rowTitles": {
|
|
384
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
385
|
+
"type": "number",
|
|
386
|
+
"title": "rowTitles"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
352
390
|
"ComplexFeedbackType": {
|
|
353
391
|
"title": "ComplexFeedbackType",
|
|
354
392
|
"type": "object",
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -108,6 +108,10 @@ Indicates if Feedback is enabled
|
|
|
108
108
|
|
|
109
109
|
Indicates if Rationale are enabled
|
|
110
110
|
|
|
111
|
+
# `spellCheckEnabled` (boolean, required)
|
|
112
|
+
|
|
113
|
+
Indicates if spellcheck is enabled for the author. Default value is true
|
|
114
|
+
|
|
111
115
|
# `studentInstructionsEnabled` (boolean, required)
|
|
112
116
|
|
|
113
117
|
Indicates if Student Instructions are enabled
|
|
@@ -127,6 +131,10 @@ This element must be one of the following enum values:
|
|
|
127
131
|
|
|
128
132
|
Default: `": 'bottom'"`
|
|
129
133
|
|
|
134
|
+
# `rubricEnabled` (boolean, required)
|
|
135
|
+
|
|
136
|
+
Indicates if Rubric is enabled
|
|
137
|
+
|
|
130
138
|
# `id` (string, required)
|
|
131
139
|
|
|
132
140
|
Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
|
|
@@ -153,6 +161,26 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
153
161
|
|
|
154
162
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
155
163
|
|
|
164
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
165
|
+
|
|
166
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
167
|
+
|
|
168
|
+
### `teacherInstructions` (number)
|
|
169
|
+
|
|
170
|
+
Indicates the max dimension for images in teacher instructions
|
|
171
|
+
|
|
172
|
+
### `prompt` (number)
|
|
173
|
+
|
|
174
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
175
|
+
|
|
176
|
+
### `rationale` (number)
|
|
177
|
+
|
|
178
|
+
Indicates the max dimension for images in rationale
|
|
179
|
+
|
|
180
|
+
### `rowTitles` (number)
|
|
181
|
+
|
|
182
|
+
Indicates the max dimension for images in row labels
|
|
183
|
+
|
|
156
184
|
## `ComplexFeedbackType` (object)
|
|
157
185
|
|
|
158
186
|
Properties of the `ComplexFeedbackType` object:
|
package/lib/answer-grid.js
CHANGED
|
@@ -37,13 +37,13 @@ var _styles = require("@material-ui/core/styles");
|
|
|
37
37
|
|
|
38
38
|
var _renderUi = require("@pie-lib/render-ui");
|
|
39
39
|
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
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; }
|
|
41
41
|
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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; }
|
|
43
43
|
|
|
44
44
|
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); }; }
|
|
45
45
|
|
|
46
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
46
|
+
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; } }
|
|
47
47
|
|
|
48
48
|
var AnswerGrid = /*#__PURE__*/function (_React$Component) {
|
|
49
49
|
(0, _inherits2["default"])(AnswerGrid, _React$Component);
|
|
@@ -96,7 +96,6 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
|
|
|
96
96
|
var _this2 = this;
|
|
97
97
|
|
|
98
98
|
var _this$props2 = this.props,
|
|
99
|
-
allowFeedback = _this$props2.allowFeedback,
|
|
100
99
|
classes = _this$props2.classes,
|
|
101
100
|
showCorrect = _this$props2.showCorrect,
|
|
102
101
|
headers = _this$props2.headers,
|
|
@@ -106,6 +105,7 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
|
|
|
106
105
|
disabled = _this$props2.disabled,
|
|
107
106
|
view = _this$props2.view;
|
|
108
107
|
var Tag = choiceMode === 'radio' ? _Radio["default"] : _Checkbox["default"];
|
|
108
|
+
var evaluate = disabled && !view;
|
|
109
109
|
|
|
110
110
|
if (!rows || rows.length === 0) {
|
|
111
111
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -160,7 +160,7 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
|
|
|
160
160
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
161
161
|
className: classes.rowItem
|
|
162
162
|
}, /*#__PURE__*/_react["default"].createElement(Tag, {
|
|
163
|
-
className: (0, _classnames["default"])((_cx2 = {}, (0, _defineProperty2["default"])(_cx2, classes.correct,
|
|
163
|
+
className: (0, _classnames["default"])((_cx2 = {}, (0, _defineProperty2["default"])(_cx2, classes.correct, showCorrect && rowItem === true || evaluate && _this2.answerIsCorrect(row.id, rowItem, answerIndex)), (0, _defineProperty2["default"])(_cx2, classes.tag, true), (0, _defineProperty2["default"])(_cx2, classes.checked, rowItem === true && !evaluate), (0, _defineProperty2["default"])(_cx2, classes.tagDisabled, disabled), (0, _defineProperty2["default"])(_cx2, classes.incorrect, evaluate && _this2.answerIsIncorrect(row.id, rowItem, answerIndex)), _cx2)),
|
|
164
164
|
disabled: disabled,
|
|
165
165
|
onChange: _this2.onRowValueChange(row.id, answerIndex),
|
|
166
166
|
checked: rowItem === true
|
|
@@ -174,7 +174,6 @@ var AnswerGrid = /*#__PURE__*/function (_React$Component) {
|
|
|
174
174
|
|
|
175
175
|
exports.AnswerGrid = AnswerGrid;
|
|
176
176
|
(0, _defineProperty2["default"])(AnswerGrid, "propTypes", {
|
|
177
|
-
allowFeedback: _propTypes["default"].bool.isRequired,
|
|
178
177
|
classes: _propTypes["default"].object.isRequired,
|
|
179
178
|
correctAnswers: _propTypes["default"].object,
|
|
180
179
|
view: _propTypes["default"].bool.isRequired,
|