@pie-element/categorize 6.7.0 → 6.7.3-next.1014
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 +171 -0
- package/configure/CHANGELOG.md +128 -0
- package/configure/lib/defaults.js +27 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/builder.js +1 -1
- package/configure/lib/design/buttons.js +6 -4
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/alternateResponses.js +4 -2
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +13 -4
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +4 -4
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +3 -3
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +84 -11
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +25 -6
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +5 -3
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +42 -8
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +15 -5
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +57 -11
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +16 -4
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/index.js +3 -3
- package/configure/lib/main.js +1 -1
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +20 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +27 -0
- package/controller/lib/index.js +83 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +139 -0
- package/docs/config-schema.json.md +109 -1
- package/docs/demo/generate.js +1 -0
- package/docs/pie-schema.json +52 -0
- package/docs/pie-schema.json.md +43 -0
- package/lib/categorize/categories.js +9 -4
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +4 -4
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +5 -4
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +12 -5
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +2 -2
- package/lib/categorize/droppable-placeholder.js.map +1 -1
- package/lib/categorize/grid-content.js +3 -3
- package/lib/categorize/grid-content.js.map +1 -1
- package/lib/categorize/index.js +11 -15
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateValidationMessage = void 0;
|
|
7
|
+
|
|
8
|
+
var generateValidationMessage = function generateValidationMessage(config) {
|
|
9
|
+
var _ref = config || {},
|
|
10
|
+
minChoices = _ref.minChoices,
|
|
11
|
+
maxChoices = _ref.maxChoices,
|
|
12
|
+
maxCategories = _ref.maxCategories;
|
|
13
|
+
|
|
14
|
+
minChoices = minChoices || 1;
|
|
15
|
+
var validationMessage = '\nThe choices content should ' + 'not be empty and should be unique.\nThere should be at least 1 ' + (maxCategories ? "and at most ".concat(maxCategories, " ") : '') + 'category' + (maxCategories ? 's' : '') + ' defined.' + (minChoices ? "\nThere should be at least ".concat(minChoices, " choices defined.") : '') + (maxChoices ? "\nNo more than ".concat(maxChoices, " choices should be defined.") : '') + '\nAt least one token should be assigned to at least one category.';
|
|
16
|
+
return 'Validation requirements:' + validationMessage;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.generateValidationMessage = generateValidationMessage;
|
|
20
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["generateValidationMessage","config","minChoices","maxChoices","maxCategories","validationMessage"],"mappings":";;;;;;;AAAO,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,CAAAC,MAAM,EAAI;AACjD,aAAgDA,MAAM,IAAI,EAA1D;AAAA,MAAMC,UAAN,QAAMA,UAAN;AAAA,MAAkBC,UAAlB,QAAkBA,UAAlB;AAAA,MAA8BC,aAA9B,QAA8BA,aAA9B;;AACAF,EAAAA,UAAU,GAAGA,UAAU,IAAI,CAA3B;AAEA,MAAMG,iBAAiB,GAAG,kCACxB,iEADwB,IAEvBD,aAAa,yBAAkBA,aAAlB,SAAqC,EAF3B,IAGxB,UAHwB,IAGVA,aAAa,GAAG,GAAH,GAAS,EAHZ,IAGkB,WAHlB,IAIvBF,UAAU,wCAAiCA,UAAjC,yBAAiE,EAJpD,KAKvBC,UAAU,4BAAqBA,UAArB,mCAA+D,EALlD,IAMxB,mEANF;AAQA,SAAO,6BAA6BE,iBAApC;AACD,CAbM","sourcesContent":["export const generateValidationMessage = config => {\n let { minChoices, maxChoices, maxCategories } = config || {};\n minChoices = minChoices || 1;\n\n const validationMessage = '\\nThe choices content should ' +\n 'not be empty and should be unique.\\nThere should be at least 1 ' +\n (maxCategories ? `and at most ${maxCategories} ` : '') +\n 'category' + (maxCategories ? 's' : '') + ' defined.' +\n (minChoices ? `\\nThere should be at least ${minChoices} choices defined.` : '') +\n (maxChoices ? `\\nNo more than ${maxChoices} choices should be defined.` : '') +\n '\\nAt least one token should be assigned to at least one category.';\n\n return 'Validation requirements:' + validationMessage;\n};\n"],"file":"utils.js"}
|
package/configure/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "src/index.js",
|
|
6
|
-
"version": "5.4.
|
|
6
|
+
"version": "5.4.19",
|
|
7
7
|
"description": "",
|
|
8
8
|
"scripts": {},
|
|
9
9
|
"author": "pie framework developers",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"@material-ui/icons": "^3.0.1",
|
|
14
14
|
"@pie-framework/pie-configure-events": "^1.2.0",
|
|
15
15
|
"@pie-lib/categorize": "^0.6.24",
|
|
16
|
-
"@pie-lib/config-ui": "^10.
|
|
16
|
+
"@pie-lib/config-ui": "^10.13.3",
|
|
17
17
|
"@pie-lib/drag": "^1.1.52",
|
|
18
|
-
"@pie-lib/editable-html": "^7.
|
|
19
|
-
"@pie-lib/render-ui": "^4.
|
|
18
|
+
"@pie-lib/editable-html": "^7.22.6",
|
|
19
|
+
"@pie-lib/render-ui": "^4.12.9",
|
|
20
20
|
"classnames": "^2.2.5",
|
|
21
21
|
"debug": "^3.1.0",
|
|
22
22
|
"lodash": "^4.17.15",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.2.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-controller@5.2.2...@pie-element/categorize-controller@5.2.4) (2021-11-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/categorize-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [5.2.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-controller@5.2.2...@pie-element/categorize-controller@5.2.3) (2021-11-11)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/categorize-controller
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [5.2.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-controller@5.2.0...@pie-element/categorize-controller@5.2.2) (2021-08-05)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# [5.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-controller@5.1.16...@pie-element/categorize-controller@5.2.0) (2021-06-29)
|
|
7
34
|
|
|
8
35
|
|
package/controller/lib/index.js
CHANGED
|
@@ -5,16 +5,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.outcome = exports.normalize = exports.model = exports.getTotalScore = exports.getPartialScore = exports.getCorrectness = exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
|
|
8
9
|
Object.defineProperty(exports, "score", {
|
|
9
10
|
enumerable: true,
|
|
10
11
|
get: function get() {
|
|
11
12
|
return _categorize.score;
|
|
12
13
|
}
|
|
13
14
|
});
|
|
14
|
-
exports.
|
|
15
|
+
exports.validate = void 0;
|
|
15
16
|
|
|
16
17
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
17
18
|
|
|
19
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
20
|
+
|
|
18
21
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
19
22
|
|
|
20
23
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -29,9 +32,9 @@ var _controllerUtils = require("@pie-lib/controller-utils");
|
|
|
29
32
|
|
|
30
33
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
31
34
|
|
|
32
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
35
|
+
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
36
|
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
37
|
+
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
38
|
|
|
36
39
|
var getPartialScore = function getPartialScore(correctResponse, builtCategories) {
|
|
37
40
|
// in the resulted best scenario we make a sum with all the correct responses
|
|
@@ -295,4 +298,81 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
295
298
|
};
|
|
296
299
|
|
|
297
300
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
301
|
+
|
|
302
|
+
var validate = function validate() {
|
|
303
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
304
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
305
|
+
var categories = model.categories,
|
|
306
|
+
choices = model.choices,
|
|
307
|
+
correctResponse = model.correctResponse;
|
|
308
|
+
var _config$minChoices = config.minChoices,
|
|
309
|
+
minChoices = _config$minChoices === void 0 ? 1 : _config$minChoices,
|
|
310
|
+
maxChoices = config.maxChoices,
|
|
311
|
+
maxCategories = config.maxCategories;
|
|
312
|
+
var reversedChoices = (0, _toConsumableArray2["default"])(choices || []).reverse();
|
|
313
|
+
var errors = {};
|
|
314
|
+
var choicesErrors = {};
|
|
315
|
+
reversedChoices.forEach(function (choice, index) {
|
|
316
|
+
var id = choice.id,
|
|
317
|
+
content = choice.content;
|
|
318
|
+
|
|
319
|
+
if (content === '' || content === '<div></div>') {
|
|
320
|
+
choicesErrors[id] = 'Content should not be empty.';
|
|
321
|
+
} else {
|
|
322
|
+
var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
|
|
323
|
+
return c.content === content;
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
if (identicalAnswer) {
|
|
327
|
+
choicesErrors[id] = 'Content should be unique.';
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
var nbOfCategories = (categories || []).length;
|
|
332
|
+
var nbOfChoices = (choices || []).length;
|
|
333
|
+
|
|
334
|
+
if (nbOfCategories > maxCategories) {
|
|
335
|
+
errors.categoriesError = "No more than ".concat(maxCategories, " categories should be defined.");
|
|
336
|
+
} else if (nbOfCategories < 1) {
|
|
337
|
+
errors.categoriesError = 'There should be at least 1 category defined.';
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (nbOfChoices < minChoices) {
|
|
341
|
+
errors.choicesError = "There should be at least ".concat(minChoices, " choices defined.");
|
|
342
|
+
} else if (nbOfChoices > maxChoices) {
|
|
343
|
+
errors.choicesError = "No more than ".concat(maxChoices, " choices should be defined.");
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (nbOfChoices && nbOfCategories) {
|
|
347
|
+
var hasAssociations = false;
|
|
348
|
+
(correctResponse || []).forEach(function (response) {
|
|
349
|
+
var _response$choices = response.choices,
|
|
350
|
+
choices = _response$choices === void 0 ? [] : _response$choices,
|
|
351
|
+
_response$alternateRe = response.alternateResponses,
|
|
352
|
+
alternateResponses = _response$alternateRe === void 0 ? [] : _response$alternateRe;
|
|
353
|
+
|
|
354
|
+
if (choices.length) {
|
|
355
|
+
hasAssociations = true;
|
|
356
|
+
} else {
|
|
357
|
+
alternateResponses.forEach(function (alternate) {
|
|
358
|
+
if ((alternate || []).length) {
|
|
359
|
+
hasAssociations = true;
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
if (!hasAssociations) {
|
|
366
|
+
errors.associationError = 'At least one token should be assigned to at least one category.';
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (!(0, _isEmpty["default"])(choicesErrors)) {
|
|
371
|
+
errors.choicesErrors = choicesErrors;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return errors;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
exports.validate = validate;
|
|
298
378
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["getPartialScore","correctResponse","builtCategories","reduce","acc","choices","placements","length","score","filter","ch","correct","maxScore","extraPlacements","totalScore","parseFloat","toFixed","getAlternates","map","c","alternateResponses","alternate","getTotalScore","question","session","env","Object","keys","categories","answers","alternates","enabled","partialScoring","getCorrectness","Promise","resolve","mode","undefined","createDefaultModel","model","defaults","normalize","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","updateSession","normalizedQuestion","answerCorrectness","role","categoriesPerRow","choicesLabel","choicesPosition","feedback","prompt","removeTilesAfterPlacing","rowLabels","rationale","note","teacherInstructions","lockChoiceOrder","fb","out","correctness","disabled","showNote","outcome","reject","Error","empty","createCorrectResponseSession","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;;;;;;AAMO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,eAAD,EAAkBC,eAAlB,EAAsC;AACnE;AACA;AAFmE,8BAGrCA,eAAe,CAACC,MAAhB,CAC5B,UAACC,GAAD;AAAA,4BAAQC,OAAR;AAAA,QAAQA,OAAR,6BAAkB,EAAl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D;AAAA,UACxCjD,eADwC,GACpBsB,QADoB,CACxCtB,eADwC;AAGhDkC,MAAAA,OAAO,CAAC;AAAEN,QAAAA,OAAO,EAAE5B,eAAX;AAA4BuE,QAAAA,EAAE,EAAE;AAAhC,OAAD,CAAP;AACD,KAJD,MAIO;AACL,aAAOrC,OAAO,CAAC,IAAD,CAAd;AACD;AACF,GAVM,CAAP;AAWD,CAZM","sourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport { buildState, score } from '@pie-lib/categorize';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport {\n lockChoices,\n getShuffledChoices,\n partialScoring,\n} from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\nexport const getPartialScore = (correctResponse, builtCategories) => {\n // in the resulted best scenario we make a sum with all the correct responses\n // and all the placements\n const { placements, score } = builtCategories.reduce(\n (acc, { choices = [] }) => ({\n placements: acc.placements + choices.length,\n score: acc.score + choices.filter((ch) => ch.correct).length,\n }),\n { placements: 0, score: 0 }\n );\n\n // in the correct response, we make a sum of the max possible score\n const { maxScore } = correctResponse.reduce(\n (acc, { choices }) => ({\n maxScore: acc.maxScore + choices.length,\n }),\n { maxScore: 0 }\n );\n\n // if there are any extra placements, we subtract from the obtained score\n const extraPlacements = placements > maxScore ? placements - maxScore : 0;\n const totalScore = (score - extraPlacements) / maxScore;\n\n return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));\n};\n\nconst getAlternates = correctResponse => correctResponse\n .map((c) => c.alternateResponses)\n .filter((alternate) => alternate);\n\nexport const getTotalScore = (question, session, env) => {\n if (!session) {\n return 0;\n }\n\n if (Object.keys(session).length === 0) {\n return 0;\n }\n const { categories, choices } = question || {};\n let { correctResponse } = question || {};\n let { answers } = session || {};\n answers = answers || [];\n correctResponse = correctResponse || [];\n\n // this function is used in pie-ui/categorize as well, in order to get the best scenario\n // so we get the best scenario and calculate the score\n const { categories: builtCategories, correct } = buildState(\n categories,\n choices,\n answers,\n correctResponse\n );\n\n const alternates = getAlternates(correctResponse);\n const enabled = partialScoring.enabled(question, env);\n\n // if there are any alternates, there will be no partial scoring!\n if (enabled && !alternates.length) {\n // we apply partial scoring\n return getPartialScore(correctResponse, builtCategories);\n }\n\n // else we apply dichotomous\n return correct ? 1 : 0;\n};\n\nexport const getCorrectness = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode === 'evaluate') {\n const score = getTotalScore(question, session, env);\n if (score === 1) {\n resolve('correct');\n } else if (score === 0) {\n resolve('incorrect');\n } else {\n resolve('partially-correct');\n }\n } else {\n resolve(undefined);\n }\n });\n};\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nexport const normalize = (question) => ({\n feedbackEnabled: true,\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 * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport const model = (question, session, env, updateSession) =>\n new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);\n\n const { mode, role } = env || {};\n\n const {\n categories,\n categoriesPerRow,\n choicesLabel,\n choicesPosition,\n correctResponse,\n feedback,\n feedbackEnabled,\n promptEnabled,\n prompt,\n removeTilesAfterPlacing,\n rowLabels,\n rationaleEnabled,\n rationale,\n note,\n teacherInstructionsEnabled,\n teacherInstructions,\n } = normalizedQuestion;\n let { choices } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(\n answerCorrectness,\n feedback\n );\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n const alternates = getAlternates(correctResponse);\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n correctness: answerCorrectness,\n choices: choices || [],\n choicesLabel: choicesLabel || '',\n choicesPosition,\n disabled: mode !== 'gather',\n feedback: fb,\n lockChoiceOrder,\n prompt: promptEnabled ? prompt : null,\n removeTilesAfterPlacing,\n rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? correctResponse : undefined,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled\n ? teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n\nexport const outcome = (question, session, env) => {\n if (env.mode !== 'evaluate') {\n return Promise.reject(\n new Error('Can not call outcome when mode is not evaluate')\n );\n } else {\n return new Promise((resolve) => {\n resolve({\n score: getTotalScore(question, session, env),\n empty: !session || isEmpty(session),\n });\n });\n }\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n const { mode, role } = env || {};\n\n if (mode !== 'evaluate' && role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({ answers: correctResponse, id: 1 });\n } else {\n return resolve(null);\n }\n });\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["getPartialScore","correctResponse","builtCategories","reduce","acc","choices","placements","length","score","filter","ch","correct","maxScore","extraPlacements","totalScore","parseFloat","toFixed","getAlternates","map","c","alternateResponses","alternate","getTotalScore","question","session","env","Object","keys","categories","answers","alternates","enabled","partialScoring","getCorrectness","Promise","resolve","mode","undefined","createDefaultModel","model","defaults","normalize","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","updateSession","normalizedQuestion","answerCorrectness","role","categoriesPerRow","choicesLabel","choicesPosition","feedback","prompt","removeTilesAfterPlacing","rowLabels","rationale","note","teacherInstructions","lockChoiceOrder","fb","out","correctness","disabled","showNote","outcome","reject","Error","empty","createCorrectResponseSession","id","validate","config","minChoices","maxChoices","maxCategories","reversedChoices","reverse","errors","choicesErrors","forEach","choice","index","content","identicalAnswer","slice","some","nbOfCategories","nbOfChoices","categoriesError","choicesError","hasAssociations","response","associationError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;;;;;;AAMO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,eAAD,EAAkBC,eAAlB,EAAsC;AACnE;AACA;AACA,8BAA8BA,eAAe,CAACC,MAAhB,CAC5B,UAACC,GAAD;AAAA,4BAAQC,OAAR;AAAA,QAAQA,OAAR,6BAAkB,EAAlB;AAAA,WAA4B;AAC1BC,MAAAA,UAAU,EAAEF,GAAG,CAACE,UAAJ,GAAiBD,OAAO,CAACE,MADX;AAE1BC,MAAAA,KAAK,EAAEJ,GAAG,CAACI,KAAJ,GAAYH,OAAO,CAACI,MAAR,CAAe,UAACC,EAAD;AAAA,eAAQA,EAAE,CAACC,OAAX;AAAA,OAAf,EAAmCJ;AAF5B,KAA5B;AAAA,GAD4B,EAK5B;AAAED,IAAAA,UAAU,EAAE,CAAd;AAAiBE,IAAAA,KAAK,EAAE;AAAxB,GAL4B,CAA9B;AAAA,MAAQF,UAAR,yBAAQA,UAAR;AAAA,MAAoBE,KAApB,yBAAoBA,KAApB,CAHmE,CAWnE;;;AACA,8BAAqBP,eAAe,CAACE,MAAhB,CACnB,UAACC,GAAD;AAAA,QAAQC,OAAR,SAAQA,OAAR;AAAA,WAAuB;AACrBO,MAAAA,QAAQ,EAAER,GAAG,CAACQ,QAAJ,GAAeP,OAAO,CAACE;AADZ,KAAvB;AAAA,GADmB,EAInB;AAAEK,IAAAA,QAAQ,EAAE;AAAZ,GAJmB,CAArB;AAAA,MAAQA,QAAR,yBAAQA,QAAR,CAZmE,CAmBnE;;;AACA,MAAMC,eAAe,GAAGP,UAAU,GAAGM,QAAb,GAAwBN,UAAU,GAAG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IAAI,EAApB,EAAwBiF,OAAxB,CAAgC,UAAAY,QAAQ,EAAI;AAC1C,8BAAkDA,QAAlD,CAAQzF,OAAR;AAAA,UAAQA,OAAR,kCAAkB,EAAlB;AAAA,kCAAkDyF,QAAlD,CAAsB1E,kBAAtB;AAAA,UAAsBA,kBAAtB,sCAA2C,EAA3C;;AAEA,UAAIf,OAAO,CAACE,MAAZ,EAAoB;AAClBsF,QAAAA,eAAe,GAAG,IAAlB;AACD,OAFD,MAEO;AACLzE,QAAAA,kBAAkB,CAAC8D,OAAnB,CAA2B,UAAA7D,SAAS,EAAI;AACtC,cAAI,CAACA,SAAS,IAAI,EAAd,EAAkBd,MAAtB,EAA8B;AAC5BsF,YAAAA,eAAe,GAAG,IAAlB;AACD;AACF,SAJD;AAKD;AACF,KAZD;;AAcA,QAAI,CAACA,eAAL,EAAsB;AACpBb,MAAAA,MAAM,CAACe,gBAAP,GAA0B,iEAA1B;AACD;AACF;;AAED,MAAI,CAAC,yBAAQd,aAAR,CAAL,EAA6B;AAC3BD,IAAAA,MAAM,CAACC,aAAP,GAAuBA,aAAvB;AACD;;AAED,SAAOD,MAAP;AACD,CA/DM","sourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport { buildState, score } from '@pie-lib/categorize';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport {\n lockChoices,\n getShuffledChoices,\n partialScoring,\n} from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\nexport const getPartialScore = (correctResponse, builtCategories) => {\n // in the resulted best scenario we make a sum with all the correct responses\n // and all the placements\n const { placements, score } = builtCategories.reduce(\n (acc, { choices = [] }) => ({\n placements: acc.placements + choices.length,\n score: acc.score + choices.filter((ch) => ch.correct).length,\n }),\n { placements: 0, score: 0 }\n );\n\n // in the correct response, we make a sum of the max possible score\n const { maxScore } = correctResponse.reduce(\n (acc, { choices }) => ({\n maxScore: acc.maxScore + choices.length,\n }),\n { maxScore: 0 }\n );\n\n // if there are any extra placements, we subtract from the obtained score\n const extraPlacements = placements > maxScore ? placements - maxScore : 0;\n const totalScore = (score - extraPlacements) / maxScore;\n\n return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));\n};\n\nconst getAlternates = correctResponse => correctResponse\n .map((c) => c.alternateResponses)\n .filter((alternate) => alternate);\n\nexport const getTotalScore = (question, session, env) => {\n if (!session) {\n return 0;\n }\n\n if (Object.keys(session).length === 0) {\n return 0;\n }\n const { categories, choices } = question || {};\n let { correctResponse } = question || {};\n let { answers } = session || {};\n answers = answers || [];\n correctResponse = correctResponse || [];\n\n // this function is used in pie-ui/categorize as well, in order to get the best scenario\n // so we get the best scenario and calculate the score\n const { categories: builtCategories, correct } = buildState(\n categories,\n choices,\n answers,\n correctResponse\n );\n\n const alternates = getAlternates(correctResponse);\n const enabled = partialScoring.enabled(question, env);\n\n // if there are any alternates, there will be no partial scoring!\n if (enabled && !alternates.length) {\n // we apply partial scoring\n return getPartialScore(correctResponse, builtCategories);\n }\n\n // else we apply dichotomous\n return correct ? 1 : 0;\n};\n\nexport const getCorrectness = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode === 'evaluate') {\n const score = getTotalScore(question, session, env);\n if (score === 1) {\n resolve('correct');\n } else if (score === 0) {\n resolve('incorrect');\n } else {\n resolve('partially-correct');\n }\n } else {\n resolve(undefined);\n }\n });\n};\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nexport const normalize = (question) => ({\n feedbackEnabled: true,\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 * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport const model = (question, session, env, updateSession) =>\n new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);\n\n const { mode, role } = env || {};\n\n const {\n categories,\n categoriesPerRow,\n choicesLabel,\n choicesPosition,\n correctResponse,\n feedback,\n feedbackEnabled,\n promptEnabled,\n prompt,\n removeTilesAfterPlacing,\n rowLabels,\n rationaleEnabled,\n rationale,\n note,\n teacherInstructionsEnabled,\n teacherInstructions,\n } = normalizedQuestion;\n let { choices } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(\n answerCorrectness,\n feedback\n );\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n const alternates = getAlternates(correctResponse);\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n correctness: answerCorrectness,\n choices: choices || [],\n choicesLabel: choicesLabel || '',\n choicesPosition,\n disabled: mode !== 'gather',\n feedback: fb,\n lockChoiceOrder,\n prompt: promptEnabled ? prompt : null,\n removeTilesAfterPlacing,\n rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? correctResponse : undefined,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled\n ? teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n\nexport const outcome = (question, session, env) => {\n if (env.mode !== 'evaluate') {\n return Promise.reject(\n new Error('Can not call outcome when mode is not evaluate')\n );\n } else {\n return new Promise((resolve) => {\n resolve({\n score: getTotalScore(question, session, env),\n empty: !session || isEmpty(session),\n });\n });\n }\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n const { mode, role } = env || {};\n\n if (mode !== 'evaluate' && role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({ answers: correctResponse, id: 1 });\n } else {\n return resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { categories, choices, correctResponse } = model;\n const { minChoices = 1, maxChoices, maxCategories } = config;\n const reversedChoices = [ ...choices || []].reverse();\n const errors = {};\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { id, content } = choice;\n\n if (content === '' || content === '<div></div>') {\n choicesErrors[id] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.content === content);\n\n if (identicalAnswer) {\n choicesErrors[id] = 'Content should be unique.';\n }\n }\n });\n\n const nbOfCategories = (categories || []).length;\n const nbOfChoices = (choices || []).length\n\n if (nbOfCategories > maxCategories) {\n errors.categoriesError = `No more than ${maxCategories} categories should be defined.`;\n } else if (nbOfCategories < 1) {\n errors.categoriesError = 'There should be at least 1 category defined.';\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} choices defined.`;\n } else if (nbOfChoices > maxChoices) {\n errors.choicesError = `No more than ${maxChoices} choices should be defined.`;\n }\n\n if (nbOfChoices && nbOfCategories) {\n let hasAssociations = false;\n\n (correctResponse || []).forEach(response => {\n const { choices = [], alternateResponses = [] } = response;\n\n if (choices.length) {\n hasAssociations = true;\n } else {\n alternateResponses.forEach(alternate => {\n if ((alternate || []).length) {\n hasAssociations = true;\n }\n });\n }\n });\n\n if (!hasAssociations) {\n errors.associationError = 'At least one token should be assigned to at least one category.';\n }\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/docs/config-schema.json
CHANGED
|
@@ -35,6 +35,22 @@
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
+
"spellCheck": {
|
|
39
|
+
"title": "ConfigureProp",
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"settings": {
|
|
43
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"title": "settings"
|
|
46
|
+
},
|
|
47
|
+
"label": {
|
|
48
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"title": "label"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
38
54
|
"scoringType": {
|
|
39
55
|
"title": "ConfigureProp",
|
|
40
56
|
"type": "object",
|
|
@@ -83,6 +99,93 @@
|
|
|
83
99
|
}
|
|
84
100
|
}
|
|
85
101
|
},
|
|
102
|
+
"minChoices": {
|
|
103
|
+
"description": "Minimum number of choices",
|
|
104
|
+
"type": "number",
|
|
105
|
+
"title": "minChoices"
|
|
106
|
+
},
|
|
107
|
+
"maxChoices": {
|
|
108
|
+
"description": "Maximum number of choices",
|
|
109
|
+
"type": "number",
|
|
110
|
+
"title": "maxChoices"
|
|
111
|
+
},
|
|
112
|
+
"maxCategories": {
|
|
113
|
+
"description": "Maximum number of categories",
|
|
114
|
+
"type": "number",
|
|
115
|
+
"title": "maxCategories"
|
|
116
|
+
},
|
|
117
|
+
"maxImageWidth": {
|
|
118
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
119
|
+
"type": "object",
|
|
120
|
+
"properties": {
|
|
121
|
+
"teacherInstructions": {
|
|
122
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
123
|
+
"type": "number",
|
|
124
|
+
"title": "teacherInstructions"
|
|
125
|
+
},
|
|
126
|
+
"prompt": {
|
|
127
|
+
"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",
|
|
128
|
+
"type": "number",
|
|
129
|
+
"title": "prompt"
|
|
130
|
+
},
|
|
131
|
+
"rationale": {
|
|
132
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
133
|
+
"type": "number",
|
|
134
|
+
"title": "rationale"
|
|
135
|
+
},
|
|
136
|
+
"choices": {
|
|
137
|
+
"description": "Indicates the max dimension for images in choices",
|
|
138
|
+
"type": "number",
|
|
139
|
+
"title": "choices"
|
|
140
|
+
},
|
|
141
|
+
"rowLabel": {
|
|
142
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
143
|
+
"type": "number",
|
|
144
|
+
"title": "rowLabel"
|
|
145
|
+
},
|
|
146
|
+
"categoryLabel": {
|
|
147
|
+
"description": "Indicates the max dimension for images in category labels",
|
|
148
|
+
"type": "number",
|
|
149
|
+
"title": "categoryLabel"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"maxImageHeight": {
|
|
154
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
155
|
+
"type": "object",
|
|
156
|
+
"properties": {
|
|
157
|
+
"teacherInstructions": {
|
|
158
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
159
|
+
"type": "number",
|
|
160
|
+
"title": "teacherInstructions"
|
|
161
|
+
},
|
|
162
|
+
"prompt": {
|
|
163
|
+
"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",
|
|
164
|
+
"type": "number",
|
|
165
|
+
"title": "prompt"
|
|
166
|
+
},
|
|
167
|
+
"rationale": {
|
|
168
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
169
|
+
"type": "number",
|
|
170
|
+
"title": "rationale"
|
|
171
|
+
},
|
|
172
|
+
"choices": {
|
|
173
|
+
"description": "Indicates the max dimension for images in choices",
|
|
174
|
+
"type": "number",
|
|
175
|
+
"title": "choices"
|
|
176
|
+
},
|
|
177
|
+
"rowLabel": {
|
|
178
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
179
|
+
"type": "number",
|
|
180
|
+
"title": "rowLabel"
|
|
181
|
+
},
|
|
182
|
+
"categoryLabel": {
|
|
183
|
+
"description": "Indicates the max dimension for images in category labels",
|
|
184
|
+
"type": "number",
|
|
185
|
+
"title": "categoryLabel"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
86
189
|
"showPrompt": {
|
|
87
190
|
"description": "Determines whether prompt field will be displayed or not",
|
|
88
191
|
"default": true,
|
|
@@ -118,6 +221,42 @@
|
|
|
118
221
|
"title": "label"
|
|
119
222
|
}
|
|
120
223
|
}
|
|
224
|
+
},
|
|
225
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
226
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
227
|
+
"type": "object",
|
|
228
|
+
"properties": {
|
|
229
|
+
"teacherInstructions": {
|
|
230
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
231
|
+
"type": "number",
|
|
232
|
+
"title": "teacherInstructions"
|
|
233
|
+
},
|
|
234
|
+
"prompt": {
|
|
235
|
+
"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",
|
|
236
|
+
"type": "number",
|
|
237
|
+
"title": "prompt"
|
|
238
|
+
},
|
|
239
|
+
"rationale": {
|
|
240
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
241
|
+
"type": "number",
|
|
242
|
+
"title": "rationale"
|
|
243
|
+
},
|
|
244
|
+
"choices": {
|
|
245
|
+
"description": "Indicates the max dimension for images in choices",
|
|
246
|
+
"type": "number",
|
|
247
|
+
"title": "choices"
|
|
248
|
+
},
|
|
249
|
+
"rowLabel": {
|
|
250
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
251
|
+
"type": "number",
|
|
252
|
+
"title": "rowLabel"
|
|
253
|
+
},
|
|
254
|
+
"categoryLabel": {
|
|
255
|
+
"description": "Indicates the max dimension for images in category labels",
|
|
256
|
+
"type": "number",
|
|
257
|
+
"title": "categoryLabel"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
121
260
|
}
|
|
122
261
|
},
|
|
123
262
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
@@ -26,6 +26,18 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
26
26
|
|
|
27
27
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
28
28
|
|
|
29
|
+
# `spellCheck` (object)
|
|
30
|
+
|
|
31
|
+
Properties of the `spellCheck` object:
|
|
32
|
+
|
|
33
|
+
## `settings` (boolean)
|
|
34
|
+
|
|
35
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
36
|
+
|
|
37
|
+
## `label` (string)
|
|
38
|
+
|
|
39
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
40
|
+
|
|
29
41
|
# `scoringType` (object)
|
|
30
42
|
|
|
31
43
|
Properties of the `scoringType` object:
|
|
@@ -62,6 +74,74 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
62
74
|
|
|
63
75
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
64
76
|
|
|
77
|
+
# `minChoices` (number)
|
|
78
|
+
|
|
79
|
+
Minimum number of choices
|
|
80
|
+
|
|
81
|
+
# `maxChoices` (number)
|
|
82
|
+
|
|
83
|
+
Maximum number of choices
|
|
84
|
+
|
|
85
|
+
# `maxCategories` (number)
|
|
86
|
+
|
|
87
|
+
Maximum number of categories
|
|
88
|
+
|
|
89
|
+
# `maxImageWidth` (object)
|
|
90
|
+
|
|
91
|
+
Properties of the `maxImageWidth` object:
|
|
92
|
+
|
|
93
|
+
## `teacherInstructions` (number)
|
|
94
|
+
|
|
95
|
+
Indicates the max dimension for images in teacher instructions
|
|
96
|
+
|
|
97
|
+
## `prompt` (number)
|
|
98
|
+
|
|
99
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
100
|
+
|
|
101
|
+
## `rationale` (number)
|
|
102
|
+
|
|
103
|
+
Indicates the max dimension for images in rationale
|
|
104
|
+
|
|
105
|
+
## `choices` (number)
|
|
106
|
+
|
|
107
|
+
Indicates the max dimension for images in choices
|
|
108
|
+
|
|
109
|
+
## `rowLabel` (number)
|
|
110
|
+
|
|
111
|
+
Indicates the max dimension for images in row labels
|
|
112
|
+
|
|
113
|
+
## `categoryLabel` (number)
|
|
114
|
+
|
|
115
|
+
Indicates the max dimension for images in category labels
|
|
116
|
+
|
|
117
|
+
# `maxImageHeight` (object)
|
|
118
|
+
|
|
119
|
+
Properties of the `maxImageHeight` object:
|
|
120
|
+
|
|
121
|
+
## `teacherInstructions` (number)
|
|
122
|
+
|
|
123
|
+
Indicates the max dimension for images in teacher instructions
|
|
124
|
+
|
|
125
|
+
## `prompt` (number)
|
|
126
|
+
|
|
127
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
128
|
+
|
|
129
|
+
## `rationale` (number)
|
|
130
|
+
|
|
131
|
+
Indicates the max dimension for images in rationale
|
|
132
|
+
|
|
133
|
+
## `choices` (number)
|
|
134
|
+
|
|
135
|
+
Indicates the max dimension for images in choices
|
|
136
|
+
|
|
137
|
+
## `rowLabel` (number)
|
|
138
|
+
|
|
139
|
+
Indicates the max dimension for images in row labels
|
|
140
|
+
|
|
141
|
+
## `categoryLabel` (number)
|
|
142
|
+
|
|
143
|
+
Indicates the max dimension for images in category labels
|
|
144
|
+
|
|
65
145
|
# `showPrompt` (boolean)
|
|
66
146
|
|
|
67
147
|
Determines whether prompt field will be displayed or not
|
|
@@ -96,4 +176,32 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
96
176
|
|
|
97
177
|
### `label` (string)
|
|
98
178
|
|
|
99
|
-
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
179
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
180
|
+
|
|
181
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
182
|
+
|
|
183
|
+
Properties of the `ConfigureMaxImageDimensionsProp` 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
|
+
### `choices` (number)
|
|
198
|
+
|
|
199
|
+
Indicates the max dimension for images in choices
|
|
200
|
+
|
|
201
|
+
### `rowLabel` (number)
|
|
202
|
+
|
|
203
|
+
Indicates the max dimension for images in row labels
|
|
204
|
+
|
|
205
|
+
### `categoryLabel` (number)
|
|
206
|
+
|
|
207
|
+
Indicates the max dimension for images in category labels
|
package/docs/demo/generate.js
CHANGED
package/docs/pie-schema.json
CHANGED
|
@@ -373,6 +373,11 @@
|
|
|
373
373
|
"type": "boolean",
|
|
374
374
|
"title": "rationaleEnabled"
|
|
375
375
|
},
|
|
376
|
+
"spellCheckEnabled": {
|
|
377
|
+
"description": "Indicates if spellcheck is enabled for the author. Default value is true",
|
|
378
|
+
"type": "boolean",
|
|
379
|
+
"title": "spellCheckEnabled"
|
|
380
|
+
},
|
|
376
381
|
"studentInstructionsEnabled": {
|
|
377
382
|
"description": "Indicates if Student Instructions are enabled",
|
|
378
383
|
"type": "boolean",
|
|
@@ -388,6 +393,16 @@
|
|
|
388
393
|
"type": "string",
|
|
389
394
|
"title": "note"
|
|
390
395
|
},
|
|
396
|
+
"toolbarEditorPosition": {
|
|
397
|
+
"description": "Indicates the editor's toolbar position which can be 'bottom' or 'top'",
|
|
398
|
+
"default": ": 'bottom'",
|
|
399
|
+
"enum": [
|
|
400
|
+
"bottom",
|
|
401
|
+
"top"
|
|
402
|
+
],
|
|
403
|
+
"type": "string",
|
|
404
|
+
"title": "toolbarEditorPosition"
|
|
405
|
+
},
|
|
391
406
|
"id": {
|
|
392
407
|
"description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
|
|
393
408
|
"type": "string",
|
|
@@ -407,6 +422,7 @@
|
|
|
407
422
|
"id",
|
|
408
423
|
"prompt",
|
|
409
424
|
"rationaleEnabled",
|
|
425
|
+
"spellCheckEnabled",
|
|
410
426
|
"studentInstructionsEnabled",
|
|
411
427
|
"teacherInstructionsEnabled"
|
|
412
428
|
],
|
|
@@ -427,6 +443,42 @@
|
|
|
427
443
|
}
|
|
428
444
|
}
|
|
429
445
|
},
|
|
446
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
447
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
448
|
+
"type": "object",
|
|
449
|
+
"properties": {
|
|
450
|
+
"teacherInstructions": {
|
|
451
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
452
|
+
"type": "number",
|
|
453
|
+
"title": "teacherInstructions"
|
|
454
|
+
},
|
|
455
|
+
"prompt": {
|
|
456
|
+
"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",
|
|
457
|
+
"type": "number",
|
|
458
|
+
"title": "prompt"
|
|
459
|
+
},
|
|
460
|
+
"rationale": {
|
|
461
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
462
|
+
"type": "number",
|
|
463
|
+
"title": "rationale"
|
|
464
|
+
},
|
|
465
|
+
"choices": {
|
|
466
|
+
"description": "Indicates the max dimension for images in choices",
|
|
467
|
+
"type": "number",
|
|
468
|
+
"title": "choices"
|
|
469
|
+
},
|
|
470
|
+
"rowLabel": {
|
|
471
|
+
"description": "Indicates the max dimension for images in row labels",
|
|
472
|
+
"type": "number",
|
|
473
|
+
"title": "rowLabel"
|
|
474
|
+
},
|
|
475
|
+
"categoryLabel": {
|
|
476
|
+
"description": "Indicates the max dimension for images in category labels",
|
|
477
|
+
"type": "number",
|
|
478
|
+
"title": "categoryLabel"
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
},
|
|
430
482
|
"CategoryChoice": {
|
|
431
483
|
"title": "CategoryChoice",
|
|
432
484
|
"type": "object",
|