@pie-element/multiple-choice 5.8.1-next.99 → 5.9.3-next.1008
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 +231 -0
- package/PRINT.md +35 -0
- package/configure/CHANGELOG.md +195 -0
- package/configure/lib/defaults.js +29 -6
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +10 -5
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +245 -62
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +18 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +62 -0
- package/controller/lib/defaults.js +1 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +85 -18
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +9 -1
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +120 -0
- package/docs/config-schema.json.md +93 -1
- package/docs/demo/generate.js +10 -5
- package/docs/pie-schema.json +48 -0
- package/docs/pie-schema.json.md +39 -0
- package/lib/choice-input.js +44 -20
- package/lib/choice-input.js.map +1 -1
- package/lib/choice.js +157 -0
- package/lib/choice.js.map +1 -0
- package/lib/feedback-tick.js +1 -1
- package/lib/feedback-tick.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/main.js +1 -1
- package/lib/main.js.map +1 -1
- package/lib/multiple-choice.js +59 -146
- package/lib/multiple-choice.js.map +1 -1
- package/lib/print.js +129 -0
- package/lib/print.js.map +1 -0
- package/package.json +11 -7
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
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
|
+
## [3.5.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.4.1...@pie-element/multiple-choice-controller@3.5.1) (2021-11-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/multiple-choice-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.5.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.3.3...@pie-element/multiple-choice-controller@3.5.0) (2021-11-11)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **multiple-choice:** accessibility label - added aria label to checkbox and radio input types ([22514bb](https://github.com/pie-framework/pie-elements/commit/22514bb5e2476bc79a55756ff9a5c0c1e0642a29))
|
|
20
|
+
* if there are no choices - do not show grid columns dropdown BREAKING CHANGE: removed verticalMode(boolean) from model & configuration - and replaced it with choicesLayout(string) ([1c36ae8](https://github.com/pie-framework/pie-elements/commit/1c36ae8b7f9369b2723a6a84e7350370e1186c50))
|
|
21
|
+
* **multiple-choice:** added possibility to change layout - vertical, grid, horizontal ([46e7681](https://github.com/pie-framework/pie-elements/commit/46e7681a178ff29c983db1c7b6206389b55e2a00))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [3.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.4.0...@pie-element/multiple-choice-controller@3.4.1) (2021-09-01)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @pie-element/multiple-choice-controller
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [3.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.3.3...@pie-element/multiple-choice-controller@3.4.0) (2021-08-05)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* **multiple-choice:** accessibility label - added aria label to checkbox and radio input types ([22514bb](https://github.com/pie-framework/pie-elements/commit/22514bb5e2476bc79a55756ff9a5c0c1e0642a29))
|
|
42
|
+
* if there are no choices - do not show grid columns dropdown BREAKING CHANGE: removed verticalMode(boolean) from model & configuration - and replaced it with choicesLayout(string) ([1c36ae8](https://github.com/pie-framework/pie-elements/commit/1c36ae8b7f9369b2723a6a84e7350370e1186c50))
|
|
43
|
+
* **multiple-choice:** added possibility to change layout - vertical, grid, horizontal ([46e7681](https://github.com/pie-framework/pie-elements/commit/46e7681a178ff29c983db1c7b6206389b55e2a00))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [3.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.3.1...@pie-element/multiple-choice-controller@3.3.3) (2021-08-05)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Bug Fixes
|
|
53
|
+
|
|
54
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## [3.3.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.3.0...@pie-element/multiple-choice-controller@3.3.1) (2021-06-29)
|
|
61
|
+
|
|
62
|
+
**Note:** Version bump only for package @pie-element/multiple-choice-controller
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
6
68
|
# [3.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@3.2.13...@pie-element/multiple-choice-controller@3.3.0) (2021-04-07)
|
|
7
69
|
|
|
8
70
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","choicePrefix","choicesLayout","gridColumns"],"mappings":";;;;;;eAAe;AACbA,EAAAA,aAAa,EAAE,IADF;AAEbC,EAAAA,gBAAgB,EAAE,IAFL;AAGbC,EAAAA,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["promptEnabled","rationaleEnabled","accessibilityLabelsEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","choicePrefix","choicesLayout","gridColumns"],"mappings":";;;;;;eAAe;AACbA,EAAAA,aAAa,EAAE,IADF;AAEbC,EAAAA,gBAAgB,EAAE,IAFL;AAGbC,EAAAA,0BAA0B,EAAE,KAHf;AAIbC,EAAAA,0BAA0B,EAAE,IAJf;AAKbC,EAAAA,0BAA0B,EAAE,IALf;AAMbC,EAAAA,YAAY,EAAE,SAND;AAObC,EAAAA,aAAa,EAAE,UAPF;AAQbC,EAAAA,WAAW,EAAE;AARA,C","sourcesContent":["export default {\n promptEnabled: true,\n rationaleEnabled: true,\n accessibilityLabelsEnabled: false,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n choicePrefix: 'letters',\n choicesLayout: 'vertical',\n gridColumns: '2'\n};\n"],"file":"defaults.js"}
|
package/controller/lib/index.js
CHANGED
|
@@ -5,15 +5,22 @@ 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;
|
|
10
|
+
exports.getScore = void 0;
|
|
9
11
|
exports.model = model;
|
|
12
|
+
exports.normalize = void 0;
|
|
10
13
|
exports.outcome = outcome;
|
|
11
|
-
exports.
|
|
14
|
+
exports.validate = void 0;
|
|
12
15
|
|
|
13
16
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
17
|
|
|
18
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
|
+
|
|
15
20
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
21
|
|
|
22
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
23
|
+
|
|
17
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
25
|
|
|
19
26
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
@@ -24,9 +31,11 @@ var _defaults = _interopRequireDefault(require("./defaults"));
|
|
|
24
31
|
|
|
25
32
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
var _excluded = ["verticalMode", "choicesLayout"];
|
|
28
35
|
|
|
29
|
-
function
|
|
36
|
+
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; }
|
|
37
|
+
|
|
38
|
+
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; }
|
|
30
39
|
|
|
31
40
|
var prepareChoice = function prepareChoice(model, env, defaultFeedback) {
|
|
32
41
|
return function (choice) {
|
|
@@ -39,6 +48,10 @@ var prepareChoice = function prepareChoice(model, env, defaultFeedback) {
|
|
|
39
48
|
value: choice.value
|
|
40
49
|
};
|
|
41
50
|
|
|
51
|
+
if (model.accessibilityLabelsEnabled) {
|
|
52
|
+
out.accessibility = (0, _utils.parseHTML)(choice.accessibility).textContent || choice.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
43
56
|
out.rationale = model.rationaleEnabled ? choice.rationale : null;
|
|
44
57
|
} else {
|
|
@@ -71,7 +84,16 @@ function createDefaultModel() {
|
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
var normalize = function normalize(question) {
|
|
74
|
-
|
|
87
|
+
var _ref2 = question || {},
|
|
88
|
+
verticalMode = _ref2.verticalMode,
|
|
89
|
+
choicesLayout = _ref2.choicesLayout,
|
|
90
|
+
questionProps = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
91
|
+
|
|
92
|
+
return _objectSpread(_objectSpread(_objectSpread({}, _defaults["default"]), questionProps), {}, {
|
|
93
|
+
// This is used for offering support for old models which have the property verticalMode
|
|
94
|
+
// Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel
|
|
95
|
+
choicesLayout: choicesLayout || verticalMode === false && 'horizontal' || _defaults["default"].choicesLayout
|
|
96
|
+
});
|
|
75
97
|
};
|
|
76
98
|
/**
|
|
77
99
|
*
|
|
@@ -90,7 +112,7 @@ function model(_x, _x2, _x3, _x4) {
|
|
|
90
112
|
|
|
91
113
|
function _model() {
|
|
92
114
|
_model = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(question, session, env, updateSession) {
|
|
93
|
-
var normalizedQuestion, defaultFeedback, choices, lockChoiceOrder,
|
|
115
|
+
var normalizedQuestion, defaultFeedback, choices, lockChoiceOrder, out, _ref4, role, mode;
|
|
94
116
|
|
|
95
117
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
96
118
|
while (1) {
|
|
@@ -116,26 +138,18 @@ function _model() {
|
|
|
116
138
|
choices = _context.sent;
|
|
117
139
|
|
|
118
140
|
case 8:
|
|
119
|
-
// This is used for offering support for old models which have the property verticalMode
|
|
120
|
-
// Same thing is set in authoring : packages/multiple-choice/configure/src/main.jsx - componentDidMount
|
|
121
|
-
layout = '';
|
|
122
|
-
|
|
123
|
-
if (normalizedQuestion.verticalMode !== undefined) {
|
|
124
|
-
layout = normalizedQuestion.verticalMode === false ? 'horizontal' : 'vertical';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
141
|
out = {
|
|
128
142
|
disabled: env.mode !== 'gather',
|
|
129
143
|
mode: env.mode,
|
|
130
144
|
prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
|
|
131
|
-
choicesLayout: normalizedQuestion.choicesLayout
|
|
145
|
+
choicesLayout: normalizedQuestion.choicesLayout,
|
|
132
146
|
gridColumns: normalizedQuestion.gridColumns,
|
|
133
147
|
choiceMode: normalizedQuestion.choiceMode,
|
|
134
148
|
keyMode: normalizedQuestion.choicePrefix,
|
|
135
149
|
choices: choices,
|
|
136
150
|
responseCorrect: env.mode === 'evaluate' ? (0, _utils.isResponseCorrect)(normalizedQuestion, session) : undefined
|
|
137
151
|
};
|
|
138
|
-
|
|
152
|
+
_ref4 = env || {}, role = _ref4.role, mode = _ref4.mode;
|
|
139
153
|
|
|
140
154
|
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
141
155
|
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
@@ -145,7 +159,7 @@ function _model() {
|
|
|
145
159
|
|
|
146
160
|
return _context.abrupt("return", out);
|
|
147
161
|
|
|
148
|
-
case
|
|
162
|
+
case 12:
|
|
149
163
|
case "end":
|
|
150
164
|
return _context.stop();
|
|
151
165
|
}
|
|
@@ -215,10 +229,10 @@ function outcome(model, session, env) {
|
|
|
215
229
|
var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
|
|
216
230
|
return new Promise(function (resolve) {
|
|
217
231
|
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
218
|
-
var
|
|
232
|
+
var _ref3 = question || {
|
|
219
233
|
choices: []
|
|
220
234
|
},
|
|
221
|
-
choices =
|
|
235
|
+
choices = _ref3.choices;
|
|
222
236
|
|
|
223
237
|
resolve({
|
|
224
238
|
id: '1',
|
|
@@ -235,4 +249,57 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
235
249
|
};
|
|
236
250
|
|
|
237
251
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
252
|
+
|
|
253
|
+
var validate = function validate() {
|
|
254
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
255
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
256
|
+
var choices = model.choices;
|
|
257
|
+
var _config$minAnswerChoi = config.minAnswerChoices,
|
|
258
|
+
minAnswerChoices = _config$minAnswerChoi === void 0 ? 2 : _config$minAnswerChoi,
|
|
259
|
+
maxAnswerChoices = config.maxAnswerChoices;
|
|
260
|
+
var reversedChoices = (0, _toConsumableArray2["default"])(choices || []).reverse();
|
|
261
|
+
var choicesErrors = {};
|
|
262
|
+
var hasCorrectResponse = false;
|
|
263
|
+
reversedChoices.forEach(function (choice, index) {
|
|
264
|
+
var correct = choice.correct,
|
|
265
|
+
value = choice.value,
|
|
266
|
+
label = choice.label;
|
|
267
|
+
|
|
268
|
+
if (correct) {
|
|
269
|
+
hasCorrectResponse = true;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (label === '' || label === '<div></div>') {
|
|
273
|
+
choicesErrors[value] = 'Content should not be empty.';
|
|
274
|
+
} else {
|
|
275
|
+
var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
|
|
276
|
+
return c.label === label;
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
if (identicalAnswer) {
|
|
280
|
+
choicesErrors[value] = 'Content should be unique.';
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
var errors = {};
|
|
285
|
+
var nbOfChoices = (choices || []).length;
|
|
286
|
+
|
|
287
|
+
if (nbOfChoices < minAnswerChoices) {
|
|
288
|
+
errors.answerChoicesError = "There should be at least ".concat(minAnswerChoices, " choices defined.");
|
|
289
|
+
} else if (nbOfChoices > maxAnswerChoices) {
|
|
290
|
+
errors.answerChoicesError = "No more than ".concat(maxAnswerChoices, " choices should be defined.");
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (!hasCorrectResponse) {
|
|
294
|
+
errors.correctResponseError = 'No correct response defined.';
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (!(0, _isEmpty["default"])(choicesErrors)) {
|
|
298
|
+
errors.choicesErrors = choicesErrors;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return errors;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
exports.validate = validate;
|
|
238
305
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["prepareChoice","model","env","defaultFeedback","choice","role","mode","out","label","value","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","createDefaultModel","Promise","resolve","defaults","normalize","question","session","updateSession","normalizedQuestion","Object","assign","incorrect","choices","map","lockChoiceOrder","layout","verticalMode","undefined","disabled","prompt","promptEnabled","choicesLayout","gridColumns","choiceMode","keyMode","choicePrefix","responseCorrect","teacherInstructions","teacherInstructionsEnabled","getScore","config","selectedChoices","correctChoices","filter","ch","score","reduce","acc","selectedChoice","find","length","str","parseFloat","toFixed","outcome","empty","partialScoringEnabled","partialScoring","enabled","createCorrectResponseSession","id","c"],"mappings":";;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAAAC,MAAM,EAAI;AAAA,eACxCF,GAAG,IAAI,EADiC;AAAA,QACvDG,IADuD,QACvDA,IADuD;AAAA,QACjDC,IADiD,QACjDA,IADiD;;AAE/D,QAAMC,GAAG,GA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A,OAAO,CAAC;AAAEiC,QAAAA,KAAK,EAAEW,qBAAqB,GAAGX,KAAH,GAAWA,KAAK,KAAK,CAAV,GAAc,CAAd,GAAkB,CAA3D;AAA8DU,QAAAA,KAAK,EAAE;AAArE,OAAD,CAAP;AACD;AACF,GAVM,CAAP;AAWD;;AAEM,IAAMI,4BAA4B,GAAG,SAA/BA,4BAA+B,CAAC5C,QAAD,EAAWpB,GAAX,EAAmB;AAC7D,SAAO,IAAIgB,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5B,QAAIjB,GAAG,CAACI,IAAJ,KAAa,UAAb,IAA2BJ,GAAG,CAACG,IAAJ,KAAa,YAA5C,EAA0D;AAAA,kBACpCiB,QAAQ,IAAI;AAAEO,QAAAA,OAAO,EAAE;AAAX,OADwB;AAAA,UAChDA,OADgD,SAChDA,OADgD;;AAGxDV,MAAAA,OAAO,CAAC;AACNgD,QAAAA,EAAE,EAAE,GADE;AAEN1D,QAAAA,KAAK,EAAEoB,OAAO,CAACqB,MAAR,CAAe,UAAAkB,CAAC;AAAA,iBAAIA,CAAC,CAACxD,OAAN;AAAA,SAAhB,EAA+BkB,GAA/B,CAAmC,UAAAsC,CAAC;AAAA,iBAAIA,CAAC,CAAC3D,KAAN;AAAA,SAApC;AAFD,OAAD,CAAP;AAID,KAPD,MAOO;AACLU,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAXM,CAAP;AAYD,CAbM","sourcesContent":["/* eslint-disable no-console */\nimport isEmpty from 'lodash/isEmpty';\nimport { isResponseCorrect } from './utils';\nimport defaults from './defaults';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-lib/controller-utils';\n\nconst prepareChoice = (model, env, defaultFeedback) => choice => {\n const { role, mode } = env || {};\n const out = {\n label: choice.label,\n value: choice.value\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = question => ({ ...defaults, ...question });\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 async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback\n );\n\n let choices = normalizedQuestion.choices.map(\n prepareChoice(normalizedQuestion, env, defaultFeedback)\n );\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(\n choices,\n session,\n updateSession,\n 'value'\n );\n }\n\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/main.jsx - componentDidMount\n let layout = '';\n if(normalizedQuestion.verticalMode !== undefined) {\n layout = normalizedQuestion.verticalMode === false ? 'horizontal': 'vertical';\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout || layout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect:\n env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\n\nexport const getScore = (config, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session.value || [];\n const correctChoices = (config.choices || []).filter(ch => ch.correct);\n\n let score = selectedChoices.reduce((acc, selectedChoice) =>\n acc + (correctChoices.find(ch => ch.value === selectedChoice) ? 1 : 0), 0);\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\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 = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise(resolve => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n } else {\n const partialScoringEnabled =\n partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });\n }\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 || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter(c => c.correct).map(c => c.value)\n });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["prepareChoice","model","env","defaultFeedback","choice","role","mode","out","label","value","accessibilityLabelsEnabled","accessibility","textContent","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","createDefaultModel","Promise","resolve","defaults","normalize","question","verticalMode","choicesLayout","questionProps","session","updateSession","normalizedQuestion","Object","assign","incorrect","choices","map","lockChoiceOrder","disabled","prompt","promptEnabled","gridColumns","choiceMode","keyMode","choicePrefix","responseCorrect","undefined","teacherInstructions","teacherInstructionsEnabled","getScore","config","selectedChoices","correctChoices","filter","ch","score","reduce","acc","selectedChoice","find","length","str","parseFloat","toFixed","outcome","empty","partialScoringEnabled","partialScoring","enabled","createCorrectResponseSession","id","c","validate","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","choicesErrors","hasCorrectResponse","forEach","index","identicalAnswer","slice","some","errors","nbOfChoices","answerChoicesError","correctResponseError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAAAC,MAAM,EAAI;AAC/D,eAAuBF,GAAG,IAAI,EAA9B;AAAA,QAAQG,IAAR,QAAQA,IAAR;AAAA,QAAcC,IAAd,QAAcA,IAAd;;AACA,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEJ,MAAM,CAACI,KADJ;AAEVC,MAAAA,KAAK,EAAEL,MAAM,CAACK;AAFJ,KAAZ;;AAKA,QAAIR,KAAK,CAACS,0BAAV,EAAsC;AACpCH,MAAAA,GAAG,CAACI,aAAJ,GAAoB,sBAAUP,MAAM,CAACO,aAAjB,EAAgCC,WAAhC,IAA+CR,MAAM,CAACK,KAA1E;AACD;;AAED,QAAIJ,IAAI,KAAK,YAAT,KAA0BC,IAAI,KAAK,MAAT,IAAmBA,IAAI,KAAK,UAAtD,CAAJ,EAAuE;AACrEC,MAAAA,GAAG,CAACM,SAAJ,GAAgBZ,KAAK,CAACa,gBAAN,GAAyBV,MAAM,CAACS,SAAhC,GAA4C,IAA5D;AACD,KAFD,MAEO;AACLN,MAAAA,GAAG,CAACM,SAAJ,GAAgB,IAAhB;AACD;;AAED,QAAIP,IAAI,KAAK,UAAb,EAAyB;AACvBC,MAAAA,GAAG,CAACQ,OAA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9B,EAA6C;AAC3CqE,MAAAA,aAAa,CAACpE,KAAD,CAAb,GAAuB,8BAAvB;AACD,KAFD,MAEO;AACL,UAAMwE,eAAe,GAAGN,eAAe,CAACO,KAAhB,CAAsBF,KAAK,GAAG,CAA9B,EAAiCG,IAAjC,CAAsC,UAAAZ,CAAC;AAAA,eAAIA,CAAC,CAAC/D,KAAF,KAAYA,KAAhB;AAAA,OAAvC,CAAxB;;AAEA,UAAIyE,eAAJ,EAAqB;AACnBJ,QAAAA,aAAa,CAACpE,KAAD,CAAb,GAAuB,2BAAvB;AACD;AACF;AACF,GAhBD;AAkBA,MAAM2E,MAAM,GAAG,EAAf;AACA,MAAMC,WAAW,GAAG,CAAClD,OAAO,IAAI,EAAZ,EAAgByB,MAApC;;AAEA,MAAIyB,WAAW,GAAGZ,gBAAlB,EAAoC;AAClCW,IAAAA,MAAM,CAACE,kBAAP,sCAAwDb,gBAAxD;AACD,GAFD,MAEO,IAAIY,WAAW,GAAGX,gBAAlB,EAAoC;AACzCU,IAAAA,MAAM,CAACE,kBAAP,0BAA4CZ,gBAA5C;AACD;;AAED,MAAI,CAACI,kBAAL,EAAyB;AACvBM,IAAAA,MAAM,CAACG,oBAAP,GAA8B,8BAA9B;AACD;;AAED,MAAI,CAAC,yBAAQV,aAAR,CAAL,EAA6B;AAC3BO,IAAAA,MAAM,CAACP,aAAP,GAAuBA,aAAvB;AACD;;AAED,SAAOO,MAAP;AACD,CA3CM","sourcesContent":["/* eslint-disable no-console */\nimport isEmpty from 'lodash/isEmpty';\nimport { isResponseCorrect, parseHTML } from './utils';\nimport defaults from './defaults';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-lib/controller-utils';\n\nconst prepareChoice = (model, env, defaultFeedback) => choice => {\n const { role, mode } = env || {};\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (model.accessibilityLabelsEnabled) {\n out.accessibility = parseHTML(choice.accessibility).textContent || choice.value;\n }\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = question => {\n const { verticalMode, choicesLayout, ...questionProps } = question || {};\n\n return {\n ...defaults,\n ...questionProps,\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel\n choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout\n };\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 async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback\n );\n\n let choices = normalizedQuestion.choices.map(\n prepareChoice(normalizedQuestion, env, defaultFeedback)\n );\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(\n choices,\n session,\n updateSession,\n 'value'\n );\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect:\n env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\n\nexport const getScore = (config, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session.value || [];\n const correctChoices = (config.choices || []).filter(ch => ch.correct);\n\n let score = selectedChoices.reduce((acc, selectedChoice) =>\n acc + (correctChoices.find(ch => ch.value === selectedChoice) ? 1 : 0), 0);\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\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 = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise(resolve => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n } else {\n const partialScoringEnabled =\n partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });\n }\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 || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter(c => c.correct).map(c => c.value)\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...choices || []].reverse();\n const choicesErrors = {};\n let hasCorrectResponse = false;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\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 const errors = {};\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponseError = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/lib/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.isResponseCorrect = exports.getCorrectResponse = void 0;
|
|
8
|
+
exports.parseHTML = exports.isResponseCorrect = exports.getCorrectResponse = void 0;
|
|
9
9
|
|
|
10
10
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
11
11
|
|
|
@@ -25,4 +25,12 @@ var isResponseCorrect = function isResponseCorrect(question, session) {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
exports.isResponseCorrect = isResponseCorrect;
|
|
28
|
+
|
|
29
|
+
var parseHTML = function parseHTML(html) {
|
|
30
|
+
var template = document.createElement('template');
|
|
31
|
+
template.innerHTML = html;
|
|
32
|
+
return template.content;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.parseHTML = parseHTML;
|
|
28
36
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","value","sort","isResponseCorrect","question","session","correctResponse"],"mappings":";;;;;;;;;AAAA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAAaA,OAAO,CACnDC,MAD4C,CACrC,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,OAAN;AAAA,GADoC,EAE5CC,GAF4C,CAExC,UAAAF,CAAC;AAAA,WAAIA,CAAC,CAACG,KAAN;AAAA,GAFuC,EAG5CC,IAH4C,EAAb;AAAA,CAA3B;;;;AAKA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,OAAX,EAAuB;AACtD,MAAIC,eAAe,GAAGX,kBAAkB,CAACS,QAAQ,CAACR,OAAV,CAAxC;AACA,SAAOS,OAAO,IAAI,yBAAQ,CAACA,OAAO,CAACJ,KAAR,IAAiB,EAAlB,EAAsBC,IAAtB,EAAR,EAAsCI,eAAtC,CAAlB;AACD,CAHM","sourcesContent":["import isEqual from 'lodash/isEqual';\n\nexport const getCorrectResponse = (choices) => choices\n .filter(c => c.correct)\n .map(c => c.value)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n let correctResponse = getCorrectResponse(question.choices);\n return session && isEqual((session.value || []).sort(), correctResponse);\n};\n"],"file":"utils.js"}
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","value","sort","isResponseCorrect","question","session","correctResponse","parseHTML","html","template","document","createElement","innerHTML","content"],"mappings":";;;;;;;;;AAAA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAAaA,OAAO,CACnDC,MAD4C,CACrC,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,OAAN;AAAA,GADoC,EAE5CC,GAF4C,CAExC,UAAAF,CAAC;AAAA,WAAIA,CAAC,CAACG,KAAN;AAAA,GAFuC,EAG5CC,IAH4C,EAAb;AAAA,CAA3B;;;;AAKA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,OAAX,EAAuB;AACtD,MAAIC,eAAe,GAAGX,kBAAkB,CAACS,QAAQ,CAACR,OAAV,CAAxC;AACA,SAAOS,OAAO,IAAI,yBAAQ,CAACA,OAAO,CAACJ,KAAR,IAAiB,EAAlB,EAAsBC,IAAtB,EAAR,EAAsCI,eAAtC,CAAlB;AACD,CAHM;;;;AAKA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,IAAD,EAAU;AACjC,MAAMC,QAAQ,GAAGC,QAAQ,CAACC,aAAT,CAAuB,UAAvB,CAAjB;AACAF,EAAAA,QAAQ,CAACG,SAAT,GAAqBJ,IAArB;AACA,SAAOC,QAAQ,CAACI,OAAhB;AACD,CAJM","sourcesContent":["import isEqual from 'lodash/isEqual';\n\nexport const getCorrectResponse = (choices) => choices\n .filter(c => c.correct)\n .map(c => c.value)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n let correctResponse = getCorrectResponse(question.choices);\n return session && isEqual((session.value || []).sort(), correctResponse);\n};\n\nexport const parseHTML = (html) => {\n const template = document.createElement('template');\n template.innerHTML = html;\n return template.content;\n};\n"],"file":"utils.js"}
|
package/controller/package.json
CHANGED
package/docs/config-schema.json
CHANGED
|
@@ -106,6 +106,22 @@
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
+
"spellCheck": {
|
|
110
|
+
"title": "ConfigureProp",
|
|
111
|
+
"type": "object",
|
|
112
|
+
"properties": {
|
|
113
|
+
"settings": {
|
|
114
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
115
|
+
"type": "boolean",
|
|
116
|
+
"title": "settings"
|
|
117
|
+
},
|
|
118
|
+
"label": {
|
|
119
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
120
|
+
"type": "string",
|
|
121
|
+
"title": "label"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
109
125
|
"choicesLayout": {
|
|
110
126
|
"title": "ConfigureProp",
|
|
111
127
|
"type": "object",
|
|
@@ -255,6 +271,84 @@
|
|
|
255
271
|
}
|
|
256
272
|
}
|
|
257
273
|
},
|
|
274
|
+
"accessibility": {
|
|
275
|
+
"title": "ConfigureProp",
|
|
276
|
+
"type": "object",
|
|
277
|
+
"properties": {
|
|
278
|
+
"settings": {
|
|
279
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
280
|
+
"type": "boolean",
|
|
281
|
+
"title": "settings"
|
|
282
|
+
},
|
|
283
|
+
"label": {
|
|
284
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
285
|
+
"type": "string",
|
|
286
|
+
"title": "label"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
"minAnswerChoices": {
|
|
291
|
+
"description": "Minimum number of answer choices",
|
|
292
|
+
"type": "number",
|
|
293
|
+
"title": "minAnswerChoices"
|
|
294
|
+
},
|
|
295
|
+
"maxAnswerChoices": {
|
|
296
|
+
"description": "Maximum number of answer choices",
|
|
297
|
+
"type": "number",
|
|
298
|
+
"title": "maxAnswerChoices"
|
|
299
|
+
},
|
|
300
|
+
"maxImageWidth": {
|
|
301
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
302
|
+
"type": "object",
|
|
303
|
+
"properties": {
|
|
304
|
+
"teacherInstructions": {
|
|
305
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
306
|
+
"type": "number",
|
|
307
|
+
"title": "teacherInstructions"
|
|
308
|
+
},
|
|
309
|
+
"prompt": {
|
|
310
|
+
"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",
|
|
311
|
+
"type": "number",
|
|
312
|
+
"title": "prompt"
|
|
313
|
+
},
|
|
314
|
+
"rationale": {
|
|
315
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
316
|
+
"type": "number",
|
|
317
|
+
"title": "rationale"
|
|
318
|
+
},
|
|
319
|
+
"choices": {
|
|
320
|
+
"description": "Indicates the max dimension for images in choices",
|
|
321
|
+
"type": "number",
|
|
322
|
+
"title": "choices"
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"maxImageHeight": {
|
|
327
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
328
|
+
"type": "object",
|
|
329
|
+
"properties": {
|
|
330
|
+
"teacherInstructions": {
|
|
331
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
332
|
+
"type": "number",
|
|
333
|
+
"title": "teacherInstructions"
|
|
334
|
+
},
|
|
335
|
+
"prompt": {
|
|
336
|
+
"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",
|
|
337
|
+
"type": "number",
|
|
338
|
+
"title": "prompt"
|
|
339
|
+
},
|
|
340
|
+
"rationale": {
|
|
341
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
342
|
+
"type": "number",
|
|
343
|
+
"title": "rationale"
|
|
344
|
+
},
|
|
345
|
+
"choices": {
|
|
346
|
+
"description": "Indicates the max dimension for images in choices",
|
|
347
|
+
"type": "number",
|
|
348
|
+
"title": "choices"
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
},
|
|
258
352
|
"showPrompt": {
|
|
259
353
|
"description": "Determines whether prompt field will be displayed or not",
|
|
260
354
|
"default": true,
|
|
@@ -305,6 +399,32 @@
|
|
|
305
399
|
"title": "enabled"
|
|
306
400
|
}
|
|
307
401
|
}
|
|
402
|
+
},
|
|
403
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
404
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
405
|
+
"type": "object",
|
|
406
|
+
"properties": {
|
|
407
|
+
"teacherInstructions": {
|
|
408
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
409
|
+
"type": "number",
|
|
410
|
+
"title": "teacherInstructions"
|
|
411
|
+
},
|
|
412
|
+
"prompt": {
|
|
413
|
+
"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",
|
|
414
|
+
"type": "number",
|
|
415
|
+
"title": "prompt"
|
|
416
|
+
},
|
|
417
|
+
"rationale": {
|
|
418
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
419
|
+
"type": "number",
|
|
420
|
+
"title": "rationale"
|
|
421
|
+
},
|
|
422
|
+
"choices": {
|
|
423
|
+
"description": "Indicates the max dimension for images in choices",
|
|
424
|
+
"type": "number",
|
|
425
|
+
"title": "choices"
|
|
426
|
+
}
|
|
427
|
+
}
|
|
308
428
|
}
|
|
309
429
|
},
|
|
310
430
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
@@ -84,6 +84,18 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
84
84
|
|
|
85
85
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
86
86
|
|
|
87
|
+
# `spellCheck` (object)
|
|
88
|
+
|
|
89
|
+
Properties of the `spellCheck` object:
|
|
90
|
+
|
|
91
|
+
## `settings` (boolean)
|
|
92
|
+
|
|
93
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
94
|
+
|
|
95
|
+
## `label` (string)
|
|
96
|
+
|
|
97
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
98
|
+
|
|
87
99
|
# `choicesLayout` (object)
|
|
88
100
|
|
|
89
101
|
Properties of the `choicesLayout` object:
|
|
@@ -197,6 +209,66 @@ Indicates the label for the item that has to be displayed in the Settings Panel
|
|
|
197
209
|
Indicates the value of the item if it affects config-ui
|
|
198
210
|
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
199
211
|
|
|
212
|
+
# `accessibility` (object)
|
|
213
|
+
|
|
214
|
+
Properties of the `accessibility` object:
|
|
215
|
+
|
|
216
|
+
## `settings` (boolean)
|
|
217
|
+
|
|
218
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
219
|
+
|
|
220
|
+
## `label` (string)
|
|
221
|
+
|
|
222
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
223
|
+
|
|
224
|
+
# `minAnswerChoices` (number)
|
|
225
|
+
|
|
226
|
+
Minimum number of answer choices
|
|
227
|
+
|
|
228
|
+
# `maxAnswerChoices` (number)
|
|
229
|
+
|
|
230
|
+
Maximum number of answer choices
|
|
231
|
+
|
|
232
|
+
# `maxImageWidth` (object)
|
|
233
|
+
|
|
234
|
+
Properties of the `maxImageWidth` object:
|
|
235
|
+
|
|
236
|
+
## `teacherInstructions` (number)
|
|
237
|
+
|
|
238
|
+
Indicates the max dimension for images in teacher instructions
|
|
239
|
+
|
|
240
|
+
## `prompt` (number)
|
|
241
|
+
|
|
242
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
243
|
+
|
|
244
|
+
## `rationale` (number)
|
|
245
|
+
|
|
246
|
+
Indicates the max dimension for images in rationale
|
|
247
|
+
|
|
248
|
+
## `choices` (number)
|
|
249
|
+
|
|
250
|
+
Indicates the max dimension for images in choices
|
|
251
|
+
|
|
252
|
+
# `maxImageHeight` (object)
|
|
253
|
+
|
|
254
|
+
Properties of the `maxImageHeight` object:
|
|
255
|
+
|
|
256
|
+
## `teacherInstructions` (number)
|
|
257
|
+
|
|
258
|
+
Indicates the max dimension for images in teacher instructions
|
|
259
|
+
|
|
260
|
+
## `prompt` (number)
|
|
261
|
+
|
|
262
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
263
|
+
|
|
264
|
+
## `rationale` (number)
|
|
265
|
+
|
|
266
|
+
Indicates the max dimension for images in rationale
|
|
267
|
+
|
|
268
|
+
## `choices` (number)
|
|
269
|
+
|
|
270
|
+
Indicates the max dimension for images in choices
|
|
271
|
+
|
|
200
272
|
# `showPrompt` (boolean)
|
|
201
273
|
|
|
202
274
|
Determines whether prompt field will be displayed or not
|
|
@@ -242,4 +314,24 @@ Indicates the label for the item that has to be displayed in the Settings Panel
|
|
|
242
314
|
### `enabled` (boolean)
|
|
243
315
|
|
|
244
316
|
Indicates the value of the item if it affects config-ui
|
|
245
|
-
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
317
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
318
|
+
|
|
319
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
320
|
+
|
|
321
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
322
|
+
|
|
323
|
+
### `teacherInstructions` (number)
|
|
324
|
+
|
|
325
|
+
Indicates the max dimension for images in teacher instructions
|
|
326
|
+
|
|
327
|
+
### `prompt` (number)
|
|
328
|
+
|
|
329
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
330
|
+
|
|
331
|
+
### `rationale` (number)
|
|
332
|
+
|
|
333
|
+
Indicates the max dimension for images in rationale
|
|
334
|
+
|
|
335
|
+
### `choices` (number)
|
|
336
|
+
|
|
337
|
+
Indicates the max dimension for images in choices
|